Why are my flask RESTplus models not registered

1.6k views Asked by At

I have a Flask RESTplus code where I instantiated models in my "models.py" folder. I named all API models inside their respective Flask SQLAlchemy model classes

For instance

class User(db.Model):
   serializer = api.model("user", {
      "name" : fields.String,
   })
   name = db.Column(db.String(10))

class Profile(db.Model):
   serializer = api.model("profile",{
      "country": fields.String,
   })
   country = db.Column(db.String(50))

Like that for each model, using Flask app factory approach, and namespaces for the API. My problem is, only one model shows up in the Swagger UI, and I'm so confused. I've tried everything to make the others show, but nothing has worked

The code is live on Heroku so you can see the Swagger UI there

https://restplus-music-review.herokuapp.com/

1

There are 1 answers

0
C0l0red On

Solved it myself. The problem was from me not using the api.marshal_with decorator on any method. But I happened to use the model parameter on a response decorator. Which caused that one model to be documented, and not the others. Thanks