Skip to content
New issue

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

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

Already on GitHub? # to your account

Make yaml serialization deterministic #233

Merged
merged 2 commits into from
Jun 6, 2018

Conversation

jmini
Copy link
Member

@jmini jmini commented Jun 6, 2018

Until swagger-api/swagger-core#2828 is solved, I propose to solve this in our project.

Instead of using Yaml.mapper().writeValueAsString(openAPI) directly, I have introduced a small utility: SerializerUtils that call the same method, but with additional configuration:

  • The properties are now sorted alphabetically (MapperFeature.SORT_PROPERTIES_ALPHABETICALLY feature of Jackson)
  • Because this default configuration was not very user friendly for the root object (OpenAPI instance), I have registered a OpenAPISerializer that order the elements of the root object.

To test it, I have added some Unit Test.
I also have updated the java-inflector sample with bin/java-inflector-petstore-server.sh

@jmini jmini added this to the 3.0.1 milestone Jun 6, 2018
@jmini jmini mentioned this pull request Jun 6, 2018
4 tasks
@jmini jmini merged commit 69a3852 into OpenAPITools:master Jun 6, 2018
jimschubert added a commit to jimschubert/openapi-generator that referenced this pull request Jun 8, 2018
* master:
  Add 'unblu inc.' to company list (OpenAPITools#246)
  put company list in alphabetical order (OpenAPITools#244)
  [jaxrs-spec] generate spec file (yaml) correctly (OpenAPITools#243)
  [C++] Adjust the names (script, sample folder, generator) to lang option (OpenAPITools#220)
  Add GMO Pepabo to company list (OpenAPITools#242)
  [Spring] Add apiFirst option (OpenAPITools#184)
  [cli] Write to stdout/stderr, allow redirection (OpenAPITools#207)
  [JAVA][Client] New object instead of null for empty POST request (OpenAPITools#98)
  Make yaml serialization deterministic (OpenAPITools#233)
  Add syntax highlighting to migration guide (OpenAPITools#237)
  Fix shippable badge (OpenAPITools#232)
  update company list (OpenAPITools#227)
  Fix OpenAPITools#210: [Ada] Update the code generator for required and optional parameters (OpenAPITools#211)
  Delete unused methods in DefaultCodegen (OpenAPITools#209)
  add note about maven plugins (OpenAPITools#216)
  add raiffeisen to company list (OpenAPITools#223)
  add a remark about homebrew installatio (OpenAPITools#217)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants