Issue with the order of as: and default: options on param declarations #2094
Comments
As a side note, if there is a better way to convert all incoming camelcase params to snake case without having to use the |
This looks like a possible bug indeed, try turning it into a spec? Regarding camelcase, I would try swapping the parameter builder to a Hashie extension that Btw, you probably want a lambda to evaluate on every request, |
Hey @dblock, I can certainly try putting a spec together for this when I get some time to, same as the Hashie extension. Regarding the {
"in": "query",
"name": "endDate",
"description": "End date of query",
"type": "string",
"format": "date",
"default": { },
"required": false
} Which then sets in the Swagger UI (using https://petstore.swagger.io) the default value to If this is another bug I can put this in another ticket if that helps keep things separated? |
That's a grape-swagger issue, so you should probably open a bug there. That said, it's not supposed to interpret a dynamic default value into some kind of documentation. Not sure what one would expect here. For your API, I suspect you don't want |
Am fairly new to Grape, so apologies if this has come up elsewhere already but doing a quick scan I couldn't see anything covering this issue I was having with using both
as
anddefault
param options.If I use the following to set an
endDate
param with a default value and convert it toend_date
then the default value behaviour works as expected.Would result in the default param value being set when no param was sent:
However if I use following for the same request, and specify the
as
option first, the default value is never set on the params, even when usingdeclared
(although not sure this would make a difference anyway).Would result in:
I'm assuming this might be a bug with how the param options are being parsed by Grape but wanted to also make sure I wasn't doing something dumb.
The text was updated successfully, but these errors were encountered: