Hello,
I am looking to set example attribute of model property but cannot find example in documentation or source code.
Basically, I would like swagger.yaml to create attribute here, like this:
properties:
title:
description: title model help_text
type: string
maxLength: 255
minLength: 1
example: My title
Then result documentation would include "My title" instead of "string" like in screenshot:

Is that possible? Would appreciate direction where to look.
Yes, you just have to set the example attribute on an openapi.Schema object (which is just an extended OrderedDict).
How you can get the opportunity to set that is covered in the documentation (override request_bosy, responses, use custom inspectors to process results, etc).
See also #89
Thanks for super fast answer. I will check links and openapi.Schema.
still could not get it.. i have a similar requirement where i need to show the example request body using drf-ysg request_body, can u pls give me sample code snippet
still could not get it.. i have a similar requirement where i need to show the example request body using drf-ysg request_body, can u pls give me sample code snippet
ahahahahah i want know too
it seems can use example only in response
still could not get it.. i have a similar requirement where i need to show the example request body using drf-ysg request_body, can u pls give me sample code snippet
ahahahahah i want know too
it seems can use example only in response
Hi @tjagadeesh @qw2536807, I don't know if you already solved this. But, assuming you creating a custom openapi.Schema for request body, you can just set keyword argument example to any example value you wanted when instantiating new schema.
Most helpful comment
still could not get it.. i have a similar requirement where i need to show the example request body using drf-ysg request_body, can u pls give me sample code snippet