swagger-api/swagger-codegen-generators

[java][okhttp4-gson] ApiClient.mustache can't support generate security scheme for http with bearer

shamrockly opened this issue · 1 comments

When define the below securitySchemes, http with basic is added when generate ApiClient, but http with bearer couldn't be generated.

When using okhttp-gson library, it works well. Comparing with it, the /src/main/resources/handlebars/Java/libraries/okhttp4-gson/ApiClient.mustache lacks of one line: {{#isBearer}}authentications.put("{{name}}", new OAuth());{{/isBearer}}.

It should be:

    // Setup authentications (key: authentication name, value: authentication).
    authentications = new HashMap<String, Authentication>();{{#authMethods}}{{#isBasic}}
    authentications.put("{{name}}", new HttpBasicAuth());{{/isBasic}}{{#isApiKey}}
    authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}}
    authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{#isBearer}}
    authentications.put("{{name}}", new OAuth());{{/isBearer}}{{/authMethods}}

securitySchemes:
HttpBasic:
type: http
scheme: basic
HttpBearer:
type: http
scheme: bearer
name: Bearer Token
bearerFormat: JWT

this has been fixed by #1178