quarkiverse / quarkus-openapi-generator

OpenAPI Generator - REST Client Generator
Apache License 2.0
108 stars 69 forks source link

Support using configKey for authentication configuration #554

Closed ismailBsd closed 6 months ago

ismailBsd commented 8 months ago

Currently, as the readme file indicates, to provide the credentials, the configuration key is composed using this template.: quarkus.openapi-generator.[filename].auth.[security_scheme_name].[auth_property_name]. Where:

filename is the sanitized name of file containing the OpenAPI spec, for example petstore_json.

It would be nice if we could use the config key if present instead of the openapi spec file.

For example if I set the config key to: quarkus.openapi-generator.codegen.spec.petstore_json.config-key=petstore

I would like my configuration keys for authentication to look like this:

for api key authentication: quarkus.openapi-generator.**petstore**.auth.api_key.api-key

for basic http authentication

quarkus.openapi-generator.petstore.auth.basic_auth.username
quarkus.openapi-generator.petstore.auth.basic_auth.password

and for bearer token authentication

quarkus.openapi-generator.petstore.auth.bearer.bearer-token

looking at the code I found that to implement it, {quarkus-generator.openApiSpecId} in the compositeAuthenticationProvider.qute template file must be replaced with {configKey} like in the api.qute file

hbelmiro commented 8 months ago

If I'm not mistaken this feature was added in https://github.com/quarkiverse/quarkus-openapi-generator/pull/457. @ismailBsd have you tried that with the latest version?

ismailBsd commented 7 months ago

@hbelmiro Sorry for the late reply, yes I tried with v1.3.13, I think it may be a template bug because compositeAuthenticationProvider.qute still uses {quarkus-generator.openApiSpecId} instead of {configKey}

mcruzdev commented 7 months ago

Hi @ismailBsd and @hbelmiro, really the compositeAuthenticationProvider.qute uses quarkus-generator.openApiSpecId.

@ismailBsd, are you willing to send a PR?

mcruzdev commented 6 months ago

Hi @hbelmiro I am working on this issue.