-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_nested_mount.py
More file actions
100 lines (88 loc) · 2.99 KB
/
Copy pathtest_nested_mount.py
File metadata and controls
100 lines (88 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
from ellar.common import Controller, get, serialize_object
from ellar.openapi import OpenAPIDocumentBuilder
from ellar.testing import Test
@Controller
class Cat1Controller:
@get("/create")
async def create_cat(self):
return {"message": "created"}
@Controller
class Cat2Controller:
@get("/create")
async def create_cat(self):
return {"message": "created"}
Cat2Controller.add_router(Cat1Controller)
tm = Test.create_test_module(controllers=[Cat2Controller])
def test_nested_route_openapi_schema():
app = tm.create_application()
document = serialize_object(OpenAPIDocumentBuilder().build_document(app))
assert document == NESTED_SCHEMA
NESTED_SCHEMA = {
"openapi": "3.1.0",
"info": {"title": "Ellar API Docs", "version": "1.0.0"},
"paths": {
"/cat2/cat1/create": {
"get": {
"tags": ["cat1"],
"operationId": "create_cat_create_get__cat1",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {"type": "object", "title": "Response Model"}
}
},
}
},
}
},
"/cat2/create": {
"get": {
"tags": ["cat2"],
"operationId": "create_cat_create_get__cat2",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {"type": "object", "title": "Response Model"}
}
},
}
},
}
},
},
"components": {
"schemas": {
"HTTPValidationError": {
"properties": {
"detail": {
"items": {"$ref": "#/components/schemas/ValidationError"},
"type": "array",
"title": "Details",
}
},
"type": "object",
"required": ["detail"],
"title": "HTTPValidationError",
},
"ValidationError": {
"properties": {
"loc": {
"items": {"type": "string"},
"type": "array",
"title": "Location",
},
"msg": {"type": "string", "title": "Message"},
"type": {"type": "string", "title": "Error Type"},
},
"type": "object",
"required": ["loc", "msg", "type"],
"title": "ValidationError",
},
}
},
"tags": [{"name": "cat1"}, {"name": "cat2"}],
}