I have a Python program which encapsulates the business logic of an app. An example:
$ app pets list
[{
"name": "Hasso",
"age": 21
},{
"name": "Lassy",
"age": 15
}]
Now I want to realize a REST API with Swagger.io. An extract of the YAML looks like this:
summary: Gets all dogs
produces:
- application/json
responses:
200:
description: array of dogs
schema:
type: array
items:
$ref: '#/definitions/Dog'
Swagger-codgen generates python code using Flask & connexion and provides the following directory structure:
└── python-flask
└── swagger_server
├── controllers
├── models
├── __pycache__
├── swagger
└── test
There are classes for all used object types in the models
-directory.
I want to keep the API-App and the BL-App(business app) separate but use the same models for convenience.
What's the best way of sharing the model definitions in-between these to applications? I will also import this BL-App into the API-Project in order to implement the controllers
-part.