Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatal1ty committed Nov 25, 2024
1 parent c94e315 commit f0ef72a
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1089,10 +1089,10 @@ following openapify dataclasses defined in `openapify.core.models`:
* `QueryParam`

Out of the box, the schema is generated by using
[`mashumaro`](https://github.com/Fatal1ty/mashumaro) library, but support
for third-party entity schema generators can be achieved through
`schema_helper` method. For example, here's what a plugin for pydantic models
might look like:
[`mashumaro`](https://github.com/Fatal1ty/mashumaro) library (see the note
below), but support for third-party entity schema generators can be achieved
through `schema_helper` method. For example, here's what a plugin for pydantic
models might look like:

```python
from typing import Any
Expand All @@ -1116,6 +1116,34 @@ class PydanticSchemaPlugin(BasePlugin):
return schema
```

> [!NOTE]\
> The [`BaseSchemaPlugin`](https://github.com/Fatal1ty/openapify/blob/master/openapify/core/base_plugins.py#L41-L64),
> which is enabled by default and has the lowest priority, is responsible for
> generating the schema. This plugin utilizes the mashumaro library for schema
> generation, which in turn incorporates its own [plugin system](https://github.com/Fatal1ty/mashumaro?tab=readme-ov-file#json-schema-plugins),
> enabling customization of JSON Schema generation and support for additional
> data types. For more nuanced modifications, particularly within nested data
> models, you can employ BaseSchemaPlugin with a specified list of mashumaro JSON
> Schema plugins. This approach allows for finer control over schema generation
> when needed:
> ```python
> from mashumaro.jsonschema.plugins import DocstringDescriptionPlugin
>
> from openapify import build_spec
> from openapify.core.base_plugins import BaseSchemaPlugin
>
> spec = build_spec(
> routes=[...],
> plugins=[
> BaseSchemaPlugin(
> plugins=[
> DocstringDescriptionPlugin(),
> ]
> ),
> ],
> )
> ```

### media_type_helper

A media type is used in OpenAPI Request
Expand Down

0 comments on commit f0ef72a

Please sign in to comment.