jsonschema-gentypes
jsonschema-gentypes copied to clipboard
Generate Python types without docstring
Description
Current;y, the jsonschema-gentypes tool generates Python types from JSON schemas with included docstrings in the output files. This creates difficulties when users want to keep generated files minimal or want to control documentation separately. For example, if follow schema.json file defined:
{
"title": "Person",
"type": "object",
"properties": {
"name": { "type": "string" },
"age": { "type": "integer" }
},
"required": ["name", "age"]
}
When we try to build Python types using follow command:
jsonschema-gentypes --json-schema=schema.json --python=person_types.py
We will get follow content in person_types.py file:
from typing import Required, TypedDict
class Person(TypedDict, total=False):
""" Person. """
name: Required[str]
""" Required property """
age: Required[int]
""" Required property """
Request
Add the options to specify in tool's configuration to omit docstrings from the generated Python type files. As the result user will get follow content in person_types.py file:
from typing import Required, TypedDict
class Person(TypedDict, total=False):
name: Required[str]
age: Required[int]
Some of possible solutions:
- The configuration parameter
generate_docstrings, which will store a boolean value. If this parameter storesfalse, the documentation lines will be omitted. - A command-line flag to omit docstrings from the generated Python type files.
I don't need that, but I have no issue with that, then if a clean pull request is proposed I will merge it :-)