Skip to content

Commit 35e69a6

Browse files
committed
Update Catalog bean validation to cascade to nested properties
1 parent 548d700 commit 35e69a6

File tree

8 files changed

+26
-0
lines changed

8 files changed

+26
-0
lines changed

spring-cloud-open-service-broker-autoconfigure/src/main/java/org/springframework/cloud/servicebroker/autoconfigure/web/Catalog.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.List;
2121
import java.util.stream.Collectors;
2222

23+
import jakarta.validation.Valid;
2324
import jakarta.validation.constraints.NotEmpty;
2425

2526
/**
@@ -37,6 +38,7 @@ public class Catalog {
3738
* A list of service offerings provided by the service broker.
3839
*/
3940
@NotEmpty
41+
@Valid
4042
private final List<ServiceDefinition> services = new ArrayList<>();
4143

4244
public List<ServiceDefinition> getServices() {

spring-cloud-open-service-broker-autoconfigure/src/main/java/org/springframework/cloud/servicebroker/autoconfigure/web/Plan.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.cloud.servicebroker.autoconfigure.web;
1818

19+
import jakarta.validation.Valid;
1920
import jakarta.validation.constraints.NotEmpty;
2021

2122
import org.springframework.boot.context.properties.NestedConfigurationProperty;
@@ -55,12 +56,14 @@ public class Plan {
5556
* The metadata for this plan.
5657
*/
5758
@NestedConfigurationProperty
59+
@Valid
5860
private PlanMetadata metadata;
5961

6062
/**
6163
* The schemas for this plan.
6264
*/
6365
@NestedConfigurationProperty
66+
@Valid
6467
private Schemas schemas;
6568

6669
/**

spring-cloud-open-service-broker-autoconfigure/src/main/java/org/springframework/cloud/servicebroker/autoconfigure/web/PlanMetadata.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import java.util.Map;
2323
import java.util.stream.Collectors;
2424

25+
import jakarta.validation.Valid;
26+
2527
import org.springframework.boot.context.properties.NestedConfigurationProperty;
2628
import org.springframework.util.CollectionUtils;
2729

@@ -46,6 +48,7 @@ public class PlanMetadata {
4648
* the user (such as a monthly + usage costs at once).
4749
*/
4850
@NestedConfigurationProperty
51+
@Valid
4952
private final List<Cost> costs = new ArrayList<>();
5053

5154
/**

spring-cloud-open-service-broker-autoconfigure/src/main/java/org/springframework/cloud/servicebroker/autoconfigure/web/Schemas.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.cloud.servicebroker.autoconfigure.web;
1818

19+
import jakarta.validation.Valid;
20+
1921
import org.springframework.boot.context.properties.NestedConfigurationProperty;
2022

2123
/**
@@ -32,12 +34,14 @@ public class Schemas {
3234
* The schemas available on a service instance.
3335
*/
3436
@NestedConfigurationProperty
37+
@Valid
3538
private ServiceInstanceSchema serviceInstance;
3639

3740
/**
3841
* The schemas available on a service binding.
3942
*/
4043
@NestedConfigurationProperty
44+
@Valid
4145
private ServiceBindingSchema serviceBinding;
4246

4347
public ServiceInstanceSchema getServiceInstance() {

spring-cloud-open-service-broker-autoconfigure/src/main/java/org/springframework/cloud/servicebroker/autoconfigure/web/ServiceBindingSchema.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.cloud.servicebroker.autoconfigure.web;
1818

19+
import jakarta.validation.Valid;
20+
1921
import org.springframework.boot.context.properties.NestedConfigurationProperty;
2022

2123
/**
@@ -32,6 +34,7 @@ public class ServiceBindingSchema {
3234
* The JSON schema for configuration parameters when creating a service binding.
3335
*/
3436
@NestedConfigurationProperty
37+
@Valid
3538
private MethodSchema create;
3639

3740
public MethodSchema getCreate() {

spring-cloud-open-service-broker-autoconfigure/src/main/java/org/springframework/cloud/servicebroker/autoconfigure/web/ServiceBrokerProperties.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.cloud.servicebroker.autoconfigure.web;
1818

19+
import jakarta.validation.Valid;
20+
1921
import org.springframework.boot.context.properties.ConfigurationProperties;
2022
import org.springframework.boot.context.properties.NestedConfigurationProperty;
2123
import org.springframework.validation.annotation.Validated;
@@ -32,6 +34,7 @@ public class ServiceBrokerProperties {
3234
private String apiVersion;
3335

3436
@NestedConfigurationProperty
37+
@Valid
3538
private Catalog catalog;
3639

3740
public String getApiVersion() {

spring-cloud-open-service-broker-autoconfigure/src/main/java/org/springframework/cloud/servicebroker/autoconfigure/web/ServiceDefinition.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.List;
2121
import java.util.stream.Collectors;
2222

23+
import jakarta.validation.Valid;
2324
import jakarta.validation.constraints.NotEmpty;
2425

2526
import org.springframework.boot.context.properties.NestedConfigurationProperty;
@@ -91,6 +92,7 @@ public class ServiceDefinition {
9192
* A map of metadata to further describe a service offering.
9293
*/
9394
@NestedConfigurationProperty
95+
@Valid
9496
private ServiceMetadata metadata;
9597

9698
/**
@@ -106,13 +108,15 @@ public class ServiceDefinition {
106108
* Data necessary to activate the Dashboard SSO feature for this service.
107109
*/
108110
@NestedConfigurationProperty
111+
@Valid
109112
private DashboardClient dashboardClient;
110113

111114
/**
112115
* A list of plans for this service.
113116
*/
114117
@NestedConfigurationProperty
115118
@NotEmpty
119+
@Valid
116120
private final List<Plan> plans = new ArrayList<>();
117121

118122
public String getId() {

spring-cloud-open-service-broker-autoconfigure/src/main/java/org/springframework/cloud/servicebroker/autoconfigure/web/ServiceInstanceSchema.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.cloud.servicebroker.autoconfigure.web;
1818

19+
import jakarta.validation.Valid;
20+
1921
import org.springframework.boot.context.properties.NestedConfigurationProperty;
2022

2123
/**
@@ -32,12 +34,14 @@ public class ServiceInstanceSchema {
3234
* The JSON schema for configuration parameters when creating a service instance.
3335
*/
3436
@NestedConfigurationProperty
37+
@Valid
3538
private MethodSchema create;
3639

3740
/**
3841
* The JSON schema for configuration parameters when updating a service instance.
3942
*/
4043
@NestedConfigurationProperty
44+
@Valid
4145
private MethodSchema update;
4246

4347
public MethodSchema getCreate() {

0 commit comments

Comments
 (0)