You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The order of JSON items within the openapi.json file created by this plugin are not consistent with the output of the /v3/api-docs endpoint. I would expect that the order of the JSON files produced by this plugin and springdoc-openapi-webmvc-core remain the same (even if pretty printed). This results in differences in presentation/implementation when using certain clients (e.g Swagger UI).
I realise that JSON is designed to be unordered. However, the fact that io.swagger.v3.oas.models.OpenAPI objects and the gson library purposely used by this plugin both retain item order makes me believe this is an oversight.
Screenshots
JSON from plugin used in Swagger UI:
JSON from jar used in Swagger UI:
To Reproduce
Add this gradle plugin to a springboot project
Execute the generateOpenApiDocs task
Execute the bootRun task
Compare the JSON of the /v3/api-docs endpoint to the openapi.json file
Example
I've provided a very quick demo that shows this in action (json-demo.zip). This project contains a test which outputs the Open API JSON file generated by the springdoc-openapi-core jar to the build directory for comparison with the JSON file produced by the plugin.
Next Steps
I'm happy to create a PR for this if it's something you agree needs fixing.
It only requires a very minor fix which involves swapping response.jsonObject.toString to response.text at OpenApiGeneratorTask.kt#L87. This is because the jsonObject field intentionally does not preserve field order.
The text was updated successfully, but these errors were encountered:
Description
The order of JSON items within the
openapi.json
file created by this plugin are not consistent with the output of the/v3/api-docs
endpoint. I would expect that the order of the JSON files produced by this plugin and springdoc-openapi-webmvc-core remain the same (even if pretty printed). This results in differences in presentation/implementation when using certain clients (e.g Swagger UI).I realise that JSON is designed to be unordered. However, the fact that
io.swagger.v3.oas.models.OpenAPI
objects and the gson library purposely used by this plugin both retain item order makes me believe this is an oversight.Screenshots
JSON from plugin used in Swagger UI:
JSON from jar used in Swagger UI:
To Reproduce
generateOpenApiDocs
taskbootRun
task/v3/api-docs
endpoint to theopenapi.json
fileExample
I've provided a very quick demo that shows this in action (json-demo.zip). This project contains a test which outputs the Open API JSON file generated by the
springdoc-openapi-core
jar to the build directory for comparison with the JSON file produced by the plugin.Next Steps
I'm happy to create a PR for this if it's something you agree needs fixing.
It only requires a very minor fix which involves swapping
response.jsonObject.toString
toresponse.text
at OpenApiGeneratorTask.kt#L87. This is because thejsonObject
field intentionally does not preserve field order.The text was updated successfully, but these errors were encountered: