diff --git a/flask_restx/reqparse.py b/flask_restx/reqparse.py index 8461f0ec..cee2ab76 100644 --- a/flask_restx/reqparse.py +++ b/flask_restx/reqparse.py @@ -309,7 +309,10 @@ def __schema__(self): param["type"] = "array" param["collectionFormat"] = "csv" if self.choices: - param["enum"] = self.choices + if param.get("collectionFormat", None) == "csv" or param.get("collectionFormat", None) == "multi": + param["items"]["enum"] = self.choices + else: + param["enum"] = self.choices return param diff --git a/flask_restx/swagger.py b/flask_restx/swagger.py index ec0a1975..1cf55757 100644 --- a/flask_restx/swagger.py +++ b/flask_restx/swagger.py @@ -486,7 +486,7 @@ def serialize_resource(self, ns, resource, url, route_doc=None, **kwargs): def serialize_operation(self, doc, method): operation = { "responses": self.responses_for(doc, method) or None, - "summary": doc[method]["docstring"]["summary"], + "summary": self.summary_for( doc, method) or None, "description": self.description_for(doc, method) or None, "operationId": self.operation_id_for(doc, method), "parameters": self.parameters_for(doc[method]) or None, @@ -523,6 +523,18 @@ def vendor_fields(self, doc, method): for k, v in doc[method].get("vendor", {}).items() ) + def summary_for(self, doc, method): + """Extract the summay metadata and fallback on the whole docstring""" + parts = [] + if "summary" in doc: + parts.append(doc["summary"] or "") + if method in doc and "summary" in doc[method]: + parts.append(doc[method]["summary"]) + if doc[method]["docstring"]["summary"]: + parts.append(doc[method]["docstring"]["summary"]) + + return "\n".join(parts).strip() + def description_for(self, doc, method): """Extract the description metadata and fallback on the whole docstring""" parts = []