add examples to openapi schema, some perf improvements

This commit is contained in:
collerek
2021-04-30 16:46:41 +02:00
parent 734c33920b
commit 12c002776b
11 changed files with 194 additions and 78 deletions

View File

@ -1,6 +1,7 @@
from typing import List
import databases
import pydantic
import pytest
import sqlalchemy
from fastapi import FastAPI
@ -124,6 +125,18 @@ def test_schema_modification():
x.get("type") == "array" for x in schema["properties"]["categories"]["anyOf"]
)
assert schema["properties"]["categories"]["title"] == "Categories"
assert schema["example"] == {
"id": 0,
"name": "string",
"categories": [{"id": 0, "name": "string"}],
}
schema = Category.schema()
assert schema["example"] == {
"id": 0,
"name": "string",
"items": [{"id": 0, "name": "string"}],
}
def test_schema_gen():