-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Support Tyk OAS with Open Policy Agent #7369
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
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
API Changes --- prev.txt 2025-09-24 09:40:44.227026989 +0000
+++ current.txt 2025-09-24 09:40:34.803947110 +0000
@@ -5664,8 +5664,6 @@
TYPES
-type FailableOption[O any] func(*O) error
-
type Option[O any] func(*O)
type Options[O any] []Option[O]
@@ -12552,6 +12550,16 @@
// Has unexported fields.
}
+# Package: ./pkg/utils
+
+package utils // import "github.com/TykTechnologies/tyk/pkg/utils"
+
+
+FUNCTIONS
+
+func Must[T any](val T, err error) T
+ Must panics if errors is not nil
+
# Package: ./regexp
package regexp // import "github.com/TykTechnologies/tyk/regexp" |
🔍 Code Analysis ResultsAn analysis of the pull request is provided below.Change Impact AnalysisWhat this PR accomplishesThis pull request introduces an extensible validation mechanism for Tyk OAS (OpenAPI Specification) API definitions. The primary goal is to allow custom, non-standard fields at the root of an API definition—such as configurations for Open Policy Agent (OPA)—without causing validation failures. Previously, the OAS validator strictly enforced the official schema, rejecting any definition with unknown root-level properties. This change makes the validator flexible by allowing the schema to be dynamically and temporarily modified before validation occurs, effectively "whitelisting" specific custom fields. Key technical changes introduced
Affected system components
Architecture VisualizationThe following diagram illustrates the new, extensible validation workflow, highlighting the logic for applying schema modifications and using the caching layer. graph TD
A[Start: ValidateOASObjectWithOptions] --> B{Has Options?};
B -- No --> C[Get Base Schema];
B -- Yes --> D[Build Schema Modifier];
D --> E{Is Modified Schema in Cache?};
E -- No --> F[Copy Base Schema];
F --> G[Apply Modifiers e.g., AllowRootFields];
G --> H[Store Modified Schema in Cache];
H --> I[Use Modified Schema];
E -- Yes --> J[Get Schema from Cache];
J --> I;
C --> K[Validate Document with Schema];
I --> K;
K --> L[End: Return Validation Result];
Powered by Visor from Probelabs Last updated: 2025-09-24T09:49:42.266Z | Triggered by: synchronize | Commit: 9e0525b |
🔍 Code Analysis ResultsSecurity Issues (2)
Performance Issues (3)
Quality Issues (2)
Style Issues (2)
Dependency Issues (4)
Connectivity Issues (2)
Powered by Visor from Probelabs Last updated: 2025-09-24T09:49:43.610Z | Triggered by: synchronize | Commit: 9e0525b |
ed48bad
to
9e0525b
Compare
|
User description
TT-10073
Description
Related Issue
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist
PR Type
Enhancement, Tests
Description
Extend OAS validation with options
Add AllowRootFields schema modifier
Introduce failable options builder
Add tests for new behavior
Diagram Walkthrough
File Walkthrough
validator.go
Pluggable OAS schema modifiers and root field allowance
apidef/oas/validator.go
option.go
Failable options support with error-aware builder
common/option/option.go
validator_test.go
Tests for optional root field allowances in OAS
apidef/oas/validator_test.go
go.mod
Add json-patch dependency for tests
go.mod