quarkus-openapi-generator icon indicating copy to clipboard operation
quarkus-openapi-generator copied to clipboard

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

Open ddelbondio opened this issue 1 year ago • 2 comments

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 avatar Aug 25 '24 21:08 ddelbondio

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.

ricardozanini avatar Aug 27 '24 13:08 ricardozanini

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

ddelbondio avatar Aug 28 '24 21:08 ddelbondio

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

https://github.com/quarkiverse/quarkus-openapi-generator/blob/ec6919d74778a05b7ceb618d777705508e9dc376/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiConfigValidator.java#L21

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?

mcruzdev avatar Nov 01 '24 03:11 mcruzdev

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

ricardozanini avatar Nov 01 '24 16:11 ricardozanini

cc: @SergioRuyDev

mcruzdev avatar Nov 19 '24 13:11 mcruzdev

Any progress?

mbard avatar Dec 21 '24 12:12 mbard

I think no @mbard, do you mind to send a PR? This is simple, you can see my last comment about the solution.

mcruzdev avatar Dec 21 '24 12:12 mcruzdev