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,9 +76,13 @@ def bottle_generate_operations(
76 76
 
77 77
     if description.errors:
78 78
         for error in description.errors:
79
+            schema_class = type(error.wrapper.schema)
79 80
             method_operations.setdefault('responses', {})\
80 81
                 [int(error.wrapper.http_code)] = {
81 82
                     'description': str(error.wrapper.http_code),
83
+                    'schema': {
84
+                        '$ref': '#/definitions/{}'.format(schema_class.__name__)  # nopep8
85
+                    }
82 86
                 }
83 87
 
84 88
     # jsonschema based
@@ -155,6 +159,10 @@ class DocGenerator(object):
155 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 166
         for schema in set(schemas):
159 167
             spec.definition(schema.__name__, schema=schema)
160 168