Repository navigation
Support per-generation primitive annotations and extra reserved field names #1529
gael-obin
started this conversation in
Feature request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Would you consider two opt-in, per-generation settings for custom model templates? One would supply a Python annotation and its import for an OpenAPI primitive (or primitive and format). The other would add caller-supplied names to the existing field identifier rules.
Reproducer
Run
openapi-python-client generate --path openapi.yaml --meta noneon 0.29.1 or 0.30.0. The generatedResultdeclarescount: int,amount: float,enabled: bool, andschema: str. A custom Pydantic v2 template needs to emitStrictInt,StrictBool, and a localNumber = StrictInt | StrictFloatso a JSON integer stays an integer. It also needs the Python fieldschema_with the wire keyschema, becauseschemais aBaseModelattribute.Requested behavior
schema_while reading and writingschema. Generation without either option keeps the current output, including when two configurations are used by one Python process.At present the config exposes class and content-type overrides, while primitive annotations such as
FloatProperty._type_stringand theRESERVED_WORDSset live inside the generator. Changing those internals globally makes custom templates sensitive to upgrades and generation order. The external-model proof of concept takes a different route. These settings would let a custom model template reuse the same parser and model names as the endpoint generator.All reactions