-
Notifications
You must be signed in to change notification settings - Fork 194
fix: error with invalid type when using exclusiveMininimum and exclusiveMaximum in OpenApi 3.0 #2384
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
AlbinaBlazhko17
wants to merge
15
commits into
main
Choose a base branch
from
fix/exclusive-minimum-maximum-in-oas-3
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
fix: error with invalid type when using exclusiveMininimum and exclusiveMaximum in OpenApi 3.0 #2384
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
53647f6
fix: error with invalid type when using exclusiveMininimum and exclus…
AlbinaBlazhko17 f9a8a75
fix: logic in ternary operator
AlbinaBlazhko17 2fcb224
chore: remove comment
AlbinaBlazhko17 1ccbb4a
fix: errors in pipeline due to incorrect type
AlbinaBlazhko17 189a407
fix: error with properties don't exist
AlbinaBlazhko17 5974751
fix: error in validation function type
AlbinaBlazhko17 ac1498a
fix: types in draft-04 ajv instance
AlbinaBlazhko17 57fe4fc
chore: change naming to fix an issue
AlbinaBlazhko17 06ff4a6
fix: cast to any type to resolve an issue
AlbinaBlazhko17 8cfe2b5
chore: cast to any type
AlbinaBlazhko17 32d45ac
chore: updated dependency
AlbinaBlazhko17 038a539
chore: remove casting to any type
AlbinaBlazhko17 ebb004d
chore: remove import and type
AlbinaBlazhko17 48255a3
feat: remove resolving refs before getting instance due to forked dra…
AlbinaBlazhko17 7dfdffa
chore: remove dependency
AlbinaBlazhko17 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,5 @@ | ||
| --- | ||
| "@redocly/openapi-core": patch | ||
| --- | ||
|
|
||
| Fixed an issue where the `no-invalid-schema-examples` rule was incorrectly linting the `exclusiveMinimum` and `exclusiveMaximum` properties in OpenAPI 3.0. |
43 changes: 43 additions & 0 deletions
43
__tests__/lint/no-invalid-media-type-examples-exclusive-minimum/openapi.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,43 @@ | ||
| openapi: 3.0.2 | ||
| info: | ||
| title: Example OpenAPI 3 definition. | ||
| version: 1.0.0 | ||
|
|
||
| paths: | ||
| /pet: | ||
| get: | ||
| parameters: | ||
| - $ref: '#/components/parameters/validExample' | ||
| responses: | ||
| '200': | ||
| description: Response description | ||
| content: | ||
| application/json: | ||
| schema: {} | ||
|
|
||
| components: | ||
| parameters: | ||
| validExample: | ||
| in: header | ||
| name: Test | ||
| schema: | ||
| type: integer | ||
| minimum: 10 | ||
| exclusiveMinimum: true | ||
| example: 11 | ||
| notValidExampleWithExclusiveMaximum: | ||
| in: query | ||
| name: anotherTest | ||
| schema: | ||
| type: integer | ||
| minimum: 5 | ||
| exclusiveMaximum: true | ||
| example: 10 | ||
| notValidExample: | ||
| in: query | ||
| name: yetAnotherTest | ||
| schema: | ||
| type: integer | ||
| minimum: 0 | ||
| exclusiveMinimum: true | ||
| example: 0 |
6 changes: 6 additions & 0 deletions
6
__tests__/lint/no-invalid-media-type-examples-exclusive-minimum/redocly.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,6 @@ | ||
| apis: | ||
| main: | ||
| root: ./openapi.yaml | ||
|
|
||
| rules: | ||
| no-invalid-schema-examples: error |
44 changes: 44 additions & 0 deletions
44
__tests__/lint/no-invalid-media-type-examples-exclusive-minimum/snapshot.txt
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,44 @@ | ||
| [1] openapi.yaml:32:9 at #/components/parameters/notValidExampleWithExclusiveMaximum/schema/schema | ||
|
|
||
| Example validation errored: exclusiveMaximum can only be used with maximum. | ||
|
|
||
| 30 | name: anotherTest | ||
| 31 | schema: | ||
| 32 | type: integer | ||
| | ^^^^^^^^^^^^^ | ||
| 33 | minimum: 5 | ||
| | ^^^^^^^^^^ | ||
| 34 | exclusiveMaximum: true | ||
| | ^^^^^^^^^^^^^^^^^^^^^^ | ||
| 35 | example: 10 | ||
| | ^^^^^^^^^^^ | ||
| 36 | notValidExample: | ||
| 37 | in: query | ||
|
|
||
| referenced from openapi.yaml:32:9 at #/components/parameters/notValidExampleWithExclusiveMaximum/schema | ||
|
|
||
| Error was generated by the no-invalid-schema-examples rule. | ||
|
|
||
|
|
||
| [2] openapi.yaml:43:18 at #/components/parameters/notValidExample/schema/example | ||
|
|
||
| Example value must conform to the schema: must be > 0. | ||
|
|
||
| 41 | minimum: 0 | ||
| 42 | exclusiveMinimum: true | ||
| 43 | example: 0 | ||
| | ^ | ||
| 44 | | ||
|
|
||
| referenced from openapi.yaml:40:9 at #/components/parameters/notValidExample/schema | ||
|
|
||
| Error was generated by the no-invalid-schema-examples rule. | ||
|
|
||
|
|
||
|
|
||
| validating openapi.yaml using lint rules for api 'main'... | ||
| openapi.yaml: validated in <test>ms | ||
|
|
||
| ❌ Validation failed with 2 errors. | ||
| run `redocly lint --generate-ignore-file` to add all problems to the ignore file. | ||
|
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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.
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.
Coud you add a comment with the link to a document which clarifies the JSON Schema drafts usage for these OAS versions?
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.
Draft-04 handles only validation of
exclusiveMinimumandexclusiveMaximumfor boolean, and all other validations it handles using types/functions/library/vocabulary from basic AJV.