-
Notifications
You must be signed in to change notification settings - Fork 7
feat: adjust validation openapi #59
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 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d10a57e
feat: align library with OpenAPI 3.2.0 and harden validation
akfaiz 634136f
feat: implement validation error severity levels and best practice ch…
akfaiz 444a3cf
feat: add support for OpenAPI 3.2.0 validation and improve version-sp…
akfaiz fcc46c5
refactor: centralize OpenAPI operation method validation logic into t…
akfaiz cb84fc7
feat: introduce dirty state tracking for incremental builds and add V…
akfaiz 1e5ca16
feat: add ValidateReport method to all adapter interfaces and routers
akfaiz c94d326
refactor: improve makefile shell exit handling and standardize test p…
akfaiz 40c4dd6
feat: support application/x-www-form-urlencoded content for querystri…
akfaiz f4f52b1
refactor: export SecuritySchemeOAuth2MetadataURL and adjust validatio…
akfaiz 5d6fcc2
refactor: move mapper to internal, remove adapter constant, and chang…
akfaiz 793c4ed
test: increase code coverage for some function and adapter
akfaiz 726cc85
refactor: upgrade OpenAPI version to 3.1.2 and improve validation err…
akfaiz 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 |
|---|---|---|
|
|
@@ -34,4 +34,6 @@ coverage/ | |
| .vscode/ | ||
|
|
||
| # AI assistant data | ||
| .claude/ | ||
| .claude/ | ||
|
|
||
| references/* | ||
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 |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| package spec_test | ||
|
|
||
| import ( | ||
| "errors" | ||
| "testing" | ||
|
|
||
| "github.com/oaswrap/spec" | ||
| "github.com/oaswrap/spec/internal/validate" | ||
| ) | ||
|
|
||
| func TestValidationErrorAlias(t *testing.T) { | ||
| // Simulate an error returned from internal/validate | ||
| inner := errors.New("validation failed") | ||
| err := error(validate.Error{ | ||
| Err: inner, | ||
| Severity: validate.SeverityWarning, | ||
| }) | ||
|
|
||
| // Verify we can use the public alias and constants | ||
| var valErr spec.ValidationError | ||
| if !errors.As(err, &valErr) { | ||
| t.Fatal("expected error to be spec.ValidationError") | ||
| } | ||
|
|
||
| if valErr.Severity != spec.SeverityWarning { | ||
| t.Errorf("expected SeverityWarning, got %v", valErr.Severity) | ||
| } | ||
|
|
||
| if !errors.Is(valErr, inner) { | ||
| t.Error("expected ValidationError to wrap inner error") | ||
| } | ||
| } | ||
|
|
||
| func TestValidationErrors_HasSeverity(t *testing.T) { | ||
| vErrs := spec.ValidationErrors{ | ||
| Errors: []error{ | ||
| spec.ValidationError{Err: errors.New("err"), Severity: spec.SeverityError}, | ||
| spec.ValidationError{Err: errors.New("warn"), Severity: spec.SeverityWarning}, | ||
| }, | ||
| } | ||
|
|
||
| if !vErrs.HasSeverity(spec.SeverityError) { | ||
| t.Error("expected to have SeverityError") | ||
| } | ||
| if !vErrs.HasSeverity(spec.SeverityWarning) { | ||
| t.Error("expected to have SeverityWarning") | ||
| } | ||
| if vErrs.HasSeverity(spec.SeverityInfo) { | ||
| t.Error("expected NOT to have SeverityInfo") | ||
| } | ||
|
|
||
| vWarnsOnly := spec.ValidationErrors{ | ||
| Errors: []error{ | ||
| spec.ValidationError{Err: errors.New("warn"), Severity: spec.SeverityWarning}, | ||
| }, | ||
| } | ||
| if vWarnsOnly.HasSeverity(spec.SeverityError) { | ||
| t.Error("expected NOT to have SeverityError in warnings-only collection") | ||
| } | ||
|
|
||
| vPtrWarnsOnly := spec.ValidationErrors{ | ||
| Errors: []error{ | ||
| &validate.Error{Err: errors.New("warn"), Severity: spec.SeverityWarning}, | ||
| }, | ||
| } | ||
| if vPtrWarnsOnly.HasSeverity(spec.SeverityError) { | ||
| t.Error("expected NOT to have SeverityError in pointer warnings-only collection") | ||
| } | ||
| } |
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
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.
P2 | Confidence: High
The
joinErrorsfunction now returnsnilwhen the collection contains no error withSeverityError. Previously any non-nil validation error (including those now reclassified asWarningorInfo) caused a non-nil return. This change alters the contract of allValidate()calls: adapters (e.g.,adapter/muxopenapi/router.go) and the generator'sMarshalYAML(viarouter.go) will now silently accept spec generation even when best-practice issues like missingoperationId,summary, ordescriptionare present. Consumers that relied onValidate()to catch any validation issue will no longer be notified of these recommendations, potentially producing suboptimal specifications. This is a deliberate design choice to align with severity levels, but it is a breaking behavioral change for existing callers.