marshmallow-mongoengine icon indicating copy to clipboard operation
marshmallow-mongoengine copied to clipboard

Add ModelSchema to swagger

Open mpgalaxy opened this issue 7 years ago • 0 comments

Hi, how can I integrate a mongoengine document / a ModelSchema into swagger with flask-restplus ?

Example:

import mongoengine as me
import marshmallow_mongoengine as ma    

class Test(me.Document):    
      order = me.IntField(required=True)
      disabled = me.BooleanField(required=False, default=False)
      core = me.BooleanField(required=True)
      type = me.StringField(required=False, default="")

class TestSchema(ma.ModelSchema):
      class Meta:
            model = Test

 ....

@test_api.route('test', methods=['GET', 'POST', 'OPTIONS'])
class TestList(Resource):
      def get(self):
          ...
      @test_api.doc(params={fields of class Test object}) <- I want to pass the field definitions of class Test into here to make them appear in swaggerUI
      def post(self):
         ....

mpgalaxy avatar Apr 15 '19 08:04 mpgalaxy