Skip to content

required not handled in oneOf clause #151

@gabormagyar

Description

@gabormagyar

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions