def getTypeModel(flaskRestPlusAPI, typeName): if typeName == 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_EBO/Space/V1/SpaceEBO:SpaceEBOTypeV1': return flaskRestPlusAPI.model( 'SpaceEBOTypeV1', { 'Identification': fields.Nested( getTypeModel( flaskRestPlusAPI, 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_EBO/Space/V1/SpaceRBO:IdentificationTypeV1' )), 'Name': fields.String(default='', description='Name of the Space'), 'Description': fields.String(default='', description='Name of the Space'), 'EffectiveDates': fields.Nested( getTypeModel( flaskRestPlusAPI, 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_CBO/V1/EffectiveDateType:EffectiveDateTypeV1' )), 'AreaInformation': fields.Nested( flaskRestPlusAPI.model( 'InlineAreaInformationType', { #Element NetArea has a type that is not catered for (xsd:decimal) 0 #Element GrossArea has a type that is not catered for (xsd:decimal) 0 #Element UpliftedArea has a type that is not catered for (xsd:decimal) 0 #Element Height has a type that is not catered for (xsd:decimal) 0 })), #Element Capacity has a type that is not catered for (xsd:int) 0 'SpaceCategory': fields.String( default='', description= 'Space Category e.g Core This needs to match one of the values from this dvm - AIAMetaData\AIAComponents\EnterpriseObjectLibrary\Core\IC_EBO\Space\V1\XXIC_SpaceCategory.dvm' ), 'SpaceType': fields.Nested( getTypeModel( flaskRestPlusAPI, 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_EBO/Space/V1/SpaceEBO:SpaceTypeV1' )), 'Building': fields.Nested( getTypeModel( flaskRestPlusAPI, 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_EBO/Building/V1/BuildingRBO:BuildingReferenceTypeV1' )), 'Floor': fields.Nested( getTypeModel( flaskRestPlusAPI, 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_EBO/Floor/V1/FloorRBO:FloorReferenceTypeV1' )), }) if typeName == 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_EBO/Space/V1/SpaceEBO:SpaceTypeV1': return flaskRestPlusAPI.model( 'SpaceTypeV1', { 'Identification': fields.Nested( flaskRestPlusAPI.model( 'InlineIdentificationType', { 'Code': fields.String( default='', description='Code of Space Type'), })), 'Name': fields.String(default='', description='Name of Space Type'), 'Description': fields.String(default='', description='Description of Space Type'), }) if typeName == 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_EBO/Building/V1/BuildingRBO:BuildingReferenceTypeV1': return flaskRestPlusAPI.model( 'BuildingReferenceTypeV1', { 'Identification': fields.Nested( getTypeModel( flaskRestPlusAPI, 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_EBO/Building/V1/BuildingRBO:IdentificationTypeV1' )), 'Name': fields.String(default='', description=''), 'Description': fields.String(default='', description=''), }) if typeName == 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_EBO/Building/V1/BuildingRBO:IdentificationTypeV1': return flaskRestPlusAPI.model( 'IdentificationTypeV1', { 'Code': fields.String(default='', description=''), }) if typeName == 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_EBO/Floor/V1/FloorRBO:FloorReferenceTypeV1': return flaskRestPlusAPI.model( 'FloorReferenceTypeV1', { 'Identification': fields.Nested( getTypeModel( flaskRestPlusAPI, 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_EBO/Floor/V1/FloorRBO:IdentificationTypeV1' )), 'Name': fields.String(default='', description=''), 'Description': fields.String(default='', description=''), }) if typeName == 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_EBO/Floor/V1/FloorRBO:IdentificationTypeV1': return flaskRestPlusAPI.model( 'IdentificationTypeV1', { 'Code': fields.String(default='', description=''), }) if typeName == 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_EBO/Space/V1/SpaceRBO:SpaceReferenceTypeV1': return flaskRestPlusAPI.model( 'SpaceReferenceTypeV1', { 'Identification': fields.Nested( getTypeModel( flaskRestPlusAPI, 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_EBO/Space/V1/SpaceRBO:IdentificationTypeV1' )), 'Name': fields.String(default='', description=''), 'Description': fields.String(default='', description=''), }) if typeName == 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_EBO/Space/V1/SpaceRBO:IdentificationTypeV1': return flaskRestPlusAPI.model( 'IdentificationTypeV1', { 'Code': fields.String( default='', description= 'Code of the Space will consist of BuildingCode-FloorCode-SpaceCode as SpaceCode itself is not unique by itself' ), }) if typeName == 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_CBO/V1/EffectiveDateType:EffectiveDateTypeV1': return flaskRestPlusAPI.model( 'EffectiveDateTypeV1', { #Element StartDateTime has a type that is not catered for (xsd:dateTime) 0 #Element EndDateTime has a type that is not catered for (xsd:dateTime) 0 }) raise Exception('Searching for unknown type')
self.id, self.language, self.framework) class LanguageSchema(Schema): id = mafields.Integer() language = mafields.String() framework = mafields.String() @post_load def create_language(self, data, **kwargs): return Language(**data) a_language = api.model( 'Language', { 'language': fields.String("the language."), 'framework': fields.String("The framework") }) languages = [] # python = {'language': 'python', 'id': 1} python = TheLanguage(id=1, language='python', framework='Flask') languages.append(python) # db.session.add(python) # db.session.commit() @api.route('/language') class Language(Resource): # @api.marshal_with(a_language, envelope='the_data') def get(self):
class MaterialDto: api = Namespace('material', description='material related operations') material = api.model( 'material', { 'id': fields.String(description='The material id'), 'name': fields.String(description='The name of the material'), 'type': fields.String( description='The material type', attribute='type._value_', enum=['bsdf', 'light_source', 'opaque', 'translucent']), 'red': fields.Float( min=0, max=1, description='The red hue of the Light material'), 'green': fields.Float(min=0, max=1, description='The green hue of the Light material'), 'blue': fields.Float(min=0, max=1, description='The blue hue of the Light material'), 'radius': fields.Float(min=0, exclusiveMin=True, description='The radius of the Light material'), 'r_reflectance': fields.Float( min=0, max=1, description='The red reflectance of the Opaque material'), 'g_reflectance': fields.Float( min=0, max=1, description='The green reflectance of the Opaque material'), 'b_reflectance': fields.Float( min=0, max=1, description='The blue reflectance of the Opaque material'), 'specularity': fields.Float(min=0, max=1, description='The specularity of the Opaque material'), 'roughness': fields.Float(min=0, max=1, description='The roughmess of the Opaque material'), 'r_transmittance': fields.Float( min=0, max=1, description='The red transmittance of the Translucent material' ), 'g_transmittance': fields.Float( min=0, max=1, description= 'The green transmittance of the Translucent material'), 'b_transmittance': fields.Float( min=0, max=1, description='The blue transmittance of the Translucent material' ), 'xml_data': fields.String( description='The XML string representation of the BSDF material' ), 'up_orientation': fields.Float(min=0, max=1, description='The orientation of the BSDF material'), 'thickness': fields.Float(min=0, exclusiveMin=True, description='The thickness of the BSDF material'), 'refraction': fields.Float(min=0, max=1, description='The refraction index of the material'), 'modifier': fields.String(description='The string modifier of the material') })
title='Reputation API', description='API: https://recomendation-api-cefet.herokuapp.com/') bootstrap = Bootstrap(app) app.config["SECRET_KEY"] = "STRINGHARDTOGUESS" client = pymongo.MongoClient( "mongodb+srv://" + mb_user + ":" + pwd + "@cluster0.d1wep.gcp.mongodb.net/RecDB?retryWrites=true&w=majority") db = client.RecDB ns = api.namespace('', description='Endpoints') #models makeEvaluation = api.model( 'makeEvaluation', { "user_id": fields.String("5fb99c9970765b0beebd6a25"), "colaborator_id": fields.String('5fb99c9a70765b0beebd6a26'), "key": fields.String('genericKey'), "evaluation": fields.Float(), "comments": fields.String(), "questions": fields.List(fields.String('O que achou?')) }) evaluationByApp = api.model( 'evaluationByApp', { "app_id": fields.String('5fb99c9a70765b0beebd6a27'), "colaborator_id": fields.String('5fb99c9a70765b0beebd6a26') }) fullEvaluation = api.model( 'fullEvaluation',
import json import uuid from flask_restplus import Namespace from flask_restplus import Resource from flask_restplus import fields from flask_restplus import reqparse from flask_restplus import abort from flask_restplus import marshal_with api = Namespace('users', description='API de usuarios') user = { 'id': fields.String(required=True, description='Identificador'), 'username': fields.String(required=True, description='Usuário'), 'email': fields.String(required=True, description='Email'), 'first_name': fields.String(required=True, description='Primeiro Nome'), 'last_name': fields.String(required=True, description='Último Nome'), 'individual_registration': fields.String(required=True, description='CPF'), 'birth_date': fields.Date(required=True, description='Data de Nascimento'), 'password': fields.String(required=True, description='Senha'), } parser = reqparse.RequestParser() parser.add_argument('username', type=str) parser.add_argument('email', type=str) parser.add_argument('first_name', type=str) parser.add_argument('last_name', type=str) parser.add_argument('individual_registration', type=str) parser.add_argument('birth_date', type=str) parser.add_argument('password', type=str)
class AuthDto: api = Namespace('auth', description='authentication operations') user_auth = api.model('auth', { 'email': fields.String(required=True, description='The email address'), 'password': fields.String(required=True, description='The user password '), })
class CleanerDto: api = Namespace('cleaner', description='cleaner operations') cleaner = api.model('cleaner', { 'name': fields.String(required=True, description='cleaner name'), 'num_boxes': fields.Integer(description='cleaner num of boxes') })
from flask_restplus import Namespace, Resource, fields, reqparse, marshal from models import db, User, Company, Stock import models from flask import jsonify, make_response import os testEp = Namespace('testing', description='testing env') # --------------- Response Model Registration ---------------- # ----------------------------- base response model ---------------------- base_response_model1 = testEp.model( 'parent', {'server_error': fields.String(default="no")}) test_model = testEp.model( 'test', { 'server_error': fields.String(default="no"), 'id': fields.Integer, 'username': fields.String, 'email': fields.String, 'country': fields.String, 'current_balance': fields.Integer, 'user_type': fields.Integer, 'current_net_worth': fields.Integer, }) user_list_model = testEp.model( 'userList', { 'server_error': fields.String(default="no"), 'users': fields.List(fields.Nested(test_model)) })
### Models for documents class AnyType(fields.Raw): __schema_type__ = "any" # limit m_limit = api.model("Rate Limit Rule", { "id": fields.String(required=True), "name": fields.String(required=True), "description": fields.String(required=True), "ttl": fields.String(required=True), "limit": fields.String(required=True), "action": fields.Raw(required=True), "include": fields.Raw(required=True), "exclude": fields.Raw(required=True), "key": AnyType(required=True), "pairwith": fields.Raw(required=True), }) # urlmap m_secprofilemap = api.model("Security Profile Map", {
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Information about this API. .. currentmodule:: {{cookiecutter.package_name}}.apis.info .. moduleauthor:: {{cookiecutter.author_name}} <{{cookiecutter.author_email}}> """ from flask_restplus import Namespace, Resource, fields from flask_restplus.model import Model from .. import __version__ api = Namespace('info', description='Get general information about the API.') InfoModel: Model = api.model( 'Info', {'version': fields.String(readOnly=True, description='the API version') }) #: the information model @api.route('/') class InfoResource(Resource): """Get general information about the API.""" @api.doc('get_info') @api.marshal_with(InfoModel, envelope='info') def get(self): # pylint: disable=no-self-use """Get general information about the API.""" return {'version': __version__}, 200
from flask import Flask from flask_restplus import fields, Api, Resource from nltk_stopwords import Stopwords, Tfcompute from cos_bow import VectorCreation import json app = Flask(__name__) api = Api(app) raw_text = api.model('Rawtext', { 'Input1': fields.String('Your Input.'), 'Input2': fields.String('Your Input.') }) @api.route('/Preprocessor') class Preprocessor(Resource): @api.expect(raw_text) def post(self): #data received from post request input_text = api.payload #dumps the json object into an element json_str = json.dumps(input_text) #load the json to a string resp = json.loads(json_str) #Stopwords elimination begins here doc11 = Stopwords(resp['Input1'].lower()) doc12 = Tfcompute(doc11) doc21 = Stopwords(resp['Input2'].lower()) doc22 = Tfcompute(doc21) doc13 = VectorCreation(resp['Input1'].lower(), resp['Input2'].lower())
InternalServerError]): """Propagate internal server error to the global app error handler.""" raise error # re-raise @api.errorhandler(Exception) def propagate_unknown_exception(error: Exception): """Propagate unknown exception to the global app error handler.""" raise error # re-raise build_fields = api.model( 'build_fields', { 'build_id': fields.String(required=True, description="Unique build identification.", example="osiris-api-1"), 'build_status': fields.String(required=True, description="Status of the build.", example="BuildStarted"), 'build_url': fields.Url( required=False, description="URL to the OCP pod.", ), 'build_log_url': fields.Url( required=False, description="URL to build logs.", ),
'mask': fields.List( fields.Integer( required=True, description='Segmented masks of each nucleus. The mask ' 'is compressed by Run-length encoding.')), 'probability': fields.Float( required=True, description='Predicted probability for presence of the nucleus') }) predict_response = MAX_API.model( 'ModelPredictResponse', { 'status': fields.String(required=True, description='Response status message'), 'predictions': fields.List(fields.Nested(label_prediction)) }) class ModelPredictAPI(PredictAPI): model_wrapper = ModelWrapper() @MAX_API.doc('predict') @MAX_API.expect(input_parser) @MAX_API.marshal_with(predict_response) def post(self): """Make a prediction given input data""" result = {'status': 'error'}
token = 'bp-smartblotter' if 'X-API-KEY' in request.headers: provided_token = request.headers['X-API-KEY'] if not provided_token: return {'message': 'API Token is missing.'}, 401 elif token != provided_token: return {'message': 'Provided API Token is incorrect'}, 401 else: return f(*args, **kwargs) return decorated json_example_format = api.model('json_example', { 'language': fields.String('programming lanuage.'), 'framework': fields.String('framework.'), 'website': fields.String(), 'python_version_info': fields.String(), 'flask_version_info': fields.String(), 'examples': fields.List(fields.String), 'boolean_test': fields.Boolean() }) # @api.route('/web_ui') # class Web_UI(Resource): # def get(self): # try: # return render_template("index.html") # except Exception as e:
host_addr = config['DEFAULT']['HOST_ADDR'] # 'secret-key-of-myapp' app = Flask(__name__) # Flask App 생성한다 api = Api(app, version='1.0', title='variety api', description='python api 모음') # API 만든다 phonetic = api.namespace('phonetic', description='발음기호 조회, 추가') # /phonetic/ 네임스페이스를 만든다 emotion = api.namespace('emotion_detection', description='감정 이모티콘 추가') # /emotion/ 네임스페이스를 만든다 # REST Api에 이용할 데이터 모델을 정의한다 model_phonetic = api.model( 'row_phonetics', { 'eng_word': fields.String( readOnly=True, required=True, description='상품번호', help='상품번호는 필수'), 'phon_word': fields.String(required=True, description='상품명', help='상품명은 필수') }) class GoodsDAO(object): '''영어단어 발음기호 Data Access Object''' def __init__(self): self.counter = 0 self.rows = [] def get(self, input_eng_word): '''영어단어를 이용하여 발음기호를 조회한다''' # Open database connection
A brief description goes here. :copyright: (c) 2018/11/30 by zwhset. :license: OPS, see LICENSE_FILE for more details. """ from flask_restplus import Namespace, Resource, fields, reqparse from core.build import Build as BuildClass api = Namespace("build", description="Build Image") buildModel = api.model("BuildModel", { 'step' : fields.Integer(required=True, description="步数"), 'step_content' : fields.List(fields.String, required=True, description="步数内容"), 'message' : fields.String(required=True, description='信息'), 'succeed' : fields.Boolean(required=True, description="是否完成") }) @api.route('/<key>') class Build(Resource): builder = BuildClass() @api.marshal_with(buildModel) def get(self, key): """获取编译项信息""" data = self.builder.get_build(key) if data: return data api.abort(404, 'not fund build info')
from flask_restplus import Namespace, fields, Resource from flask import request from api.security import token_required from database.database import db from bson import ObjectId heatings_collection = db.heatings heating_namespace = Namespace('heating', description='Heating API functions') heating_update_model = heating_namespace.model( 'HeatingUpdate', { 'name': fields.String(require=False, example='Living room heating'), 'description': fields.String(require=False, example='Radiator on the left from the window'), 'current_temperature': fields.Integer( require=False, example=19, description='Current temperature in the room. Temperature in °C.') }) heating_model = heating_namespace.inherit( 'Heating', heating_update_model, { 'id': fields.String(require=True, example='KLJLK43268'), }) @heating_namespace.route('')
foreign_keys=role_id, post_update=True, uselist=False) school = db.relationship(School, foreign_keys=school_id, post_update=True, uselist=False) def __init__(self, dict): ModelSuper.__init__(self, dict) user_role_request_model = api.model( 'User_Role_Request', { 'user_id': fields.String(required=True, description="The user identifier"), 'role_id': fields.String(required=True, description="The role identifier"), 'school_id': fields.String(required=True, description="The school identifier"), }) user_role_response_model = api.inherit( 'User_Role_Response', model_super_model, { 'user': fields.Nested(user_response_model), 'role': fields.Nested(role_response_model), 'school': fields.Nested(school_response_model), }) class UserRoleService(object):
class RestaurantDto: api = Namespace('restaurant', description='restaurant operations') restaurant = api.model('restaurant', { 'name': fields.String(required=True, description='restaurant name'), 'num_boxes': fields.Integer(description='restaurant num of boxes') })
# //TODO: create folder for each domain for allowed_domain in ALLOWED_DOMAINS: if not os.path.exists( os.path.join(os.path.abspath(WKD_KEY_STORE), allowed_domain)): print('%s does not exist. Creating...' % os.path.join(os.path.abspath(WKD_KEY_STORE), allowed_domain)) os.makedirs( os.path.join(os.path.abspath(WKD_KEY_STORE), allowed_domain), 0o700) key_model = api.model( 'Key Model', { 'key': fields.String(required=True, description="key of the person", help="Key cannot be blank.") }) # Add admin namespace admin_ns = api.namespace('admin', description='Admin APIs') # load wkd-store wkd_store = WKDFileStore(WKD_KEY_STORE) # token_required decorator for Token check def token_required(f): @wraps(f) def decorated(*args, **kwargs): token = None
version='1.0', title='RESTful Pi', description='A RESTful API to control the GPIO pins of a Raspbery Pi', doc='/docs') ns = api.namespace('pins', description='Pin related operations') pin_model = api.model( 'pins', { 'id': fields.Integer(readonly=True, description='The pin unique identifier'), 'pin_num': fields.Integer(required=True, description='GPIO pin associated with this endpoint'), 'color': fields.String(required=True, description='LED color'), 'state': fields.String(required=True, description='LED on or off') }) class PinUtil(object): def __init__(self): self.counter = 0 self.pins = [] def get(self, id): for pin in self.pins: if pin['id'] == id: return pin api.abort(404, f"pin {id} doesn't exist.")
from flask_restplus import fields, Namespace, Resource from gtfs_api.models import StopTime, Stop stop_time_namespace = Namespace('stop_time', description='通過時間に関するエンドポイント') stop_time = stop_time_namespace.model( 'StopTime', { 'trip_id': fields.String(require=True, description='', example=''), 'arrival_time': fields.String(require=True, description='', example=''), 'departure_time': fields.String(require=True, description='', example=''), 'stop_id': fields.String(require=True, description='', example=''), 'sequence': fields.Integer(require=True, description='', example=''), 'headsign': fields.String(require=False, description='', example=''), 'pickup_type': fields.Integer(require=False, description='', example=''), 'drop_off_type': fields.Integer(require=False, description='', example=''), 'shape_dist_traveled': fields.Float(require=False, description='', example=''), 'timepoint': fields.Integer(require=False, description='', example='') })
from flask_restplus import fields from gamr.api.restplus import api # Game object used in endpoint responses gameResponseModel = api.model( 'Game', { 'id': fields.Integer(readOnly=True, description='The unique identifier of a game', example=1), 'title': fields.String( required=True, description='Game title', example='Pac Man'), 'year': fields.Integer(required=True, description='Release year of the game', example=1980), 'pic': fields.String( required=True, description='Game picture', example='pacman.jpg'), 'avgRating': fields.Float(required=True, description='Average rating of the game', example=0.87), 'votes': fields.Integer(required=True, description='Number of votes for the game', example=23) }) # Response wrapper for single games
CORS(app) api = Api( app, version='1.0', title='Serums POC Server', description= 'Sends the results of the POC to the corresponding use case partner', ) # Models hello = api.model( 'Server Check', { 'hello': fields.String(required=True, description='Quick check that the server is on', example='Welcome to the POC server. The server is on') }) question_fields = api.model( 'Survey Submit', { 'case_study': fields.String( required=True, description= "The name of the use case partner. This is used to pick the email address that will receive the results. The example here selects my one which I am using for testing so as to not clog up everyone else's inboxes", example='TEST'), 'question': fields.String( required=True, description=
'cant_obs_asenl': 'Cant. Obs. (ASENL)', 'monto_asenl': 'Monto (ASENL)', 'cant_obs_cytg': 'Cant. Obs. (CyTG)', 'monto_cytg': 'Monto (CyTG)', 'ejercicio_ini': 'Ejercicio (desde)', 'ejercicio_fin': 'Ejercicio (hasta)', 'division_id': 'Id de la direccion del usuario', } ns = api.namespace("reporte_53", description="Servicios para los reportes 52 y 53") data_row = api.model( 'Data row (Reporte 53)', { 'dep': fields.String(description=reporte_53_ns_captions['dependencia']), 'ej': fields.Integer(description=reporte_53_ns_captions['ejercicio']), 'c_asf': fields.Integer(description=reporte_53_ns_captions['cant_obs_asf']), 'm_asf': fields.Float(description=reporte_53_ns_captions['monto_asf']), 'c_sfp': fields.Integer(description=reporte_53_ns_captions['cant_obs_sfp']), 'm_sfp': fields.Float(description=reporte_53_ns_captions['monto_sfp']), 'c_asenl': fields.Integer(description=reporte_53_ns_captions['cant_obs_asenl']), 'm_asenl': fields.Float(description=reporte_53_ns_captions['monto_asenl']), 'c_cytg':
from sqlalchemy import and_, or_, asc, desc from ..model.guest_message import GuestMessage from project.utils import token_required, token_optional from project.helpers import auctionMillisecondsDeadline from definitions import SITE_PREFIX, COINS_BASE_PRICE, GEMS_BASE_PRICE, AUCTION_START_PROGRESS import math search_ns = Namespace('search') participants_fields = search_ns.model('ParticipantsFields', { "icons": fields.List(fields.String), "count": fields.Integer() }) charity_fields = search_ns.model('ParticipantsFields', { "icon": fields.String(), "description": fields.String() }) status_fields = search_ns.model( 'ParticipantsFields', { "bidPrice": fields.Integer(), "name": fields.String(), "avatar": fields.String() }) coin_fields = search_ns.model( 'CoinFields', { "planId": fields.Integer(), "title": fields.String(), "count": fields.Integer(),
app.config.from_object(Config) api = Api( app, prefix="/v1", title="Users", description="Users CURD api.", authorizations=dict(key={ 'type': 'apiKey', 'in': 'Header', 'name': 'X-API-KEY' }), ) language = api.model( 'language', { 'language': fields.List(fields.String('TheLanguage')), 'num': fields.Integer(required=True) }) a_language = api.model( 'languageList', { 'data': fields.List(fields.Nested(language)), 'success': fields.Boolean(description="查询是否成功"), 'message': fields.String(description="返回结果信息") }) languages = list() python = {'language': 'python'} languages.append(python) def authorized(func):
from utils.hashids_iiuv import hashids_iivu_encode from utils.jwt_util import generate_jwt from utils.constants import MEMBERS_TABLE from utils.mysql_cli import MysqlSearch, MysqlWrite from utils.snowflake.id_worker import IdWorker from utils.http_status import HttpStatus from utils.short_link import get_short_link login = Namespace('login', description='手机登录 请求方式:json') user_api.add_namespace(login) register_model = user_api.model( 'Register', { 'mobile': fields.Integer(required=True, description='手机号码'), 'code': fields.Integer(required=True, description='手机验证码'), 'iiuv': fields.String(description='是否通过二维码过来注册,是就要携带,不是可以为空'), '返回内容': fields.String(description='当前接口返回一个token'), }) @login.route('') class LoginView(Resource): def _generate_tokens(self, user_id, setreal, mobile, with_refresh_token=True): """ 生成token :param user_id: 用户id :return: token, refresh_token
class WEADto: api = Namespace('wea', description='ladybug formatted wea file') data_collection = api.model( 'data collection', { # TODO: add header parameter 'header': fields.Nested( api.model( 'data collection header', { 'data_type': fields.String( description='Name of the data type eg: temperature' ), 'unit': DataCollectionUnit( description= 'The unit of measurement of the data collection eg: cm' ) })), 'data': fields.List( fields.Nested( api.model( 'data point', { 'nickname': DataCollectionUnit( description= 'Honestly... I\'m not sure what this does...'), 'standard': fields.String(description='Measurement standard', enum=['SI', 'IP']), 'datetime': fields.Nested( api.model( 'datetime', { 'month': fields.Integer(), 'day': fields.Integer(), 'hour': fields.Integer(), 'minute': fields.Integer(), 'year': fields.Integer(), 'leap_year': fields.Boolean() })), 'value': DataCollectionValue( description='Value of the measurement') }))) }) location = api.model( 'location', { 'city': fields.String(description='The city the epw is modelled for'), 'country': fields.String(description='The country the epw is modelled for'), 'source': fields.String(description='The name of the provider of the EPW'), 'station_id': fields.String( description= 'The id of the station the epw is measured from (if it exists)' ), 'latitude': fields.Float(description=''), 'longitude': fields.Float(description=''), 'time_zone': fields.Float(), 'elevation': fields.Float() }) wea = api.model( 'epw', { 'id': fields.String(description='The wea id'), 'location': fields.Nested(location), "direct_normal_radiation": fields.Nested(data_collection), "diffuse_horizontal_radiation": fields.Nested(data_collection) })
from flask_restplus.reqparse import RequestParser from ngsapp.common.schema import ProjectSchema from ngsapp.ext import pagination, db from ngsapp.models import Project, Team from ngsapp.resources.team import team_schema from ngsapp.resources.users import user_schema from ngsapp.tasks import rq_notify from ngsapp.utils import roles_required ns_project = Namespace('project', 'Project management') project_schema = ns_project.model( 'Project', { 'id': fields.Integer(), 'uuid': fields.String(), 'user': fields.Nested(user_schema), 'name': fields.String(), 'description': fields.String(), 'start_date': fields.DateTime(), 'due_date': fields.DateTime(), 'budget': fields.Float(), "teams": fields.Nested(team_schema, allow_null=True), 'priority': fields.String(), 'status': fields.String(), 'active': fields.Boolean(), 'created': fields.DateTime(), }) schema = ProjectSchema() parser = RequestParser(bundle_errors=True, trim=True) parser.add_argument('name', required=True, location='json', type=str)