Skip to content

Output properties order are not consistent. #146

@jpuerto

Description

@jpuerto

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:

internal fun validatedJson(api: OpenAPI): JSONObject {
val json = Json.mapper().writeValueAsString(api)
OpenAPIV3Parser().read(toFile(json).absolutePath)
return JSONObject(json)
}

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions