📝 Support better schema generation parameters (#1462)
Currently we don't pass quite a lot of options to both
pydantic and msgspec schema generation:django-modern-rest/dmr/plugins/pydantic/schema.py
Lines 27 to 30 in 405ba9b
When
pydantic defines this method as:def json_schema(
self,
*,
by_alias: bool = True,
ref_template: str = DEFAULT_REF_TEMPLATE,
union_format: Literal['any_of', 'primitive_type_array'] = 'any_of',
schema_generator: type[GenerateJsonSchema] = GenerateJsonSchema,
mode: JsonSchemaMode = 'validation',
) -> dict[str, Any]:
The same with
msgspec:django-modern-rest/dmr/plugins/msgspec/schema.py
Lines 24 to 27 in 405ba9b
Signature:
def schema(
type: Any,
*,
schema_hook: Optional[Callable[[type], dict[str, Any]]] = None,
ref_template: str = _REF_TEMPLATE,
) -> dict[str, Any]:
So, what we need to do:
1. Provide way to easily customize the schema generation for both
pydantic and msgspec2. Both would have different API, matching the current defaults
3. Document how to customize the schema generation this way: create your own serializer, subclass schema generator, use it
4. Add tests for 2 of these cases, especially with custom
schema_hook and schema_generator options#feature #good_first_issue #help_wanted #openapi #opensource_september #django_modern_rest
sent via relator