diff --git a/modules/openapi-generator/src/main/resources/ruby-client/README.mustache b/modules/openapi-generator/src/main/resources/ruby-client/README.mustache index 00f50d813403..182bb34f4f50 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/README.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/README.mustache @@ -65,10 +65,12 @@ Please follow the [installation](#installation) procedure and then run the follo require '{{{gemName}}}' {{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}} # Setup authorization -{{{moduleName}}}.configure do |config|{{#authMethods}}{{#isBasic}} +{{{moduleName}}}.configure do |config|{{#authMethods}}{{#isBasic}}{{^isBasicBearer}} # Configure HTTP basic authorization: {{{name}}} - config.username = 'YOUR USERNAME' - config.password = 'YOUR PASSWORD'{{/isBasic}}{{#isApiKey}} + config.username = 'YOUR_USERNAME' + config.password = 'YOUR_PASSWORD'{{/isBasicBearer}}{{#isBasicBearer}} + # Configure Bearer authorization{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}: {{{name}}} + config.access_token = 'YOUR_BEARER_TOKEN'{{/isBasicBearer}}{{/isBasic}}{{#isApiKey}} # Configure API key authorization: {{{name}}} config.api_key['{{{keyParamName}}}'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) @@ -128,7 +130,10 @@ Class | Method | HTTP request | Description - **API key parameter name**: {{keyParamName}} - **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} {{/isApiKey}} -{{#isBasic}}- **Type**: HTTP basic authentication +{{#isBasic}} +{{^isBasicBearer}}- **Type**: HTTP basic authentication +{{/isBasicBearer}}{{#isBasicBearer}}- **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} +{{/isBasicBearer}} {{/isBasic}} {{#isOAuth}} diff --git a/modules/openapi-generator/src/main/resources/ruby-client/api_doc.mustache b/modules/openapi-generator/src/main/resources/ruby-client/api_doc.mustache index 960c0552dcf8..dc163725e163 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/api_doc.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/api_doc.mustache @@ -27,10 +27,12 @@ Method | HTTP request | Description require '{{{gemName}}}' {{#hasAuthMethods}} # setup authorization -{{{moduleName}}}.configure do |config|{{#authMethods}}{{#isBasic}} +{{{moduleName}}}.configure do |config|{{#authMethods}}{{#isBasic}}{{^isBasicBearer}} # Configure HTTP basic authorization: {{{name}}} config.username = 'YOUR USERNAME' - config.password = 'YOUR PASSWORD'{{/isBasic}}{{#isApiKey}} + config.password = 'YOUR PASSWORD'{{/isBasicBearer}}{{#isBasicBearer}} + # Configure Bearer authorization{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}: {{{name}}} + config.access_token = 'YOUR_BEARER_TOKEN'{{/isBasicBearer}}{{/isBasic}}{{#isApiKey}} # Configure API key authorization: {{{name}}} config.api_key['{{{keyParamName}}}'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) diff --git a/modules/openapi-generator/src/main/resources/ruby-client/configuration.mustache b/modules/openapi-generator/src/main/resources/ruby-client/configuration.mustache index d0d190ff2f5b..2f43306a3b9f 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/configuration.mustache @@ -199,6 +199,7 @@ module {{moduleName}} }, {{/isApiKey}} {{#isBasic}} +{{^isBasicBearer}} '{{name}}' => { type: 'basic', @@ -206,6 +207,19 @@ module {{moduleName}} key: 'Authorization', value: basic_auth_token }, +{{/isBasicBearer}} +{{#isBasicBearer}} + '{{name}}' => + { + type: 'bearer', + in: 'header', + {{#bearerFormat}} + format: '{{{.}}}', + {{/bearerFormat}} + key: 'Authorization', + value: "Bearer #{access_token}" + }, +{{/isBasicBearer}} {{/isBasic}} {{#isOAuth}} '{{name}}' => diff --git a/samples/openapi3/client/petstore/ruby/README.md b/samples/openapi3/client/petstore/ruby/README.md index 80fd4176e9a9..6fb930ed9a88 100644 --- a/samples/openapi3/client/petstore/ruby/README.md +++ b/samples/openapi3/client/petstore/ruby/README.md @@ -180,7 +180,7 @@ Class | Method | HTTP request | Description ### bearer_test -- **Type**: HTTP basic authentication +- **Type**: Bearer authentication (JWT) ### http_basic_test diff --git a/samples/openapi3/client/petstore/ruby/docs/FakeApi.md b/samples/openapi3/client/petstore/ruby/docs/FakeApi.md index b1168cc938c3..ab79170143b9 100644 --- a/samples/openapi3/client/petstore/ruby/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/ruby/docs/FakeApi.md @@ -547,9 +547,8 @@ Fake endpoint to test group parameters (optional) require 'petstore' # setup authorization Petstore.configure do |config| - # Configure HTTP basic authorization: bearer_test - config.username = 'YOUR USERNAME' - config.password = 'YOUR PASSWORD' + # Configure Bearer authorization (JWT): bearer_test + config.access_token = 'YOUR_BEARER_TOKEN' end api_instance = Petstore::FakeApi.new diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/configuration.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/configuration.rb index fe5524905c79..6bf61b7e7fc3 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/configuration.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/configuration.rb @@ -212,10 +212,11 @@ def auth_settings }, 'bearer_test' => { - type: 'basic', + type: 'bearer', in: 'header', + format: 'JWT', key: 'Authorization', - value: basic_auth_token + value: "Bearer #{access_token}" }, 'http_basic_test' => {