|
@@ -20,25 +20,30 @@ def bottle_generate_operations(
|
20
|
20
|
description: ControllerDescription,
|
21
|
21
|
):
|
22
|
22
|
method_operations = dict()
|
23
|
|
-
|
|
23
|
+ # TODO : Convert many=True in list of elems
|
24
|
24
|
# schema based
|
25
|
25
|
if description.input_body:
|
26
|
|
- schema_class = type(description.input_body.wrapper.processor.schema)
|
|
26
|
+ schema_class = spec.schema_class_resolver(
|
|
27
|
+ description.input_body.wrapper.processor.schema)
|
27
|
28
|
method_operations.setdefault('parameters', []).append({
|
28
|
29
|
'in': 'body',
|
29
|
30
|
'name': 'body',
|
30
|
31
|
'schema': {
|
31
|
|
- '$ref': '#/definitions/{}'.format(schema_class.__name__)
|
|
32
|
+ '$ref': '#/definitions/{}'.format(
|
|
33
|
+ spec.schema_name_resolver(schema_class))
|
32
|
34
|
}
|
33
|
35
|
})
|
34
|
36
|
|
35
|
37
|
if description.output_body:
|
36
|
|
- schema_class = type(description.output_body.wrapper.processor.schema)
|
|
38
|
+ schema_class = spec.schema_class_resolver(
|
|
39
|
+ description.output_body.wrapper.processor.schema)
|
37
|
40
|
method_operations.setdefault('responses', {})\
|
38
|
41
|
[int(description.output_body.wrapper.default_http_code)] = {
|
39
|
42
|
'description': str(int(description.output_body.wrapper.default_http_code)), # nopep8
|
40
|
43
|
'schema': {
|
41
|
|
- '$ref': '#/definitions/{}'.format(schema_class.__name__)
|
|
44
|
+ '$ref': '#/definitions/{}'.format(
|
|
45
|
+ spec.schema_name_resolver(schema_class)
|
|
46
|
+ )
|
42
|
47
|
}
|
43
|
48
|
}
|
44
|
49
|
|
|
@@ -58,13 +63,16 @@ def bottle_generate_operations(
|
58
|
63
|
[int(error.wrapper.http_code)] = {
|
59
|
64
|
'description': str(int(error.wrapper.http_code)),
|
60
|
65
|
'schema': {
|
61
|
|
- '$ref': '#/definitions/{}'.format(schema_class.__name__) # nopep8
|
|
66
|
+ '$ref': '#/definitions/{}'.format(
|
|
67
|
+ spec.schema_name_resolver(schema_class)
|
|
68
|
+ )
|
62
|
69
|
}
|
63
|
70
|
}
|
64
|
71
|
|
65
|
72
|
# jsonschema based
|
66
|
73
|
if description.input_path:
|
67
|
|
- schema_class = type(description.input_path.wrapper.processor.schema)
|
|
74
|
+ schema_class = spec.schema_class_resolver(
|
|
75
|
+ description.input_path.wrapper.processor.schema)
|
68
|
76
|
# TODO: look schema2parameters ?
|
69
|
77
|
jsonschema = schema2jsonschema(schema_class, spec=spec)
|
70
|
78
|
for name, schema in jsonschema.get('properties', {}).items():
|
|
@@ -76,7 +84,8 @@ def bottle_generate_operations(
|
76
|
84
|
})
|
77
|
85
|
|
78
|
86
|
if description.input_query:
|
79
|
|
- schema_class = type(description.input_query.wrapper.processor.schema)
|
|
87
|
+ schema_class = spec.schema_class_resolver(
|
|
88
|
+ description.input_query.wrapper.processor.schema)
|
80
|
89
|
jsonschema = schema2jsonschema(schema_class, spec=spec)
|
81
|
90
|
for name, schema in jsonschema.get('properties', {}).items():
|
82
|
91
|
method_operations.setdefault('parameters', []).append({
|
|
@@ -131,7 +140,7 @@ class DocGenerator(object):
|
131
|
140
|
plugins=(
|
132
|
141
|
'apispec.ext.marshmallow',
|
133
|
142
|
),
|
134
|
|
- schema_name_resolver=generate_schema_name,
|
|
143
|
+ auto_referencing=True,
|
135
|
144
|
)
|
136
|
145
|
|
137
|
146
|
schemas = []
|
|
@@ -140,17 +149,17 @@ class DocGenerator(object):
|
140
|
149
|
description = controller.description
|
141
|
150
|
|
142
|
151
|
if description.input_body:
|
143
|
|
- schemas.append(type(
|
|
152
|
+ schemas.append(spec.schema_class_resolver(
|
144
|
153
|
description.input_body.wrapper.processor.schema
|
145
|
154
|
))
|
146
|
155
|
|
147
|
156
|
if description.input_forms:
|
148
|
|
- schemas.append(type(
|
|
157
|
+ schemas.append(spec.schema_class_resolver(
|
149
|
158
|
description.input_forms.wrapper.processor.schema
|
150
|
159
|
))
|
151
|
160
|
|
152
|
161
|
if description.output_body:
|
153
|
|
- schemas.append(type(
|
|
162
|
+ schemas.append(spec.schema_class_resolver(
|
154
|
163
|
description.output_body.wrapper.processor.schema
|
155
|
164
|
))
|
156
|
165
|
|
|
@@ -159,7 +168,7 @@ class DocGenerator(object):
|
159
|
168
|
schemas.append(type(error.wrapper.error_builder))
|
160
|
169
|
|
161
|
170
|
for schema in set(schemas):
|
162
|
|
- spec.definition(schema.__name__, schema=schema)
|
|
171
|
+ spec.definition(spec.schema_name_resolver(schema), schema=schema)
|
163
|
172
|
|
164
|
173
|
# add views
|
165
|
174
|
# with app.test_request_context():
|