Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client Generator: Custom config-key with minus (-) get translated to underscore (_) in the generated code. #778

Open
ddelbondio opened this issue Aug 25, 2024 · 5 comments
Assignees
Labels
area:client This item is related to the client extension bug Something isn't working

Comments

@ddelbondio
Copy link

If a custom config-key setting is used, the value of config-key gets its "-" replaced with "_".

Example:

quarkus.openapi-generator.codegen.spec.my_json-config-key=my-api

results in

@RegisterRestClient(baseUri="...", configKey="my_api")
@ddelbondio ddelbondio changed the title Custom config-key with minus (-) get translated to underscore (_) in the generated code. Client Generator: Custom config-key with minus (-) get translated to underscore (_) in the generated code. Aug 25, 2024
@ricardozanini
Copy link
Member

Hi! Thanks for reporting it. Can you open a PR to fix it? It should be reasonably straightforward. The key might follow the same rules for name sanitization we use for the OpenAPI ID.

@ddelbondio
Copy link
Author

Sure, will have a look. Earliest next week though.

@ricardozanini ricardozanini added area:client This item is related to the client extension bug Something isn't working labels Sep 4, 2024
@mcruzdev
Copy link
Member

mcruzdev commented Nov 1, 2024

Hi @ricardozanini, @hbelmiro actually with config-key feature we can use by example:

quarkus.openapi-generator.codegen.spec.my_json.config-key=my-api
quarkus.openapi-generator.codegen.spec.my-api.base-package=com.quarkiverse

"quarkus\\.openapi-generator\\.codegen\\.(spec.(?<specId>\\w*)\\.)?(?<configName>[A-Za-z0-9_\\-]*)\\.?(?<configMap>.+)?");

Looking the regex above, the only allowed specId is my_api not my-api. Thinking here, this group only allows alphanumeric + _ because the file is sanitized.

@ddelbondio I think you have two solutions:

  • To add - to regex
  • To receive the list of configured config-key values and to check it on that method.

Guys, any suggestions?

@ricardozanini
Copy link
Member

@mcruzdev I think it's reasonable to have the - added to the regexp in case of a custom config like this. 🤔

@mcruzdev
Copy link
Member

cc: @SergioRuyDev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:client This item is related to the client extension bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants