micronaut-openapi icon indicating copy to clipboard operation
micronaut-openapi copied to clipboard

Not resolving Micronaut config values in Controller annotation

Open brunodomenici opened this issue 6 years ago • 9 comments

Hi,

I have some config in my @Controller annotation, like this:

@Controller("/v${applications.api.version}/applications")

And my OpenAPI is being generated like this:

  /v${applications.api.version}/applications:
    get:

I believe that correct would be:

  /v1/applications:
    get:

Because I've stetted ${applications.api.version} to 1:

Micronaut works fine, I'm able to resolve the controller /v1/applications.

Thanks a lot and great project!

brunodomenici avatar Mar 04 '20 09:03 brunodomenici

These placeholders are runtime configuration flags. They cannot be resolved at compilation time.

croudet avatar Mar 04 '20 12:03 croudet

OpenAPI spec does have something called server variables, wonder if it is possible to translate this syntax to those.

graemerocher avatar Mar 04 '20 13:03 graemerocher

Or you can use a server context path with an HttpFiler: https://micronaut-projects.github.io/micronaut-openapi/latest/guide/index.html#openApiViews

croudet avatar Mar 05 '20 14:03 croudet

Another alternative could be to allow applications.api.version to be specified in openapi.properties. Would mean duplicating one property but I don't think that is a huge deal.

graemerocher avatar Mar 05 '20 14:03 graemerocher

I have tested a dirty hack, where the spec file is parsed, placeholders resolved and then served: https://gist.github.com/croudet/d41cfd69021257948c550cac08f13528

croudet avatar Mar 05 '20 19:03 croudet

Any updates? 2 years passed..

AlexanderKhudoev avatar Mar 31 '22 11:03 AlexanderKhudoev

Any updates? 2 years passed..

I just hard coded it. Not fancy, but it's not a big deal for my project.

brunodomenici avatar Mar 31 '22 12:03 brunodomenici

This is understandable, but if there are many projects, it is inconvenient. Why don't developers improve and fix this module?

AlexanderKhudoev avatar Mar 31 '22 12:03 AlexanderKhudoev

PRs are welcome as always

graemerocher avatar Mar 31 '22 13:03 graemerocher