swagger-api / swagger-core

Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API

Home Page:http://swagger.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to always generate yaml/json with the same element order?

rodrigo-rufino opened this issue · comments

I need to generate the yaml file for my application, but I need it to be the same every time I generate it in order to compare it the current generated yaml with the current state of my API.

But I'm having trouble making this comparison deterministic.

Is there any way I can make swagger to:

  • Generate the yaml file with the same element order?
  • Generate the same yaml file if no changes to the endpoint codes are made?

I know springdoc has some configurations to do that, but my project does not use spring.

Notes

  • I'm using io.swagger.core.v3:swagger-jaxrs2:2.0.1.

Just a hint .. the swagger maven plugin supports "sortOutput" and "prettyPrint".

  • io.swagger.v3.oas.integration.SwaggerConfiguration.setSortOutput(Boolean)
  • io.swagger.v3.oas.integration.GenericOpenApiContext.init()

It was noy available on the version I'm using. I sorted it manually.