swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

Add support for JAX-RS 2.1

Open shaddyz opened this issue 2 years ago • 0 comments

JAX-RS 2.1 most notably adds support for async responses using CompletionStage. The latest version of swagger-core is unable to produce a useable open api spec with operations that return a CompletionStage.

Resource:

@Produces(MediaType.APPLICATION_JSON)
@Path("widget/api/v1")
interface WidgetApi {

    @GET
    @Path("get/{id}")
    fun get(@PathParam("id") id: String): CompletionStage<GetWidgetOutput>

    @POST
    @Path("create")
    fun create(input: CreateWidgetInput): CompletionStage<CreateWidgetOutput>
}

Generated spec:

openapi: 3.0.1
info:
  title: Widget Service
  version: "1.0"
paths:
  /widget/api/v1/create:
    post:
      operationId: create
      requestBody:
        content:
          '*/*':
            schema:
              $ref: '#/components/schemas/CreateWidgetInput'
      responses:
        default:
          content:
            application/json:
              schema:
                type: object
          description: default response
  /widget/api/v1/get/{id}:
    get:
      operationId: get
      parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
      responses:
        default:
          content:
            application/json:
              schema:
                type: object
          description: default response
components:
  schemas:
    CreateWidgetInput:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string

versions:

  • annotations: jakarta.ws.rs:jakarta.ws.rs-api:3.0.0
  • swagger-core: io.swagger.core.v3:swagger-jaxrs2-jakarta:2.1.13
  • maven plugin: io.swagger.core.v3:swagger-maven-plugin-jakarta:2.1.13

shaddyz avatar Mar 12 '22 20:03 shaddyz