Redocly / Redocly/openapi-sampler
`required` not handled in `oneOf` clause
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 228
- Forks
- 52
- Avg merge
- 48m
- Merged PRs (30d)
- 6
Description
See reproduced example here:
https://codesandbox.io/p/sandbox/openapi-sampler-oneof-bug-ignfcs
I have the following schema:
{
type: "object",
properties: {
a: {
type: "string",
},
b: {
type: "string",
},
},
oneOf: [
{
required: ["a"],
},
{
required: ["b"],
},
],
};
Since either a is required or b is required I would expect {a: "string"} or {b: "string"} to be correct examples for this schema.
openapi-sampler produces {a: "string", b: "string"} as an example which is incorrect. The error given by asyncapi parser is must match exactly one schema in oneOf.
If I add the {skipNonRequired: true} option then the example becomes {} which is also incorrect.
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 with the linked CodeSandbox reproduction and compare the generated examples for the schema's oneOf clauses with and without skipNonRequired. Trace how oneOf and required are handled, then verify that the resulting example satisfies exactly one branch and is accepted by the AsyncAPI parser.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100