Open roquie opened 6 months ago
Describe the bug Does not generate an enumeration for oneOf + cost. For example, autocomplete in Jetbrains IDE works fine for this case.
To Reproduce
Example schema:
# definition nodeJsModeEnum: title: NodeJS mode type: string description: | A long description here. default: npm oneOf: - title: npm const: npm - title: yarn const: yarn - title: npm ci const: npm_ci # usage properties: mode: $ref: "#/definitions/nodejsModeEnum"
Used commandline:
pdm run datamodel-codegen --input config/schema/cd.schema.yaml --input-file-type jsonschema --output src/config/cd_model.py --output-model-type pydantic_v2.BaseModel # pyproject.toml options #[tool.datamodel-codegen] #field-constraints = true #snake-case-field = true #strip-default-none = false #target-python-version = "3.11"
Expected behavior
# expects class NodeJsModeEnum(Enum): npm = 'npm' yarn = 'yarn' npm_ci = 'npm_ci' # actual class NodeJsModeEnum(RootModel[str]): root: str = Field( ..., description='...' )
Version:
How to fix with problem ? @roquie
Describe the bug Does not generate an enumeration for oneOf + cost. For example, autocomplete in Jetbrains IDE works fine for this case.
To Reproduce
Example schema:
Used commandline:
Expected behavior
Version: