isebarn
isebarn

Reputation: 3950

flask_restx - api.expect from two sources for swagger

Hei there!

I have a flask restx api and I have an endpoint that essentially needs to do the following

filters = api.model('filters', {
  x = fields.Raw('x')
}

parser = reqparse.RequestParser()
parser.add_argument('b', type=int, location='args')

class Process(Resource):
  @api.expect(filters)
  @api.expect(parser)
  def get()
  .      
  .

why?

I have a large set of endpoints that all accept the same filter design, but some endpoints also need query parameters

The code works just fine, I can access the json payload and the query parameters inside the method.

The problem I need everything documented by swagger but I need to "mix" the api.model object with the parser object into the @api.expect()

Upvotes: 2

Views: 1425

Answers (1)

Alessandro Calmanovici
Alessandro Calmanovici

Reputation: 101

@api.expect(filters,parser) should work

Upvotes: 0

Related Questions