Generator fails on type: array without items even though it's valid in JSON Schema 2020-12 / OpenAPI 3.1

Abierto
#1,435 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
64/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Tranquilo
Stack tecnológico
openapi, python
Área
api, tooling

Línea de trabajo

Empieza rastreando cómo el generador gestiona los esquemas de arrays y las ramas anyOf cuando falta items, usando como entradas los dos esquemas del issue. Añade cobertura de regresión para arrays simples y arrays con maxItems, luego ejecuta el generador y confirma que ambos producen una propiedad List[Any] en lugar de omitirse.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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)
Lenguaje dominante
Python
Estrellas
2k
Forks
293
Merge medio
34 min
PR fusionados (30 d)
1

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de openapi-generators/openapi-python-client

Todos los issues de openapi-generators/openapi-python-client

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.