-
Notifications
You must be signed in to change notification settings - Fork 9
fix: support OpenAPI 3.0 boolean exclusiveMinimum/exclusiveMaximum validation #52
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
fix: support OpenAPI 3.0 boolean exclusiveMinimum/exclusiveMaximum validation #52
Conversation
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.
Pull Request Overview
This PR fixes OpenAPI 3.0 boolean exclusiveMinimum/exclusiveMaximum validation by implementing version-aware schema validation. The validation logic was incorrectly applying OpenAPI 3.1 rules (numeric exclusive bounds) to 3.0 documents (boolean exclusive bounds).
- Added version-aware schema validation to detect OpenAPI document version from context or explicit
$schemadeclarations - Created OpenAPI 3.0 schema definition with proper boolean support for exclusive bounds
- Refactored validation calls to use instance methods with proper context propagation
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
jsonschema/oas3/validation.go |
Implements version-aware schema selection and validation logic |
jsonschema/oas3/schema30.json |
New OpenAPI 3.0 schema definition supporting boolean exclusive bounds |
jsonschema/oas3/schema_exclusive_validation_test.go |
Comprehensive test suite for exclusive bounds validation |
openapi/openapi.go |
Adds document version context to validation options |
openapi/parameter.go |
Updates schema validation to use instance method |
openapi/mediatype.go |
Updates schema validation to use instance method |
openapi/header.go |
Updates schema validation to use instance method |
openapi/components.go |
Simplifies schema validation logic |
arazzo/arazzo.go |
Adds document version context for Arazzo validation |
arazzo/components.go |
Updates input validation to use instance method |
| Test files | Replace custom helper functions with standard pointer utility |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
📊 Test Coverage ReportCurrent Coverage: Coverage Change: 📈 +.1% (improved) Coverage by Package
Generated by GitHub Actions |
Fix: Support OpenAPI 3.0 Boolean exclusiveMinimum/exclusiveMaximum Validation
Problem
The OpenAPI library was incorrectly rejecting boolean values for
exclusiveMinimumandexclusiveMaximumfields in OpenAPI 3.0 documents, throwing validation errors like:This occurred because the validation logic was using JSON Schema Draft 2020-12 (which only supports numeric values) for all schemas, regardless of the OpenAPI version.
Root Cause
exclusiveMinimum/exclusiveMaximumare boolean fields that modifyminimum/maximumexclusiveMinimum/exclusiveMaximumare numeric fields that replaceminimum/maximumThe validation was incorrectly applying 3.1 rules to 3.0 documents.
Solution
1. Version-Aware Schema Validation
validation.goto detect OpenAPI version from document context or explicit$schemadeclarationsschema30.json(supports boolean exclusive bounds)schema31.json(supports numeric exclusive bounds)2. OpenAPI 3.0 Schema Definition
schema30.jsonwith official OpenAPI 3.0 Schema Object definition$schemaproperty support for explicit dialect declarations3. Comprehensive Test Coverage
schema_exclusive_validation_test.go$schemadeclarationsChanges
Files Modified
jsonschema/oas3/validation.go- Added version-aware schema selectionjsonschema/oas3/schema30.json- New OpenAPI 3.0 schema definitionjsonschema/oas3/schema_exclusive_validation_test.go- Comprehensive test suiteFiles Removed
jsonschema/oas3/schema_exclusive_boolean_test.go- Consolidated into main testjsonschema/oas3/schema30_validation_test.go- Consolidated into main testTesting
All tests pass with comprehensive coverage:
Backward Compatibility
This fix maintains full backward compatibility: