diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 55853a0b5..a62f9155a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -20,7 +20,7 @@ org-testcontainers = "1.21.4" owasp-dependencycheck = "12.1.9" protobuf = "4.33.2" protobuf-plugin = "0.9.6" -spotless = "8.0.0" +spotless = "8.1.0" spring-boot-plugin = "4.0.1" spring-cloud = "2025.1.0" # not managed by spring-boot-dependencies spring-cloud-stream = "5.0.0" # not managed by spring-boot-dependencies diff --git a/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/bindings/googlepubsub/GooglePubSubBindingTest.java b/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/bindings/googlepubsub/GooglePubSubBindingTest.java index 7dc1233ae..4752af3b3 100644 --- a/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/bindings/googlepubsub/GooglePubSubBindingTest.java +++ b/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/bindings/googlepubsub/GooglePubSubBindingTest.java @@ -59,8 +59,7 @@ void shouldSerializeGooglePubSubMessage() throws Exception { .name("MessageProto") .payload(MessagePayload.of(MultiFormatSchema.builder() .schemaFormat("application/vnd.google.protobuf;version=3") - .schema( - """ + .schema(""" syntax = "proto3"; message Message { diff --git a/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/model/schema/SchemaTest.java b/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/model/schema/SchemaTest.java index 7f71bc45f..2243fe60a 100644 --- a/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/model/schema/SchemaTest.java +++ b/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/model/schema/SchemaTest.java @@ -19,8 +19,7 @@ void shouldSerializePrimitiveSample() throws Exception { var schema = SchemaObject.builder().type(SchemaType.STRING).format("email").build(); - String example = - """ + String example = """ { "type": "string", "format": "email" @@ -45,8 +44,7 @@ void shouldSerializeSimpleModel() throws Exception { .build())) .build(); - String example = - """ + String example = """ { "type": "object", "required": [ @@ -78,8 +76,7 @@ void shouldSerializeStringToStringMapping() throws Exception { SchemaObject.builder().type(SchemaType.STRING).build())) .build(); - var example = - """ + var example = """ { "type": "object", "additionalProperties": { @@ -97,8 +94,7 @@ void shouldSerializeModelMapping() throws Exception { .additionalProperties(ComponentSchema.of(SchemaReference.toSchema("ComplexModel"))) .build(); - var example = - """ + var example = """ { "type": "object", "additionalProperties": { @@ -124,8 +120,7 @@ void shouldSerializeModelWithExample() throws Exception { .examples(List.of(Map.of("name", "Puma", "id", 1))) .build(); - var example = - """ + var example = """ { "type": "object", "properties": { @@ -161,8 +156,7 @@ void shouldSerializeModelWithBooleans() throws Exception { .required(List.of("anySchema")) .build(); - var example = - """ + var example = """ { "type": "object", "required": [ @@ -213,8 +207,7 @@ void shouldSerializeModelsWithComposition() throws Exception { .build()))) .build())); - var example = - """ + var example = """ { "schemas": { "ErrorModel": { @@ -340,8 +333,7 @@ void shouldSerializeModelsWithPolimorphismSupport() throws Exception { .required(List.of("color")) .build()))) .build())); - var example = - """ + var example = """ { "schemas": { "Pet": { diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadSchemaObject.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadSchemaObject.java index d4fbaa4d4..7ff0ba355 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadSchemaObject.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadSchemaObject.java @@ -12,7 +12,8 @@ * @param simpleSchemaName * @param schema The SchemaObject. */ -public record PayloadSchemaObject(String name, String simpleSchemaName, @Nullable ComponentSchema schema) { +public record PayloadSchemaObject( + String name, String simpleSchemaName, @Nullable ComponentSchema schema) { public String title() { return (simpleSchemaName() != null) ? simpleSchemaName() : name(); } diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaMapper.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaMapper.java index bfbb93168..2d21b7876 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaMapper.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaMapper.java @@ -66,8 +66,8 @@ public ComponentSchema mapSchema(Schema swaggerSchema) { PayloadSchemaFormat payloadSchemaFormat = springwolfConfigProperties.getDocket().getPayloadSchemaFormat(); return switch (payloadSchemaFormat) { - case OPENAPI_V3, OPENAPI_V3_1 -> ComponentSchema.of( - new MultiFormatSchema(payloadSchemaFormat.getSchemaFormat().value, swaggerSchema)); + case OPENAPI_V3, OPENAPI_V3_1 -> + ComponentSchema.of(new MultiFormatSchema(payloadSchemaFormat.getSchemaFormat().value, swaggerSchema)); case ASYNCAPI_V3 -> ComponentSchema.of(mapSwaggerSchemaToAsyncApiSchema(swaggerSchema)); }; } diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/DefaultComponentsServiceTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/DefaultComponentsServiceTest.java index 2445fe110..e8e886ac6 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/DefaultComponentsServiceTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/DefaultComponentsServiceTest.java @@ -37,8 +37,7 @@ void getMessages() throws Exception { String actualDefinitions = jsonMapper.writerWithDefaultPrettyPrinter().writeValueAsString(componentsService.getMessages()); - String expected = - """ + String expected = """ { "messageName1" : { "name" : "messageName1" @@ -46,8 +45,7 @@ void getMessages() throws Exception { "messageName2" : { "name" : "messageName2" } - }""" - .stripIndent(); + }""".stripIndent(); System.out.println("Got: " + actualDefinitions); assertThat(actualDefinitions).isEqualTo(expected); diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/DefaultJsonComponentsServiceIntegrationTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/DefaultJsonComponentsServiceIntegrationTest.java index da2990b25..d4324ae59 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/DefaultJsonComponentsServiceIntegrationTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/DefaultJsonComponentsServiceIntegrationTest.java @@ -323,7 +323,8 @@ void getJsonTypeDefinitions() throws Exception { @Schema(description = "Json Type Info Payload Dto model") public record JsonTypeInfoPayloadDto( - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED) JsonTypeInfoInterface jsonTypeInfoInterface) {} + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED) + JsonTypeInfoInterface jsonTypeInfoInterface) {} @JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION, property = "type") @JsonSubTypes({ @@ -337,20 +338,20 @@ public interface JsonTypeInfoInterface {} @Schema(description = "Json Type Info Example Two model") public record JsonTypeInfoExampleTwo( @Schema( - description = "Boo field", - example = "booValue", - requiredMode = Schema.RequiredMode.NOT_REQUIRED) - String boo) + description = "Boo field", + example = "booValue", + requiredMode = Schema.RequiredMode.NOT_REQUIRED) + String boo) implements JsonTypeInfoInterface {} @JsonTypeName("exampleOne") @Schema(description = "Json Type Info Example One model") public record JsonTypeInfoExampleOne( @Schema( - description = "Foo field", - example = "fooValue", - requiredMode = Schema.RequiredMode.NOT_REQUIRED) - String foo) + description = "Foo field", + example = "fooValue", + requiredMode = Schema.RequiredMode.NOT_REQUIRED) + String foo) implements JsonTypeInfoInterface {} } } diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/DefaultYamlComponentsServiceIntegrationTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/DefaultYamlComponentsServiceIntegrationTest.java index 54241316a..acdcd2fac 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/DefaultYamlComponentsServiceIntegrationTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/DefaultYamlComponentsServiceIntegrationTest.java @@ -329,7 +329,7 @@ void getJsonTypeDefinitions() throws Exception { @Schema(description = "Json Type Info Payload Dto model") public record JsonTypeInfoPayloadDto( @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED) - JsonTypeTest.JsonTypeInfoInterface jsonTypeInfoInterface) {} + JsonTypeTest.JsonTypeInfoInterface jsonTypeInfoInterface) {} @JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION, property = "type") @JsonSubTypes({ @@ -343,20 +343,20 @@ public interface JsonTypeInfoInterface {} @Schema(description = "Json Type Info Example Two model") public record JsonTypeInfoExampleTwo( @Schema( - description = "Boo field", - example = "booValue", - requiredMode = Schema.RequiredMode.NOT_REQUIRED) - String boo) + description = "Boo field", + example = "booValue", + requiredMode = Schema.RequiredMode.NOT_REQUIRED) + String boo) implements JsonTypeInfoInterface {} @JsonTypeName("exampleOne") @Schema(description = "Json Type Info Example One model") public record JsonTypeInfoExampleOne( @Schema( - description = "Foo field", - example = "fooValue", - requiredMode = Schema.RequiredMode.NOT_REQUIRED) - String foo) + description = "Foo field", + example = "fooValue", + requiredMode = Schema.RequiredMode.NOT_REQUIRED) + String foo) implements JsonTypeInfoInterface {} } } diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/examples/walkers/DefaultSchemaWalkerYamlIntegrationTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/examples/walkers/DefaultSchemaWalkerYamlIntegrationTest.java index db913fa2c..f65509d15 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/examples/walkers/DefaultSchemaWalkerYamlIntegrationTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/examples/walkers/DefaultSchemaWalkerYamlIntegrationTest.java @@ -304,9 +304,7 @@ void type_string_format_binary(TestInfo testInfo) { String actualString = jsonSchemaWalker.fromSchema(schema, emptyMap()); - assertThat(actualString) - .isEqualTo( - """ + assertThat(actualString).isEqualTo(""" "0111010001100101011100110111010000101101011000100110100101101110011000010110010001111001" """); } @@ -330,8 +328,7 @@ void type_string_format_datetime(TestInfo testInfo) { String actualString = jsonSchemaWalker.fromSchema(schema, emptyMap()); - assertThat(actualString) - .isEqualTo(""" + assertThat(actualString).isEqualTo(""" 2015-07-20T15:49:04-07:00 """); } @@ -367,8 +364,7 @@ void type_string_format_uuid(TestInfo testInfo) { String actualString = jsonSchemaWalker.fromSchema(schema, emptyMap()); - assertThat(actualString) - .isEqualTo(""" + assertThat(actualString).isEqualTo(""" 3fa85f64-5717-4562-b3fc-2c963f66afa6 """); } @@ -381,8 +377,7 @@ void type_string_format_unknown(TestInfo testInfo) { String actualString = jsonSchemaWalker.fromSchema(schema, emptyMap()); - assertThat(actualString) - .isEqualTo(""" + assertThat(actualString).isEqualTo(""" "unknown string schema format: unknown" """); } @@ -400,8 +395,7 @@ class TestSchema extends Schema { String actualString = jsonSchemaWalker.fromSchema(schema, emptyMap()); - assertThat(actualString) - .isEqualTo(""" + assertThat(actualString).isEqualTo(""" "unknown schema type: test-schema" """); } @@ -434,9 +428,7 @@ void type_object_array(TestInfo testInfo) { String actualString = jsonSchemaWalker.fromSchema(schema, emptyMap()); - assertThat(actualString) - .isEqualTo( - """ + assertThat(actualString).isEqualTo(""" - b: true s: string """); @@ -451,8 +443,7 @@ void composite_object_without_references(TestInfo testInfo) { String actualString = jsonSchemaWalker.fromSchema(schema, emptyMap()); - assertThat(actualString) - .isEqualTo(""" + assertThat(actualString).isEqualTo(""" b: true s: string """); @@ -473,9 +464,7 @@ void composite_object_with_references(TestInfo testInfo) { nestedSchema.addProperty("b", new BooleanSchema()); String actualString = jsonSchemaWalker.fromSchema(compositeSchema, Map.of("Nested", nestedSchema)); - assertThat(actualString) - .isEqualTo( - """ + assertThat(actualString).isEqualTo(""" f: b: true s: string @@ -532,9 +521,7 @@ void object_with_allOf(TestInfo testInfo) { String actualString = jsonSchemaWalker.fromSchema(compositeSchema, Map.of("Nested", propertySchema)); - assertThat(actualString) - .isEqualTo( - """ + assertThat(actualString).isEqualTo(""" allOfField: field1: string field2: 1.1 @@ -581,9 +568,7 @@ void schema_with_problematic_object_toString_example(TestInfo testInfo) { String actualString = jsonSchemaWalker.fromSchema(schema, Map.of()); - assertThat(actualString) - .isEqualTo( - """ + assertThat(actualString).isEqualTo(""" Text with special character /\\\\'\\b\\f\\t\\r\\n. """); } diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/utils/TextUtilsTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/utils/TextUtilsTest.java index 491b2c8ca..04fa091fb 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/utils/TextUtilsTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/utils/TextUtilsTest.java @@ -33,8 +33,7 @@ void textWithSingleIndentShouldBeUntouched() { @Test void removeIndent() { - var description = - """ + var description = """ This is a string with two lines """; @@ -54,8 +53,7 @@ void simpleTextWithoutIndentShouldBeUntouched() { @Test void removeEmptyLinesUntilTextIsFound() { - var description = - """ + var description = """ This is a string diff --git a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/dtos/ExamplePayloadDto.java b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/dtos/ExamplePayloadDto.java index e72c6ccfc..9d5af0520 100644 --- a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/dtos/ExamplePayloadDto.java +++ b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/springwolf/examples/kafka/dtos/ExamplePayloadDto.java @@ -9,9 +9,7 @@ import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; -@Schema( - description = - """ +@Schema(description = """ Example payload model demonstrating markdown text styling: **bold**, *cursive* and underlined """) @@ -19,9 +17,7 @@ @AllArgsConstructor @NoArgsConstructor public class ExamplePayloadDto { - @Schema( - description = - """ + @Schema(description = """ ### Some string field with Markdown - **bold** @@ -34,9 +30,7 @@ public class ExamplePayloadDto { "key2":"value2" } ``` - """, - example = "some string value", - requiredMode = REQUIRED) + """, example = "some string value", requiredMode = REQUIRED) private String someString; @Schema(description = "Some long field", example = "5", minimum = "0") diff --git a/springwolf-plugins/springwolf-jms-plugin/src/test/java/io/github/springwolf/plugins/jms/controller/SpringwolfJmsControllerIntegrationTest.java b/springwolf-plugins/springwolf-jms-plugin/src/test/java/io/github/springwolf/plugins/jms/controller/SpringwolfJmsControllerIntegrationTest.java index 6e20c5cfe..7db858066 100644 --- a/springwolf-plugins/springwolf-jms-plugin/src/test/java/io/github/springwolf/plugins/jms/controller/SpringwolfJmsControllerIntegrationTest.java +++ b/springwolf-plugins/springwolf-jms-plugin/src/test/java/io/github/springwolf/plugins/jms/controller/SpringwolfJmsControllerIntegrationTest.java @@ -126,8 +126,7 @@ void controllerShouldReturnNotFoundWhenPublishingIsDisabled() throws Exception { @Test void controllerShouldReturnBadRequestIfPayloadIsEmpty() throws Exception { - String content = - """ + String content = """ { "bindings": null, "headers": null, @@ -143,8 +142,7 @@ void controllerShouldReturnBadRequestIfPayloadIsEmpty() throws Exception { @Test void controllerShouldAcceptIfPayloadIsNotSet() throws Exception { - String content = - """ + String content = """ { "bindings": null, "headers": null @@ -161,8 +159,7 @@ void controllerShouldAcceptIfPayloadIsNotSet() throws Exception { void controllerShouldReturnNotFoundIfNoJmsProducerIsEnabled() throws Exception { when(springwolfJmsProducer.isEnabled()).thenReturn(false); - String content = - """ + String content = """ { "bindings": null, "headers": null, @@ -178,8 +175,7 @@ void controllerShouldReturnNotFoundIfNoJmsProducerIsEnabled() throws Exception { void controllerShouldCallJmsProducerIfOnlyPayloadIsSend() throws Exception { when(springwolfJmsProducer.isEnabled()).thenReturn(true); - String content = - """ + String content = """ { "bindings": null, "headers": null, @@ -202,8 +198,7 @@ void controllerShouldCallJmsProducerIfOnlyPayloadIsSend() throws Exception { void controllerShouldCallJmsProducerIfPayloadAndHeadersAreSend() throws Exception { when(springwolfJmsProducer.isEnabled()).thenReturn(true); - String content = - """ + String content = """ { "bindings": null, "headers": { diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/controller/SpringwolfKafkaControllerIntegrationTest.java b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/controller/SpringwolfKafkaControllerIntegrationTest.java index eb635d9ad..68bb03139 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/controller/SpringwolfKafkaControllerIntegrationTest.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/controller/SpringwolfKafkaControllerIntegrationTest.java @@ -126,8 +126,7 @@ void controllerShouldReturnNotFoundWhenPublishingIsDisabled() throws Exception { @Test void controllerShouldReturnBadRequestIfPayloadIsEmpty() throws Exception { - String content = - """ + String content = """ { "bindings": null, "headers": null, @@ -143,8 +142,7 @@ void controllerShouldReturnBadRequestIfPayloadIsEmpty() throws Exception { @Test void controllerShouldAcceptIfPayloadIsNotSet() throws Exception { - String content = - """ + String content = """ { "bindings": null, "headers": null @@ -161,8 +159,7 @@ void controllerShouldAcceptIfPayloadIsNotSet() throws Exception { void controllerShouldReturnNotFoundIfNoKafkaProducerIsEnabled() throws Exception { when(springwolfKafkaProducer.isEnabled()).thenReturn(false); - String content = - """ + String content = """ { "bindings": null, "headers": null, @@ -178,8 +175,7 @@ void controllerShouldReturnNotFoundIfNoKafkaProducerIsEnabled() throws Exception void controllerShouldCallKafkaProducerIfOnlyPayloadIsSend() throws Exception { when(springwolfKafkaProducer.isEnabled()).thenReturn(true); - String content = - """ + String content = """ { "bindings": null, "headers": null, @@ -202,8 +198,7 @@ void controllerShouldCallKafkaProducerIfOnlyPayloadIsSend() throws Exception { void controllerShouldCallKafkaProducerIfPayloadAndHeadersAreSend() throws Exception { when(springwolfKafkaProducer.isEnabled()).thenReturn(true); - String content = - """ + String content = """ { "bindings": null, "headers": { @@ -231,8 +226,7 @@ void controllerShouldCallKafkaProducerIfPayloadAndHeadersAreSend() throws Except void controllerShouldCallKafkaProducerIfPayloadAndHeadersAndBindingsAreSend() throws Exception { when(springwolfKafkaProducer.isEnabled()).thenReturn(true); - String content = - """ + String content = """ { "bindings": { "key": "kafka-key-value"