4

[Python、Flask、flask_restplus、Swagger を使用]

schema modelを使用して下の図のように表示しようとしていますflask_restplus。Python ではなく yml のプロトタイプ スキーマ:

ここに画像の説明を入力

を作成しましたschema_modelが、GET 呼び出しとペアになるようにコードに入力する方法がわかりません。schema_model を表示するにはどうすればよいですか?


import requests
from flask import Flask, request, json, jsonify, Blueprint
from flask_restplus import Resource, Api, reqparse, fields, SchemaModel

app = Flask(__name__)
api = Api(app, title='Function Test', doc='/FT')

rbt = api.namespace('RBT', description='Accessible by API')

address = api.schema_model('Address', {
    'properties': {
        'road': {
            'type': 'string'
        },
    },
    'type': 'object'
})

@rbt.route('/<string:resource>/<string:responder>/<string:tag>')
class RBT(Resource):

    @rbt.doc(responses={
        200: 'Success',
        400: 'Validation Error',
        500: 'Internal Server Error'
    })

    #@rbt.marshal_with(address)
    def get(self, resource, responder, tag, **kwargs):
        '''TC#1 Definition'''
        url2 = 'http://' + host +  port + '/' + resource + '?' +responder
        print(url2)

        url = 'http://httpbin.org/get'

        parameters = {'resource': resource, 'responder':responder, 'tag': tag}
        r = requests.get(url)
        data = r.text

        return data
4

1 に答える 1