s-knibbs / dataclasses-jsonschema

JSON schema generation from dataclasses
MIT License
166 stars 38 forks source link

Schema for tuple types incompatible with OpenAPI Spec 3.0 #182

Closed s-knibbs closed 2 years ago

s-knibbs commented 2 years ago

The following schema is valid for jsonschema but not for openapi 3.0:

{
  "type": "array",
  "minItems": 2,
  "maxItems": 2,
  "items": [{"type": "number"}, {"type": "number"}]
}

For the above case, since both tuple items have the same type, we can replace the above with this:

{
  "type": "array",
  "minItems": 2,
  "maxItems": 2,
  "items": {"type": "number"}
}