Browse Source

Use errors schema in generated doc. Closes #16

Bastien Sevajol 6 years ago
parent
commit
0cb05bc703
1 changed files with 8 additions and 0 deletions
  1. 8 0
      hapic/doc.py

+ 8 - 0
hapic/doc.py View File

76
 
76
 
77
     if description.errors:
77
     if description.errors:
78
         for error in description.errors:
78
         for error in description.errors:
79
+            schema_class = type(error.wrapper.schema)
79
             method_operations.setdefault('responses', {})\
80
             method_operations.setdefault('responses', {})\
80
                 [int(error.wrapper.http_code)] = {
81
                 [int(error.wrapper.http_code)] = {
81
                     'description': str(error.wrapper.http_code),
82
                     'description': str(error.wrapper.http_code),
83
+                    'schema': {
84
+                        '$ref': '#/definitions/{}'.format(schema_class.__name__)  # nopep8
85
+                    }
82
                 }
86
                 }
83
 
87
 
84
     # jsonschema based
88
     # jsonschema based
155
                     description.output_body.wrapper.processor.schema
159
                     description.output_body.wrapper.processor.schema
156
                 ))
160
                 ))
157
 
161
 
162
+            if description.errors:
163
+                for error in description.errors:
164
+                    schemas.append(type(error.wrapper.schema))
165
+
158
         for schema in set(schemas):
166
         for schema in set(schemas):
159
             spec.definition(schema.__name__, schema=schema)
167
             spec.definition(schema.__name__, schema=schema)
160
 
168