kotlin-openapi3-dsl icon indicating copy to clipboard operation
kotlin-openapi3-dsl copied to clipboard

Output properties order are not consistent.

Open jpuerto opened this issue 2 years ago • 0 comments

I have found an issue while creating an OpenAPI definition with this library.

I define my operation responses as:

               responses {
                    response("204") {
                        description = "..."
                    }
                    responses.putAll(standardResponses)
                }

Where standardResponses is a collection of common responses. The responses method is a builder for ApiResponses class from swagger that implement LinkedHashMap so the order should be preserved.

Everything should work but the output does not keep the same order I used while inserting the responses, the cuprit seems to be the JSONObject used for formatting: https://github.com/derveloper/kotlin-openapi3-dsl/blob/3d08c129b974dc1f557f33676296aeb1d2cca1b5/src/main/kotlin/cc/vileda/openapi/dsl/OpenApiDsl.kt#L33-L37

Looks like there is a debate about this problem at the moment, see issue

jpuerto avatar Nov 16 '23 15:11 jpuerto