Generator creates enum property types that can collide with user-defined types, causing generation failures
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Riprodurre il problema con il comando openapi-python-client generate fornito e lo schema App Store Connect 3.6.0, quindi tracciare come l'enum type dell'oggetto Certificate diventa CertificateType ed entra in conflitto con il tipo di schema esistente. Il lavoro è completato quando la generazione non scarta più gli schemi interessati e non produce un client che fallisce a runtime quando si accede a questi endpoint.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
When the generator creates a new Python type to represent a schema property's enum type it can sometimes get unlucky by generating the name of a user-defined type that already exists in the schema.
When this happens, the generator gives up and issues a warning. The Python type for the enum property and the generated API client are only partially generated as a result. This warning manifests as a runtime error in the Python client when affected endpoints are accessed by the generated Python code. I have so far been unable to figure out any configuration-based way of working around the issue.
OpenAPI Spec File
This issue can be reproduced deterministically by running:
openapi-python-client generate --url https://raw.githubusercontent.com/EvanBacon/App-Store-Connect-OpenAPI-Spec/refs/heads/main/specs/3.6.0.json --overwrite
Relevant warning output is in the "Additional context" section below.
Desktop (please complete the following information):
- OS: macOS 15.1.1
- Python Version: 3.12.1
- openapi-python-client version 0.21.6
Additional context
We discovered this "in the wild" while attempting to generate a Python client for the Apple App Store Connect API.
When we ran the generator on version 3.6.0 of the App Store Connect OpenAPI schema, we saw this (among other) warnings:
Unable to process schema /components/schemas/Certificate:
Found conflicting enums named CertificateType with incompatible values.
Failure to process schema has resulted in the removal of:
/components/schemas/Certificate
/components/schemas/CertificatesWithoutIncludesResponse
/components/schemas/CertificatesResponse
/components/schemas/CertificateResponse
Schema(title=None, multipleOf=None, maximum=None, exclusiveMaximum=None, minimum=None, exclusiveMinimum=None, maxLength=None, minLength=None, pattern=None, maxItems=None, minItems=None, uniqueItems=None, maxProperties=None, minProperties=None, required=None, enum=['certificates'], const=None, type=<DataType.STRING: 'string'>, allOf=[], oneOf=[], anyOf=[], schema_not=None, items=None, prefixItems=[], properties=None, additionalProperties=None, description=None, schema_format=None, default=None, nullable=False, discriminator=None, readOnly=None, writeOnly=None, xml=None, externalDocs=None, example=None, deprecated=None)
This was happening because the generator was attempting to create a type called "CertificateType" when it was traversing the properties of the "Certificate" object, who had a child enum property called "type", excerpt below:
"Certificate": {
"type": "object",
"title": "Certificate",
"properties": {
"type": {
"type": "string",
"enum": [
"certificates"
]
The generator took the name of the parent, and concatenated it with the name of the property to create the name "CertificateType".
Sadly, as noted above, that type name was already taken in the API by a separate user-defined "CertificateType", excerpted below:
"CertificateType": {
"type": "string",
"enum": [
"IOS_DEVELOPMENT",
"IOS_DISTRIBUTION",
- Lingua principale
- Python
- Stelle
- 2k
- Fork
- 293
- Merge medio
- 34m
- PR unite (30g)
- 1
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di openapi-generators/openapi-python-client
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
openapi-generators/openapi-python-client#1451 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 64/100
openapi-generators/openapi-python-client#1435 · 1 commento ·
Tutte le issue di openapi-generators/openapi-python-client
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
anthropics/skills#1811 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
speaches-ai/speaches#678 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
datalayer/mcp-compose#42 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
conda-forge/spacy-feedstock#177 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
UKGovernmentBEIS/inspect_evals#2523 ·