Esempio n. 1
0
        "type": "string"
    },
    "read": {
        "type": "string",
    },
    "delete": {
        "type": "string"
    },
}

blueprint.create_validator(
    "symbol",
    {
        "type": "object",
        "properties": {
            "symbol": {
                "type": "string",
            },
            **all_schema,
        }
    },
)

stock_request = blueprint.create_validator("stock", {
    "type": "object",
    "properties": {
        "symbol": {
            "type": "string",
        }
    }
})
Esempio n. 2
0
""":mod:'irastretto.web.blueprints.tasks'

"""
from quart import g, request, jsonify
from quart_openapi import PintBlueprint, Resource

from irastretto.services import extractor
from .models import taskVaildator

blueprint = PintBlueprint('tasks', __name__)

TaskValidator = blueprint.create_validator('task_request', taskVaildator)


@blueprint.route('/tasks')
class Tasks(Resource):
    @blueprint.expect(TaskValidator)
    async def post(self) -> dict:
        result = extractor.extract(resource=await request.json)
        return jsonify(result)


@blueprint.route('/tasks/<string:task_id>')
class ExistTasks(Resource):
    async def get(self, task_id):
        return jsonify(task_id)
Esempio n. 3
0
from http import HTTPStatus

from quart import jsonify
from quart_openapi import Resource, PintBlueprint

from battlefield.session.domain.use_cases.creator import SessionCreator
from battlefield.session.domain.use_cases.lister import SessionLister
from battlefield.session.data.data_access import SessionDataAccess
from battlefield.session.data.presenters import SessionPresenter

sessions = PintBlueprint("sessions", "sessions")

resp_obj = sessions.create_validator("response", {"type": "Session"})
resp_list = sessions.create_validator("response", {
    "type": "array",
    "items": {
        "type": "Session"
    }
})


@sessions.route("/sessions")
class Sessions(Resource):
    @sessions.response(HTTPStatus.OK, "OK", resp_obj)
    async def post(self):
        saver = SessionDataAccess()
        creation_result = await SessionCreator(saver).create()
        result = SessionPresenter(creation_result).to_dict()
        return jsonify(result)

    @sessions.response(HTTPStatus.OK, "OK", resp_list)