We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug
Given an OpenAPI component schema configured with nullable: true, properties referencing this schema are not generated as optional.
nullable: true
To Reproduce
Example schema (OpenAPI):
openapi: 3.0.3 components: schemas: Parent: type: object required: - child properties: child: $ref: "#/components/schemas/Child" Child: nullable: true type: object required: - value properties: value: type: string
Used commandline:
datamodel-code-generator datamodel-codegen \ --input ... \ --input-file-type openapi \ --output-model-type typing.TypedDict \ --target-python-version 3.12 \ --strict-nullable \ --use-annotated \ --use-field-description \ --use-schema-description \ --use-standard-collections \ --use-union-operator \ --disable-timestamp
Model output
# generated by datamodel-codegen: # filename: openapi.yaml from __future__ import annotations from typing import TypedDict class Child(TypedDict): value: str class Parent(TypedDict): child: Child
Expected behavior It is expected that the child property of the Parent model be optional.
child
Parent
# generated by datamodel-codegen: # filename: openapi.yaml from __future__ import annotations from typing import TypedDict class Child(TypedDict): value: str class Parent(TypedDict): child: Child | None
Version:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
Given an OpenAPI component schema configured with
nullable: true
, properties referencing this schema are not generated as optional.To Reproduce
Example schema (OpenAPI):
Used commandline:
Model output
Expected behavior
It is expected that the
child
property of theParent
model be optional.Model output
Version:
The text was updated successfully, but these errors were encountered: