3

how can i add 'value example' (like on picture 3) to swagger documentation (picture 4 is that where i want to put 'value example' in) without using decorator marshall_with/marshall_list_with? Cuz the function got two responses depending on two endpoints enter image description here

enter image description here

enter image description here enter image description here

Chep
  • 41
  • 2

1 Answers1

0

You can use the model to define an example, like this:

...
# define model with example
example_response = api.model('ExampleResponse', {
    'field_you_want': fields.String(example="Example Value")
})


@api.route("/")
class Example(Resource):

    @api.marshal_with(example_response)
    def get(self):
        response = get_response()
        return response, 200
...
natielle
  • 380
  • 3
  • 14