Skip to content

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

@fxnn

Description

@fxnn

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions