All Downloads are FREE. Search and download functionalities are using the official Maven repository.

python-flask.controller.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
import connexion
import six

{{#imports}}{{import}}  # noqa: E501
{{/imports}}
from {{packageName}} import util
{{#operations}}
{{#operation}}


def {{operationId}}({{#allParams}}{{paramName}}{{^required}}=None{{/required}}{{^-last}}, {{/-last}}{{/allParams}}):  # noqa: E501
    """{{summary}}{{^summary}}{{operationId}}{{/summary}}

    {{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}}
        {{#isArray}}
            {{#items}}
                {{#isPrimitiveType}}
    :type {{paramName}}: List[{{>param_type}}]
                {{/isPrimitiveType}}
                {{^isPrimitiveType}}
    :type {{paramName}}: list | bytes
                {{/isPrimitiveType}}
            {{/items}}
        {{/isArray}}
        {{#isMap}}
            {{#items}}
                {{#isPrimitiveType}}
    :type {{paramName}}: Dict[str, {{>param_type}}]
                {{/isPrimitiveType}}
                {{^isPrimitiveType}}
    :type {{paramName}}: dict | bytes
                {{/isPrimitiveType}}
            {{/items}}
        {{/isMap}}
    {{/allParams}}

    :rtype: {{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}}{{^baseType}}{{#dataType}} {{.}}{{/dataType}}{{/baseType}}.from_dict(connexion.request.get_json())  # noqa: E501
                    {{/isUuid}}
                {{/isFile}}
            {{/isPrimitiveType}}
        {{/isContainer}}
        {{#isArray}}
            {{#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}}
        {{/isArray}}
        {{#isMap}}
            {{#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}}
        {{/isMap}}
    {{/allParams}}
    return 'do some magic!'
{{/operation}}
{{/operations}}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy