openapi-tools / swagger-maven-plugin

Maven plugin to activate the Swagger Core library to generate OpenAPI documentation.
MIT License
70 stars 45 forks source link

Fix #47. Sort paths and components for deterministic specification #49

Closed hiddewie closed 4 years ago

hiddewie commented 4 years ago

Problem

There is non-deterministic output of the generation of the OpenAPI 3.0 document produced by this plugin. Also see #47.

When the file is committed to a source code repository, this causes a diff without changing the actual content of the specification.

The sorting is done by a specialized class, which may be removed after this has been fixed in swagger-core.

This PR

This should solve the problem.

References to other issues and pull requests in Swagger Core:

langecode commented 4 years ago

Great, thx. I will take a look today or tonight and possibly make a new release including this feature.

hiddewie commented 4 years ago

We found another non-deterministic issue with the order of the properties of a Schema (/components/schemas/*/properties). We will also push a fix for that as well on this branch.

All the sorting logic will be extracted to a separate class for better separation of concerns.

hiddewie commented 4 years ago

I also created https://github.com/swagger-api/swagger-core/pull/3613 which solves exactly this problem in Swagger Core, without the code in this PR.

hiddewie commented 4 years ago

Thank you @langecode for the very quick response!

langecode commented 4 years ago

You're welcome. I did change the implementation a little bit but should have the same sematics :)