openapi-tools / swagger-maven-plugin

Maven plugin to activate the Swagger Core library to generate OpenAPI documentation.
MIT License
70 stars 45 forks source link

OpenApi.json / yaml are not the same as one available during runtime #51

Open ewoks opened 3 years ago

ewoks commented 3 years ago

Describe the bug generated json|yaml file has different content than one available on host:8080/openapi

To Reproduce

  1. execute: $ mvn io.openapitools.swagger:swagger-maven-plugin:2.1.4:generate
  2. start application and send request like: curl <host>:8080/openapi > runtime_openapi.yaml
  3. compare the files with diff <generated>-openapi.yaml runtime_openapi.yaml
<       operationId: getAll
29,30c10,11
<         default:
<           description: default response
---
>         "200":
>           description: OK
34,37c15
<                 uniqueItems: true
<                 type: array
<                 items:
<                   $ref: '#/components/schemas/Fruit'
---
>                 $ref: '#/components/schemas/SetFruit'
39d16
<       operationId: add
46,47c23,24
<         default:
<           description: default response
---
74d43
<       operationId: hello
76,77c45,46
<         default:
<           description: default response
---
>         "200":
>           description: OK
84,89c53,58
<       operationId: greeting
<       requestBody:
<         content:
<           '*/*':
<             schema:
<               type: string
---
>       parameters:
>       - name: name
>         in: path
>         required: true
>         schema:
>           type: string
91,92c60,61
<         default:
<           description: default response
---
>         "200":
>           description: OK

Expected behavior Both generated and runtime available openapi spec have the same content

ewoks commented 3 years ago

@langecode maybe I misunderstood something? Your opinion would be very appreciated

langecode commented 3 years ago

Hi @ewoks

I think there could be a couple of things here. First of all your runtime generation and the build time generation may not run the same version of the Swagger library. I would think this may cause the difference.

Second I am not sure which of the two OpenAPI specifications you actually consider the most correct one? It seems the one have a "default" response where the other has "200". I am not quite sure what is the most correct - of course if you actually did document your responses using the Swagger OpenAPI annotations in the code that should be reflected in the generated documentation. However, if you have not actually documented anything I think it may be a bit more tricky.

langecode commented 3 years ago

Could you attach or link to both of the documents? Or would that reveal anything confidential...