Conditional required properties (if/then/else)
See original GitHub issueHey,
Loosley related to #288, most likely just a question and not a request 😃 I again have this code:
@JsonAlias("uid")
@JsonPropertyDescription("The ID of the parameter. This ID must be unique in a given application.")
public String id;
// Compat with 4.x
@Deprecated(forRemoval = true)
@JsonProperty("uid")
@JsonPropertyDescription("DEPRECATED: Use 'id' instead.")
public String getUid() {
return id;
};
Now I would like the schema to require either of them to be set. AFAIK this is achieved using if/then/else in the schema (?) - how would I best go about configuring the generator appropriately? Thanks!
(Note: Both id
and uid
end up in the schema fine already, thanks to #288 one of them is even marked deprecated)
Issue Analytics
- State:
- Created a year ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Applying Subschemas Conditionally - JSON Schema
dependentRequired¶. The dependentRequired keyword conditionally requires that certain properties must be present if a given property is present in an object ...
Read more >jsonSchema attribute conditionally required - Stack Overflow
I can think of four different ways to conditionally require a field. Dependencies. The dependentSchemas keyword is a conditional way to apply a...
Read more >If Then Else - Liquid Technologies
The 3 properties If, Then, Else make it possible to specify conditional validation rules for a schema. Each of them contains a JSON...
Read more >Applying subschemas conditionally | Opis JSON Schema
if-then-else. This is a conditional structure containing three keywords: if , then and else . Every keyword value must be a valid JSON...
Read more >Field required based on condition · Issue #539 · json-schema ...
conditional requirement of properties; conditions expressed as relationships among properties. The first part can be implemented today with if :.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey. I adapted my code to be very close to what you provided. Thanks. That solves all the remaining issues I had 😃
Woah, nice, thanks a TON! Will try this on Monday!