示例#1
0
def get_benchmark_app():
    """
    Creates a Sanic application whose routes are documented using the lower level `doc` module.

    The routes and their documentation must be kept in sync with the application created
    by `get_app()`, so this application can serve as a benchmark in test cases.
    """
    app = Sanic("test_api_benchmark_{}".format(next(benchmark_app_ID)))
    app.blueprint(swagger_blueprint)

    @app.post("/message")
    @doc.summary("MessageAPI summary.")
    @doc.description("MessageAPI description.")
    @doc.consumes(
        doc.Object(MessageAPI.consumes, object_name="MessageAPIConsumes"),
        content_type=MessageAPI.consumes_content_type,
        location=MessageAPI.consumes_location,
        required=MessageAPI.consumes_required,
    )
    @doc.produces(
        doc.Object(MessageAPI.consumes, object_name="MessageAPIProduces"),
        content_type=MessageAPI.produces_content_type,
    )
    @doc.response(201, {"code": int})
    @doc.response(202, {"code": int}, description="202 description")
    @doc.tag("Bar")
    @doc.tag("Foo")
    @json_response
    def message(request):
        data = request.json
        assert "message" in data
        return {"message": "Message received."}

    return app
示例#2
0
class CustomerReg:
    namec = doc.String("The full name of the customer.")
    email = doc.String("A valid email for the customer.")
    planKey = doc.String(
        "The planKey you would like to use for this customer. Valid planKeys will be provided by Paystand."
    )
    vanityName = doc.String(
        "The vanity name is a unique key used for providing public access to a billing portal."
    )
    description = doc.String(
        "An optional description you can attribute to this customer.")
    address = doc.Object(Address, "The address of the customer.")
    contact = doc.Object(Contact, "The contact information for the customer.")
    defaultBank = doc.Object(
        Bank,
        "The default bank used for this customer. This can be used for withdrawing funds, and optionally can be used to pay subscription fees."
    )
    legalEntity = doc.Object(
        LegalEntity,
        "Detailed information about the legal entity for this customer.")
    merchant = doc.Object(
        Merchant,
        "Detailed information about the business this customer represents.")
    username = doc.String(
        "The login name used for an optional user created with this customer.")
    password = doc.String(
        "The password used for an optional user created with this customer.")
示例#3
0
class PayerCardPayment:
    amount = doc.String("The amount of the payment")
    currency = doc.String('The currency of the payment')
    card = doc.Object(Card, 'Card object that will be used')
    payer = doc.Object(Payer, 'Payer Object', required=False)
    payerId = doc.String('Payer id if already exist', required=False)
    accountKey = doc.String('The key of the account to send the funds to',
                            required=False)
    description = doc.String('A short description of the payment.')
示例#4
0
class PayerBankPayment:
    amount = doc.String("The amount of the payment")
    currency = doc.String('The currency of the payment')
    bank = doc.Object(Bank, 'The bank object to use for the bank payment')
    payer = doc.Object(Payer, 'Payer Object', required=False)
    payerId = doc.String('Payer id if already exist', required=False)
    accountKey = doc.String('The key of the account to send the funds to',
                            required=False)
    description = doc.String('A short description of the payment.')
示例#5
0
class AdditionalOwner:
    # id = doc.String("The unique identifier for the additional owner.")
    # object = doc.String("Value is legalEntityAdditionalOwner")
    personalTaxId = doc.String("The personal tax id of the owner")
    # last4PersonalTaxId = doc.String("The last 4 digits of the personal tax id of the owner. This is returned in responses instead of returning the full personal tax id.")
    stakePercent = doc.String(
        "The stake percentage in the company for the additional owner.")
    title = doc.String("The title of the additional owner.")
    address = doc.Object(Address, "The address of the additional owner.")
    contact = doc.Object(Contact, "The contact of the additional owner.")
示例#6
0
        class _script_file_list:
            class _file_list:
                label = doc.String(description='The file name')
                type = doc.String(
                    description='The file type: file or directory')
                children = doc.List(doc.JsonBody())

            test_scripts = doc.List(doc.Object(_file_list),
                                    description='The test script file list')
            test_libraries = doc.List(
                doc.Object(_file_list),
                description='The python script file list')
示例#7
0
    class user_avatar(json_response):
        class _user_avatar:
            type = doc.String()
            data = doc.String(
                description='the file content being base64 encoded')

        data = doc.Object(_user_avatar)
示例#8
0
        class _doc_history:
            class __doc_history:
                title = doc.String()
                revision = doc.String()
                description = doc.String()

            history = doc.List(doc.Object(__doc_history))
示例#9
0
    class run_task(json_response):
        class _run_task:
            running = doc.List(doc.String())
            failed = doc.List(doc.String())
            succeeded = doc.List(doc.String())

        data = doc.Object(_run_task)
示例#10
0
def test_object_field(app):

    field = doc.Object(TestSchema)
    assert field.serialize() == {"type": "object", "$ref": "#/definitions/TestSchema"}

    @app.get("/")
    @doc.consumes(field, location="body", required=True)
    def test(request):
        return text("test")

    _, response = app.test_client.get("/swagger/swagger.json")
    assert response.status == 200
    assert response.content_type == "application/json"

    swagger_json = response.json
    path = swagger_json["paths"]["/"]["get"]
    assert path["parameters"][0] == {
        "required": True,
        "in": "body",
        "name": None,
        "type": "object",
        "schema": {"$ref": "#/definitions/TestSchema"},
    }

    assert swagger_json["definitions"]["TestSchema"] == {
        "type": "object",
        "properties": {},
    }
示例#11
0
        class _doc_pictures:
            class __doc_pictures:
                name = doc.String()
                data = doc.String()
                type = doc.String()
                size = doc.Integer()

            file_list = doc.List(doc.Object(__doc_pictures))
示例#12
0
class Card:
    nameOnCard = doc.String('The name on the card')
    cardNumber = doc.String('The number of the card')
    expirationMonth = doc.String('The expiration month of the card.')
    expirationYear = doc.String('The expiration year of the card.')
    securityCode = doc.String('The security code of the card.')
    billingAddress = doc.Object(
        Address, 'The billing address associated with the card.')
示例#13
0
        class _task_resource_file_list:
            class _file_list:
                label = doc.String(description='The file name')
                type = doc.String(
                    description='The file type: file or directory')
                children = doc.List(doc.JsonBody())

            files = doc.List(doc.Object(_file_list),
                             description='The test script file list')
示例#14
0
    class doc_roots(json_response):
        class _doc_roots:
            class __doc_roots:
                value = doc.Integer(description='the item index')
                label = doc.String(description='the path\'s value')

            paths = doc.List(doc.Object(__doc_roots))

        data = doc.Object(_doc_roots)
示例#15
0
    class doc_history(json_response):
        class _doc_history:
            class __doc_history:
                title = doc.String()
                revision = doc.String()
                description = doc.String()

            history = doc.List(doc.Object(__doc_history))

        data = doc.Object(_doc_history)
示例#16
0
    class user_list(json_response):
        class _user_list:
            class _user:
                label = doc.String(description='The user name')
                email = doc.String(description='The user email')
                value = doc.String(description='The user ID')

            users = doc.List(_user)

        data = doc.Object(_user_list)
示例#17
0
    class task_result_files(json_response):
        class _task_result_files:
            class _file_list:
                label = doc.String(description='The file name')
                type = doc.String(
                    description='The file type: file or directory')
                children = doc.List(doc.JsonBody())

            files = doc.List(_file_list,
                             description='The test script file list')

        data = doc.Object(_task_result_files)
示例#18
0
    class user_list(json_response):
        class _user_list:
            class _user_info:
                user_id = doc.String(description='User identifier')
                email = doc.String()
                username = doc.String()
                introduction = doc.String()
                region = doc.String()

            user = doc.List(_user_info)

        data = doc.Object(_user_list)
示例#19
0
class Merchant:
    businessName = doc.String("The name of the business.")
    businessUrl = doc.String("The URL for the business's website.")
    businessLogo = doc.String("The URL for the business's logo.")
    supportEmail = doc.String("The support email for the business.")
    supportPhone = doc.String("The support phone number for the business.")
    supportUrl = doc.String(
        "The URL to reach the support website for the business.")
    productDescription = doc.String("A description of the business's product.")
    statementDescriptor = doc.String(
        "The statement descriptor that will show up on a payer's bank statement when processing through your Paystand network. Length 1-20. Valid Characters: [0-9, a-z, A-Z, &, *, #, period, comma, and space]"
    )
    defaultCurrency = doc.String(
        "The default currency that will be set for this customer. According to  ISO4217 currency code"
    )
    merchantCategoryCode = doc.String(
        "MCC is used to classify a business by the type of goods or services it provides."
    )
    bank = doc.Object(Bank, "The bank account information for this merchant.")
    businessAddress = doc.Object(Address, "The address for this business.")
    personalContact = doc.Object(Contact,
                                 "The personal contact for this business.")
示例#20
0
class Bank:
    # id = doc.String("The unique identifier for the bank.")
    # object = doc.String("Value is bank.")
    accountType = doc.String("The account type of the bank.")
    bankName = doc.String("The bank name.")
    routingNumber = doc.String("The bank routing number.")
    accountNumber = doc.String("The bank account number.")
    nameOnAccount = doc.String("The name on the bank account.")
    accountHolderType = doc.String("The account holder type for the bank")
    currency = doc.String("The currency of the bank")
    country = doc.String("The country for the bank")
    billingAddress = doc.Object(
        Address, "The billing address associated with the bank")
示例#21
0
    class test_suite_list(json_response):
        class _test_suite_list:
            class _test_suite:
                id = doc.String()
                test_suite = doc.String()
                path = doc.String()
                test_cases = doc.List(doc.String())
                variables = doc.JsonBody()
                author = doc.String()

            test_suites = doc.List(_test_suite)

        data = doc.Object(_test_suite_list)
示例#22
0
    class team_list(json_response):
        class _team_list:
            class _team:
                label = doc.String(description='The team name')
                owner = doc.String(description='The team owner\'s name')
                owner_email = doc.String(description='The team owner\'s email')
                organization_id = doc.String(
                    description=
                    'The ID of the organization that the team belongs to')
                value = doc.String(description='The team ID')

            teams = doc.List(_team)

        data = doc.Object(_team_list)
示例#23
0
            class _queuing_tasks:
                class _queuing_task:
                    endpoint = doc.String(description="The endpoint name")
                    endpoint_uid = doc.String(description="The endpoint uid")
                    priority = doc.Integer()
                    task = doc.String(description="The test name")
                    task_id = doc.String(description="The task id")
                    status = doc.String()

                endpoint_uid = doc.String(description="The endpoint uid")
                endpoint = doc.String(description="The endpoint name")
                priority = doc.Integer()
                waiting = doc.Integer()
                status = doc.String()
                tasks = doc.List(doc.Object(_queuing_task))
示例#24
0
class LegalEntity:
    entityType = doc.String(
        "Entity type: ISP,LLC,CORP. If the entityType is ISP, then the personalTaxId parameter should also be sent. The stakePercent parameter should be 100, and no additional owners will be allowed. If the entityType is LLC or CORP,  then the businessTaxId parameter should also be sent."
    )
    businessName = doc.String(
        "This name is strictly for legal verification purposes. Under certain conditions this may be the same as merchant name."
    )
    businessTaxId = doc.String("The tax id belonging to the business.")
    businessSalesVolume = doc.String("The annual sales volume.")
    businessAcceptedCards = doc.String(
        "Whether or not the business accepted card payments in the past or is currently accepting card payments."
    )
    yearsInBusiness = doc.String(
        "The number of years this business has been operating.")
    personalTaxId = doc.String("The tax id for the owner of the business.")
    # last4PersonalTaxId = doc.String("The last 4 digits of the tax id for the owner of the business.")
    businessAddress = doc.Object(Address, "The address of the legal entity.")
    personalAddress = doc.Object(
        Address, "The address of the primary contact for the legal entity.")
    personalContact = doc.Object(
        Contact, "The details of the primary contact for the legal entity.")
    stakePercent = doc.String("The primary owner's stake in the entity.")
    additionalOwners = doc.Object(AdditionalOwner,
                                  "Any additional owners of the entity.")
示例#25
0
            class _organization_team:
                class _team:
                    label = doc.String(description='The team name')
                    owner = doc.String(description='The team owner\'s name')
                    owner_email = doc.String(
                        description='The team owner\'s email')
                    value = doc.String(description='The team ID')

                label = doc.String(description='The organization name')
                owner = doc.String(
                    description='The organization owner\'s name')
                owner_email = doc.String(
                    description='The organization owner\'s email')
                value = doc.String(description='The organization ID')
                children = doc.List(doc.Object(_team))
示例#26
0
    class task_stat_list(json_response):
        class _task_stat_list:
            class _task_stat_of_a_day:
                succeeded = doc.Integer(
                    description='The count of tasks ran successfully in the day'
                )
                failed = doc.Integer(
                    description='The count of tasks failed to run in the day')
                running = doc.Integer(
                    description='The count of tasks running right now')
                waiting = doc.Integer(
                    description='The count of tasks waiting right now')

            stats = doc.List(_task_stat_of_a_day)

        data = doc.Object(_task_stat_list)
示例#27
0
    class organization_list(json_response):
        class _organization_list:
            class _organization:
                label = doc.String(description='The organization name')
                owner = doc.String(
                    description='The organization owner\'s name')
                owner_email = doc.String(
                    description='The organization owner\'s email')
                personal = doc.Boolean(
                    description='The organization is of person'
                )  #, default=False)
                value = doc.String(description='The organization ID')

            organizations = doc.List(_organization)

        data = doc.Object(_organization_list)
示例#28
0
        class _package_list:
            class _package_summary:
                name = doc.String()
                summary = doc.String()
                description = doc.String()
                stars = doc.Integer()
                download_times = doc.Integer()
                package_type = doc.String()
                versions = doc.List(doc.String())
                upload_date = doc.Integer(
                    description=
                    'The upload date in form of timestamp from the epoch in milliseconds'
                )

            packages = doc.List(doc.Object(_package_summary))
            total = doc.Integer()
示例#29
0
        class _endpoint_list:
            class _endpoint_item:
                endpoint_uid = doc.String()
                name = doc.String()
                status = doc.String()
                enable = doc.Boolean()
                last_run = doc.Integer(
                    description="Timestamp in milliseconds, 0 if not run yet")
                tests = doc.List(doc.String())
                test_refs = doc.List(doc.String())
                endpoint_uid = doc.String()

            endpoints = doc.List(
                doc.Object(_endpoint_item),
                description='endpoints of the current queried page')
            total = doc.Integer(
                description='total number of the queried the endpoints')
示例#30
0
    class organization_team_list(json_response):
        class _organization_team_list:
            class _organization_team:
                class _team:
                    label = doc.String(description='The team name')
                    owner = doc.String(description='The team owner\'s name')
                    owner_email = doc.String(
                        description='The team owner\'s email')
                    value = doc.String(description='The team ID')

                label = doc.String(description='The organization name')
                owner = doc.String(
                    description='The organization owner\'s name')
                owner_email = doc.String(
                    description='The organization owner\'s email')
                value = doc.String(description='The organization ID')
                children = doc.List(doc.Object(_team))

            organization_team = doc.List(_organization_team)

        data = doc.Object(_organization_team_list)