0

Does the flask_restplus library allows to define a model once and re-use it in multiple namespaces. In my use case, I would like to have a general model for returning on successful post requests. At the moment, I have to redefine the model in every namespace.

API with two namespaces

from flask_restplus import Api

from api_service.api.api_1 import api as ns_1
from api_service.api.api_2 import api as ns_2

api = Api()


api.add_namespace(ns_1, path='/api_1')
api.add_namespace(ns_2, path='/api_2')

Code snippet, I have to redefine in every namespace

post_response_model = api.model("Post response", {
    'message': fields.String(),
    'id': fields.String(description="Id of inserted entry")
})
Molitoris
  • 935
  • 1
  • 9
  • 31

0 Answers0