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

+ 7 - 2
hapic/hapic.py View File

337
             return decoration.get_wrapper(func)
337
             return decoration.get_wrapper(func)
338
         return decorator
338
         return decorator
339
 
339
 
340
-    def generate_doc(self, app):
340
+    def generate_doc(self, app, title: str='', description: str=''):
341
         # FIXME: j'ai du tricher avec app, see #11
341
         # FIXME: j'ai du tricher avec app, see #11
342
         # FIXME @Damien bottle specific code ! see #11
342
         # FIXME @Damien bottle specific code ! see #11
343
         # rendre ca generique
343
         # rendre ca generique
344
         app = app or self._context.get_app()
344
         app = app or self._context.get_app()
345
         doc_generator = DocGenerator()
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
+        )