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:
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too