forked from getkin/kin-openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: OpenAPI 3.1 support with scoped validation enhancements #1
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
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
8f1d2f1
feat: add OpenAPI 3.1 support
reuvenharrison c78c494
fix: resolve $ref in OpenAPI 3.1 schema fields (prefixItems, contains…
reuvenharrison 219e544
fix: recurse into OpenAPI 3.1 fields in transformOpenAPIToJSONSchema
reuvenharrison fe6fb07
fix: validate sub-schemas in OpenAPI 3.1 schema fields
reuvenharrison 96c3af9
feat: add const keyword validation to built-in validator
reuvenharrison e0bf83d
fix: improve OpenAPI 3.1 spec compliance
reuvenharrison 74e884b
feat: add remaining JSON Schema 2020-12 keywords and improvements
reuvenharrison 2345e97
style: fix go fmt formatting
reuvenharrison af306ee
fix: resolve 8 correctness issues in OpenAPI 3.1 support
reuvenharrison a0258b9
fix: avoid CI lint match in OPEN_ISSUES.md
reuvenharrison 228d056
chore: remove OPEN_ISSUES.md from repo
reuvenharrison 80bf5ba
fix: resolve 8 additional OpenAPI 3.1 issues
reuvenharrison 543927f
feat: add $schema, $defs keywords and fix remaining issues
reuvenharrison ee89396
fix: strip __origin__ from Const and Examples in Schema.UnmarshalJSON
reuvenharrison 7ae20e3
fix: strip __origin__ from Encoding, Variables, and Webhooks maps
reuvenharrison e1021c6
feat: implement OpenAPI 3.1 validation enhancements
5d2e5c3
chore: update generated docs for ConstIsSet field
c3bbe47
feat: add PathItems field to Components for OpenAPI 3.1
ba653da
fix: use named PathItems type with JSONLookup in Components
1eb90ec
feat: resolve components.pathItems refs in loader
a08ac68
test: add components.pathItems loader, router, and request validation…
f3b181d
chore: regenerate docs for components.PathItems field
995a8c0
add test
6470a96
fix: address CodeRabbit review comments
2a6ad4f
fix: address CodeRabbit review comments (round 2)
f5bb9db
fix: remove capitalized fmt.Printf that triggered CI error-string lin…
0610b4a
ci
72f3982
feat: gate mutualTLS security scheme type to OpenAPI 3.1+
f56b22c
fix: address CodeRabbit review comments (round 3)
ce1a9ca
openapi3: populate SchemaError.Value/Schema/customizeMessageError fro…
d4828ce
openapi3: avoid anchor index pollution from sibling-merged refs
c1a81fd
chore: remove obsolete components.pathItems plan doc
6853b59
openapi3: allow const null in built-in null validation path
526b895
openapi3: constrain const:null null short-circuit to unconstrained sc…
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
Large diffs are not rendered by default.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,25 @@ | ||
| // Package openapi3 parses and writes OpenAPI 3 specification documents. | ||
| // | ||
| // See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md | ||
| // Supports both OpenAPI 3.0 and OpenAPI 3.1: | ||
| // - OpenAPI 3.0.x: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md | ||
| // - OpenAPI 3.1.x: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md | ||
| // | ||
| // OpenAPI 3.1 Features: | ||
| // - Type arrays with null support (e.g., ["string", "null"]) | ||
| // - JSON Schema 2020-12 keywords (const, examples, prefixItems, etc.) | ||
| // - Webhooks for defining callback operations | ||
| // - JSON Schema dialect specification | ||
| // - SPDX license identifiers | ||
| // | ||
| // The implementation is designed to preserve backward compatibility with OpenAPI 3.0. | ||
| // | ||
| // For OpenAPI 3.1 validation, use the JSON Schema 2020-12 validator option: | ||
| // | ||
| // schema.VisitJSON(value, openapi3.EnableJSONSchema2020()) | ||
| // | ||
| // Version detection is available via helper methods: | ||
| // | ||
| // if doc.IsOpenAPI3_1() { | ||
| // // Handle OpenAPI 3.1 specific features | ||
| // } | ||
| package openapi3 |
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.
Bug (Medium): OAS 3→2 conversion produces wrong constraints when both
minimumand numericexclusiveMinimumare presenteffectiveMin/effectiveMaxunconditionally preferminovereb.Valuewhen both are set. ButexclusiveBoundToBoolindependently returnstruewheneb.Value != nil. This combination can change the meaning of constraints.Example: OAS 3.1 schema with
{"minimum": 5, "exclusiveMinimum": 3}meansvalue >= 5 AND value > 3, effectivelyvalue >= 5. The conversion produces OAS 2.0minimum: 5, exclusiveMinimum: true, which meansvalue > 5— a different, stricter constraint.Suggestion: When both
minandeb.Valueare set, compare them to determine the tighter bound and set the boolean accordingly.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.
Fixed in commit f56b22c: introduced
exclusiveMinToBool/exclusiveMaxToBoolhelpers that pick the tighter bound (numericexclusiveMinimum/exclusiveMaximumvsminimum/maximum) when converting OAS 3.1 → 2.0 exclusive bounds.