s-knibbs / dataclasses-jsonschema

JSON schema generation from dataclasses
MIT License
166 stars 38 forks source link

Add option to include the python module name #114

Closed s-knibbs closed 3 years ago

s-knibbs commented 4 years ago

To aid code generation when generating python code from the schemas within an OpenAPI spec, it would be useful to have an option to include the module name with each schema:


@dataclass
class Pet(JsonSchemaMixin):
    """A pet"""
    name: str
    age: int

>>> JsonSchemaMixin.all_json_schemas(schema_type=SchemaType.SWAGGER_V3, include_module_names=True)
{
    "Pet": {
        "description": "A pet",
        "type": "object",
        "x-module-name": "petstore.data_types",
        ....
    }
}