4

したがって、フラスコ ブループリント ( https://github.com/rantav/flask-restful-swagger/blob/master/examples/blueprints.py )を使用した Swagger UI の使用例に従って、次のコードを作成します。

app = Flask(__name__)
test_blueprint = Blueprint('tests', __name__)
test_api = swagger.docs(restful.Api(test_blueprint), apiVersion='0.1',
                        basePath='http://localhost:5000',
                        produces=["application/json", "text/html"],
                        api_spec_url='/api/spec')

# Operation TestOp defined here
test_api.add_resource(TestOp, '/')

if __name__ == "__main__":
    app.register_blueprint(test_blueprint, url_prefix='/test')
    app.run(debug=True)

しかし、API 仕様ドキュメントにアクセスしようとすると、URL が見つかりません。私はもう試した...

localhost:5000/api/spec
localhost:5000/test_api/api/spec
localhost:5000/test_api

...すべてが 404 を返します。また、設計図なしでアプリを作成して、ドキュメントを作成してみました

swagger.docs(restful.Api(app)...)

代わりは。これが完了し、設計図が含まれていない場合、次のドキュメントにアクセスできます。

localhost:5000/api/spec

では、設計図を使用してアプリケーションを間違って作成しているのでしょうか、それともドキュメントにアクセスするための正しい URL にアクセスしていないだけなのでしょうか?

4

3 に答える 3