You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How can I use your code to document the swagger model - I can't really get it to work. The representer shows up in the grape documentation but both type and description are missing for the defined properties…
Update: Got it! The documentation method has to look like this (the documentation values are stored under attribute[:documentation]):
def documentation
Hash[representable_attrs.map do |attribute|
property_name = attribute[:as].evaluate nil, nil
next if property_name == '_links'
[property_name, {desc: attribute[:documentation][:desc], type: attribute[:documentation][:type]}]
end.compact]
end
PR #47 documents the existing optional grape-swagger-representable parser rather than duplicating its integration. Use a Roar decorator as the response model and declare property metadata as documentation: { type: Integer, desc: "Product ID" }; require the parser before add_swagger_documentation.
The exact README example was executed with Grape 4.0.1, grape-swagger 2.2.0, and grape-swagger-representable 0.2.2. The generated Swagger response reference, property types/descriptions, and actual rendered response match. The parser registers decorator classes, not representer modules; response metadata does not validate incoming parameters.
Activity
taybin commentedon Jul 31, 2014
Does this implement https://github.com/tim-vandecasteele/grape-swagger/issues/121?
dblock commentedon Jul 31, 2014
@taybin Mostly, yes.
danielkummer commentedon Oct 10, 2014
How can I use your code to document the swagger model - I can't really get it to work. The representer shows up in the grape documentation but both type and description are missing for the defined properties…
Update: Got it! The documentation method has to look like this (the documentation values are stored under attribute[:documentation]):
dblock commentedon Oct 10, 2014
Would love it if someone turned this into production code :)
sebweaver commentedon Feb 11, 2016
👍
dblock commentedon Oct 27, 2026
PR #47 documents the existing optional grape-swagger-representable parser rather than duplicating its integration. Use a Roar decorator as the response model and declare property metadata as
documentation: { type: Integer, desc: "Product ID" }; require the parser beforeadd_swagger_documentation.The exact README example was executed with Grape 4.0.1, grape-swagger 2.2.0, and grape-swagger-representable 0.2.2. The generated Swagger response reference, property types/descriptions, and actual rendered response match. The parser registers decorator classes, not representer modules; response metadata does not validate incoming parameters.
Posted by Copilot, an AI, on behalf of @dblock.