Skip to content

Could array items contain an array of schemas? #1869

Closed
@adjenks

Description

@adjenks

I'm having difficulty understanding why in a requestBody one cannot specify the elements of an array explicitly. One can only have a general schema that applies to all items.

As it states in the latest OpenApi Spec:

items - Value MUST be an object and not an array. Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema. items MUST be present if the type is array.

But in json schema it states:

The value of "items" MUST be either a valid JSON Schema or an array
of valid JSON Schemas.

My particular API REALLY needs to have request bodies that contain arrays with specifically ordered and typed elements, but with the current definition this is not allowed. I'm having a hard time understanding why the specification should disallow the definition of any particular JSON structure.

My schema definition currently breaks all the tools, so I've worked around it by defining my schemas as empty like so:

type: array
items: {}

and then I provide the details of how it should really be structured in the examples section.

So, as the title says, I'd like to know why it was chosen to not allow this. I'd also like to know if anyone would be open to the idea of getting rid of the "and not an array" requirement? I know this likely has a variety of implications, but let's talk about them 😀.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions