Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from Jul 2, 2020
Merged

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

merged 5 commits into from Jul 2, 2020

Conversation

hiddewie
Copy link
Contributor

@hiddewie hiddewie commented Jul 1, 2020

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

  • Add sorting of:
    • paths
    • components:
      • Schemas (recursively)
      • Responses
      • Parameters
      • Examples
      • RequestBodies
      • Headers
      • SecuritySchemes
      • Links
      • Callbacks
      • Extensions
  • Improve tests by adding strict file contents equality for existing fixtures. Some of the fixtures in the source code were actually not waht the plugin generated (the OpenAPI content was equal, but the file contents were not).

This should solve the problem.

References to other issues and pull requests in Swagger Core:

@langecode
Copy link
Member

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

@hiddewie
Copy link
Contributor Author

hiddewie commented Jul 2, 2020

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
Copy link
Contributor Author

hiddewie commented Jul 2, 2020

I also created swagger-api/swagger-core#3613 which solves exactly this problem in Swagger Core, without the code in this PR.

@langecode langecode merged commit 0cb405c into openapi-tools:master Jul 2, 2020
@hiddewie hiddewie deleted the 47-deterministic-sort branch July 3, 2020 06:00
@hiddewie
Copy link
Contributor Author

hiddewie commented Jul 3, 2020

Thank you @langecode for the very quick response!

@langecode
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants