micronaut-projects / micronaut-jaxrs

Support for the JAX-RS API in Micronaut
Apache License 2.0
9 stars 7 forks source link

Class level path ignored when using micronaut-openapi #129

Closed mikaelvik closed 1 year ago

mikaelvik commented 3 years ago

I'm having an issue with micronaut-jaxrs-processor in combination with micronaut-openapi.

I was able to solve the issue locally with a fix in JaxRsTypeElementVisitor#visitClass. By adding a UriMapping annotation in addition to the Controller annotation, the micronaut-openapi processor is able to discover the base path.

I can provide a PR.

Steps to Reproduce

Given a controller using JaxRS annotations:

@Path("/base")
public class ExampleController {

    @GET
    @Path("/method")
    public String hello() {
        return "hello";
    }
}

Expected Behaviour

I would expect the following openapi specification:

openapi: 3.0.1
info:
  title: micronaut-jaxrs-demo
  version: "0.1"
paths:
  /base/method: # CORRECT PATH
    get:
      operationId: hello
      parameters: []
      responses:
        "200":
          description: hello 200 response
          content:
            application/json:
              schema:
                type: string

Actual Behaviour

The path is wrong:

openapi: 3.0.1
info:
  title: micronaut-jaxrs-demo
  version: "0.1"
paths:
  /method: # WRONG PATH
    get:
      operationId: hello
      parameters: []
      responses:
        "200":
          description: hello 200 response
          content:
            application/json:
              schema:
                type: string

Environment Information

timyates commented 1 year ago

Confirmed this works with Micronaut 4

I believe it was fixed by https://github.com/micronaut-projects/micronaut-jaxrs/pull/130 which went out with v2.0.2 of this module

That was part of Micronaut 3