rantav / flask-restful-swagger

A Swagger spec extractor for flask-restful
MIT License
665 stars 215 forks source link

[Question] How can I set an example value? #139

Open reddytocode opened 4 years ago

reddytocode commented 4 years ago

I'm doing an auth service

my Register endpoint looks like:

class Register(Resource):
    @swagger.operation(
        notes='Register a new User',
        responseClass=SwaggerUserModel.__name__,
        nickname='create',
        parameters=[
            {
                "name": "body",
                "description": "This should send {"name", "password"}",
                "required": True,
                "allowMultiple": False,
                "dataType": SwaggerUserModel.__name__,
                "paramType": "body",
                "exampleValue": fake_auth_register_form
            }
        ])
    def post(self):
        data = parser.parse_args()

when I get the swagger ui it only shows me the body as an empty field, but I want to get a filled value to only press the button of "Try it out!" not having an empty one

niall-byrne commented 4 years ago

I'd like to find out if we aren't meeting the spec here, did you have any luck with this?

qtvspa commented 4 years ago

try replace "exampleValue" to "defaultValue", it works for me.