Open pistacchio opened 6 years ago
Did you ever figure this out? Having the exact problem.
Also looking for a solution to this issue
I am also looking to do the same thing. It's a real shame because I really do like Flask but the Swagger integration is a bit all over the place.
If anyone in the future is looking to set both the body and parser inside the doc, this will add both to the Swagger documentation.
parser = api.parser()
parser.add_argument('API_KEY', type=str, location='headers')
@api.doc('Example description.', parser=parser, body=example_model)
You can also do it by passing both the parser and the model as parameters to @api.expect:
my_part_schema_model = {
"part_name": "test_name",
"part_type": "test_type"
}
parser = api.parser()
parser.add_argument("Auth", location = "headers", help = "authentication token")
model = api.schema_model( "mymodel", my_part_schema_model)
...
@api.expect(parser, model, validate=True)
...
Hi, I'm using
@api.expect(MyModel, validate=True)
in order to validate the input json of a post request again a custom model. I've created the model withMyModel = api.model('MyModel', {...})
.I also want to add a required (expected) header to be handled and validated by the request. I can do this:
But how can I expect and validate a model and a header since
api.parser
andadd_argument
lets me add headers but doesn't seem to handle a "add this model as body payload" whileapi.model
doesn't let me add headers?Thanks