Fix reference creation when two types are provided #756
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously the type from param definition would be used to documentation even if we try to override it in the
documentation
hash.It caused Swagger UI to render, for example, "Unknown Type: Color" instead of using the provided entity.
It terms of code, before this change we would return something like this:
{ color: { type: 'Color' }
instead of:
{ color: { '$ref' => 'ColorEntity' }
if
Color
is not inherited fromGrape::Entity
Having different types can be useful when two different classes are used for parsing and presenting an attribute.
E.g. the input format for Base64 File can be represented as a Hash (content, content_type and filename), whereas the type after parsing can be
ActionDispatch::Http::UploadedFile
.In the current situation the solution to this problem is to put coercion methods to the same entity and specify
type
only for the param without usingdocumentation
.