This server was generated by the swagger-codegen project. By using the OpenAPI-Spec from a remote server, you can easily generate a server stub. This is an example of building a swagger-enabled Flask server.
This example uses the Connexion library on top of Flask.
Python 3.5.2+
To run the server, please execute the following from the root directory:
pip3 install -r requirements.txt
# start a mock server by default
python3 -m unicorn_server
# you can specify a controller as backend
python3 -m unicorn_server -B kytos -s config/settings.py
# check the detailed usage
python3 -m unicorn_server --help
usage: __main__.py [-h] [-B {mock,odl,kytos}] [-a ADDRESS] [-p PORT] [-A AUTH]
[-k] [-s SETTINGS]
Unicorn Domain Manager.
optional arguments:
-h, --help show this help message and exit
-B {mock,odl,kytos}, --backend {mock,odl,kytos}
set backend controller.
-a ADDRESS, --addr ADDRESS
ip address of the backend controller (default:
localhost).
-p PORT, --port PORT tcp port the backend controller REST API will listen
on (default: 8181).
-A AUTH, --auth AUTH the authentication of the backend controller REST API.
-k, --secure use HTTPS to talk to REST API of the backend
controller.
-s SETTINGS, --settings SETTINGS
import a python file as extra settings.
and open your browser to here:
http://localhost:9000/v1/unicorn/ui/
Your Swagger definition lives here:
http://localhost:9000/v1/unicorn/swagger.json
To launch the integration tests, use tox:
sudo pip install tox
tox
To run the server on a Docker container, please execute the following from the root directory:
# building the image
docker build -t unicorn_server .
# starting up a container
docker run -p 9000:9000 unicorn_server
If you modified the api specification, you can run make
from the root
directory to regenerate the model files:
# run make directly will download swagger-codegen to .bin
make
# or you can specify the exec path of your existing swagger-codegen to void
# downloading the binary of swagger-codegen
SWAGGER_EXEC=swagger-codegen make