grape-swagger icon indicating copy to clipboard operation
grape-swagger copied to clipboard

Feature request: set Swagger defaultValue without needing to set a grape default

Open thatsanicehat opened this issue 10 years ago • 7 comments

Right now, the grape "default" field is used to populate the swagger defaultValue field.

The expectations of these two parameters is slightly different. In Swagger, defaultValue pre-populates the field only, but in Grape, it will use the default to fill in a missing parameter.

It would be great to be able to set values like these directly with the "documentation" hash that grape lets you pass.

Will submit a PR some time next week

thatsanicehat avatar Feb 12 '15 20:02 thatsanicehat

Makes sense. Would like to see a PR.

dblock avatar Feb 12 '15 21:02 dblock

:+1:

dm1try avatar Feb 13 '15 13:02 dm1try

+1

calfzhou avatar Mar 04 '15 10:03 calfzhou

@jv-dan , two questions about your PR:

default and default_value are not very clear describing their behavior, since default is used by grape, how about naming the latter for example demo, sample, example, etc.?

It would be better to hint the user through swagger ui, that the displayed default value might be only a sample value, not actually the default value of the API. He should provide a specific value when requesting the API.

calfzhou avatar Mar 05 '15 13:03 calfzhou

Good points. The grape documentation uses "example" in it's "Additional documentation"... documentation, so I'll update to that.

thatsanicehat avatar Mar 05 '15 14:03 thatsanicehat

any updates on this?

calfzhou avatar Mar 12 '15 11:03 calfzhou

The updates have been made. Don't know why PR #223 didn't update this thread as well...

thatsanicehat avatar Mar 12 '15 14:03 thatsanicehat