当前位置: 首页>>代码示例>>Python>>正文


Python Api.parser方法代码示例

本文整理汇总了Python中flask_restplus.Api.parser方法的典型用法代码示例。如果您正苦于以下问题:Python Api.parser方法的具体用法?Python Api.parser怎么用?Python Api.parser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask_restplus.Api的用法示例。


在下文中一共展示了Api.parser方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_api_shortcut

# 需要导入模块: from flask_restplus import Api [as 别名]
# 或者: from flask_restplus.Api import parser [as 别名]
 def test_api_shortcut(self):
     api = Api(self.app)
     parser = api.parser()
     self.assertIsInstance(parser, RequestParser)
开发者ID:aaronbenz,项目名称:flask-restplus,代码行数:6,代码来源:test_reqparse.py

示例2: Flask

# 需要导入模块: from flask_restplus import Api [as 别名]
# 或者: from flask_restplus.Api import parser [as 别名]
        return summary


app = Flask(__name__)


api = Api(app, version='1.0', title='Summary API',
    description='A simple review summarization API which uses Python\'s sumy library'
)

app.config.SWAGGER_UI_DOC_EXPANSION = 'list'

ns = api.namespace('sum/v1.0', 'Text Summary v1.0 ')

parser = api.parser()
parser.add_argument('reviews', required=True, location='json', help='Input Format -> {"reviews":[ {"reviewer_id":"string","reviewee_id":"string","score":"string","feedback":"string"}]}')

parser_sum = api.parser()
parser_sum.add_argument('sentences', required=True, location='json', help='Input Format -> {"sentences":["sentence1"]')


###### Definition of data model for documentation
summary_marshaller = api.model('summary_marshaller',{
    'summary': fields.String(description='Summary of the review')
})

message_marshaller = api.model('message_marshaller',{
    'message': fields.String(description='Api call status', required=True)
})
开发者ID:peerlogic,项目名称:AutoSummaryV1,代码行数:31,代码来源:AutoSummary.py

示例3: abort_if_todo_doesnt_exist

# 需要导入模块: from flask_restplus import Api [as 别名]
# 或者: from flask_restplus.Api import parser [as 别名]
todo = api.model('Todo', {
    'task': fields.String(required=True, description='The task details')
})

listed_todo = api.model('ListedTodo', {
    'id': fields.String(required=True, description='The todo ID'),
    'todo': fields.Nested(todo, description='The Todo')
})


def abort_if_todo_doesnt_exist(todo_id):
    if todo_id not in TODOS:
        api.abort(404, "Todo {} doesn't exist".format(todo_id))

parser = api.parser()
parser.add_argument('task', type=str, required=True, help='The task details', location='form')


@ns.route('/<string:todo_id>')
@api.doc(responses={404: 'Todo not found'}, params={'todo_id': 'The Todo ID'})
class Todo(Resource):
    '''Show a single todo item and lets you delete them'''
    @api.doc(description='todo_id should be in {0}'.format(', '.join(TODOS.keys())))
    @api.marshal_with(todo)
    def get(self, todo_id):
        '''Fetch a given resource'''
        abort_if_todo_doesnt_exist(todo_id)
        return TODOS[todo_id]

    @api.doc(responses={204: 'Todo deleted'})
开发者ID:aaronbenz,项目名称:flask-restplus,代码行数:32,代码来源:todo.py

示例4: import

# 需要导入模块: from flask_restplus import Api [as 别名]
# 或者: from flask_restplus.Api import parser [as 别名]
    ensure_can_edit_user,
    ensure_can_edit_contact)
from fooapi.schemata import (
    LimitOffsetSchema,
    UserSchema,
    ContactSchema,
    AccessTokenSchema)
from fooapi.models import Contact
from fooapi.utils import validation_errors_to_unicode_message


api = Api(prefix='/api')


# these parsers are here only for the purposes of Swagger UI generation
auth_parser = api.parser()
auth_parser.add_argument('X-Access-Token', type=str,location='headers')

user_parser = api.parser()
user_parser.add_argument('name', type=unicode, location='form')
user_parser.add_argument('X-Access-Token', type=str,location='headers')

contact_parser = api.parser()
contact_parser.add_argument('phone_no', type=str, location='form')
contact_parser.add_argument('email', type=str, location='form')
contact_parser.add_argument('type', type=str, location='form',
                            choices=Contact.NAMES_TO_TYPES.keys())
contact_parser.add_argument('X-Access-Token', type=str, location='headers')

list_parser = api.parser()
list_parser.add_argument('limit', type=int, location='args')
开发者ID:croshchupkin,项目名称:fooapi,代码行数:33,代码来源:api.py

示例5: Flask

# 需要导入模块: from flask_restplus import Api [as 别名]
# 或者: from flask_restplus.Api import parser [as 别名]
from werkzeug.datastructures import FileStorage
from threading import Thread

from settings import BaseConfig
from job_model import JobStatus, Job, JobSchema

# Extensions initialization
# =========================
app = Flask(__name__)
api = Api(app, version='1.0', title='Name classificator study API',
    description='This service using for training name classification model',
)

ns = api.namespace('new-jobs', description='Jobs for ML models study')

upload_parser = api.parser()
upload_parser.add_argument('file', location=BaseConfig.UPLOAD_DIR,
                           type=FileStorage, required=True)

# Data layer - Collections
# ========================
jobs = []

# Routes
# ======
@ns.route('/')
class JobList(Resource):
    # Shows a list of all jobs, and lets you POST to add new jobs
    def get(self):
        # List all jobs
        schema = JobSchema(many=True)
开发者ID:Rosdex,项目名称:rest-category-classificator-study,代码行数:33,代码来源:run.py

示例6: check_city

# 需要导入模块: from flask_restplus import Api [as 别名]
# 或者: from flask_restplus.Api import parser [as 别名]
        api.abort(422, "date from the request cannot be parsed: {}".format(e))
    return dt

def check_city(city):
    if city not in CITIES:
        api.abort(404, "City {} not found".format(city))


api = Api(title='Jitenshea: Bicycle-sharing data analysis',
          prefix='/api',
          doc=False,
          version='0.1',
          description="Retrieve some data related to bicycle-sharing data from some cities.")

# Parsers
station_list_parser = api.parser()
station_list_parser.add_argument("limit", required=False, type=int, default=100,
                                 dest='limit', location='args', help='Limit')
station_list_parser.add_argument("geojson", required=False, default=False, dest='geojson',
                                 location='args', help='GeoJSON format?')

daily_parser = api.parser()
daily_parser.add_argument("date", required=True, dest="date", location="args",
                          help="day of the transactions (YYYY-MM-DD)")
daily_parser.add_argument("window", required=False, type=int, default=0, dest="window",
                          location="args", help="How many days?")
daily_parser.add_argument("backward", required=False, type=inputs.boolean, default=True, dest="backward",
                          location="args", help="Backward window of days or not?")

daily_list_parser = api.parser()
daily_list_parser.add_argument("limit", required=False, type=int, default=20,
开发者ID:armgilles,项目名称:jitenshea,代码行数:33,代码来源:webapi.py

示例7: Api

# 需要导入模块: from flask_restplus import Api [as 别名]
# 或者: from flask_restplus.Api import parser [as 别名]
                           iris=data['complete_code'],
                           name=data['name'],
                           citycode=data['citycode'],
                           city=data['city'],
                           iris_type=data['type'])


api = Api(service,
          title='INSEE/IRIS Geolocalizer',
          ui=False,
          prefix='/api',
          version='0.1',
          description="Retrieve some data related to the IRIS codes. Look for an IRIS from an address.")
api.add_namespace(insee_api)

geojson_parser = api.parser()
geojson_parser.add_argument("geojson", type=inputs.boolean, default=False, location='args',
                            help='GeoJSON')

iris_code_parser = geojson_parser.copy()
iris_code_parser.add_argument("limit", required=False, default=10, dest='limit',
                              location='args', help='Limit')

address_parser = geojson_parser.copy()
address_parser.add_argument("q", required=True, dest='q', location='args',
                            help='Query')

coords_parser = geojson_parser.copy()
coords_parser.add_argument("lat", required=True, type=float, dest='lat', location='args',
                            help='Latitude')
coords_parser.add_argument("lon", required=True, type=float, dest='lon', location='args',
开发者ID:garaud,项目名称:pyris,代码行数:33,代码来源:app.py

示例8: test_api_shortcut

# 需要导入模块: from flask_restplus import Api [as 别名]
# 或者: from flask_restplus.Api import parser [as 别名]
 def test_api_shortcut(self, app):
     api = Api(app)
     parser = api.parser()
     assert isinstance(parser, RequestParser)
开发者ID:bedge,项目名称:flask-restplus,代码行数:6,代码来源:test_reqparse.py


注:本文中的flask_restplus.Api.parser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。