Open api generator : change Client name

2.3k views Asked by At

I am using the "OpenApi generator" to create the client library for an api.

openapi-generator generate -i https://xxxx.cloudfront.net/openapi/en-us/product/2-0/openapi.yaml -g ruby -o tmp/test/custom_name

This generate a class "OpenapiClient" but I need to change this name to "CustomApiClient". How can I pass this value? This seems to me a standard thing to do, why is not so immediate? Am I following the best practice?

# Load the gem
require 'openapi_client'

# Setup authorization
OpenapiClient.configure do |config|
  # Configure Bearer authorization: bearer
  config.access_token = 'YOUR_BEARER_TOKEN'
end
1

There are 1 answers

2
e-e On

This seemed way harder to find than it should have been, but if you run openapi-generator config-help -g ruby, it will show you all the options for ruby client configurations. Specifically, gemName. So you can simply create a config file like:

# config.yaml
gemName: custom_api_client

and provide -c /path/to/your/config.yaml when running the generate command.