OpenAPI generated server
Overview
This server was generated by the OpenAPI Generator project. By using the OpenAPI-Spec from a remote server, you can easily generate a server stub. This is an example of building a OpenAPI-enabled Flask server.
This app uses the Connexion library on top of Flask.
Requirements
Python 3.5.2+
Usage
To run the server, please execute the following from the root directory:
pip3 install -r requirements.txt
python3 -m openapi_server
and open your browser to here:
http://localhost:8080/ui/
Your OpenAPI definition lives here:
http://localhost:8080/openapi.json
DEV requirements (testing libs):
pip3 install -r requirements/dev.txt
To launch unit tests, use pytest:
python -m pytest openapi_server
Typing checks:
mypy openapi_server/
To launch the integration tests, use tox:
sudo pip install tox
tox
Running with Docker
To run the server on a Docker container, please execute the following from the root directory:
# building the image
docker build -t openapi_server .
# starting up a container
docker run -p 8080:8080 openapi_server
Adding new endpoints
-
Edit
bq-api-spec.yaml
according to Swagger documentation. -
You can check/debug it here.
-
Run this command:
openapi-generator generate -i bq-api-spec.yaml -g python-flask -o . -s
it will create endpoints, models, controller stubs and documentation.
-s
flag will prevent your code from being overwritten.
[Julia] When i run this command, documentation is not correctly created, to bypass it,
I run this command in an empty project without -s
flag and then copy-paste file contents.
Dear reader, if you know the better way to do this, please update this doc.