forked from pydantic/pydantic
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enums as separate models (pydantic#1432)
* Updates schema() to generate enums as separate models * Fixes mypy annotations * Adds changes file * Fixes comment * Removes unused import * Fixes test case * Fixes missing partial branch in test coverage * Resolves PR comments * 🐛 Include enums in flat model schema handling as they now have independent schemas, they kinda behave like top-level models, and should be taken into account for top level definitions * ✅ Add test for coverage * 🐛 Use Type[Enum] as type for consistency Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
- Loading branch information
1 parent
913025a
commit 5195e55
Showing
3 changed files
with
117 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Updates OpenAPI schema generation to output all enums as separate models. | ||
Instead of inlining the enum values in the model schema, models now use a `$ref` | ||
property to point to the enum definition. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters