-
Notifications
You must be signed in to change notification settings - Fork 737
A required field cannot be nested beneath an absent optional field #429
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
Comments
Interesting use case. I hadn't considered people nesting a required field beneath an optional one, and wanting the required field to only actually be required when the optional field is present. The behaviour you're seeing now has always been the case without an array, for example with a payload like this:
You'd have the same problem if I'll see what can be done to support your requirement. It may be possible to fix this in 1.2.x if it can be done without an API change. |
A more concrete example is shapes on a map. For example, our REST endpoint will index shapes. Each shape has an optional Sample response:
This test used to pass in 1.2.1, but fails under 1.2.2 because of this issue. |
I've prototyped something and I think this requirement can be supported in 1.2.x as it doesn't require an API change |
@joemccall86 @ghost When this build has finished, a fix will be available in 1.2.3.BUILD-SNAPSHOT available from https://repo.spring.io/libs-snapshot. If you have a moment, please give it a try and check that it fixes things for you. |
I'm having some problems after #402, but don't know if this suppose to be in this ways or not.
I have a json with structure like that:
So, "cc" node is optional, but "dd" node is required.
After #402 I have to declare both "cc" and "dd" as optional, otherwise test fails. Which feels kind of wrong - if "cc" present, then it MUST have "dd".
The text was updated successfully, but these errors were encountered: