Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the blueprint for pydantic version 2
Use the proper `ref_template`, specifying the `{model}` in the template. An example is documented here: https://github.com/pydantic/pydantic/blob/main/docs/usage/json_schema.md#schema-customization We need to specify `ref_template = '#/components/schemas/{model}'`, not `ref_template = '#/components/schemas/'` (need that extra `{model}` at the end). `model_json_schema` generates something like this, for a `Parent` model with a `child` field of type `Child`: ```json { "$defs": { "Child": { "properties": { "foo": { "default": 5, "title": "Foo", "type": "integer" } }, "title": "Child", "type": "object" } }, "properties": { "child": { "anyOf": [ { "$ref": "#/components/schemas/Child" }, { "type": "null" } ], "default": null } }, "title": "Parent", "type": "object" } ``` The definitions are in a key `$defs` (not `definitions`), and the references start with `#/components/schemas` as expected.
- Loading branch information