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 JSON for response example #420

Closed
ppatierno opened this issue Jun 7, 2020 · 5 comments
Closed

Wrong JSON for response example #420

ppatierno opened this issue Jun 7, 2020 · 5 comments

Comments

@ppatierno
Copy link
Member

Every response value example in the paths.adoc is wrong because it shows a JSON where the field is application/vnd.kafka.v2+json having as a value the actual response.
For example, on consumer creation:

{
  "application/vnd.kafka.v2+json" : {
    "instance_id" : "consumer1",
    "base_uri" : "http://localhost:8080/consumers/my-group/instances/consumer1"
  }
}

while the actual response value is just

{
   "instance_id" : "consumer1",   
   "base_uri" : "http://localhost:8080/consumers/my-group/instances/consumer1"
}
@ppatierno
Copy link
Member Author

ppatierno commented Jun 7, 2020

So as described in the OpenAPI v2 specification here, the response object contains an "examples" field. The corresponding "Example Object", described here has the mime type as field name and the example response as value.
It means that what we have in the OpenAPI v2 specification file is right but the tool which auto-generates the doc should strip the mime type in the showed example.

For example, on consumer creation, we have the following in the OpenAPI v2 specification file

"responses": {
          "200": {
            "description": "Consumer created successfully.",
            "schema": {
              "$ref": "#/definitions/CreatedConsumer"
            },
            "examples": {
              "application/vnd.kafka.v2+json": {
                "instance_id": "consumer1",
                "base_uri": "http://localhost:8080/consumers/my-group/instances/consumer1"
              }
            }
          }

which is compliant with the specification (example object with the mime type "application/vnd.kafka.v2+json" as field name, and the actual example as value) but the tool should generate just the following as an example response value (so what the HTTP client has to expect in the HTTP body).

{
   "instance_id" : "consumer1",   
   "base_uri" : "http://localhost:8080/consumers/my-group/instances/consumer1"
}

and not the entire "Example Object" like this:

{
  "application/vnd.kafka.v2+json" : {
    "instance_id" : "consumer1",
    "base_uri" : "http://localhost:8080/consumers/my-group/instances/consumer1"
  }
}

@ppatierno ppatierno changed the title Wrong JSON example responses Wrong JSON for response example Jun 7, 2020
@ppatierno
Copy link
Member Author

ppatierno commented Jun 7, 2020

I opened a corresponding issue on the maven plugin project Swagger2Markup/swagger2markup#409

@ppatierno
Copy link
Member Author

The Swagger2Markup was fixed but it's not released yet. We have to wait for the 2.0.0 version.

@ppatierno
Copy link
Member Author

I opened this issue about pushing the maintainers to have a new bug-fixed release.
Swagger2Markup/swagger2markup#413

@ppatierno
Copy link
Member Author

This was fixed by #602

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

Successfully merging a pull request may close this issue.

1 participant