openapi-generators / openapi-generators/openapi-python-client
Generates SyntaxError if a path parameter without a default value follows another that has a default value
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 2k
- Fork
- 293
- Merge medio
- 34m
- PR unite (30g)
- 1
Descrizione
Describe the bug
Fails to generate client when a path parameter without a default value follows another one that has a default value.
Message:
Error(s) encountered while generating, client was not created
ruff failed
SyntaxError: Parameter without a default cannot follow a parameter with a default
OpenAPI Spec File
Motivating api: https://avaandmed.keskkonnaportaal.ee/swagger/index.html ("File of document")
Minimum example:
openapi: 3.0.0
info:
title: Minimal Repro for Parameter Order Bug
version: 1.0.0
paths:
/test/{has_default}/{no_default}:
get:
summary: Test endpoint with required path params, some with defaults
parameters:
- name: has_default
in: path
required: true
schema:
type: string
default: default_value
description: Required path param with default
- name: no_default
in: path
required: true
schema:
type: integer
description: Required path param, no default
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
result:
type: string
Desktop (please complete the following information):
- OS: Ubuntu 22.04.5 LTS
- Python Version: 3.10.12
- openapi-python-client version 0.25.2
Additional context
The generated function signature for _get_kwargs looks like this:
def _get_kwargs(
has_default: str = 'default_value',
no_default: int,
) -> dict[str, Any]:
The issue does not occur for query parameters, as the generator emits keyword-only arguments (*) for them. It only occurs for path parameters, which are emitted as positional-or-keyword arguments.
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.
Direzione di ricerca
Riproduci il problema con la specifica OpenAPI minima riportata e ispeziona il percorso del generatore che costruisce la firma _get_kwargs generata per i parametri di percorso. Conferma la correzione generando correttamente un client e verificando che i parametri di percorso obbligatori possano seguire parametri con valori predefiniti senza causare un Python SyntaxError.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- openapi, python
- Ambito
- api, tooling
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 50/100