Repository navigation
fix: allow the file type in OpenAPI 2.0 response schemas - #3255
Merged
Daryna-del merged 5 commits intoOct 19, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: cfc814e The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
JLekawa
reviewed
Oct 19, 2026
JLekawa
approved these changes
Oct 19, 2026
Contributor
Performance Benchmark (Lower is Faster)
|
Daryna-del
approved these changes
Oct 19, 2026
Contributor
|
@HawkForge |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What/Why/How?
The OpenAPI 2.0 spec allows
type: filein the schema of a Response Object ("As an extension to the Schema Object, its roottypevalue may also be"file"").The
structrule rejected it because the OAS 2Schemanode type only allowsobject,array,string,number,integer,boolean, andnullfortype.This adds
fileto that enum inpackages/core/src/types/oas2.ts.Responses and nested schemas share the same
Schemanode type, sofileis now accepted at any depth, not only at the root of a response schema.That matches how the enum already accepts
null, which OAS 2 does not define either. A separate node type for the response schema root would keep other rules from visiting it as aSchema.Reference
Fixes #540. Thanks @thejan2009 for the report.
Testing
Added a case to
packages/core/src/rules/oas2/__tests__/struct/operation.test.tswith a200response whose schema istype: file.It fails without the change (the
typecan be one of the following only... error at#/paths/~1download/get/responses/200/schema/type) and passes with it.npm run unit -- packages/core/src/rules --coverage=falsepasses (705 tests).Screenshots (optional)
Check yourself
Security
Note
Low Risk
Narrow validation-schema change with a regression test; no auth, runtime API, or data-handling impact.
Overview
Fixes false positives from the
structrule on valid Swagger 2.0 specs that declaretype: fileon a responseschema(allowed by the spec for file/binary responses).The OAS 2
Schemanode type inpackages/core/src/types/oas2.tsnow includesfilein the allowed values fortype, aligning response schemas with parameter types that already acceptedfile. A struct test covers aGET /downloadresponse withschema.type: fileand expects no lint errors. A patch changeset notes the fix for@redocly/openapi-coreand@redocly/cli.Reviewed by Cursor Bugbot for commit 8b95f63. Configure here.