pydantic_openapi_helper.core module

pydantic_openapi_helper.core.get_openapi(base_object: List[Any], title: Optional[str] = None, version: Optional[str] = None, openapi_version: str = '3.0.2', description: Optional[str] = None, info: Optional[dict] = None, external_docs: Optional[dict] = None, inheritance: bool = False, add_discriminator: bool = True) Dict[source]

Get openapi compatible dictionary from a list of Pydantic objects.

Parameters:
  • base_objects – A list of Pydantic model objects to be included in the OpenAPI schema.

  • title – An optional title for OpenAPI title in info field.

  • version – Schema version to set the version in info.

  • openapi_version – Version for OpenAPI schema. Default is 3.0.2.

  • description – A short description for schema info.

  • info – Schema info as a dictionary. You can use this input to provide title, version and description together.

  • external_docs – Link to external docs for schema.

  • inheritance – A boolean to wheather the OpenAPI specification should be modified to use polymorphism. We use Pydantic to generate the initial version and then post-process the output dictionary to generate the new schema.

Returns:

Dict – OpenAPI schema as a dictionary.