-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Param type Rack::Multipart::UploadedFile does not result in object of that type #1164
Labels
Comments
That's correct. This hash is created by post '/' do
params.avatar.filename # => 'avatar.png'
params.avatar.type # => 'image/png'
params.avatar.tempfile # => #<File>
end Not sure if this is documented anywhere in either library. |
I'll leave this open, @alexandergitter feel free to suggest a doc improvement? |
Sure, I'll take a look at it later this week. |
dslh
added a commit
to dslh/grape
that referenced
this issue
Sep 28, 2015
Addresses ruby-grape#1164, ruby-grape#690, ruby-grape#689, ruby-grape#693. Depends on solnic/virtus#343 `Grape::ParameterTypes` is renamed `Grape::Validations::Types` to reflect that it should probably be bundled with an eventual `grape-validations` gem. It is expanded to include two new categories of types, 'special' and 'recognized' (see 'lib/grape/validations/types.rb'). `CoerceValidator` now makes use of `Virtus::Attribute::value_coerced?`, simplifying its internals. `CustomTypeCoercer` is introduced, attempting to standardize support for custom types by decoupling coercion and type-checking logic from the `type` class supplied to `Grape::Dsl::Parameters::requires`. `JSON`, `Array[JSON]` and `Rack::Multipart::UploadedFile (a.k.a `File`) are designated 'special' types, for which special implementations of `Virtus::Attribute` are provided. Instances of `Virtus::Attribute` built with `Virtus::Attribute.build` may now also be passed as the `type` parameter for `requires`. A number of pre-rolled attributes are available providing coercion for `Date` and `DateTime` objects from various formats in `lib/grape/validations/types/date.rb` and `date_time.rb`.
dslh
added a commit
to dslh/grape
that referenced
this issue
Sep 28, 2015
Addresses ruby-grape#1164, ruby-grape#690, ruby-grape#689, ruby-grape#693. Depends on solnic/virtus#343 `Grape::ParameterTypes` is renamed `Grape::Validations::Types` to reflect that it should probably be bundled with an eventual `grape-validations` gem. It is expanded to include two new categories of types, 'special' and 'recognized' (see 'lib/grape/validations/types.rb'). `CoerceValidator` now makes use of `Virtus::Attribute::value_coerced?`, simplifying its internals. `CustomTypeCoercer` is introduced, attempting to standardize support for custom types by decoupling coercion and type-checking logic from the `type` class supplied to `Grape::Dsl::Parameters::requires`. `JSON`, `Array[JSON]` and `Rack::Multipart::UploadedFile (a.k.a `File`) are designated 'special' types, for which special implementations of `Virtus::Attribute` are provided. Instances of `Virtus::Attribute` built with `Virtus::Attribute.build` may now also be passed as the `type` parameter for `requires`. A number of pre-rolled attributes are available providing coercion for `Date` and `DateTime` objects from various formats in `lib/grape/validations/types/date.rb` and `date_time.rb`.
dslh
added a commit
to dslh/grape
that referenced
this issue
Sep 28, 2015
Addresses ruby-grape#1164, ruby-grape#690, ruby-grape#689, ruby-grape#693. Depends on solnic/virtus#343 `Grape::ParameterTypes` is renamed `Grape::Validations::Types` to reflect that it should probably be bundled with an eventual `grape-validations` gem. It is expanded to include two new categories of types, 'special' and 'recognized' (see 'lib/grape/validations/types.rb'). `CoerceValidator` now makes use of `Virtus::Attribute::value_coerced?`, simplifying its internals. `CustomTypeCoercer` is introduced, attempting to standardize support for custom types by decoupling coercion and type-checking logic from the `type` class supplied to `Grape::Dsl::Parameters::requires`. `JSON`, `Array[JSON]` and `Rack::Multipart::UploadedFile (a.k.a `File`) are designated 'special' types, for which special implementations of `Virtus::Attribute` are provided. Instances of `Virtus::Attribute` built with `Virtus::Attribute.build` may now also be passed as the `type` parameter for `requires`. A number of pre-rolled attributes are available providing coercion for `Date` and `DateTime` objects from various formats in `lib/grape/validations/types/date.rb` and `date_time.rb`.
dslh
added a commit
to dslh/grape
that referenced
this issue
Sep 30, 2015
Addresses ruby-grape#1164, ruby-grape#690, ruby-grape#689, ruby-grape#693. Depends on solnic/virtus#343 `Grape::ParameterTypes` is renamed `Grape::Validations::Types` to reflect that it should probably be bundled with an eventual `grape-validations` gem. It is expanded to include two new categories of types, 'special' and 'recognized' (see 'lib/grape/validations/types.rb'). `CoerceValidator` now makes use of `Virtus::Attribute::value_coerced?`, simplifying its internals. `CustomTypeCoercer` is introduced, attempting to standardize support for custom types by decoupling coercion and type-checking logic from the `type` class supplied to `Grape::Dsl::Parameters::requires`. The process for inferring which logic to use for each type and coercion method is encoded in `lib/grape/validations/types/build_coercer.rb`. `JSON`, `Array[JSON]` and `Rack::Multipart::UploadedFile (a.k.a `File`) are designated 'special' types, for which special implementations of `Virtus::Attribute` are provided. Instances of `Virtus::Attribute` built with `Virtus::Attribute.build` may now also be passed as the `type` parameter for `requires`. A number of pre-rolled attributes are available providing coercion for `Date` and `DateTime` objects from various formats in `lib/grape/validations/formats/date.rb` and `date_time.rb`.
dslh
added a commit
to dslh/grape
that referenced
this issue
Sep 30, 2015
Addresses ruby-grape#1164, ruby-grape#690, ruby-grape#689, ruby-grape#693. `Grape::ParameterTypes` is renamed `Grape::Validations::Types` to reflect that it should probably be bundled with an eventual `grape-validations` gem. It is expanded to include two new categories of types, 'special' and 'recognized' (see 'lib/grape/validations/types.rb'). `CoerceValidator` now makes use of `Virtus::Attribute::value_coerced?`, simplifying its internals. `CustomTypeCoercer` is introduced, attempting to standardize support for custom types by decoupling coercion and type-checking logic from the `type` class supplied to `Grape::Dsl::Parameters::requires`. The process for inferring which logic to use for each type and coercion method is encoded in `lib/grape/validations/types/build_coercer.rb`. `JSON`, `Array[JSON]` and `Rack::Multipart::UploadedFile (a.k.a `File`) are designated 'special' types, for which special implementations of `Virtus::Attribute` are provided. Instances of `Virtus::Attribute` built with `Virtus::Attribute.build` may now also be passed as the `type` parameter for `requires`. A number of pre-rolled attributes are available providing coercion for `Date` and `DateTime` objects from various formats in `lib/grape/validations/formats/date.rb` and `date_time.rb`. Depends on a monkey patch to `Virtus::Attribute::Collection`, included in `lib/grape/validations/types/virtus_collection_patch.rb`. See pull request 343 on solnic/virtus for more details.
dslh
added a commit
to dslh/grape
that referenced
this issue
Sep 30, 2015
Addresses ruby-grape#1164, ruby-grape#690, ruby-grape#689, ruby-grape#693. `Grape::ParameterTypes` is renamed `Grape::Validations::Types` to reflect that it should probably be bundled with an eventual `grape-validations` gem. It is expanded to include two new categories of types, 'special' and 'recognized' (see 'lib/grape/validations/types.rb'). `CoerceValidator` now makes use of `Virtus::Attribute::value_coerced?`, simplifying its internals. `CustomTypeCoercer` is introduced, attempting to standardize support for custom types by decoupling coercion and type-checking logic from the `type` class supplied to `Grape::Dsl::Parameters::requires`. The process for inferring which logic to use for each type and coercion method is encoded in `lib/grape/validations/types/build_coercer.rb`. `JSON`, `Array[JSON]` and `Rack::Multipart::UploadedFile (a.k.a `File`) are designated 'special' types, for which special implementations of `Virtus::Attribute` are provided. Instances of `Virtus::Attribute` built with `Virtus::Attribute.build` may now also be passed as the `type` parameter for `requires`. Depends on a monkey patch to `Virtus::Attribute::Collection`, included in `lib/grape/validations/types/virtus_collection_patch.rb`. See pull request 343 on solnic/virtus for more details.
This is now documented in the readme. Close? |
Closing. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Declaring a parameter as Rack::Multipart::UploadedFile doesn't seem to actually yield a parameter of the same type. Instead I'm getting instances of Hashie::Mash.
The endpoint i use to test this looks as follows:
The text was updated successfully, but these errors were encountered: