Browse Source

fix schema_class_resolver method usage

Guénaël Muller 6 years ago
parent
commit
87271c71c4
1 changed files with 21 additions and 6 deletions
  1. 21 6
      hapic/doc.py

+ 21 - 6
hapic/doc.py View File

@@ -24,19 +24,24 @@ def bottle_generate_operations(
24 24
     # schema based
25 25
     if description.input_body:
26 26
         schema_class = spec.schema_class_resolver(
27
-            description.input_body.wrapper.processor.schema)
27
+            spec,
28
+            description.input_body.wrapper.processor.schema
29
+        )
28 30
         method_operations.setdefault('parameters', []).append({
29 31
             'in': 'body',
30 32
             'name': 'body',
31 33
             'schema': {
32 34
                 '$ref': '#/definitions/{}'.format(
33
-                    spec.schema_name_resolver(schema_class))
35
+                    spec.schema_name_resolver(schema_class)
36
+                )
34 37
             }
35 38
         })
36 39
 
37 40
     if description.output_body:
38 41
         schema_class = spec.schema_class_resolver(
39
-            description.output_body.wrapper.processor.schema)
42
+            spec,
43
+            description.output_body.wrapper.processor.schema
44
+        )
40 45
         method_operations.setdefault('responses', {})\
41 46
             [int(description.output_body.wrapper.default_http_code)] = {
42 47
                 'description': str(int(description.output_body.wrapper.default_http_code)),  # nopep8
@@ -72,7 +77,9 @@ def bottle_generate_operations(
72 77
     # jsonschema based
73 78
     if description.input_path:
74 79
         schema_class = spec.schema_class_resolver(
75
-            description.input_path.wrapper.processor.schema)
80
+            spec,
81
+            description.input_path.wrapper.processor.schema
82
+        )
76 83
         # TODO: look schema2parameters ?
77 84
         jsonschema = schema2jsonschema(schema_class, spec=spec)
78 85
         for name, schema in jsonschema.get('properties', {}).items():
@@ -85,7 +92,9 @@ def bottle_generate_operations(
85 92
 
86 93
     if description.input_query:
87 94
         schema_class = spec.schema_class_resolver(
88
-            description.input_query.wrapper.processor.schema)
95
+            spec,
96
+            description.input_query.wrapper.processor.schema
97
+        )
89 98
         jsonschema = schema2jsonschema(schema_class, spec=spec)
90 99
         for name, schema in jsonschema.get('properties', {}).items():
91 100
             method_operations.setdefault('parameters', []).append({
@@ -150,16 +159,19 @@ class DocGenerator(object):
150 159
 
151 160
             if description.input_body:
152 161
                 schemas.append(spec.schema_class_resolver(
162
+                    spec,
153 163
                     description.input_body.wrapper.processor.schema
154 164
                 ))
155 165
 
156 166
             if description.input_forms:
157 167
                 schemas.append(spec.schema_class_resolver(
168
+                    spec,
158 169
                     description.input_forms.wrapper.processor.schema
159 170
                 ))
160 171
 
161 172
             if description.output_body:
162 173
                 schemas.append(spec.schema_class_resolver(
174
+                    spec,
163 175
                     description.output_body.wrapper.processor.schema
164 176
                 ))
165 177
 
@@ -168,7 +180,10 @@ class DocGenerator(object):
168 180
                     schemas.append(type(error.wrapper.error_builder))
169 181
 
170 182
         for schema in set(schemas):
171
-            spec.definition(spec.schema_name_resolver(schema), schema=schema)
183
+            spec.definition(
184
+                spec.schema_name_resolver(schema),
185
+                schema=schema
186
+            )
172 187
 
173 188
         # add views
174 189
         # with app.test_request_context():