-
Notifications
You must be signed in to change notification settings - Fork 225
fix: keep sibling keywords when a referenced schema has a root-level $ref #2965
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
Open
RomanHotsiy
wants to merge
21
commits into
main
Choose a base branch
from
fix/bundle-root-ref-sibling-keywords
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
5d101df
fix: keep sibling keywords when a referenced schema has a root-level …
RomanHotsiy 4e46cf2
chore: simplify changeset wording
RomanHotsiy 113c97d
Apply suggestion from @RomanHotsiy
RomanHotsiy 420e2e9
fix: follow composed $ref chains in no-required-schema-properties-und…
RomanHotsiy 232e3e3
Apply suggestion from @JLekawa
JLekawa 15453a9
Merge branch 'main' into fix/bundle-root-ref-sibling-keywords
RomanHotsiy 2cb6857
feat: expose composed $ref chains on the resolve result instead of st…
RomanHotsiy 2df7b6e
Merge branch 'fix/bundle-root-ref-sibling-keywords' of github.com:Red…
RomanHotsiy 1c03c85
fix: validate required on inline composed $refs and ignore non-array …
RomanHotsiy 094ff48
fix: walk $ref sibling values that collide with resolved node keys
RomanHotsiy 71b7bc5
test: pin per-level chain independence for multi-hop composed refs
RomanHotsiy 7801c2b
fix: keep the resolve contract for rewritten bundled refs
RomanHotsiy 5d8b082
refactor: carry a Location on chain hops and simplify walker checks
RomanHotsiy 7f9f301
fix: check composed chain hops even when the chain end was already vi…
RomanHotsiy 1093b74
refactor: build the bundled ref registration from the resolve result
RomanHotsiy eded810
Apply suggestion from @RomanHotsiy
RomanHotsiy 6261d46
Merge branch 'main' into fix/bundle-root-ref-sibling-keywords
RomanHotsiy 64e1a0f
refactor: walk each composed hop in its own frame and split sibling w…
RomanHotsiy 8d88d3a
Merge branch 'fix/bundle-root-ref-sibling-keywords' of github.com:Red…
RomanHotsiy 6fbd859
test: cover discriminator mappings pointing to composed schemas
RomanHotsiy b704b0b
fix: do not crash on $ref siblings when the ref resolves to null
RomanHotsiy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| '@redocly/openapi-core': minor | ||
| '@redocly/cli': minor | ||
| --- | ||
|
|
||
| Fixed the `bundle` command losing schema keywords (such as `title`, `properties`, or `required`) written next to a `$ref` when the referenced schemas started with their own `$ref`. |
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
23 changes: 23 additions & 0 deletions
23
packages/core/src/__tests__/fixtures/sibling-refs/openapi-discriminator-mapping.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| openapi: 3.1.0 | ||
| info: | ||
| title: Discriminator mapping to a composed schema | ||
| version: 1.0.0 | ||
| paths: | ||
| /pets: | ||
| get: | ||
| responses: | ||
| '200': | ||
| description: OK | ||
| content: | ||
| application/json: | ||
| schema: | ||
| oneOf: | ||
| - $ref: '#/components/schemas/Pet' | ||
| components: | ||
| schemas: | ||
| Pet: | ||
| type: object | ||
| discriminator: | ||
| propertyName: type | ||
| mapping: | ||
| cat: ./schemas/Cat.yaml |
24 changes: 24 additions & 0 deletions
24
packages/core/src/__tests__/fixtures/sibling-refs/openapi-root-ref-siblings.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| openapi: 3.1.0 | ||
| info: | ||
| title: Root-level $ref with sibling keywords | ||
| version: 1.0.0 | ||
| paths: | ||
| /demo: | ||
| get: | ||
| responses: | ||
| '400': | ||
| description: Bad request | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: ./schemas/BadRequest.yaml | ||
| components: | ||
| schemas: | ||
| BadRequest: | ||
| $ref: ./schemas/BadRequest.yaml | ||
| ProblemAlias: | ||
| $ref: ./schemas/BaseProblem.yaml | ||
| title: Problem alias | ||
| Problem: | ||
| $ref: '#/components/schemas/ProblemAlias' | ||
| description: Composed problem |
25 changes: 25 additions & 0 deletions
25
packages/core/src/__tests__/fixtures/sibling-refs/openapi-sibling-collision.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| openapi: 3.1.0 | ||
| info: | ||
| title: Sibling properties colliding with the referenced schema keys | ||
| version: 1.0.0 | ||
| paths: | ||
| /demo: | ||
| get: | ||
| responses: | ||
| '200': | ||
| description: OK | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/Test' | ||
| properties: | ||
| second: | ||
| $ref: ./schemas/BaseProblem.yaml | ||
| components: | ||
| schemas: | ||
| Test: | ||
| type: object | ||
| title: Test schema | ||
| properties: | ||
| first: | ||
| type: integer |
10 changes: 10 additions & 0 deletions
10
packages/core/src/__tests__/fixtures/sibling-refs/schemas/BadRequest.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| title: Bad request | ||
| type: object | ||
| $ref: ./BaseProblem.yaml | ||
| properties: | ||
| status: | ||
| type: integer | ||
| minimum: 400 | ||
| maximum: 400 | ||
| required: | ||
| - status |
4 changes: 4 additions & 0 deletions
4
packages/core/src/__tests__/fixtures/sibling-refs/schemas/BaseProblem.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| type: object | ||
| properties: | ||
| title: | ||
| type: string |
5 changes: 5 additions & 0 deletions
5
packages/core/src/__tests__/fixtures/sibling-refs/schemas/Cat.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| title: Cat | ||
| $ref: ./BaseProblem.yaml | ||
| properties: | ||
| toy: | ||
| $ref: ./Toy.yaml |
1 change: 1 addition & 0 deletions
1
packages/core/src/__tests__/fixtures/sibling-refs/schemas/Toy.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| type: string |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't it be better to use snapshot check?