Generate OpenAI OpenAPI for python pydantic2.datamodel #2965
-
|
Hi, when I run: OPENAPI_URL="https://app.stainless.com/api/spec/documented/openai/openapi.documented.yml"
OPENAPI_FILE="./openapi.documented.yml"
echo "Downloading OpenAPI spec from $OPENAPI_URL..."
curl -s --fail-with-body -o "$OPENAPI_FILE" "$OPENAPI_URL"
# Generate Python models using datamodel-code-generator
OUTPUT_FILE="./openapi_models.py"
echo "Generating Python models..."
# Run datamodel-code-generator with basic options similar to the main models
uv run datamodel-codegen \
--input "$OPENAPI_FILE" \
--output "$OUTPUT_FILE" \
--output-model-type pydantic_v2.BaseModel \
--formatters ruff-format \
--input-file-type openapiThen the models are generated, but when using them, I get this error: I now struggle where the error lies: is it a missing CLI argument when running the generator, is it a flaw in the openapi spec or something else? Can somebody with some more knowlege then me support me here to successfully geneate usable files? |
Beta Was this translation helpful? Give feedback.
Answered by
ilovelinux
Jan 23, 2026
Replies: 1 comment
-
|
Hi! I can replicate with Thanks for reporting! |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
guenhter
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! I can replicate with
v.0.53.0and it looks like a bug caused by an unhanded sub-case. Can you open an issue about that?Thanks for reporting!