Skip to content

Commit a0fcbc3

Browse files
committed
chore: resolve some maintainer notes with breaking changes
1 parent d942af3 commit a0fcbc3

File tree

47 files changed

+264
-244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+264
-244
lines changed

springwolf-add-ons/springwolf-json-schema/src/test/java/io/github/springwolf/addons/json_schema/JsonSchemaCustomizerTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.junit.jupiter.api.Test;
1111

1212
import java.util.Map;
13+
import java.util.Set;
1314

1415
import static org.assertj.core.api.Assertions.assertThat;
1516
import static org.mockito.ArgumentMatchers.any;
@@ -44,7 +45,7 @@ void shouldAddJsonSchemaExtensionTest() throws Exception {
4445
// given
4546
AsyncAPI asyncAPI = createAsyncApi();
4647
SchemaObject schemaObject = new SchemaObject();
47-
schemaObject.setType(SchemaType.OBJECT);
48+
schemaObject.setType(Set.of(SchemaType.OBJECT));
4849
asyncAPI.getComponents().setSchemas(Map.of("schema", ComponentSchema.of(schemaObject)));
4950

5051
when(jsonSchemaGenerator.fromSchema(any(), any())).thenReturn("mock-string");

springwolf-add-ons/springwolf-json-schema/src/test/java/io/github/springwolf/addons/json_schema/JsonSchemaGeneratorTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.math.BigDecimal;
2929
import java.util.List;
3030
import java.util.Map;
31+
import java.util.Set;
3132
import java.util.TreeMap;
3233
import java.util.function.Supplier;
3334
import java.util.stream.Stream;
@@ -54,14 +55,14 @@ void validateJsonSchemaTest(String expectedJsonSchema, Supplier<Schema<?>> async
5455

5556
// ref cycle ping -> pingField -> pong -> pongField -> ping (repeat)
5657
SchemaObject pingSchema = new SchemaObject();
57-
pingSchema.setType(SchemaType.OBJECT);
58+
pingSchema.setType(Set.of(SchemaType.OBJECT));
5859
pingSchema.setProperties(Map.of("pingfield", ComponentSchema.of(SchemaReference.toSchema("PongSchema"))));
5960
SchemaObject pongSchema = new SchemaObject();
60-
pongSchema.setType(SchemaType.OBJECT);
61+
pongSchema.setType(Set.of(SchemaType.OBJECT));
6162
pongSchema.setProperties(Map.of("pongField", ComponentSchema.of(SchemaReference.toSchema("PingSchema"))));
6263

6364
SchemaObject stringSchema = new SchemaObject();
64-
stringSchema.setType(SchemaType.STRING);
65+
stringSchema.setType(Set.of(SchemaType.STRING));
6566

6667
Map<String, ComponentSchema> definitions = Map.of(
6768
"StringRef",

springwolf-asyncapi/src/main/java/io/github/springwolf/asyncapi/v3/model/components/ComponentSchema.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import lombok.ToString;
1313

1414
/**
15-
* Container class representing a schema in the 'components' block of an AsnycApi document. Contains either
15+
* Container class representing a schema in the 'components' block of an AsyncAPI document. Contains either
1616
* <ul>
1717
* <li>a {@link SchemaObject} instance, which represents an schema formatted with the default asyncapi schema format</li>
1818
* <li>a {@link SchemaReference}} instance, pointing to an other schema </li>

springwolf-asyncapi/src/main/java/io/github/springwolf/asyncapi/v3/model/schema/SchemaObject.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -142,30 +142,4 @@ public class SchemaObject extends ExtendableObject implements Schema {
142142

143143
@JsonProperty(value = "maxItems")
144144
private Integer maxItems;
145-
146-
public void setType(String type) {
147-
// maintainer note: review with OpenAPI 3.1
148-
this.type = Set.of(type);
149-
}
150-
151-
public void setTypes(Set<String> types) {
152-
// maintainer note: review with OpenAPI 3.1
153-
this.type = types;
154-
}
155-
156-
public static class SchemaObjectBuilder {
157-
// maintainer note: remove custom builder in next major release and use Lomboks provided version
158-
159-
public SchemaObjectBuilder type(Set<String> type) {
160-
this.type = type;
161-
return this;
162-
}
163-
164-
public SchemaObjectBuilder type(String type) {
165-
if (type != null) {
166-
this.type = Set.of(type);
167-
}
168-
return this;
169-
}
170-
}
171145
}

springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/bindings/kafka/KafkaBindingTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import java.util.List;
1717
import java.util.Map;
18+
import java.util.Set;
1819

1920
import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
2021

@@ -52,11 +53,11 @@ void shouldSerializeKafkaOperationBinding() throws Exception {
5253
"kafka",
5354
KafkaOperationBinding.builder()
5455
.groupId(SchemaObject.builder()
55-
.type(SchemaType.STRING)
56+
.type(Set.of(SchemaType.STRING))
5657
.enumValues(List.of("myGroupId"))
5758
.build())
5859
.clientId(SchemaObject.builder()
59-
.type(SchemaType.STRING)
60+
.type(Set.of(SchemaType.STRING))
6061
.enumValues(List.of("myClientId"))
6162
.build())
6263
.build()))
@@ -140,7 +141,7 @@ void shouldSerializeKafkaMessage() throws Exception {
140141
KafkaMessageBinding.builder()
141142
.key(
142143
SchemaObject.builder()
143-
.type(SchemaType.STRING)
144+
.type(Set.of(SchemaType.STRING))
144145
.enumValues(List.of("myKey"))
145146
.build())
146147
.schemaIdLocation("payload")

springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/bindings/mqtt/MQTTBindingTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import java.math.BigDecimal;
1313
import java.util.Map;
14+
import java.util.Set;
1415

1516
import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
1617

@@ -58,12 +59,12 @@ void shouldSerializeMQTTServerExample2() throws Exception {
5859
"mqtt",
5960
MQTTServerBinding.builder()
6061
.sessionExpiryInterval(SchemaObject.builder()
61-
.type(SchemaType.INTEGER)
62+
.type(Set.of(SchemaType.INTEGER))
6263
.minimum(new BigDecimal("30"))
6364
.maximum(new BigDecimal("1200"))
6465
.build())
6566
.maximumPacketSize(SchemaObject.builder()
66-
.type(SchemaType.INTEGER)
67+
.type(Set.of(SchemaType.INTEGER))
6768
.minimum(new BigDecimal("256"))
6869
.build())
6970
.build()))

springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/jackson/DefaultAsyncApiSerializerServiceIntegrationTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import java.nio.charset.StandardCharsets;
3838
import java.util.List;
3939
import java.util.Map;
40+
import java.util.Set;
4041
import java.util.stream.Stream;
4142

4243
import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
@@ -80,15 +81,15 @@ private AsyncAPI getAsyncAPITestObject(SchemaFormat schemaFormat) {
8081
KafkaMessageBinding.builder()
8182
// FIXME: We should have a SchemaString (Schema<String>)
8283
.key(SchemaObject.builder()
83-
.type(SchemaType.STRING)
84+
.type(Set.of(SchemaType.STRING))
8485
.build())
8586
.build()))
8687
.build();
8788
Map<String, Message> messages = Map.of(message.getMessageId(), message);
8889

8990
SchemaObject groupId = new SchemaObject();
9091
groupId.setEnumValues(List.of("myGroupId"));
91-
groupId.setType(SchemaType.STRING);
92+
groupId.setType(Set.of(SchemaType.STRING));
9293

9394
OperationBinding operationBinding =
9495
KafkaOperationBinding.builder().groupId(groupId).build();
@@ -128,9 +129,9 @@ private Map<String, ComponentSchema> createPayloadSchema(SchemaFormat schemaForm
128129
switch (schemaFormat) {
129130
case DEFAULT: {
130131
SchemaObject examplePayloadSchema = new SchemaObject();
131-
examplePayloadSchema.setType(SchemaType.OBJECT);
132+
examplePayloadSchema.setType(Set.of(SchemaType.OBJECT));
132133
SchemaObject stringSchema = new SchemaObject();
133-
stringSchema.setType(SchemaType.STRING);
134+
stringSchema.setType(Set.of(SchemaType.STRING));
134135
examplePayloadSchema.setProperties(Map.of("s", stringSchema));
135136
return Map.of("ExamplePayload", ComponentSchema.of(examplePayloadSchema));
136137
}

springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/model/AsyncAPITest.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.math.BigDecimal;
3131
import java.util.List;
3232
import java.util.Map;
33+
import java.util.Set;
3334

3435
import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
3536

@@ -41,16 +42,16 @@ void shouldCreateSimpleAsyncAPI() throws Exception {
4142
var userSignUpMessage = MessageObject.builder()
4243
.messageId("UserSignedUp")
4344
.payload(MessagePayload.of(SchemaObject.builder()
44-
.type(SchemaType.OBJECT)
45+
.type(Set.of(SchemaType.OBJECT))
4546
.properties(Map.of(
4647
"displayName",
4748
SchemaObject.builder()
48-
.type(SchemaType.STRING)
49+
.type(Set.of(SchemaType.STRING))
4950
.description("Name of the user")
5051
.build(),
5152
"email",
5253
SchemaObject.builder()
53-
.type(SchemaType.STRING)
54+
.type(Set.of(SchemaType.STRING))
5455
.format("email")
5556
.description("Email of the user")
5657
.build()))
@@ -285,11 +286,11 @@ void shouldCreateStreetlightsKafkaAsyncAPI() throws Exception {
285286
.schemas(Map.of(
286287
"lightMeasuredPayload",
287288
ComponentSchema.of(SchemaObject.builder()
288-
.type(SchemaType.OBJECT)
289+
.type(Set.of(SchemaType.OBJECT))
289290
.properties(Map.of(
290291
"lumens",
291292
SchemaObject.builder()
292-
.type(SchemaType.INTEGER)
293+
.type(Set.of(SchemaType.INTEGER))
293294
.minimum(BigDecimal.ZERO)
294295
.description("Light intensity measured in lumens.")
295296
.build(),
@@ -298,11 +299,11 @@ void shouldCreateStreetlightsKafkaAsyncAPI() throws Exception {
298299
.build()),
299300
"turnOnOffPayload",
300301
ComponentSchema.of(SchemaObject.builder()
301-
.type(SchemaType.OBJECT)
302+
.type(Set.of(SchemaType.OBJECT))
302303
.properties(Map.of(
303304
"command",
304305
SchemaObject.builder()
305-
.type(SchemaType.STRING)
306+
.type(Set.of(SchemaType.STRING))
306307
.enumValues(List.of("on", "off"))
307308
.description("Whether to turn on or off the light.")
308309
.build(),
@@ -311,11 +312,11 @@ void shouldCreateStreetlightsKafkaAsyncAPI() throws Exception {
311312
.build()),
312313
"dimLightPayload",
313314
ComponentSchema.of(SchemaObject.builder()
314-
.type(SchemaType.OBJECT)
315+
.type(Set.of(SchemaType.OBJECT))
315316
.properties(Map.of(
316317
"percentage",
317318
SchemaObject.builder()
318-
.type(SchemaType.INTEGER)
319+
.type(Set.of(SchemaType.INTEGER))
319320
.description(
320321
"Percentage to which the light should be dimmed to.")
321322
.minimum(BigDecimal.ZERO)
@@ -326,7 +327,7 @@ void shouldCreateStreetlightsKafkaAsyncAPI() throws Exception {
326327
.build()),
327328
"sentAt",
328329
ComponentSchema.of(SchemaObject.builder()
329-
.type(SchemaType.STRING)
330+
.type(Set.of(SchemaType.STRING))
330331
.format("date-time")
331332
.description("Date and time when the message was sent.")
332333
.build())))
@@ -350,11 +351,11 @@ void shouldCreateStreetlightsKafkaAsyncAPI() throws Exception {
350351
"commonHeaders",
351352
MessageTrait.builder()
352353
.headers(MessageHeaders.of(SchemaObject.builder()
353-
.type(SchemaType.OBJECT)
354+
.type(Set.of(SchemaType.OBJECT))
354355
.properties(Map.of(
355356
"my-app-header",
356357
SchemaObject.builder()
357-
.type(SchemaType.INTEGER)
358+
.type(Set.of(SchemaType.INTEGER))
358359
.minimum(BigDecimal.ZERO)
359360
.maximum(new BigDecimal("100"))
360361
.build()))
@@ -367,7 +368,7 @@ void shouldCreateStreetlightsKafkaAsyncAPI() throws Exception {
367368
"kafka",
368369
KafkaOperationBinding.builder()
369370
.clientId(SchemaObject.builder()
370-
.type(SchemaType.STRING)
371+
.type(Set.of(SchemaType.STRING))
371372
.enumValues(List.of("my-app-id"))
372373
.build())
373374
.build()))

springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/model/channel/MessageTest.java

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

1717
import java.util.List;
1818
import java.util.Map;
19+
import java.util.Set;
1920

2021
import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
2122

@@ -35,22 +36,22 @@ void shouldSerializeMessage() throws Exception {
3536
Tag.builder().name("signup").build(),
3637
Tag.builder().name("register").build()))
3738
.headers(MessageHeaders.of(SchemaObject.builder()
38-
.type(SchemaType.OBJECT)
39+
.type(Set.of(SchemaType.OBJECT))
3940
.properties(Map.of(
4041
"correlationId",
4142
SchemaObject.builder()
4243
.description("Correlation ID set by application")
43-
.type(SchemaType.STRING)
44+
.type(Set.of(SchemaType.STRING))
4445
.build(),
4546
"applicationInstanceId",
4647
SchemaObject.builder()
4748
.description(
4849
"Unique identifier for a given instance of the publishing application")
49-
.type(SchemaType.STRING)
50+
.type(Set.of(SchemaType.STRING))
5051
.build()))
5152
.build()))
5253
.payload(MessagePayload.of(SchemaObject.builder()
53-
.type(SchemaType.OBJECT)
54+
.type(Set.of(SchemaType.OBJECT))
5455
.properties(Map.of(
5556
"user", SchemaReference.toSchema("userCreate"),
5657
"signup", SchemaReference.toSchema("signup")))

0 commit comments

Comments
 (0)