openapi-generators / openapi-generators/openapi-python-client
Generator fails on type: array without items even though it's valid in JSON Schema 2020-12 / OpenAPI 3.1
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2k
- Forks
- 293
- Avg merge
- 34m
- Merged PRs (30d)
- 1
Description
Describe the bug
When a schema has "type": "array" without an "items" field, the generator fails to produce a property for it. In JSON Schema 2020-12 (used by OpenAPI 3.1), omitting items is valid and means "array of any type". The generator should treat it as equivalent to "items": {} (i.e., generate a List[Any] property) rather than silently failing.
OpenAPI Spec File
We encountered this in two forms:
Case 1 — bare array with no constraints:
{
"type": "array",
"description": "Array of objects representing a row of metrics data - can be any format."
}
Case 2 — array with maxItems but no items:
{
"anyOf": [
{ "type": "array", "maxItems": 0 },
{ "type": "object", "properties": { "tag": { "type": "array", "items": { "type": "string" } } } }
]
}
In both cases the generator silently skips the schema (or the anyOf branch) without an error. Adding ["items": {}] to each fixes the generation.
Expected behaviour: {"type": "array"} (with or without other constraints like maxItems) should generate a List[Any] property, consistent with how JSON Schema 2020-12 defines it.
Desktop (please complete the following information):
- OS: Ubuntu 24.04.3 LTS
- Python Version: 3.12.3
- openapi-python-client 0.28.1
- OpenAPI version: 3.1.1 (JSON Schema 2020-12)
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 by tracing how the generator handles array schemas and anyOf branches when items is absent, using the two schemas in the issue as inputs. Add regression coverage for bare arrays and arrays with maxItems, then run the generator and confirm both produce a List[Any] property instead of being skipped.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, python
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 64/100