You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, I have a Flask project where I want to generate Swagger docs with Flasgger, Apispec and Marshmallow.
Since I want to use requestBody, I moved to OpenAPI 3.0.2, and when I did it, Swagger showed me errors saying that it can't find my schemas, because the definitions themselves moved under components/schemas/MyMarshmallow (without the "Schema" part), but for endpoints, schemas are still in "$ref": "#/definitions/MyMarshmallowSchema".
The code that leads to this:
from flask import Flask
from apispec.ext.marshmallow import MarshmallowPlugin
from apispec_webframeworks.flask import FlaskPlugin
from flasgger import APISpec, Swagger
from app.my_api import api_blueprint
spec = APISpec(
title="My Test API",
version="1.0.0",
openapi_version="3.0.2",
info=dict(description="My Test API"),
plugins=[
FlaskPlugin(),
MarshmallowPlugin(),
],
)
flask_app = Flask(__name__)
# just in case
flask_app.config['SWAGGER'] = {
'uiversion': 3,
'title': 'My Test API',
'openapi': '3.0.2'
}
template = spec.to_flasgger(
flask_app,
definitions=[MyMarshmallowSchema]
)
swag = Swagger(flask_app, template=template)
flask_app.register_blueprint(api_blueprint)
flask_app.run(debug=True)
Basically, this results in a broken swagger, because the schema definition is de facto under components/schemas/MyMarshmallow (OpenAPI 3.0.2 style) , but methods expect it to be under "$ref": "#/definitions/MyMarshmallowSchema" (Swagger 2.0 style).
Since this came from the swag_from, I think it's Flasgger's fault, and I already told it I'm using OpenAPI 3.0.2 in APISpec object and in Flask 'SWAGGER' config part.
I solved this by manually changing the definition to "schema": {"$ref": "#/components/schemas/MyMarshmallow" } in swag_from, but I don't think this is the correct behaviour.
The text was updated successfully, but these errors were encountered:
So, I have a Flask project where I want to generate Swagger docs with Flasgger, Apispec and Marshmallow.
Since I want to use requestBody, I moved to OpenAPI 3.0.2, and when I did it, Swagger showed me errors saying that it can't find my schemas, because the definitions themselves moved under
components/schemas/MyMarshmallow
(without the "Schema" part), but for endpoints, schemas are still in"$ref": "#/definitions/MyMarshmallowSchema"
.The code that leads to this:
and
swag_from
for my endpoint:Basically, this results in a broken swagger, because the schema definition is de facto under
components/schemas/MyMarshmallow
(OpenAPI 3.0.2 style) , but methods expect it to be under"$ref": "#/definitions/MyMarshmallowSchema"
(Swagger 2.0 style).Since this came from the
swag_from
, I think it's Flasgger's fault, and I already told it I'm using OpenAPI 3.0.2 in APISpec object and in Flask 'SWAGGER' config part.I solved this by manually changing the definition to
"schema": {"$ref": "#/components/schemas/MyMarshmallow" }
inswag_from
, but I don't think this is the correct behaviour.The text was updated successfully, but these errors were encountered: