feat: update pydantic
This commit is contained in:
@@ -16,6 +16,9 @@ from aiohttp_pydantic.oas.view import generate_oas
|
||||
|
||||
|
||||
class Color(str, Enum):
|
||||
"""
|
||||
Pet color
|
||||
"""
|
||||
RED = "red"
|
||||
GREEN = "green"
|
||||
PINK = "pink"
|
||||
@@ -142,22 +145,18 @@ async def generated_oas(aiohttp_client, event_loop) -> web.Application:
|
||||
async def test_generated_oas_should_have_components_schemas(generated_oas):
|
||||
assert generated_oas["components"]["schemas"] == {
|
||||
'Cat': {'properties': {'meows': {'title': 'Meows', 'type': 'integer'},
|
||||
'pet_type': {'enum': ['cat'],
|
||||
'title': 'Pet Type',
|
||||
'type': 'string'}},
|
||||
'pet_type': {'const': 'cat', 'title': 'Pet Type'}},
|
||||
'required': ['pet_type', 'meows'],
|
||||
'title': 'Cat',
|
||||
'type': 'object'},
|
||||
"Color": {
|
||||
"description": "An enumeration.",
|
||||
"description": "Pet color",
|
||||
"enum": ["red", "green", "pink"],
|
||||
"title": "Color",
|
||||
"type": "string",
|
||||
},
|
||||
'Dog': {'properties': {'barks': {'title': 'Barks', 'type': 'number'},
|
||||
'pet_type': {'enum': ['dog'],
|
||||
'title': 'Pet Type',
|
||||
'type': 'string'}},
|
||||
'pet_type': {'const': 'dog', 'title': 'Pet Type'}},
|
||||
'required': ['pet_type', 'barks'],
|
||||
'title': 'Dog',
|
||||
'type': 'object'},
|
||||
@@ -170,7 +169,6 @@ async def test_generated_oas_should_have_components_schemas(generated_oas):
|
||||
'type': 'object'
|
||||
},
|
||||
'Lang': {
|
||||
'description': 'An enumeration.',
|
||||
'enum': ['en', 'fr'],
|
||||
'title': 'Lang',
|
||||
'type': 'string'
|
||||
@@ -187,7 +185,13 @@ async def test_generated_oas_should_have_components_schemas(generated_oas):
|
||||
'Pet': {
|
||||
'properties': {
|
||||
'id': {'title': 'Id', 'type': 'integer'},
|
||||
'name': {'title': 'Name', 'type': 'string'},
|
||||
'name': {
|
||||
'anyOf': [
|
||||
{'type': 'string'},
|
||||
{'type': 'null'}
|
||||
],
|
||||
'default': None,
|
||||
'title': 'Name'},
|
||||
'toys': {
|
||||
'items': {'$ref': '#/components/schemas/Toy'},
|
||||
'title': 'Toys',
|
||||
@@ -231,13 +235,24 @@ async def test_pets_route_should_have_get_method(generated_oas):
|
||||
"in": "query",
|
||||
"name": "name",
|
||||
"required": False,
|
||||
"schema": {"title": "name", "type": "string"},
|
||||
"schema": {
|
||||
'anyOf': [{'type': 'string'}, {'type': 'null'}],
|
||||
'default': None,
|
||||
'title': 'name'
|
||||
},
|
||||
},
|
||||
{
|
||||
"in": "header",
|
||||
"name": "promo",
|
||||
"required": False,
|
||||
"schema": {"format": "uuid", "title": "promo", "type": "string"},
|
||||
"schema": {
|
||||
'anyOf': [
|
||||
{'format': 'uuid', 'type': 'string'},
|
||||
{'type': 'null'}
|
||||
],
|
||||
'default': None,
|
||||
'title': 'promo'
|
||||
},
|
||||
},
|
||||
],
|
||||
"responses": {
|
||||
@@ -265,7 +280,14 @@ async def test_pets_route_should_have_post_method(generated_oas):
|
||||
"schema": {
|
||||
"properties": {
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"name": {
|
||||
'anyOf': [
|
||||
{'type': 'string'},
|
||||
{'type': 'null'}
|
||||
],
|
||||
'default': None,
|
||||
'title': 'Name'
|
||||
},
|
||||
"toys": {
|
||||
"items": {"$ref": "#/components/schemas/Toy"},
|
||||
"title": "Toys",
|
||||
@@ -337,9 +359,9 @@ async def test_pets_id_route_should_have_get_method(generated_oas):
|
||||
"name": "day",
|
||||
"required": False,
|
||||
"schema": {
|
||||
"anyOf": [{"type": "integer"}, {"enum": ["now"], "type": "string"}],
|
||||
"default": "now",
|
||||
"title": "day",
|
||||
'anyOf': [{'type': 'integer'}, {'const': 'now'}],
|
||||
'default': 'now',
|
||||
'title': 'day'
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -370,7 +392,13 @@ async def test_pets_id_route_should_have_put_method(generated_oas):
|
||||
"schema": {
|
||||
"properties": {
|
||||
"id": {"title": "Id", "type": "integer"},
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"name": {
|
||||
'anyOf': [
|
||||
{'type': 'string'},
|
||||
{'type': 'null'}
|
||||
],
|
||||
'default': None,
|
||||
'title': 'Name'},
|
||||
"toys": {
|
||||
"items": {"$ref": "#/components/schemas/Toy"},
|
||||
"title": "Toys",
|
||||
|
||||
@@ -97,10 +97,10 @@ async def test_post_an_array_json_to_an_object_model_should_return_an_error(
|
||||
assert resp.content_type == "application/json"
|
||||
assert await resp.json() == [
|
||||
{
|
||||
"in": "body",
|
||||
"loc": ["__root__"],
|
||||
"msg": "value is not a valid dict",
|
||||
"type": "type_error.dict",
|
||||
'loc': ['root'],
|
||||
'loc_in': 'body',
|
||||
'msg': 'value is not a valid dict',
|
||||
'type': 'type_error.dict'
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user