Repository navigation
Preserve descriptor order in JSON Schema and OpenAPI output - #302
Open
moohee-lee wants to merge 1 commit into
Open
moohee-lee wants to merge 1 commit into
moohee-lee wants to merge 1 commit into
Conversation
Everit's schema serialization loses field descriptor order, so ordered schema collection maps alone do not preserve the declared property order. Build each parent's child order once from the original descriptors and reuse it for nested objects and array items. Use escaped full parent paths to distinguish repeated field names and names containing slashes or tildes. Keep the existing descriptor deduplication and type merging behavior. Align required names with property order in OpenAPI 2 and 3 output after Swagger sorts those names alphabetically. Preserve numeric defaults when converting Swagger models to JSON trees. Add regression coverage for JSON, YAML and YML output, optional fields absent from examples, root and nested arrays, duplicate descriptors, and repeated or escaped field names. Verify Postman example bodies remain unchanged and document the ordering guarantees. Validation: ./gradlew build with JDK 17; 189 tests passed, 3 existing skips.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Generated request and response schemas can lose
fieldWithPathdeclaration order during Everit serialization. The schema collection changes in #280 do not address this common JSON Schema generation path.Changes
propertiesandrequiredorder from the original field descriptors, including nested objects and root or nested arrays.requiredlists with property order in the OpenAPI 2 and 3 writers after Swagger sorts those lists alphabetically. Preserve numeric defaults during serialization.Validation
./gradlew buildwith JDK 17: 189 tests passed, 3 existing tests skipped; Kotlin lint and plugin validation passed.Fixes #198.