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

Wrong schema generating with multiple Java methods based on one path. #2611

Open
lociko opened this issue Jan 9, 2018 · 0 comments
Open

Comments

@lociko
Copy link

lociko commented Jan 9, 2018

Q A
Bug or feature request? Bug
Which Swagger-Core version? OpenApi 3.0.0
Which Java version? any
Which JAX-RS framework & version? JAX-RS framework 2.0

Hi,
There is an issue with schema generation from JAX-RS framework. Lest we have a service with three POST methods based on one path. Each Java methods have own Content-Type. For example:

@Service
@Path("/testService")
@OpenAPIDefinition
public class TestServices {

    @POST
    @Operation(description = "Some provided query description 1")
    @Consumes({"application/provided +json"})
    @Produces({"application/multiLevelData+json", "application/flatData+json", "application/multiAxesData+json"})
    public Response executeQuery(ProvidedRequest request) throws Exception {
        return null;
    }

    @POST
    @Operation(description = "Some multiLevel description 2")
    @Consumes({"application/multiLevel+json"})
    @Produces({"application/multiLevelData+json", "application/flatData+json"})
    public Response executeQuery(MultiLevelRequest request) throws Exception {
       return null;
    }

    @POST
    @Operation(description = "Some multiAxes description 3")
    @Consumes({"application/multiAxes+json"})
    @Produces({"application/multiAxesData+json"})
    public Response executeQuery(MultiAxesRequest request) throws Exception {
        return null;
    }
}

The generaited shema looks like below:

openapi: 3.0.0
info:
  title: Swagger Sample App
paths:
  /testService:
    post:
      description: Some provided query description 1
      operationId: executeQuery
      requestBody:
        content:
          application/provide+json:
            schema:
              $ref: '#/components/schemas/ProvidedRequest '
      responses:
        default:
          description: default response

As you can see:

  1. POST method with “provided” content type can generate 3 type of responses data: multilevelData, flatData, multiAxesData.
  2. POST method with “multilevel” content type can generate just 2 type of responses data: multilevelData, flatData.
  3. POST method with “multiaxes” content type can generate just 1 type of response data: multiAxesData.

So, the questions are:

  1. Is Open API 3.0 specification itself allow defining multiple specifications per path? The related question has been filed in Support an operation to have multiple specifications per path (e.g. multiple POST operation per path) OAI/OpenAPI-Specification#182.
  2. If 1) is possible, then how to achieve it by using swagger annotations.

We didn’t find this in Open API reference doc. So, it seems there is no way to do it. So, we should define one POST request, where Request/Response Content describes all possibles Schemas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant