Getting parser error
karkir0003 opened this issue · comments
Hi,
I hope you are doing well. I have a flask app that I'm trying to add in flasgger to in order to take advantage of Open API. Here is a sample of my code
from flasgger import Swagger
from flasgger.utils import swag_from
# and other code imports here
app = Flask(
__name__,
static_folder=os.path.join(os.getcwd(), "frontend", "playground-frontend", "build"),
)
CORS(app)
app.config['SWAGGER'] = {
'title': 'DLP API',
'uiversion': 3,
'host': 'localhost:8000',
'basePath': '/'
}
swagger = Swagger(app, template_file="dlpapi.yaml")
@app.route("/test")
@swag_from('dlpapi.yaml')
def verify_backend_alive():
return {"Status": "Backend is alive"}
Here is the yaml file I'm trying to get rendered
openapi: '3.0.0'
info:
title: DLP API
description: API endpoints for the Deep Learning Playground Project
version: '1.0.0'
paths:
/test:
get:
summary: A simple endpoint to test if our backend is alive
responses:
200:
description: Test Backend alive
content:
application/json:
schema:
type: object
properties:
Status:
type: string
example: "Backend is alive"
Problem:
When I spin up localhost:8000/apidocs
, I get this error
Investigation Strategies I've Tried:
- Went into https://codebeautify.org/yaml-validator and pasted the above yaml in to see if there is any syntax error. There isn't a syntax error according to the tool
- I also make sure to add
openapi
version properly along withinfo
andpaths
- I also tried adding in the
template_file="dlpapi.yaml
in theSwagger
constructor in Flask. That didn't really do anything
Anything else you'd suggest I try to resolve this issue
@rochacbruno could you or someone from the flasgger team please help me out
UPDATE: resolved this issue. I needed to set app.config["SWAGGER"]["openapi"] to version 3.0.2
according to the README with uiversion: 3