Connexion is an open source API first REST framework for Python, built on top of Flask and based on OpenAPI/Swagger, targeted for microservice development. Connexion automagically handles request routing, oauth2 security, request validation and response serialization based on an OpenAPI 2.0 Specification file in YAML, so you don’t have to care about boilerplate anymore.
Because it is based on Flask it supports everything that Flask does, including deployment options and extensions.
At Zalando we’ve adopted “API First” as one of our key engineering principles, to ensure our API are robust, consistent, general and
abstracted from specific implementation and use cases. But when we tried to implement this principle for the first time we were faced with the lack of a python framework to achieve it in a easy fashion - there were several frameworks that produce a swagger definition from the
implementation but none that do it the other way around - so we decided to fill that gap.
Henning will show how to get started with OpenAPI+Connexion, present some real-world use cases and deployment options such as Kubernetes.
2. 2
ZALANDO AT A GLANCE
~ 4.5billion EUR
revenue 2017
> 200
million
visits
per
month
> 15.000
employees in
Europe
> 70%
of visits via
mobile devices
> 23
million
active customers
> 300.000
product choices
~ 2.000
brands
15
countries
18. 18
CONNEXION: USAGE
PETS = {}
def get_pets(animal_type=None):
return [pet for pet in PETS.values()
if not animal_type or pet['animal_type'] == animal_type]
def get_pet(pet_id):
pet = PETS.get(pet_id)
return pet or ('Not found', 404)
# ...
app = connexion.App(__name__)
app.add_api('swagger.yaml')
app.run(port=8080, server='gevent')
https://github.com/zalando/connexion
22. 22
SWAGGER CODEGEN..
docker run -it -p 8080:8080 swagger-codegen-server
... OAuth2 token info URL missing. **IGNORING SECURITY REQUIREMENTS**
* Serving Flask app "__main__" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)