feat(rulesets): improve OAS 3.1 external references validation#2844
feat(rulesets): improve OAS 3.1 external references validation#2844fluz wants to merge 6 commits into
Conversation
- Update OAS 3.1 schema to better support external references - Add external references test scenario in test-harness - Update Arazzo schema validators to use improved OAS 3.1 schema - Enhance OAS 3 schema test coverage Fixes issues with external reference validation in OpenAPI 3.1 documents.
a7c06e7 to
fde1451
Compare
|
Hi someone can review my proposal. TIA |
|
Hi Pals, just a kindly reminder to not forget my PR 🙏🏾 :-) |
|
Hi @mnaumanali94 , can you please take a look on this PR when you have time 🙏🏾 :-) |
|
Could you please take a look at my PR? 🙏🏾 Thanks! |
|
Thank you @fluz for providing a fix for this issue. The |
|
Hi @stoplightio/oss-spectral Please take a look when it is possible in this PR. 🙏🏾 Thanks in advance |
|
@fluz did you consider requesting a review personally (not from the whole team)? |
|
@katepol I tried, but I will check again who can support us on this :-/ |
|
@tomek-tursa-sb @tekyu you both seem to have privilege to approve and merge PRs. Could you please have a look here? It's open for 6 months without any feedback from the team. If you don't want to merge: Who's the right person to contact? |
|
@tomek-tursa-sb @SB-rohitdesai @tekyu @mattshaner can you support us and take an eye on this PR 🙏🏾 |
|
@tomek-tursa-sb @SB-rohitdesai @fluz We should close this PR, I dont think we should change the oas/v3.1, the oas json is the official ruleset from openapi. Looking into the latest oas schema version the |
@NelDev1104, I couldn't find the changes in your link, the Maybe I'm looking in the wrong place. Could you please clarify where the difference is? |
|
@fluz "paths": {
"type": "object",
"patternProperties": {
"^/": {
"$ref": "#/$defs/path-item"
}
},
"$ref": "#/$defs/specification-extensions",
"unevaluatedProperties": false
},
"path-item": {
"type": "object",
"properties": {
"summary": {
"type": "string"
},
"description": {
"type": "string"
},
"servers": {
"type": "array",
"items": {
"$ref": "#/$defs/server"
}
},
"parameters": {
"type": "array",
"items": {
"$ref": "#/$defs/parameter-or-reference"
}
}
},Oas 3.1 latest version "paths": {
"$comment": "https://spec.openapis.org/oas/v3.1#paths-object",
"type": "object",
"patternProperties": {
"^/": {
"$ref": "#/$defs/path-item"
}
},
"$ref": "#/$defs/specification-extensions",
"unevaluatedProperties": false
},
"path-item": {
"$comment": "https://spec.openapis.org/oas/v3.1#path-item-object",
"type": "object",
"properties": {
"$ref": {
"type": "string",
"format": "uri-reference"
},
"summary": {
"type": "string"
},
"description": {
"type": "string"
},
"servers": {
"type": "array",
"items": {
"$ref": "#/$defs/server"
}
},
"parameters": {
"type": "array",
"items": {
"$ref": "#/$defs/parameter-or-reference"
}
},In the current version $ref is missing in the properties path-item |
Nice 😍 , thanks for the clarification. Feel free to close this one and open a new one. But I think the most important thing is to have this issue solved 😢. |
|
So what is the state of this problem? Is it solved somehow? I still have this error. |
slegarraga
left a comment
There was a problem hiding this comment.
Good test coverage for OAS 3.1 external $ref on paths — harness scenario + unit case both document the expected “no false schema errors” behavior.
Small surface area in validators; aligns with #2899. Looks good from my side.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds support for validating OpenAPI 3.1 documents that use external $ref at the Path Item level, and introduces regression coverage in both the test harness and unit tests.
Changes:
- Added a new OAS 3.1 scenario that lints a document with an external Path Item
$ref. - Updated the OAS 3.1 JSON Schema for
pathsentries to allow a Path Item or a reference. - Added a unit test ensuring an OAS 3.1 document with an external Path Item
$refdoes not produce schema errors.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test-harness/scenarios/oas3.1/external-ref.scenario | New integration-style scenario validating external Path Item $ref passes linting. |
| packages/rulesets/src/oas/schemas/oas/v3.1/index.json | Schema change to permit reference-style Path Items under paths. |
| packages/rulesets/src/oas/tests/oas3-schema.test.ts | Regression test for OAS 3.1 external Path Item $ref acceptance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,40 @@ | |||
| ====test==== | |||
| OAS 3.1 - External Ref Validation | |||
| "patternProperties": { | ||
| "^/": { | ||
| "$ref": "#/$defs/path-item" | ||
| "$ref": "#/$defs/path-item-or-reference" |
Fix schema validation error where path items were incorrectly flagged as having unevaluated properties. Changed paths pattern properties to use path-item-or-reference instead of path-item to support external references in OpenAPI 3.1 specifications properly.
Fixes the issue where documents like:
Would generate:
"~1greetings" property must not have unevaluated properties.Fixes #2655
Checklist
Does this PR introduce a breaking change?