I am using datamodel-code-generator to generate models to go along with Uplink to create REST clients. My REST API documentation is in OpenAPI yaml format and includes examples for field values. These example values are useful for the API client users to understand the field value and formats.
VSCode and other IDE with intellisense pick up the doc string to display help on a function and its arguments.
The values of Example field in the OpenAPI documents are translated as Field(example='your example here') which benefits if the model is dumped as JSON schema but fails in the goal of guiding the user during development.
The ideal solution would incorporate the example field as part of docstring and thereby show up in intellisense.
If adopted, this feature adds an argument example_as_docstring to datamodel_code_generator.generate() and an option --use-field-description-example to CLI
I am using
datamodel-code-generatorto generate models to go along withUplinkto create REST clients. My REST API documentation is in OpenAPI yaml format and includes examples for field values. These example values are useful for the API client users to understand the field value and formats.VSCode and other IDE with intellisense pick up the doc string to display help on a function and its arguments.
The values of Example field in the OpenAPI documents are translated as
Field(example='your example here')which benefits if the model is dumped as JSON schema but fails in the goal of guiding the user during development.The ideal solution would incorporate the
examplefield as part of docstring and thereby show up in intellisense.If adopted, this feature adds an argument
example_as_docstringtodatamodel_code_generator.generate()and an option--use-field-description-exampleto CLI