flask-restful-swagger icon indicating copy to clipboard operation
flask-restful-swagger copied to clipboard

"None" if no comment but summary / notes parameter given.

Open lukas-gitl opened this issue 10 years ago • 3 comments

In the swagger.operation when the "summary" or "notes" parameter are given but no comment is given in the function, a "None" is displayed below. See picture. rsz_2014-11-15-161731_1022x574_scrot

lukas-gitl avatar Nov 16 '14 00:11 lukas-gitl

Hi @lukas-gitl, Experimented same issue few days ago without seeing this opened case.

The answer was already in the project samples: Seem that you shouldn't put the 'summary' and 'notes' directives inside the @swagger.operation decorator, but just inside the operation comments: @swagger.operation(blabla) def get(self, my_arg1): """This is the summary These are the notes line1 line2 """

If you just modify the initialization in the _parse_doc method, you'll end with a <br/> after your summary in the html, due to extract_operations method which add first_line+<br/>+"empty string" (last line below): for att_name, att_value in list(decorators.items()): if isinstance(att_value, (str, int, list)): if att_name == 'parameters': op['parameters'] = merge_parameter_list( op['parameters'], att_value) else: if att_name in op and att_name is not 'nickname': att_value = '{0}<br/>{1}'.format(att_value, op[att_name])

regards

lounagen avatar Dec 06 '14 13:12 lounagen

Sure, the workaround works. However I want to be able to separate the decorator/description from the code. So can't define these in the function comment.

Currently I get a None and a br. I agree that my pull request only deals with the "None".

lukas-gitl avatar Dec 06 '14 14:12 lukas-gitl

Here is a proposal to deal with both None and <br/>, and to avoid mixing text from method_impl and decorator if both are defined : https://github.com/lounagen/flask-restful-swagger/commit/b13b059d604c53a74460baccaeca1c2a980c2809 It takes default summary/notes from method_impl only when not defined in decorator already

lounagen avatar Dec 06 '14 22:12 lounagen