flaskConnexion.controller.mustache Maven / Gradle / Ivy
import connexion
import six
{{#imports}}{{import}} # noqa: E501
{{/imports}}
from {{packageName}} import util
{{#operations}}
{{#operation}}
def {{operationId}}({{#allParams}}{{paramName}}{{^required}}=None{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}): # noqa: E501
"""{{#summary}}{{.}}{{/summary}}{{^summary}}{{operationId}}{{/summary}}
{{#notes}}{{.}}{{/notes}} # noqa: E501
{{#allParams}}
:param {{paramName}}: {{description}}
{{^isContainer}}
{{#isPrimitiveType}}
:type {{paramName}}: {{>param_type}}
{{/isPrimitiveType}}
{{#isUuid}}
:type {{paramName}}: {{>param_type}}
{{/isUuid}}
{{^isPrimitiveType}}
{{#isFile}}
:type {{paramName}}: werkzeug.datastructures.FileStorage
{{/isFile}}
{{^isFile}}
{{^isUuid}}
:type {{paramName}}: dict | bytes
{{/isUuid}}
{{/isFile}}
{{/isPrimitiveType}}
{{/isContainer}}
{{#isListContainer}}
{{#items}}
{{#isPrimitiveType}}
:type {{paramName}}: List[{{>param_type}}]
{{/isPrimitiveType}}
{{^isPrimitiveType}}
:type {{paramName}}: list | bytes
{{/isPrimitiveType}}
{{/items}}
{{/isListContainer}}
{{#isMapContainer}}
{{#items}}
{{#isPrimitiveType}}
:type {{paramName}}: Dict[str, {{>param_type}}]
{{/isPrimitiveType}}
{{^isPrimitiveType}}
:type {{paramName}}: dict | bytes
{{/isPrimitiveType}}
{{/items}}
{{/isMapContainer}}
{{/allParams}}
:rtype: {{#returnType}}{{.}}{{/returnType}}{{^returnType}}None{{/returnType}}
"""
{{#allParams}}
{{^isContainer}}
{{#isDate}}
{{paramName}} = util.deserialize_date({{paramName}})
{{/isDate}}
{{#isDateTime}}
{{paramName}} = util.deserialize_datetime({{paramName}})
{{/isDateTime}}
{{^isPrimitiveType}}
{{^isFile}}
{{^isUuid}}
if connexion.request.is_json:
{{paramName}} = {{baseType}}.from_dict(connexion.request.get_json()) # noqa: E501
{{/isUuid}}
{{/isFile}}
{{/isPrimitiveType}}
{{/isContainer}}
{{#isListContainer}}
{{#items}}
{{#isDate}}
if connexion.request.is_json:
{{paramName}} = [util.deserialize_date(s) for s in connexion.request.get_json()] # noqa: E501
{{/isDate}}
{{#isDateTime}}
if connexion.request.is_json:
{{paramName}} = [util.deserialize_datetime(s) for s in connexion.request.get_json()] # noqa: E501
{{/isDateTime}}
{{#complexType}}
if connexion.request.is_json:
{{paramName}} = [{{complexType}}.from_dict(d) for d in connexion.request.get_json()] # noqa: E501
{{/complexType}}
{{/items}}
{{/isListContainer}}
{{#isMapContainer}}
{{#items}}
{{#isDate}}
if connexion.request.is_json:
{{paramName}} = {k: util.deserialize_date(v) for k, v in six.iteritems(connexion.request.get_json())} # noqa: E501
{{/isDate}}
{{#isDateTime}}
if connexion.request.is_json:
{{paramName}} = {k: util.deserialize_datetime(v) for k, v in six.iteritems(connexion.request.get_json())} # noqa: E501
{{/isDateTime}}
{{#complexType}}
if connexion.request.is_json:
{{paramName}} = {k: {{baseType}}.from_dict(v) for k, v in six.iteritems(connexion.request.get_json())} # noqa: E501
{{/complexType}}
{{/items}}
{{/isMapContainer}}
{{/allParams}}
return 'do some magic!'
{{/operation}}
{{/operations}}