How to use the connexion.request.is_json function in connexion

To help you get started, we’ve selected a few connexion examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-microservices / microservices-scaffold / project / views / views.py View on Github external
def create_view():
    """Example endpoint return create a color
    """
    current_app.logger.info("Create color")
    if connexion.request.is_json:
        data = connexion.request.get_json()
        color = Color(name=data["name"])
        db.session.add(color)
        db.session.commit()

        return jsonify(ColorSchema().dump(color))
    return jsonify({})
github OpenAPITools / openapi-generator / samples / server / petstore / python-flask / openapi_server / controllers / user_controller.py View on Github external
def create_users_with_list_input(body):  # noqa: E501
    """Creates list of users with given input array

     # noqa: E501

    :param body: List of user object
    :type body: list | bytes

    :rtype: None
    """
    if connexion.request.is_json:
        body = [User.from_dict(d) for d in connexion.request.get_json()]  # noqa: E501
    return 'do some magic!'
github OpenNetworkingFoundation / TAPI / RI / flask_server / tapi_server / controllers / tapi_topology_controller.py View on Github external
def data_context_topology_context_post(tapi_topology_topology_context=None):  # noqa: E501
    """data_context_topology_context_post

    creates tapi.topology.TopologyContext # noqa: E501

    :param tapi_topology_topology_context: tapi.topology.TopologyContext to be added to list
    :type tapi_topology_topology_context: dict | bytes

    :rtype: None
    """
    if connexion.request.is_json:
        tapi_topology_topology_context = TapiTopologyTopologyContext.from_dict(connexion.request.get_json())  # noqa: E501
    return 'do some magic!'
github OpenAPITools / openapi-generator / samples / openapi3 / server / petstore / python-flask-python2 / openapi_server / controllers / pet_controller.py View on Github external
def add_pet(pet):  # noqa: E501
    """Add a new pet to the store

     # noqa: E501

    :param pet: Pet object that needs to be added to the store
    :type pet: dict | bytes

    :rtype: None
    """
    if connexion.request.is_json:
        pet = Pet.from_dict(connexion.request.get_json())  # noqa: E501
    return 'do some magic!'
github OpenAPITools / openapi-generator / samples / server / petstore / flaskConnexion-python2 / openapi_server / controllers / user_controller.py View on Github external
def create_users_with_list_input(user):  # noqa: E501
    """Creates list of users with given input array

     # noqa: E501

    :param user: List of user object
    :type user: list | bytes

    :rtype: None
    """
    if connexion.request.is_json:
        user = [User.from_dict(d) for d in connexion.request.get_json()]  # noqa: E501
    return 'do some magic!'
github RTXteam / RTX / code / UI / OpenAPI / python-flask-server / swagger_server / controllers / translate_controller.py View on Github external
def translate(body):  # noqa: E501
    """Translate natural language question into a standardized query

     # noqa: E501

    :param body: Question object that needs to be translated
    :type body: dict | bytes

    :rtype: List[Query]
    """
    if connexion.request.is_json:
        question = connexion.request.get_json()
        txltr = ParseQuestion()
        query = txltr.format_response(question)
    return query
github OpenVisualCloud / Ad-Insertion-Sample / ad-insertion / analytics / app / server / openapi_server / controllers / default_controller.py View on Github external
"""pipelines_name_version_post

    Start new instance of pipeline. Specify the source and destination parameters as URIs # noqa: E501

    :param name: 
    :type name: str
    :param version: 
    :type version: int
    :param pipeline_request: 
    :type pipeline_request: dict | bytes

    :rtype: None
    """

    logger.debug("POST on /pipelines/{name}/{version}".format(name=name, version=version))
    if connexion.request.is_json:
        try:
            pipeline_id, err = PipelineManager.create_instance(name, version, connexion.request.get_json())
            if pipeline_id is not None:
                return pipeline_id
            return (err, HTTPStatus.BAD_REQUEST)
        except Exception as e:
            logger.error('pipelines_name_version_post ' +e)
            return ('Unexpected error', HTTPStatus.INTERNAL_SERVER_ERROR)
github OpenAPITools / openapi-generator / samples / server / petstore / flaskConnexion-python2 / openapi_server / controllers / pet_controller.py View on Github external
def update_pet(pet):  # noqa: E501
    """Update an existing pet

     # noqa: E501

    :param pet: Pet object that needs to be added to the store
    :type pet: dict | bytes

    :rtype: None
    """
    if connexion.request.is_json:
        pet = Pet.from_dict(connexion.request.get_json())  # noqa: E501
    return 'do some magic!'
github OpenAPITools / openapi-generator / samples / openapi3 / server / petstore / python-flask / openapi_server / controllers / user_controller.py View on Github external
def create_users_with_array_input(user):  # noqa: E501
    """Creates list of users with given input array

     # noqa: E501

    :param user: List of user object
    :type user: list | bytes

    :rtype: None
    """
    if connexion.request.is_json:
        user = [User.from_dict(d) for d in connexion.request.get_json()]  # noqa: E501
    return 'do some magic!'
github kearch / kearch / packages / me-gateway / openapi_server / controllers / default_controller.py View on Github external
def add_a_summary_post(summary):  # noqa: E501
    """Add a summary to meta server.

     # noqa: E501

    :param summary: A summary of the specialist server.
    :type summary: dict | bytes

    :rtype: InlineResponse200
    """
    if connexion.request.is_json:
        summary = Summary.from_dict(connexion.request.get_json())  # noqa: E501
        engine_name = summary.engine_name()
        sp_host = summary.sp_host()
        dump = summary.dump()
        res = meta_gateway.add_new_sp_server(sp_host, engine_name, dump)
        return res