-
Notifications
You must be signed in to change notification settings - Fork 472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Addes support for enum values in entity documentation and form parameters #132
Addes support for enum values in entity documentation and form parameters #132
Conversation
This has effect on Swagger UI that the parameter number now gets an select drop down box with values 1 , 2 , 3 in it and the entity documentation shows all enum values before the parameter description. |
@@ -13,6 +13,7 @@ | |||
* [#126](https://github.com/tim-vandecasteele/grape-swagger/pull/126): Rewritten demo in the `test` folder with CORS enabled - [@dblock](https://github.com/dblock). | |||
* [#127](https://github.com/tim-vandecasteele/grape-swagger/pull/127): Fixed `undefined method 'reject' for nil:NilClass` error for an invalid route, now returning 404 Not Found - [@dblock](https://github.com/dblock). | |||
* [#128](https://github.com/tim-vandecasteele/grape-swagger/pull/128): Combine global models and endpoint entities - [@dspaeth-faber](https://github.com/dspaeth-faber). | |||
* [#132](https://github.com/tim-vandecasteele/grape-swagger/pull/132): Addes support for enum values in entity documentation and form parameters - [@Antek-drzewiecki](https://github.com/Antek-drzewiecki) |
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.
Missing a period at the end ;)
This is good. Can you please amend the few small things noted above. |
@dblock , done thanks for the feedback. |
@@ -10,6 +10,13 @@ class Something < Grape::Entity | |||
end | |||
|
|||
module Entities | |||
class EnumValues < Grape::Entity | |||
expose :gender, documentation: { type: 'string', desc: 'Content of something.', values: %w(Male Female) } |
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.
Btw, if you're going to use this in a production API, please do allow other genders than 'male' and 'female', for once facebook did it right :)
Great, merging. |
Addes support for enum values in entity documentation and form parameters
…anged throw of StandardError to ArgumentError.
Grape supports has a value restrictions trough arrays or Proc. Swagger UI supports form parameter restrictions trough the enum field. You can also document an entity enum values with the enum field in Swagger UI. This push request adds parameter value integration between Grape (Entity) and Swagger UI.
Usage: