jmcarp / jmcarp/flask-apispec

Unable to set default parameters when using with Marshmallow schemas

Open
#154 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
652
Forks
151
PR merge metrics
No merged PRs in 30d

Description

I have this Marshmallow Schema:
```
class ApplyPromoResponse(Schema):
testfield = fields.Str(missing='abcd',default='abcd', metadata={example='abcd'})
```

And I'm using it like this:
`@marshal_with(ApplyPromoResponse, code=200)`

This is what I get on Swagger UI:
Screenshot 2019-06-27 at 9 37 43 AM
Screenshot 2019-06-27 at 9 37 52 AM

On clicking the `Try it out` button, I get this:
![image](https://user-images.githubusercontent.com/31135861/60233762-58f2e680-98bf-11e9-98b1-fad5e41ff2b2.png)

Basically I want the default parameters to be set so that I don't have to manually type them while trying GET and POST requests. Hence, what I want to get on clicking the `Try it out` button is:
![image](https://user-images.githubusercontent.com/31135861/60233773-64461200-98bf-11e9-9e9c-341a14f3f58b.png)

I have the `missing`, `default` and `example` fields specified in the Marshmallow Schema but it's not working. Can anyone help debug this issue? Thanks!

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the issue with ApplyPromoResponse, @marshal_with(...), and Swagger UI's Try it out flow; first compare how the Marshmallow missing, default, and example values appear in the generated schema. Done means Swagger UI shows the requested default values without requiring manual entry.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.