-
-
Notifications
You must be signed in to change notification settings - Fork 52
Description
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
- Add this gradle plugin to a springboot project
- Execute the
generateOpenApiDocstask - Execute the
bootRuntask - Compare the JSON of the
/v3/api-docsendpoint to theopenapi.jsonfile
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.

