本文整理汇总了Python中flask_restplus.Namespace.model方法的典型用法代码示例。如果您正苦于以下问题:Python Namespace.model方法的具体用法?Python Namespace.model怎么用?Python Namespace.model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask_restplus.Namespace
的用法示例。
在下文中一共展示了Namespace.model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_clone_with_multiple_parents
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import model [as 别名]
def test_clone_with_multiple_parents(self):
api = Namespace('test')
grand_parent = api.model('GrandParent', {})
parent = api.model('Parent', {})
api.clone('Child', grand_parent, parent, {})
assert 'Child' in api.models
assert 'Parent' in api.models
assert 'GrandParent' in api.models
示例2: test_inherit_from_multiple_parents
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import model [as 别名]
def test_inherit_from_multiple_parents(self):
api = Namespace('test')
grand_parent = api.model('GrandParent', {})
parent = api.model('Parent', {})
api.inherit('Child', grand_parent, parent, {})
assert 'GrandParent' in api.models
assert 'Parent' in api.models
assert 'Child' in api.models
示例3: test_inherit
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import model [as 别名]
def test_inherit(self):
api = Namespace('test')
parent = api.model('Parent', {})
api.inherit('Child', parent, {})
self.assertIn('Parent', api.models)
self.assertIn('Child', api.models)
示例4: test_clone
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import model [as 别名]
def test_clone(self):
api = Namespace('test')
parent = api.model('Parent', {})
api.clone('Child', parent, {})
assert 'Child' in api.models
assert 'Parent' in api.models
示例5: test_inherit
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import model [as 别名]
def test_inherit(self):
authorizations = {
'apikey': {
'type': 'apiKey',
'in': 'header',
'name': 'X-API-KEY'
}
}
api = Namespace('test', authorizations=authorizations)
parent = api.model('Parent', {})
api.inherit('Child', parent, {})
assert 'Parent' in api.models
assert 'Child' in api.models
assert api.authorizations == authorizations
示例6: test_ordered_model
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import model [as 别名]
def test_ordered_model(self):
api = Namespace('test', ordered=True)
api.model('Person', {})
assert 'Person' in api.models
assert isinstance(api.models['Person'], OrderedModel)
示例7: Namespace
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import model [as 别名]
import shlex
from flask import request
from flask_restplus import Resource, Namespace, fields
from son_editor.impl.gitimpl import clone, pull, commit_and_push, create_commit_and_push, delete, list, diff, init, \
status
from son_editor.util.constants import WORKSPACES, GIT
from son_editor.util.requestutil import get_json, prepare_response
namespace = Namespace(WORKSPACES + '/<int:ws_id>/' + GIT, description='Git API')
pull_model = namespace.model('Pull information', {
'project_id': fields.Integer(description='Project ID of the project to get pulled from')
})
init_model = namespace.model('Init information', {
'project_id': fields.Integer(description='Project ID of the project to call git init from')
})
diff_model = namespace.model('Diff information', {
'project_id': fields.Integer(description='Project ID of the project to get diff information')
})
clone_model = namespace.model('Clone information', {
'url': fields.String(description='URL to clone from')
})
delete_model = namespace.model('Delete information', {
'project_id': fields.Integer(description='Project ID of the project to get diff information'),
'repo_name': fields.String(description='Remote repository that gets deleted'),
示例8: GPIOPin
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import model [as 别名]
GPIOPin(22),
GPIOPin(29),
GPIOPin(31),
GPIOPin(33),
GPIOPin(35),
GPIOPin(11),
GPIOPin(13),
GPIOPin(15),
GPIOPin(12),
]
api = Namespace('gpio')
gpio_model = api.model('gpio_pin', {
'channel': fields.Integer(required=True),
'value': fields.Integer(required=True),
'direction': fields.String(enum=('in', 'out'), required=True),
})
@api.route('/')
class GPIOListResource(Resource):
@api.marshal_with(gpio_model, as_list=True)
def get(self):
""" List of GPIO pins """
return PINS
parser = reqparse.RequestParser()
parser.add_argument('direction', type=str, choices=['in', 'out'], location='values')
parser.add_argument('value', type=int, choices=[1, 0], location='values')
@api.route('/<int:channel>')
示例9: test_model
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import model [as 别名]
def test_model(self):
api = Namespace('test')
api.model('Person', {})
assert 'Person' in api.models
assert isinstance(api.models['Person'], Model)
示例10: Namespace
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import model [as 别名]
import datetime
import json
from flask.ext.jwt import current_identity, jwt_required
from flask_restplus import Namespace, Resource, fields, reqparse
from packr.models import Order, OrderStatus, StatusType
api = Namespace('update',
description='Operations related to updating an order')
update_status = api.model('UpdateStatus', {
'con_number': fields.Integer(readOnly=True,
description='The consignment number'),
'status': fields.String(readOnly=True,
description='The new status')
})
update_driver = api.model('UpdateDriver', {
'con_number': fields.Integer(readOnly=True,
description='The consignment number'),
'adminComments': fields.String(readOnly=True,
description='The admin comments')
})
update_admin = api.model('UpdateAdmin', {
'con_number': fields.Integer(readOnly=True,
description='The consignment number'),
'driver': fields.String(readOnly=True,
description='The driver'),
'eta': fields.String(readOnly=True,
示例11: Namespace
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import model [as 别名]
from karmapi import base
from flask import request
from flask_restplus import Namespace, Resource, fields
api = Namespace("euro", description="api for euro")
from karmapi.meta.weather import Image
Image = api.model("Image", Image)
@api.route('/locations/<location>/<item>')
class location(Resource):
""" Rough notes on how to plot centred on a location using basemap
What I really want to do is implement a Karma Pi path something like
this:
locations/{location}/{item}
That will show you {item} from location's point of view.
Now {item} works best if it does not have any /'s, so for
the item parameter we'll convert /'s to ,'s and see how that looks.
The idea is {item} will be a path to something in Karma Pi.
So here is how it might go:
示例12: Model
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import model [as 别名]
'version': fields.String(required=True, description='The VNF Version')
})
uid = Model("VNF_UID", {
'id': fields.String(required=True, description='The VNF UID')
})
funct_response = funct.inherit("FunctionResponse", funct, {
"descriptor": fields.Nested(model=funct, description="The Complete VNF Descriptor"),
"id": fields.Integer(description='The Project ID'),
"project_id": fields.Integer(description='The parent project id'),
})
message_response = proj_namespace.model("Message", {
'message': fields.String(required=True, description="The result message")
})
proj_namespace.add_model(funct.name, funct)
proj_namespace.add_model(funct_response.name, funct_response)
@proj_namespace.route('/')
@cata_namespace.route('/')
@plat_namespace.route('/')
@proj_namespace.param('ws_id', 'The Workspace identifier')
@cata_namespace.param('ws_id', 'The Workspace identifier')
@plat_namespace.param('ws_id', 'The Workspace identifier')
@proj_namespace.param('parent_id', 'The Project identifier')
@cata_namespace.param('parent_id', 'The Catalogue identifier')
@plat_namespace.param('parent_id', 'The Platform identifier')
示例13: Namespace
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import model [as 别名]
api = Namespace('quote',
description='Operations related to generating a quote')
quote = api.model('Quote', {
'businessName': fields.String(readOnly=True,
description='The name of the business'),
'contactName': fields.String(readOnly=True,
description='The contact name'),
'phone': fields.String(readOnly=True,
description='The phone number'),
'email': fields.String(readOnly=True,
description='The email address'),
'type': fields.String(readOnly=True,
descriptuon='The service type'),
'dangerous': fields.String(readOnly=True,
description='The danger type, if applicable'),
'street': fields.String(readOnly=True,
description='The street name and number'),
'suburb': fields.String(readOnly=True,
description='The suburb name'),
'state': fields.String(readOnly=True,
description='The state'),
'postCode': fields.Integer(readOnly=True,
description='The postal code'),
'packages': fields.String(readOnly=True,
description='A JSON map of the packages')
})
@api.route('/')
class QuoteItem(Resource):
示例14: Namespace
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import model [as 别名]
from flask import session
from flask_restplus import Resource, Namespace, fields, reqparse, abort
from flask_restplus.inputs import boolean
from db import datastore
from ..restplus import api
from ..decorators import require_token, require_admin
from helpers import addWhiskey, deleteWhiskey, updateWhiskey, getAllWhiskeyNames
logger = logging.getLogger("whiskey-routes")
whiskeyApi = Namespace('whiskey', description='Whiskey related operations')
whiskey = whiskeyApi.model('Whiskey', {
'name': fields.String(required=True, description='The name of the whiskey'),
'proof': fields.Float(required=True, description='The proof of the whiskey'),
'price': fields.Float(required=True, description='The price of the whiskey'),
'style': fields.String(required=True, description='The style of whiskey'),
'age': fields.Integer(required=True, description='The age of the whiskey'),
'icon': fields.Url(required=False, absolute=True, description='The url for the whiskey icon'),
'url': fields.Url(required=False, absolute=True, description='The original url for the whiskey icon')
})
dbm = datastore.DbManager(testMode=False)
getAllParser = whiskeyApi.parser()
getAllParser.add_argument('currentPage', type=int, required=True, default=1, help='Current page of the query, count starts at 1')
getAllParser.add_argument('itemsPerPage', type=int, required=True, default=20, help='Number of items returned per page, max=100')
getAllParser.add_argument('sortField', type=str, required=False, default='name', help='The name of the field to sort on: name, price, proof, style, or age')
getAllParser.add_argument('namesOnly', type=boolean, required=False, default=False, help='Return just a list of Whiskey names')
getParser = whiskeyApi.parser()
getParser.add_argument('name', type=str, required=True, help='The name of the whiskey')
示例15: Namespace
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import model [as 别名]
api = Namespace('vocterm', description='VocTerm module operations')
# Define the API for fields that you can search by
vocterm_parser = reqparse.RequestParser()
vocterm_parser.add_argument('_term_key')
vocterm_parser.add_argument('_vocab_key')
vocterm_parser.add_argument('vocab_name')
vocterm_parser.add_argument('id')
vocterm_parser.add_argument('creation_date')
vocterm_parser.add_argument('modification_date')
vocterm_model = api.model('VocTerm', {
'_term_key': fields.Integer,
'_vocab_key': fields.Integer,
'vocab_name': fields.String,
'id': fields.String,
'creation_date': fields.DateTime,
'modification_date': fields.DateTime
})
voctermemaps_parser = reqparse.RequestParser()
voctermemaps_parser.add_argument('emapsid')
voctermemaps_parser.add_argument('_term_key')
voctermemaps_parser.add_argument('_emapa_term_key')
voctermemaps_parser.add_argument('_stage_key')
voctermemaps_model = api.model('VocTermEMAPS', {
'emapsid': fields.String,
'_term_key': fields.Integer,
'_emapa_term_key': fields.Integer,
'_stage_key': fields.Integer,