I've got the following structure in my Flask-RestX application:
- api_models
- users
- permissions
- namespaces
- users
- permissions
I've got a permission_model in api_models/permissions which I want to use in user_model in api_models/users. Usecase:
Permission model: (in api_models/permissions.py)
permission_model = permission_api.model('Permission', {
"id": fields.String(description="Permission ID", required=True)
})
User model: (in api_models/users.py)
from .permissions import permission_model
user_model = users_api.model('User', {
"id": fields.String(description="User ID", required=True),
"permissions": fields.List(fields.Nested(permission_model))
})
I thought it's just as easy as importing models from one file to the other but the whole API breaks down when doing that ("No API definition provided."). I assume this is because they are attached to different Namespaces?
- Is there a workaround?
- How do people use models cross Namespaces?
Thanks.