This example application implement a very basic "Pet Store" REST service using the Connexion.
Connexion is a framework that automagically handles HTTP requests based on OpenAPI Specification of your API described in YAML format.
This example application uses the following modules and has features.
- OpenAPI 3.0
- Connexion >= 2.0.0
- SQLAlchemy ORM, SQLAlchemy-Utils, Flask-Alchemy, sqlathanor
- one-to-many relationship (store and pets)
- automatically encode ORM objects to JSON using sqlathanor
- json_querybuilder
- search resources by simple query language in JSON
- pytest, WebTest
Python 3.5.2+
- controllers/
- controller functions mapped using
operationId
inopenapi.yaml
- simply call model methods
- controller functions mapped using
- models/
- staticmethods implement business logic using ORMs
- orm/
- just a SQLAlchemy ORM
To run the server, please execute the following from the root directory:
pip3 install -r requirements.txt
make spec # if you modified tiny-petstore.yaml
python3 app.py
or
./bin/start-server
and open your browser to here:
http://localhost:9090/v3/ui/
Your OpenAPI definition lives here:
http://localhost:9090/v3/openapi.json
To launch the integration tests, use tox:
pip3 install -r requirements.txt -r test-requirements.txt
python3 setup.py test
or
PYTHONPATH=. pytest
To run the server on a Docker container, please execute the following from the root directory:
# building the image
docker build -t tiny_petstore .
# starting up a container
docker run -p 9090:9090 tiny_petstore
We welcome your ideas, issues and pull requests!