micronaut-projects / micronaut-openapi

Generates OpenAPI / Swagger Documentation for Micronaut projects
https://micronaut-projects.github.io/micronaut-openapi/latest/guide/index.html
Apache License 2.0
79 stars 93 forks source link

posobility to set implicitHeadersRegex and implicitHeaders swagger options #1729

Closed alapierre closed 3 weeks ago

alapierre commented 1 month ago

Feature description

Sometimes it is convenient to skip some header parameters when Java code is generated form open api yaml file. implicitHeadersRegex and implicitHeaders params do the job for this case.

altro3 commented 1 month ago

Could you give an example of what the spec file should look like and what should be generated.

Also, judging by the feature description:

implicitHeaders | Skip header parameters in the generated API methods using @ApiImplicitParams annotation.
implicitHeadersRegex | Skip  header parameters that matches given regex in the generated API methods  using @ApiImplicitParams annotation. Note: this parameter is ignored  when implicitHeaders=true

The default generator adds swagger1 annotations, but we don't support swagger1. So what do we want to see with this feature? Just remove all headers from controller methods or regex headers?

altro3 commented 1 month ago

Anyway, I figured it out myself. I'll add this.

alapierre commented 1 month ago

it will be nice if we can provide any openApi configuration property eg. in this way: micronaut.openapi.configuration.implicitHeaders=true - similar like in openapi-maven-plugin

altro3 commented 1 month ago

I will add the ability to set these settings using the plugin for gradle and maven from micronaut

altro3 commented 1 month ago

about other properties: I add them as requests come. It's not that fast to add absolutely everything, because we have 2 generators for Java and Kotlin and there's no point in wasting time on something that no one needs. When people write that they need something additionally, I add it. For example, like you

karolbryzgiel commented 1 month ago

I also agree that such functionality would be useful. We’ve been writing applications in Micronaut for some time now, after migrating from Spring, and I would add that in Spring, it worked like this: If we defined:

<implicitHeaders>true</implicitHeaders>

Then OpenAPI would generate the endpoint like this:

@Parameters({
        @Parameter(name = "X-EXAMPLE-HEADER", description = "Example header", required = true, in = ParameterIn.HEADER)
    })
ResponseEntity<Foo> testApi();
altro3 commented 1 month ago

@karolbryzgiel I already fixed it here: https://github.com/micronaut-projects/micronaut-openapi/pull/1730, wait next release