swagger-maven-plugin icon indicating copy to clipboard operation
swagger-maven-plugin copied to clipboard

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

Open ewoks opened this issue 5 years ago • 3 comments

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 avatar Aug 04 '20 17:08 ewoks

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

ewoks avatar Aug 04 '20 17:08 ewoks

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 avatar Aug 06 '20 09:08 langecode

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

langecode avatar Aug 06 '20 09:08 langecode