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

@Parameter(ref = ...) overwrites other parameters #659

Closed
fxnn opened this issue Feb 5, 2021 · 0 comments · Fixed by #662
Closed

@Parameter(ref = ...) overwrites other parameters #659

fxnn opened this issue Feb 5, 2021 · 0 comments · Fixed by #662
Labels
bug Something isn't working
Milestone

Comments

@fxnn
Copy link

fxnn commented Feb 5, 2021

Affected Artifact

io.smallrye:smallrye-open-api-maven-plugin:2.1.1

Problem Context

I use smallrye-open-api to generate OpenAPI Specs from JAX-RS/MP-OpenAPI annotations. I have a method like following:

  @GET
  @Path("/{pathParam1}/{pathParam2}")
  @Parameter(ref = "queryParam1")
  String exampleEndpoint(
    @PathParam("pathParam1") String pathParam1,
    @PathParam("pathParam2") String pathParam2);

While there's two @PathParams, there's also a query parameter given as @Parameter with a reference to the definition like following:

@OpenAPIDefinition(
    // ...
    components = @Components(parameters = {
        @Parameter(name = "queryParam1", in = ParameterIn.QUERY)
    })
)

Expected Behaviour

The generated OpenAPI specs contain all three parameters in the paths: /{pathParam}: get: parameters: section.

Actual Behaviour

The generated OpenAPI specs do only contain the queryParam1 and the pathParam2. The pathParam1 is missing.

Further Observations

  • When queryParam1 would not use a ref, but was defined directly on the method, it would work and we could see all three parameters in the spec.
  • When there'd be only pathParam1 in the code, without pathParam2, then queryParam1 would be the only parameter in the generated specs.
  • When there's no @Parameter annotation at all, all two path parameters are generated.
  • When the path params are also given als @Parameter, the behaviour doesn't change compared to what's given above under "Actual Behaviour":
      @Parameter(name = "pathParam1", in = ParameterIn.PATH)
      @Parameter(name = "pathParam2", in = ParameterIn.PATH)
      @Parameter(ref = "queryParam1")
  • If we would declare pathParam1 and pathParam2 through @Parameter(ref = ...), we also get similar results. However, if we leave out the queryParam1, we get pathParam2 twice -- once as ref, and once as explicit specification.

Reproducer

@MikeEdgar MikeEdgar added the bug Something isn't working label Feb 7, 2021
@MikeEdgar MikeEdgar added this to the 2.0.20 milestone Feb 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants