Reputation: 23
I've built a RESTful API with Python and Flask, and deployed it on Heroku. The API works fine but I can't access my swagger UI page, I get a 404 error, but when I run it locally I don't have the problem.
I saw many posts saying that the problem could come from the HTTPS connection, so I specified the different schemes in my swagger.yml
file but it doesn't change anything.
swagger: "2.0"
info:
description: my swagger file
version: "1.0.0"
title: my title
consumes:
- application/json
produces:
- application/json
host : myapi.herokuapp.com
basePath: /api
schemes: [http, https]
paths:
/spread:
get:
operationId: spread.read_all
tags:
- Spread
summary: Read the file containing all calculated values
description: Read the file containing all calculated values
parameters:
- name: length
in: query
type: integer
description: Number of people to get from people
required: false
- name: offset
in: query
type: integer
description: Offset from beginning of list where to start gathering people
required: false
responses:
200:
description: description
schema:
type: array
items:
properties:
exp_spread:
type: string
And here is my requirements.txt
:
flask
pandas
gunicorn
connexion
I'd just like to access my swagger documentation page like I do locally, by typing https://myapi.herokuapp.com/api/ui
.
Upvotes: 0
Views: 1782
Reputation: 137278
Update your requirements.txt
to depend on
connexion[swagger-ui]
instead of just connexion
, then redeploy. The UI isn't installed by default:
The Swagger UI for an API is available through pip extras. You can install it with
pip install connexion[swagger-ui]
. It will be served up at{base_path}/ui/
wherebase_path
is the base path of the API.
Upvotes: 1