Improper handling of type compatibility in allOf clauses for OpenAPI 3.1 Spec
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 25.9k
- Forks
- 2.4k
- Avg merge
- 13h 10m
- Merged PRs (30d)
- 4
Description
Since OpenAPI 3.1, the type schema field can now be a list, for example:
"type": ["string", "null"]
Would mean that the schema can be a string or null.
Redoc verifies that when "overriding" a property with allOf, the type is identical (see here). But the check is done using ===, which does not work well for lists, hence I'm getting this error:
Incompatible types in allOf at "/properties/error/properties/code": "string,null" and "string,null"
Expected behavior
If both types in the parent and child schema are ["string", "null"], there shouldn't be an error.
The solution is probably to modify the comparison to be smarter than a simple ===.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/services/OpenAPIParser.ts around the type compatibility check at line 245, using the linked implementation as the entry point. Reproduce the OpenAPI 3.1 allOf case with matching string-and-null type lists and verify that identical parent and child types no longer produce an incompatibility error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, documentation
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100