Feature request: 'strict' input binding / JSON-schema support
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
### Task List
- [x] Steps to reproduce provided
- [x] Stacktrace (if present) provided
- [x] Example that reproduces the problem uploaded to Github
- [x] Full description of the issue provided (see below)
### Steps to Reproduce
1. Check out the sample project
2. POST to /master with the following input:
{
"misspelledDetail": []
}
### Expected Behaviour
When using the default input binding behavior for a Domain object, Grails should have a 'strict' input validation setting.
If this setting is enabled, the input binding process should reject property values which are unmapped, resulting in an HTTP 400 (validation error).
Alternately, something like the JSON-schema tool could be used:
[http://json-schema.org/](http://json-schema.org/)
### Actual Behaviour
Grails ignores the invalid JSON property and persists a blank domain object.
### Environment Information
- **Operating System**: Win7 x64
- **GORM Version:** 6.1.4.RELEASE
- **Grails Version (if using Grails):** 3.3.0.M2
- **JDK Version:** 1.8.0_131
### Example Application
I created this example for another issue, but it can be used here, as well:
- [https://github.com/rmorrise/bindToSubclassExample](https://github.com/rmorrise/bindToSubclassExample)
Contributor guide
Research direction
Start with the linked bindToSubclassExample application and reproduce the POST to /master using the misspelledDetail property. Read the Grails/GORM input-binding behavior involved in the example; done means unmapped input is rejected with an HTTP 400, or the supported JSON-schema behavior is clearly defined and implemented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100