Browse Source

Add title and description parameters to generate doc

Bastien Sevajol 6 years ago
parent
commit
681fcf54f6
2 changed files with 11 additions and 3 deletions
  1. 4 1
      hapic/doc.py
  2. 7 2
      hapic/hapic.py

+ 4 - 1
hapic/doc.py View File

@@ -140,6 +140,8 @@ class DocGenerator(object):
140 140
         self,
141 141
         controllers: typing.List[DecoratedController],
142 142
         app,
143
+        title: str='',
144
+        description: str='',
143 145
     ) -> dict:
144 146
         # TODO: Découper, see #11
145 147
         # TODO: bottle specific code !, see #11
@@ -150,7 +152,8 @@ class DocGenerator(object):
150 152
         flatten = lambda l: [item for sublist in l for item in sublist]
151 153
 
152 154
         spec = APISpec(
153
-            title='Swagger Petstore',
155
+            title=title,
156
+            description=description,
154 157
             version='1.0.0',
155 158
             plugins=[
156 159
                 'apispec.ext.bottle',

+ 7 - 2
hapic/hapic.py View File

@@ -337,10 +337,15 @@ class Hapic(object):
337 337
             return decoration.get_wrapper(func)
338 338
         return decorator
339 339
 
340
-    def generate_doc(self, app):
340
+    def generate_doc(self, app, title: str='', description: str=''):
341 341
         # FIXME: j'ai du tricher avec app, see #11
342 342
         # FIXME @Damien bottle specific code ! see #11
343 343
         # rendre ca generique
344 344
         app = app or self._context.get_app()
345 345
         doc_generator = DocGenerator()
346
-        return doc_generator.get_doc(self._controllers, app)
346
+        return doc_generator.get_doc(
347
+            self._controllers,
348
+            app,
349
+            title=title,
350
+            description=description,
351
+        )