-
Notifications
You must be signed in to change notification settings - Fork 152
Description
Hello 👋
I am creating this ticket to ask if it would be possible to introduce type validation to exposed fields.
Currently there is not checking if the exposed fields are of a specified type. We can add documentation to specify a type (that is then exposed as part of the swagger docs) but if there is a mismatch there is no way for the server to validate this break in contract.
I am thinking we can add type validation (using dry-types or dry-validation) to the exposed fields (maybe after formatting). This would of course be opt-in with the expose DSL method accepting two new options
type (this is the type the field should be or be coercible to) a dry type or standard ruby type like Numeric.
nullable a boolean field to validate if the value can be nil or not.
These options then can be used to populate the swagger documentation automatically without specifying them in the documents hash.
I am happy to start contribute this feature but first want to check if the maintainers @dblock & @LeFnord are okay with it 😅