pydantic_openapi_helper.inheritance module¶
- pydantic_openapi_helper.inheritance.class_mapper(models, find_and_replace=None)[source]¶
Create a mapper between OpenAPI models and Python modules.
This mapper is used by dotnet generator to organize the models under similar module structure.
- Parameters:
models – Input Pydantic models.
find_and_replace – A list of two string values for pattern and what it should be replaced with.
- pydantic_openapi_helper.inheritance.get_model_mapper(models, stoppage=None, full=True, include_enum=False)[source]¶
Get a dictionary of name: class for all the objects in model.
- pydantic_openapi_helper.inheritance.get_schemas_inheritance(model_cls)[source]¶
This method modifies the default OpenAPI from Pydantic.
It adds referenced values to subclasses using allOf field as explained in this post: https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism
- pydantic_openapi_helper.inheritance.set_inheritance(name, top_classes, schemas)[source]¶
Set inheritance for an object.
- Parameters:
name – name of the object.
top_classes – List of ancestors for this class.
schemas – A dictionary of all the schema objects.
- Returns:
Dict - updated schema for the object with the input name.