forked from ruby-grape/grape-swagger
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add allowedValues and defaultValues + remove format
- Loading branch information
1 parent
706a215
commit 2aeaae0
Showing
1 changed file
with
7 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2aeaae0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was looking for the allowableValues option as well, which is how I found your work here. How do I use it in a grape API?
I tried this but it did not work:
2aeaae0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sample that works for me.
:params =>
{
"gender" => {
:desc => "gender; 0-Unspecified, 1-Male, 2-Female",
:type => "Integer" ,
:allowableValues => {
:valueType => "LIST",
:values => [ 0, 1, 2 ]
} ,
:defaultValue => 0
}
}
2aeaae0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I am still missing something here. What you posted looks like the JSON that grape-swagger will generate based on the annotations in the ruby code. Isn't it?
I tried the following:
Then I get an error saying:
So that is an exception from grape, not from grape-swagger.
So far I thought that grape-swagger just uses the normal grape params and descriptions to generate the JSON file that is needed by swagger. Or not?