diff --git a/springwolf-add-ons/springwolf-json-schema/src/test/java/io/github/springwolf/addons/json_schema/JsonSchemaCustomizerTest.java b/springwolf-add-ons/springwolf-json-schema/src/test/java/io/github/springwolf/addons/json_schema/JsonSchemaCustomizerTest.java index 436a5193d..1d79be7f7 100644 --- a/springwolf-add-ons/springwolf-json-schema/src/test/java/io/github/springwolf/addons/json_schema/JsonSchemaCustomizerTest.java +++ b/springwolf-add-ons/springwolf-json-schema/src/test/java/io/github/springwolf/addons/json_schema/JsonSchemaCustomizerTest.java @@ -5,6 +5,7 @@ import io.github.springwolf.asyncapi.v3.model.AsyncAPI; import io.github.springwolf.asyncapi.v3.model.components.Components; import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject; +import io.github.springwolf.asyncapi.v3.model.schema.SchemaType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -43,7 +44,7 @@ public void shouldAddJsonSchemaExtensionTest() throws JsonProcessingException { // given AsyncAPI asyncAPI = createAsyncApi(); SchemaObject schemaObject = new SchemaObject(); - schemaObject.setType("object"); + schemaObject.setType(SchemaType.OBJECT); asyncAPI.getComponents().setSchemas(Map.of("schema", schemaObject)); when(jsonSchemaGenerator.fromSchema(any(), any())).thenReturn("mock-string"); diff --git a/springwolf-add-ons/springwolf-json-schema/src/test/java/io/github/springwolf/addons/json_schema/JsonSchemaGeneratorTest.java b/springwolf-add-ons/springwolf-json-schema/src/test/java/io/github/springwolf/addons/json_schema/JsonSchemaGeneratorTest.java index ee0de216a..1fc16c49c 100644 --- a/springwolf-add-ons/springwolf-json-schema/src/test/java/io/github/springwolf/addons/json_schema/JsonSchemaGeneratorTest.java +++ b/springwolf-add-ons/springwolf-json-schema/src/test/java/io/github/springwolf/addons/json_schema/JsonSchemaGeneratorTest.java @@ -9,6 +9,7 @@ import io.github.springwolf.asyncapi.v3.model.channel.message.MessageReference; import io.github.springwolf.asyncapi.v3.model.components.ComponentSchema; import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject; +import io.github.springwolf.asyncapi.v3.model.schema.SchemaType; import io.github.springwolf.core.asyncapi.schemas.SwaggerSchemaUtil; import io.swagger.v3.core.util.Json; import io.swagger.v3.oas.models.media.ArraySchema; @@ -50,14 +51,14 @@ public void validateJsonSchemaTest(String expectedJsonSchema, Supplier // ref cycle ping -> pingField -> pong -> pongField -> ping (repeat) SchemaObject pingSchema = new SchemaObject(); - pingSchema.setType("object"); + pingSchema.setType(SchemaType.OBJECT); pingSchema.setProperties(Map.of("pingfield", ComponentSchema.of(MessageReference.toSchema("PongSchema")))); SchemaObject pongSchema = new SchemaObject(); - pongSchema.setType("object"); + pongSchema.setType(SchemaType.OBJECT); pongSchema.setProperties(Map.of("pongField", ComponentSchema.of(MessageReference.toSchema("PingSchema")))); SchemaObject stringSchema = new SchemaObject(); - stringSchema.setType("string"); + stringSchema.setType(SchemaType.STRING); Map definitions = Map.of("StringRef", stringSchema, "PingSchema", pingSchema, "PongSchema", pongSchema); diff --git a/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/bindings/kafka/KafkaBindingTest.java b/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/bindings/kafka/KafkaBindingTest.java index e85f0aa32..5c06747b4 100644 --- a/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/bindings/kafka/KafkaBindingTest.java +++ b/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/bindings/kafka/KafkaBindingTest.java @@ -9,6 +9,7 @@ import io.github.springwolf.asyncapi.v3.model.operation.Operation; import io.github.springwolf.asyncapi.v3.model.operation.OperationAction; import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject; +import io.github.springwolf.asyncapi.v3.model.schema.SchemaType; import io.github.springwolf.asyncapi.v3.model.server.Server; import org.junit.jupiter.api.Test; @@ -52,11 +53,11 @@ void shouldSerializeKafkaOperationBinding() throws IOException { "kafka", KafkaOperationBinding.builder() .groupId(SchemaObject.builder() - .type("string") + .type(SchemaType.STRING) .enumValues(List.of("myGroupId")) .build()) .clientId(SchemaObject.builder() - .type("string") + .type(SchemaType.STRING) .enumValues(List.of("myClientId")) .build()) .build())) @@ -140,7 +141,7 @@ void shouldSerializeKafkaMessage() throws IOException { KafkaMessageBinding.builder() .key( SchemaObject.builder() - .type("string") + .type(SchemaType.STRING) .enumValues(List.of("myKey")) .build()) .schemaIdLocation("payload") diff --git a/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/bindings/mqtt/MQTTBindingTest.java b/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/bindings/mqtt/MQTTBindingTest.java index a1751aa87..0f35cfe98 100644 --- a/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/bindings/mqtt/MQTTBindingTest.java +++ b/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/bindings/mqtt/MQTTBindingTest.java @@ -5,6 +5,7 @@ import io.github.springwolf.asyncapi.v3.jackson.DefaultAsyncApiSerializerService; import io.github.springwolf.asyncapi.v3.model.AsyncAPI; import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject; +import io.github.springwolf.asyncapi.v3.model.schema.SchemaType; import io.github.springwolf.asyncapi.v3.model.server.Server; import org.junit.jupiter.api.Test; @@ -58,12 +59,12 @@ void shouldSerializeMQTTServerExample2() throws IOException { "mqtt", MQTTServerBinding.builder() .sessionExpiryInterval(SchemaObject.builder() - .type("integer") + .type(SchemaType.INTEGER) .minimum(new BigDecimal("30")) .maximum(new BigDecimal("1200")) .build()) .maximumPacketSize(SchemaObject.builder() - .type("integer") + .type(SchemaType.INTEGER) .minimum(new BigDecimal("256")) .build()) .build())) diff --git a/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/jackson/DefaultAsyncApiSerializerServiceIntegrationTest.java b/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/jackson/DefaultAsyncApiSerializerServiceIntegrationTest.java index d0266aeb0..0dd549cd5 100644 --- a/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/jackson/DefaultAsyncApiSerializerServiceIntegrationTest.java +++ b/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/jackson/DefaultAsyncApiSerializerServiceIntegrationTest.java @@ -71,7 +71,9 @@ private AsyncAPI getAsyncAPITestObject() { "kafka", KafkaMessageBinding.builder() // FIXME: We should have a SchemaString (Schema) - .key(SchemaObject.builder().type("string").build()) + .key(SchemaObject.builder() + .type(SchemaType.STRING) + .build()) .build())) .build(); Map messages = Map.of(message.getMessageId(), message); @@ -100,9 +102,9 @@ private AsyncAPI getAsyncAPITestObject() { .build(); SchemaObject examplePayloadSchema = new SchemaObject(); - examplePayloadSchema.setType("object"); + examplePayloadSchema.setType(SchemaType.OBJECT); SchemaObject stringSchema = new SchemaObject(); - stringSchema.setType("string"); + stringSchema.setType(SchemaType.STRING); examplePayloadSchema.setProperties(Map.of("s", stringSchema)); Map schemas = Map.of("ExamplePayload", examplePayloadSchema); diff --git a/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/model/AsyncAPITest.java b/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/model/AsyncAPITest.java index de1352a62..2cd6dbc04 100644 --- a/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/model/AsyncAPITest.java +++ b/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/model/AsyncAPITest.java @@ -20,6 +20,7 @@ import io.github.springwolf.asyncapi.v3.model.operation.OperationTraits; import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject; import io.github.springwolf.asyncapi.v3.model.schema.SchemaReference; +import io.github.springwolf.asyncapi.v3.model.schema.SchemaType; import io.github.springwolf.asyncapi.v3.model.security_scheme.SecurityScheme; import io.github.springwolf.asyncapi.v3.model.security_scheme.SecurityType; import io.github.springwolf.asyncapi.v3.model.server.Server; @@ -40,16 +41,16 @@ void shouldCreateSimpleAsyncAPI() throws IOException { var userSignUpMessage = MessageObject.builder() .messageId("UserSignedUp") .payload(MessagePayload.of(SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .properties(Map.of( "displayName", SchemaObject.builder() - .type("string") + .type(SchemaType.STRING) .description("Name of the user") .build(), "email", SchemaObject.builder() - .type("string") + .type(SchemaType.STRING) .format("email") .description("Email of the user") .build())) @@ -284,11 +285,11 @@ void shouldCreateStreetlightsKafkaAsyncAPI() throws IOException { .schemas(Map.of( "lightMeasuredPayload", SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .properties(Map.of( "lumens", SchemaObject.builder() - .type("integer") + .type(SchemaType.INTEGER) .minimum(BigDecimal.ZERO) .description("Light intensity measured in lumens.") .build(), @@ -297,11 +298,11 @@ void shouldCreateStreetlightsKafkaAsyncAPI() throws IOException { .build(), "turnOnOffPayload", SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .properties(Map.of( "command", SchemaObject.builder() - .type("string") + .type(SchemaType.STRING) .enumValues(List.of("on", "off")) .description("Whether to turn on or off the light.") .build(), @@ -310,11 +311,11 @@ void shouldCreateStreetlightsKafkaAsyncAPI() throws IOException { .build(), "dimLightPayload", SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .properties(Map.of( "percentage", SchemaObject.builder() - .type("integer") + .type(SchemaType.INTEGER) .description( "Percentage to which the light should be dimmed to.") .minimum(BigDecimal.ZERO) @@ -325,7 +326,7 @@ void shouldCreateStreetlightsKafkaAsyncAPI() throws IOException { .build(), "sentAt", SchemaObject.builder() - .type("string") + .type(SchemaType.STRING) .format("date-time") .description("Date and time when the message was sent.") .build())) @@ -349,11 +350,11 @@ void shouldCreateStreetlightsKafkaAsyncAPI() throws IOException { "commonHeaders", MessageTrait.builder() .headers(MessageHeaders.of(SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .properties(Map.of( "my-app-header", SchemaObject.builder() - .type("integer") + .type(SchemaType.INTEGER) .minimum(BigDecimal.ZERO) .maximum(new BigDecimal("100")) .build())) @@ -366,7 +367,7 @@ void shouldCreateStreetlightsKafkaAsyncAPI() throws IOException { "kafka", KafkaOperationBinding.builder() .clientId(SchemaObject.builder() - .type("string") + .type(SchemaType.STRING) .enumValues(List.of("my-app-id")) .build()) .build())) diff --git a/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/model/channel/MessageTest.java b/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/model/channel/MessageTest.java index 1d990ef1f..08cdb36c7 100644 --- a/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/model/channel/MessageTest.java +++ b/springwolf-asyncapi/src/test/java/io/github/springwolf/asyncapi/v3/model/channel/MessageTest.java @@ -11,6 +11,7 @@ import io.github.springwolf.asyncapi.v3.model.channel.message.MessageTrait; import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject; import io.github.springwolf.asyncapi.v3.model.schema.SchemaReference; +import io.github.springwolf.asyncapi.v3.model.schema.SchemaType; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -35,22 +36,22 @@ void shouldSerializeMessage() throws IOException { Tag.builder().name("signup").build(), Tag.builder().name("register").build())) .headers(MessageHeaders.of(SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .properties(Map.of( "correlationId", SchemaObject.builder() .description("Correlation ID set by application") - .type("string") + .type(SchemaType.STRING) .build(), "applicationInstanceId", SchemaObject.builder() .description( "Unique identifier for a given instance of the publishing application") - .type("string") + .type(SchemaType.STRING) .build())) .build())) .payload(MessagePayload.of(SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .properties(Map.of( "user", SchemaReference.fromSchema("userCreate"), "signup", SchemaReference.fromSchema("signup"))) 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 11823cb52..b2f3ca6d2 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 @@ -18,7 +18,8 @@ class SchemaTest { @Test void shouldSerializePrimitiveSample() throws JsonProcessingException { - var schema = SchemaObject.builder().type("string").format("email").build(); + var schema = + SchemaObject.builder().type(SchemaType.STRING).format("email").build(); String example = """ @@ -33,14 +34,14 @@ void shouldSerializePrimitiveSample() throws JsonProcessingException { @Test void shouldSerializeSimpleModel() throws JsonProcessingException { var schema = SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .required(List.of("name")) .properties(Map.of( - "name", SchemaObject.builder().type("string").build(), + "name", SchemaObject.builder().type(SchemaType.STRING).build(), "address", SchemaReference.fromSchema("Address"), "age", SchemaObject.builder() - .type("integer") + .type(SchemaType.INTEGER) .format("int32") .minimum(BigDecimal.ZERO) .build())) @@ -74,9 +75,9 @@ void shouldSerializeSimpleModel() throws JsonProcessingException { @Test void shouldSerializeStringToStringMapping() throws JsonProcessingException { var schema = SchemaObject.builder() - .type("object") - .additionalProperties( - ComponentSchema.of(SchemaObject.builder().type("string").build())) + .type(SchemaType.OBJECT) + .additionalProperties(ComponentSchema.of( + SchemaObject.builder().type(SchemaType.STRING).build())) .build(); var example = @@ -94,7 +95,7 @@ void shouldSerializeStringToStringMapping() throws JsonProcessingException { @Test void shouldSerializeModelMapping() throws JsonProcessingException { var schema = SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .additionalProperties(ComponentSchema.of(MessageReference.toSchema("ComplexModel"))) .build(); @@ -113,14 +114,14 @@ void shouldSerializeModelMapping() throws JsonProcessingException { @Test void shouldSerializeModelWithExample() throws JsonProcessingException { var schema = SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .properties(Map.of( "id", SchemaObject.builder() - .type("integer") + .type(SchemaType.INTEGER) .format("int64") .build(), - "name", SchemaObject.builder().type("string").build())) + "name", SchemaObject.builder().type(SchemaType.STRING).build())) .required(List.of("name")) .examples(List.of(Map.of("name", "Puma", "id", 1))) .build(); @@ -155,7 +156,7 @@ void shouldSerializeModelWithExample() throws JsonProcessingException { @Test void shouldSerializeModelWithBooleans() throws JsonProcessingException { var schema = SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .properties(Map.of( "anySchema", true, "cannotBeDefined", false)) @@ -185,16 +186,16 @@ void shouldSerializeModelsWithComposition() throws JsonProcessingException { Map.of( "ErrorModel", SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .required(List.of("message", "code")) .properties(Map.of( "message", SchemaObject.builder() - .type("string") + .type(SchemaType.STRING) .build(), "code", SchemaObject.builder() - .type("integer") + .type(SchemaType.INTEGER) .minimum(new BigDecimal("100")) .maximum(new BigDecimal("600")) .build())) @@ -204,12 +205,12 @@ void shouldSerializeModelsWithComposition() throws JsonProcessingException { .allOf(List.of( ComponentSchema.of(MessageReference.toSchema("ErrorModel")), ComponentSchema.of(SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .required(List.of("rootCause")) .properties(Map.of( "rootCause", SchemaObject.builder() - .type("string") + .type(SchemaType.STRING) .build())) .build()))) .build())); @@ -266,13 +267,17 @@ void shouldSerializeModelsWithPolimorphismSupport() throws JsonProcessingExcepti Map.of( "Pet", SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .discriminator("petType") .properties(Map.of( "name", - SchemaObject.builder().type("string").build(), + SchemaObject.builder() + .type(SchemaType.STRING) + .build(), "petType", - SchemaObject.builder().type("string").build())) + SchemaObject.builder() + .type(SchemaType.STRING) + .build())) .required(List.of("name", "petType")) .build(), "Cat", @@ -282,11 +287,11 @@ void shouldSerializeModelsWithPolimorphismSupport() throws JsonProcessingExcepti .allOf(List.of( ComponentSchema.of(MessageReference.toSchema("Pet")), ComponentSchema.of(SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .properties(Map.of( "huntingSkill", SchemaObject.builder() - .type("string") + .type(SchemaType.STRING) .description("The measured skill for hunting") .enumValues( List.of( @@ -305,11 +310,11 @@ void shouldSerializeModelsWithPolimorphismSupport() throws JsonProcessingExcepti .allOf(List.of( ComponentSchema.of(MessageReference.toSchema("Pet")), ComponentSchema.of(SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .properties(Map.of( "packSize", SchemaObject.builder() - .type("integer") + .type(SchemaType.INTEGER) .format("int32") .description("the size of the pack the dog is from") .minimum(BigDecimal.ZERO) @@ -324,7 +329,7 @@ void shouldSerializeModelsWithPolimorphismSupport() throws JsonProcessingExcepti .allOf(List.of( ComponentSchema.of(MessageReference.toSchema("Pet")), ComponentSchema.of(SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .properties(Map.of( "petType", SchemaObject.builder() @@ -332,7 +337,7 @@ void shouldSerializeModelsWithPolimorphismSupport() throws JsonProcessingExcepti .build(), "color", SchemaObject.builder() - .type("string") + .type(SchemaType.STRING) .build())) .required(List.of("color")) .build()))) diff --git a/springwolf-bindings/springwolf-kafka-binding/src/main/java/io/github/springwolf/bindings/kafka/scanners/messages/KafkaMessageBindingProcessor.java b/springwolf-bindings/springwolf-kafka-binding/src/main/java/io/github/springwolf/bindings/kafka/scanners/messages/KafkaMessageBindingProcessor.java index 938353153..3f8e35641 100644 --- a/springwolf-bindings/springwolf-kafka-binding/src/main/java/io/github/springwolf/bindings/kafka/scanners/messages/KafkaMessageBindingProcessor.java +++ b/springwolf-bindings/springwolf-kafka-binding/src/main/java/io/github/springwolf/bindings/kafka/scanners/messages/KafkaMessageBindingProcessor.java @@ -4,6 +4,7 @@ import io.github.springwolf.asyncapi.v3.bindings.kafka.KafkaMessageBinding; import io.github.springwolf.asyncapi.v3.model.schema.Schema; import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject; +import io.github.springwolf.asyncapi.v3.model.schema.SchemaType; import io.github.springwolf.bindings.kafka.annotations.KafkaAsyncOperationBinding; import io.github.springwolf.core.asyncapi.scanners.bindings.messages.MessageBindingProcessor; import io.github.springwolf.core.asyncapi.scanners.bindings.messages.ProcessedMessageBinding; @@ -59,7 +60,7 @@ private Schema resolveSchemaOrNull(KafkaAsyncOperationBinding.KafkaAsyncMessageB break; case STRING_KEY: schemaDefinition = SchemaObject.builder() - .type("string") + .type(SchemaType.STRING) .examples(List.of(messageBinding.key().example())) .description(resolveOrNull(messageBinding.key().description())) .build(); diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/components/ComponentsService.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/components/ComponentsService.java index c53fa3a49..6ce13ca29 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/components/ComponentsService.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/components/ComponentsService.java @@ -18,7 +18,7 @@ public interface ComponentsService { String registerSchema(SchemaObject headers); - String registerSchema(Class type, String contentType); + String resolvePayloadSchema(Class type, String contentType); Map getMessages(); diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/components/DefaultComponentsService.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/components/DefaultComponentsService.java index 15bbaba5b..c842cd41b 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/components/DefaultComponentsService.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/components/DefaultComponentsService.java @@ -45,7 +45,7 @@ public String registerSchema(SchemaObject headers) { } @Override - public String registerSchema(Class type, String contentType) { + public String resolvePayloadSchema(Class type, String contentType) { log.debug("Registering schema for {}", type.getSimpleName()); SwaggerSchemaService.ExtractedSchemas schemas = schemaService.extractSchema(type, contentType); diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/channels/annotations/SpringAnnotationMethodLevelChannelsScanner.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/channels/annotations/SpringAnnotationMethodLevelChannelsScanner.java index fea8f2f95..e1b64ce60 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/channels/annotations/SpringAnnotationMethodLevelChannelsScanner.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/channels/annotations/SpringAnnotationMethodLevelChannelsScanner.java @@ -12,8 +12,8 @@ import io.github.springwolf.core.asyncapi.scanners.common.MethodLevelAnnotationScanner; import io.github.springwolf.core.asyncapi.scanners.common.headers.AsyncHeadersBuilder; import io.github.springwolf.core.asyncapi.scanners.common.headers.HeaderClassExtractor; -import io.github.springwolf.core.asyncapi.scanners.common.payload.NamedSchemaObject; import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadMethodService; +import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadSchemaObject; import io.github.springwolf.core.asyncapi.scanners.common.utils.AnnotationScannerUtil; import lombok.extern.slf4j.Slf4j; @@ -64,7 +64,7 @@ private Map.Entry mapMethodToChannel(Method method) { MethodAnnotation annotation = AnnotationScannerUtil.findAnnotationOrThrow(methodAnnotationClass, method); - NamedSchemaObject payloadSchema = payloadMethodService.extractSchema(method); + PayloadSchemaObject payloadSchema = payloadMethodService.extractSchema(method); SchemaObject headerSchema = headerClassExtractor.extractHeader(method, payloadSchema); ChannelObject channelItem = buildChannelItem(annotation, payloadSchema, headerSchema); @@ -72,7 +72,7 @@ private Map.Entry mapMethodToChannel(Method method) { } private ChannelObject buildChannelItem( - MethodAnnotation annotation, NamedSchemaObject payloadSchema, SchemaObject headerSchema) { + MethodAnnotation annotation, PayloadSchemaObject payloadSchema, SchemaObject headerSchema) { MessageObject message = buildMessage(annotation, payloadSchema, headerSchema); return buildChannelItem(annotation, message); } diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/AsyncAnnotationScanner.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/AsyncAnnotationScanner.java index 3d094afe5..7bd72c08f 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/AsyncAnnotationScanner.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/AsyncAnnotationScanner.java @@ -17,8 +17,8 @@ import io.github.springwolf.core.asyncapi.components.ComponentsService; import io.github.springwolf.core.asyncapi.scanners.bindings.messages.MessageBindingProcessor; import io.github.springwolf.core.asyncapi.scanners.bindings.operations.OperationBindingProcessor; -import io.github.springwolf.core.asyncapi.scanners.common.payload.NamedSchemaObject; import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadAsyncOperationService; +import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadSchemaObject; import io.github.springwolf.core.asyncapi.scanners.common.utils.AnnotationScannerUtil; import io.github.springwolf.core.asyncapi.scanners.common.utils.AsyncAnnotationUtil; import io.github.springwolf.core.asyncapi.scanners.common.utils.TextUtils; @@ -91,7 +91,7 @@ protected Operation buildOperation(AsyncOperation asyncOperation, Method method, } protected MessageObject buildMessage(AsyncOperation operationData, Method method) { - NamedSchemaObject payloadSchema = payloadAsyncOperationService.extractSchema(operationData, method); + PayloadSchemaObject payloadSchema = payloadAsyncOperationService.extractSchema(operationData, method); SchemaObject headerSchema = AsyncAnnotationUtil.getAsyncHeaders(operationData, resolver); String headerSchemaName = this.componentsService.registerSchema(headerSchema); diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/ClassLevelAnnotationScanner.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/ClassLevelAnnotationScanner.java index dc054eb77..180a6232b 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/ClassLevelAnnotationScanner.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/ClassLevelAnnotationScanner.java @@ -13,8 +13,8 @@ import io.github.springwolf.core.asyncapi.scanners.bindings.BindingFactory; import io.github.springwolf.core.asyncapi.scanners.common.headers.AsyncHeadersBuilder; import io.github.springwolf.core.asyncapi.scanners.common.headers.HeaderClassExtractor; -import io.github.springwolf.core.asyncapi.scanners.common.payload.NamedSchemaObject; import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadMethodService; +import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadSchemaObject; import io.github.springwolf.core.asyncapi.scanners.common.utils.AnnotationScannerUtil; import io.github.springwolf.core.asyncapi.scanners.operations.annotations.SpringAnnotationClassLevelOperationsScanner; import io.github.springwolf.core.asyncapi.schemas.SchemaObjectMerger; @@ -81,7 +81,7 @@ protected Map buildMessages( SpringAnnotationClassLevelOperationsScanner.MessageType messageType) { Set messages = methods.stream() .map((Method method) -> { - NamedSchemaObject payloadSchema = payloadMethodService.extractSchema(method); + PayloadSchemaObject payloadSchema = payloadMethodService.extractSchema(method); SchemaObject headerSchema = headerClassExtractor.extractHeader(method, payloadSchema); return buildMessage(classAnnotation, payloadSchema, headerSchema); }) @@ -95,7 +95,7 @@ protected Map buildMessages( } protected MessageObject buildMessage( - ClassAnnotation classAnnotation, NamedSchemaObject payloadSchema, SchemaObject headers) { + ClassAnnotation classAnnotation, PayloadSchemaObject payloadSchema, SchemaObject headers) { SchemaObject headerSchema = asyncHeadersBuilder.buildHeaders(payloadSchema); SchemaObject mergedHeaderSchema = SchemaObjectMerger.merge(headerSchema, headers); String headerSchemaName = componentsService.registerSchema(mergedHeaderSchema); diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/MethodLevelAnnotationScanner.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/MethodLevelAnnotationScanner.java index b0d938e19..7c6ab2f5c 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/MethodLevelAnnotationScanner.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/MethodLevelAnnotationScanner.java @@ -12,7 +12,7 @@ import io.github.springwolf.core.asyncapi.components.ComponentsService; import io.github.springwolf.core.asyncapi.scanners.bindings.BindingFactory; import io.github.springwolf.core.asyncapi.scanners.common.headers.AsyncHeadersBuilder; -import io.github.springwolf.core.asyncapi.scanners.common.payload.NamedSchemaObject; +import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadSchemaObject; import io.github.springwolf.core.asyncapi.schemas.SchemaObjectMerger; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -29,7 +29,7 @@ public abstract class MethodLevelAnnotationScanner()) .build(); diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadAsyncOperationService.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadAsyncOperationService.java index e4c82325d..b18f21d8a 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadAsyncOperationService.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadAsyncOperationService.java @@ -14,7 +14,7 @@ public class PayloadAsyncOperationService { private final PayloadClassExtractor payloadClassExtractor; private final PayloadService payloadService; - public NamedSchemaObject extractSchema(AsyncOperation operationData, Method method) { + public PayloadSchemaObject extractSchema(AsyncOperation operationData, Method method) { Optional> payloadType = operationData.payloadType() != Object.class ? Optional.of(operationData.payloadType()) : payloadClassExtractor.extractFrom(method); diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadMethodParameterService.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadMethodParameterService.java index 105d7e2f8..6aedca93a 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadMethodParameterService.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadMethodParameterService.java @@ -13,7 +13,7 @@ public class PayloadMethodParameterService implements PayloadMethodService { private final PayloadClassExtractor payloadClassExtractor; private final PayloadService payloadService; - public NamedSchemaObject extractSchema(Method method) { + public PayloadSchemaObject extractSchema(Method method) { Optional> payloadType = payloadClassExtractor.extractFrom(method); return payloadType.map(payloadService::buildSchema).orElseGet(payloadService::useUnusedPayload); diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadMethodReturnService.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadMethodReturnService.java index d3aacee91..947824e2c 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadMethodReturnService.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadMethodReturnService.java @@ -11,7 +11,7 @@ public class PayloadMethodReturnService implements PayloadMethodService { private final PayloadService payloadService; @Override - public NamedSchemaObject extractSchema(Method method) { + public PayloadSchemaObject extractSchema(Method method) { return payloadService.buildSchema(method.getReturnType()); } } diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadMethodService.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadMethodService.java index ec90197f8..289484973 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadMethodService.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadMethodService.java @@ -4,5 +4,5 @@ import java.lang.reflect.Method; public interface PayloadMethodService { - NamedSchemaObject extractSchema(Method method); + PayloadSchemaObject extractSchema(Method method); } diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/NamedSchemaObject.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadSchemaObject.java similarity index 85% rename from springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/NamedSchemaObject.java rename to springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadSchemaObject.java index e269ae0e1..3832d9eaa 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/NamedSchemaObject.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadSchemaObject.java @@ -9,7 +9,7 @@ * @param name The fully qualified name or the simple name of the schema. * @param schema The SchemaObject. */ -public record NamedSchemaObject(String name, @Nullable SchemaObject schema) { +public record PayloadSchemaObject(String name, @Nullable SchemaObject schema) { public String title() { return schema != null ? schema.getTitle() : name(); } diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/internal/PayloadService.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/internal/PayloadService.java index 6ffcecd0b..05b687219 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/internal/PayloadService.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/payload/internal/PayloadService.java @@ -2,8 +2,9 @@ package io.github.springwolf.core.asyncapi.scanners.common.payload.internal; import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject; +import io.github.springwolf.asyncapi.v3.model.schema.SchemaType; import io.github.springwolf.core.asyncapi.components.ComponentsService; -import io.github.springwolf.core.asyncapi.scanners.common.payload.NamedSchemaObject; +import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadSchemaObject; import io.github.springwolf.core.configuration.properties.SpringwolfConfigProperties; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -17,32 +18,33 @@ public class PayloadService { private final SpringwolfConfigProperties properties; private static final String PAYLOAD_NOT_USED_KEY = "PayloadNotUsed"; - public static final NamedSchemaObject PAYLOAD_NOT_USED = new NamedSchemaObject( + public static final PayloadSchemaObject PAYLOAD_NOT_USED = new PayloadSchemaObject( PAYLOAD_NOT_USED_KEY, SchemaObject.builder() + .type(SchemaType.OBJECT) .title(PAYLOAD_NOT_USED_KEY) .description("No payload specified") .properties(Map.of()) .build()); - public NamedSchemaObject buildSchema(Class payloadType) { + public PayloadSchemaObject buildSchema(Class payloadType) { String contentType = properties.getDocket().getDefaultContentType(); return buildSchema(contentType, payloadType); } - public NamedSchemaObject buildSchema(String contentType, Class payloadType) { - String componentsSchemaName = this.componentsService.registerSchema(payloadType, contentType); + public PayloadSchemaObject buildSchema(String contentType, Class payloadType) { + String componentsSchemaName = this.componentsService.resolvePayloadSchema(payloadType, contentType); SchemaObject schema = componentsService.resolveSchema(componentsSchemaName); if (schema != null) { schema.setTitle(payloadType.getSimpleName()); } - return new NamedSchemaObject(componentsSchemaName, schema); + return new PayloadSchemaObject(componentsSchemaName, schema); } - public NamedSchemaObject useUnusedPayload() { + public PayloadSchemaObject useUnusedPayload() { SchemaObject schema = PAYLOAD_NOT_USED.schema(); if (schema != null) { this.componentsService.registerSchema(schema); diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/utils/AsyncAnnotationUtil.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/utils/AsyncAnnotationUtil.java index 25e42f5a1..229e53070 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/utils/AsyncAnnotationUtil.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/utils/AsyncAnnotationUtil.java @@ -6,6 +6,7 @@ import io.github.springwolf.asyncapi.v3.bindings.OperationBinding; import io.github.springwolf.asyncapi.v3.model.channel.message.MessageObject; import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject; +import io.github.springwolf.asyncapi.v3.model.schema.SchemaType; import io.github.springwolf.core.asyncapi.annotations.AsyncMessage; import io.github.springwolf.core.asyncapi.annotations.AsyncOperation; import io.github.springwolf.core.asyncapi.scanners.bindings.channels.ChannelBindingProcessor; @@ -51,7 +52,7 @@ public static SchemaObject getAsyncHeaders(AsyncOperation op, StringValueResolve StringUtils.hasText(headers.description()) ? resolver.resolveStringValue(headers.description()) : null; SchemaObject headerSchema = new SchemaObject(); - headerSchema.setType("object"); + headerSchema.setType(SchemaType.OBJECT); headerSchema.setTitle(headers.schemaName()); headerSchema.setDescription(headerDescription); headerSchema.setProperties(new HashMap<>()); @@ -62,7 +63,7 @@ public static SchemaObject getAsyncHeaders(AsyncOperation op, StringValueResolve String propertyName = resolver.resolveStringValue(headerName); SchemaObject property = new SchemaObject(); - property.setType("string"); + property.setType(SchemaType.STRING); property.setTitle(propertyName); property.setDescription(getDescription(headersValues, resolver)); List values = getHeaderValues(headersValues, resolver); diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/operations/annotations/SpringAnnotationMethodLevelOperationsScanner.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/operations/annotations/SpringAnnotationMethodLevelOperationsScanner.java index d60659d1d..35ae45fad 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/operations/annotations/SpringAnnotationMethodLevelOperationsScanner.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/operations/annotations/SpringAnnotationMethodLevelOperationsScanner.java @@ -14,8 +14,8 @@ import io.github.springwolf.core.asyncapi.scanners.common.MethodLevelAnnotationScanner; import io.github.springwolf.core.asyncapi.scanners.common.headers.AsyncHeadersBuilder; import io.github.springwolf.core.asyncapi.scanners.common.headers.HeaderClassExtractor; -import io.github.springwolf.core.asyncapi.scanners.common.payload.NamedSchemaObject; import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadMethodParameterService; +import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadSchemaObject; import io.github.springwolf.core.asyncapi.scanners.common.utils.AnnotationScannerUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -74,7 +74,7 @@ private Map.Entry mapMethodToOperation(Method method) { String operationId = StringUtils.joinWith( "_", ReferenceUtil.toValidId(channelName), OperationAction.RECEIVE, method.getName()); - NamedSchemaObject payloadSchema = payloadMethodParameterService.extractSchema(method); + PayloadSchemaObject payloadSchema = payloadMethodParameterService.extractSchema(method); SchemaObject headerSchema = headerClassExtractor.extractHeader(method, payloadSchema); Operation operation = buildOperation(annotation, payloadSchema, headerSchema); @@ -83,7 +83,7 @@ private Map.Entry mapMethodToOperation(Method method) { } private Operation buildOperation( - MethodAnnotation annotation, NamedSchemaObject payloadType, SchemaObject headerSchema) { + MethodAnnotation annotation, PayloadSchemaObject payloadType, SchemaObject headerSchema) { MessageObject message = buildMessage(annotation, payloadType, headerSchema); Map operationBinding = bindingFactory.buildOperationBinding(annotation); Map opBinding = operationBinding != null ? new HashMap<>(operationBinding) : null; diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/DefaultComponentsServiceIntegrationTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/DefaultComponentsServiceIntegrationTest.java index 85e27fd6a..0d1858d5e 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/DefaultComponentsServiceIntegrationTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/DefaultComponentsServiceIntegrationTest.java @@ -3,6 +3,7 @@ import io.github.springwolf.asyncapi.v3.model.components.ComponentSchema; import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject; +import io.github.springwolf.asyncapi.v3.model.schema.SchemaType; import io.github.springwolf.core.asyncapi.annotations.AsyncApiPayload; import io.github.springwolf.core.asyncapi.schemas.SwaggerSchemaService; import io.github.springwolf.core.asyncapi.schemas.SwaggerSchemaUtil; @@ -33,7 +34,7 @@ class DefaultComponentsServiceIntegrationTest { class AllSchemaFields { @Test void getStringSchemas() { - componentsService.registerSchema(StringFoo.class, CONTENT_TYPE_APPLICATION_JSON); + componentsService.resolvePayloadSchema(StringFoo.class, CONTENT_TYPE_APPLICATION_JSON); Map schemas = componentsService.getSchemas(); assertThat(schemas).hasSize(1); @@ -42,11 +43,11 @@ void getStringSchemas() { assertThat(objectFoo) .isEqualTo(SchemaObject.builder() .title("title") - .type("object") + .type(SchemaType.OBJECT) .properties(Map.of( "s", ComponentSchema.of(SchemaObject.builder() - .type("string") + .type(SchemaType.STRING) .minLength(1) .maxLength(10) .examples(List.of("\"example\"")) @@ -60,7 +61,7 @@ void getStringSchemas() { @Test void getArraySchemas() { - componentsService.registerSchema(ArrayFoo.class, CONTENT_TYPE_APPLICATION_JSON); + componentsService.resolvePayloadSchema(ArrayFoo.class, CONTENT_TYPE_APPLICATION_JSON); Map schemas = componentsService.getSchemas(); assertThat(schemas).hasSize(1); @@ -69,13 +70,13 @@ void getArraySchemas() { assertThat(objectFoo) .isEqualTo(SchemaObject.builder() .title("title") - .type("object") + .type(SchemaType.OBJECT) .properties(Map.of( "array", ComponentSchema.of(SchemaObject.builder() - .type("array") + .type(SchemaType.ARRAY) .items(ComponentSchema.of(SchemaObject.builder() - .type("string") + .type(SchemaType.STRING) .description("items description") .build())) .maxItems(10) @@ -88,7 +89,7 @@ void getArraySchemas() { @Test void getRefSchemas() { - componentsService.registerSchema(RefFoo.class, CONTENT_TYPE_APPLICATION_JSON); + componentsService.resolvePayloadSchema(RefFoo.class, CONTENT_TYPE_APPLICATION_JSON); Map schemas = componentsService.getSchemas(); assertThat(schemas).hasSize(1); @@ -97,22 +98,22 @@ void getRefSchemas() { assertThat(objectFoo) .isEqualTo(SchemaObject.builder() .title("title") - .type("object") + .type(SchemaType.OBJECT) .properties(Map.of( "ref", ComponentSchema.of(SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .not(ComponentSchema.of(SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .build())) .oneOf(List.of(ComponentSchema.of(SchemaObject.builder() - .type("string") + .type(SchemaType.STRING) .build()))) .anyOf(List.of(ComponentSchema.of(SchemaObject.builder() - .type("string") + .type(SchemaType.STRING) .build()))) .allOf(List.of(ComponentSchema.of(SchemaObject.builder() - .type("string") + .type(SchemaType.STRING) .build()))) .build()))) .build()); @@ -120,7 +121,7 @@ void getRefSchemas() { @Test void getNumberSchemas() { - componentsService.registerSchema(NumberFoo.class, CONTENT_TYPE_APPLICATION_JSON); + componentsService.resolvePayloadSchema(NumberFoo.class, CONTENT_TYPE_APPLICATION_JSON); Map schemas = componentsService.getSchemas(); assertThat(schemas).hasSize(1); @@ -129,11 +130,11 @@ void getNumberSchemas() { assertThat(objectFoo) .isEqualTo(SchemaObject.builder() .title("title") - .type("object") + .type(SchemaType.OBJECT) .properties(Map.of( "number", ComponentSchema.of(SchemaObject.builder() - .type("number") + .type(SchemaType.NUMBER) .format("double") .multipleOf(BigDecimal.ONE) .exclusiveMaximum(BigDecimal.valueOf(5)) @@ -145,15 +146,17 @@ void getNumberSchemas() { @Test void getNotSupportedSchemas() { - componentsService.registerSchema(NotSupportedFoo.class, CONTENT_TYPE_APPLICATION_JSON); + componentsService.resolvePayloadSchema(NotSupportedFoo.class, CONTENT_TYPE_APPLICATION_JSON); Map schemas = componentsService.getSchemas(); assertThat(schemas).hasSize(1); SchemaObject objectFoo = schemas.get(this.getClass().getName() + "$NotSupportedFoo"); assertThat(objectFoo) - .isEqualTo( - SchemaObject.builder().title("title").type("object").build()); + .isEqualTo(SchemaObject.builder() + .title("title") + .type(SchemaType.OBJECT) + .build()); } @Data @@ -237,7 +240,7 @@ private static class NotSupportedFoo { class AsyncApiPayloadTest { @Test void stringEnvelopTest() { - componentsService.registerSchema(StringEnvelop.class, CONTENT_TYPE_APPLICATION_JSON); + componentsService.resolvePayloadSchema(StringEnvelop.class, CONTENT_TYPE_APPLICATION_JSON); Map schemas = componentsService.getSchemas(); assertThat(schemas).hasSize(1); @@ -245,7 +248,7 @@ void stringEnvelopTest() { SchemaObject schema = schemas.get(this.getClass().getName() + "$StringEnvelop"); assertThat(schema) .isEqualTo(SchemaObject.builder() - .type("string") + .type(SchemaType.STRING) .description("The payload in the envelop") .maxLength(10) .build()); @@ -253,7 +256,7 @@ void stringEnvelopTest() { @Test void illegalEnvelopTest() { - componentsService.registerSchema( + componentsService.resolvePayloadSchema( EnvelopWithMultipleAsyncApiPayloadAnnotations.class, CONTENT_TYPE_APPLICATION_JSON); Map schemas = componentsService.getSchemas(); @@ -264,16 +267,16 @@ void illegalEnvelopTest() { schemas.get(this.getClass().getName() + "$EnvelopWithMultipleAsyncApiPayloadAnnotations"); assertThat(schema) .isEqualTo(SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .properties(Map.of( "otherField", ComponentSchema.of(SchemaObject.builder() - .type("integer") + .type(SchemaType.INTEGER) .format("int32") .build()), "payload", ComponentSchema.of(SchemaObject.builder() - .type("string") + .type(SchemaType.STRING) .description("The payload in the envelop") .maxLength(10) .build()))) 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 4f5a031b7..62cb3f773 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 @@ -61,8 +61,8 @@ class DefaultJsonComponentsServiceIntegrationTest { @Test void getSchemas() throws IOException { - componentsService.registerSchema(CompositeFoo.class, CONTENT_TYPE_APPLICATION_JSON); - componentsService.registerSchema(FooWithEnum.class, CONTENT_TYPE_APPLICATION_JSON); + componentsService.resolvePayloadSchema(CompositeFoo.class, CONTENT_TYPE_APPLICATION_JSON); + componentsService.resolvePayloadSchema(FooWithEnum.class, CONTENT_TYPE_APPLICATION_JSON); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = loadDefinition("/schemas/json/definitions.json", actualDefinitions); @@ -73,7 +73,7 @@ void getSchemas() throws IOException { @Test void getDocumentedDefinitions() throws IOException { - componentsService.registerSchema(DocumentedSimpleFoo.class, CONTENT_TYPE_APPLICATION_JSON); + componentsService.resolvePayloadSchema(DocumentedSimpleFoo.class, CONTENT_TYPE_APPLICATION_JSON); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = loadDefinition("/schemas/json/documented-definitions.json", actualDefinitions); @@ -84,7 +84,7 @@ void getDocumentedDefinitions() throws IOException { @Test void getArrayDefinitions() throws IOException { - componentsService.registerSchema(ArrayFoo.class, CONTENT_TYPE_APPLICATION_JSON); + componentsService.resolvePayloadSchema(ArrayFoo.class, CONTENT_TYPE_APPLICATION_JSON); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = loadDefinition("/schemas/json/array-definitions.json", actualDefinitions); @@ -95,7 +95,7 @@ void getArrayDefinitions() throws IOException { @Test void getComplexDefinitions() throws IOException { - componentsService.registerSchema(ComplexFoo.class, CONTENT_TYPE_APPLICATION_JSON); + componentsService.resolvePayloadSchema(ComplexFoo.class, CONTENT_TYPE_APPLICATION_JSON); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = loadDefinition("/schemas/json/complex-definitions.json", actualDefinitions); @@ -106,7 +106,7 @@ void getComplexDefinitions() throws IOException { @Test void getListWrapperDefinitions() throws IOException { - componentsService.registerSchema(ListWrapper.class, CONTENT_TYPE_APPLICATION_JSON); + componentsService.resolvePayloadSchema(ListWrapper.class, CONTENT_TYPE_APPLICATION_JSON); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = loadDefinition("/schemas/json/generics-wrapper-definitions.json", actualDefinitions); @@ -226,7 +226,7 @@ private static class MyClass { class SchemaWithOneOf { @Test void testSchemaWithOneOf() throws IOException { - componentsService.registerSchema(SchemaAnnotationFoo.class, CONTENT_TYPE_APPLICATION_JSON); + componentsService.resolvePayloadSchema(SchemaAnnotationFoo.class, CONTENT_TYPE_APPLICATION_JSON); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = loadDefinition("/schemas/json/annotation-definitions.json", actualDefinitions); @@ -272,7 +272,7 @@ public class ImplementationTwo { class JsonSubTypesRecursionTest { @Test void registerSchemaWithoutStackOverflowException() { - componentsService.registerSchema(CriteriaMessage.class, CONTENT_TYPE_APPLICATION_JSON); + componentsService.resolvePayloadSchema(CriteriaMessage.class, CONTENT_TYPE_APPLICATION_JSON); Map schemas = componentsService.getSchemas(); assertThat(schemas) @@ -305,7 +305,7 @@ public class LegacyCriteriaMessage extends CriteriaMessage { class JsonTypeTest { @Test void getJsonTypeDefinitions() throws IOException { - componentsService.registerSchema(JsonTypeInfoPayloadDto.class, CONTENT_TYPE_APPLICATION_JSON); + componentsService.resolvePayloadSchema(JsonTypeInfoPayloadDto.class, CONTENT_TYPE_APPLICATION_JSON); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = loadDefinition("/schemas/json/json-type-definitions.json", actualDefinitions); diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/DefaultXmlComponentsServiceIntegrationTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/DefaultXmlComponentsServiceIntegrationTest.java index 6f8e63c51..fe1eac8fa 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/DefaultXmlComponentsServiceIntegrationTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/DefaultXmlComponentsServiceIntegrationTest.java @@ -55,8 +55,8 @@ class DefaultXmlComponentsServiceIntegrationTest { @Test void getSchemas() throws IOException { - componentsService.registerSchema(CompositeFoo.class, "text/xml"); - componentsService.registerSchema(FooWithEnum.class, "text/xml"); + componentsService.resolvePayloadSchema(CompositeFoo.class, "text/xml"); + componentsService.resolvePayloadSchema(FooWithEnum.class, "text/xml"); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = loadDefinition("/schemas/xml/definitions-xml.json", actualDefinitions); @@ -67,7 +67,7 @@ void getSchemas() throws IOException { @Test void getDocumentedDefinitions() throws IOException { - componentsService.registerSchema(DocumentedSimpleFoo.class, "text/xml"); + componentsService.resolvePayloadSchema(DocumentedSimpleFoo.class, "text/xml"); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = loadDefinition("/schemas/xml/documented-definitions-xml.json", actualDefinitions); @@ -78,7 +78,7 @@ void getDocumentedDefinitions() throws IOException { @Test void getArrayDefinitions() throws IOException { - componentsService.registerSchema(ArrayFoo.class, "text/xml"); + componentsService.resolvePayloadSchema(ArrayFoo.class, "text/xml"); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = loadDefinition("/schemas/xml/array-definitions-xml.json", actualDefinitions); @@ -89,7 +89,7 @@ void getArrayDefinitions() throws IOException { @Test void getComplexDefinitions() throws IOException { - componentsService.registerSchema(ComplexFoo.class, "text/xml"); + componentsService.resolvePayloadSchema(ComplexFoo.class, "text/xml"); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = loadDefinition("/schemas/xml/complex-definitions-xml.json", actualDefinitions); @@ -100,7 +100,7 @@ void getComplexDefinitions() throws IOException { @Test void getComplexDefinitionsWithAttributes() throws IOException { - componentsService.registerSchema(ComplexAttributesFoo.class, "text/xml"); + componentsService.resolvePayloadSchema(ComplexAttributesFoo.class, "text/xml"); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = @@ -112,7 +112,7 @@ void getComplexDefinitionsWithAttributes() throws IOException { @Test void getListWrapperDefinitions() throws IOException { - componentsService.registerSchema(ListWrapper.class, "text/xml"); + componentsService.resolvePayloadSchema(ListWrapper.class, "text/xml"); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = loadDefinition("/schemas/xml/generics-wrapper-definitions-xml.json", actualDefinitions); @@ -242,7 +242,7 @@ private static class MyClass { class SchemaWithOneOf { @Test void testSchemaWithOneOf() throws IOException { - componentsService.registerSchema(SchemaAnnotationFoo.class, "text/xml"); + componentsService.resolvePayloadSchema(SchemaAnnotationFoo.class, "text/xml"); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = loadDefinition("/schemas/xml/annotation-definitions-xml.json", actualDefinitions); @@ -341,8 +341,8 @@ private static class MyClassWithAttribute { class XmlSchemaName { @Test void testSchemasWithSharedProperty() throws IOException { - componentsService.registerSchema(XmlSchemaName.ClassB.class, "text/xml"); - componentsService.registerSchema(XmlSchemaName.ClassA.class, "text/xml"); + componentsService.resolvePayloadSchema(XmlSchemaName.ClassB.class, "text/xml"); + componentsService.resolvePayloadSchema(XmlSchemaName.ClassA.class, "text/xml"); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = loadDefinition("/schemas/xml/schema-with-shared-property.json", actualDefinitions); 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 b7a8f7e6e..82966ab22 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 @@ -67,8 +67,8 @@ class DefaultYamlComponentsServiceIntegrationTest { @Test void getSchemas() throws IOException { - componentsService.registerSchema(CompositeFoo.class, CONTENT_TYPE_APPLICATION_YAML); - componentsService.registerSchema(FooWithEnum.class, CONTENT_TYPE_APPLICATION_YAML); + componentsService.resolvePayloadSchema(CompositeFoo.class, CONTENT_TYPE_APPLICATION_YAML); + componentsService.resolvePayloadSchema(FooWithEnum.class, CONTENT_TYPE_APPLICATION_YAML); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = loadDefinitions("/schemas/yaml/definitions-yaml.json", actualDefinitions); @@ -79,7 +79,7 @@ void getSchemas() throws IOException { @Test void getDocumentedDefinitions() throws IOException { - componentsService.registerSchema(DocumentedSimpleFoo.class, CONTENT_TYPE_APPLICATION_YAML); + componentsService.resolvePayloadSchema(DocumentedSimpleFoo.class, CONTENT_TYPE_APPLICATION_YAML); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = loadDefinitions("/schemas/yaml/documented-definitions-yaml.json", actualDefinitions); @@ -90,7 +90,7 @@ void getDocumentedDefinitions() throws IOException { @Test void getArrayDefinitions() throws IOException { - componentsService.registerSchema(ArrayFoo.class, CONTENT_TYPE_APPLICATION_YAML); + componentsService.resolvePayloadSchema(ArrayFoo.class, CONTENT_TYPE_APPLICATION_YAML); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = loadDefinitions("/schemas/yaml/array-definitions-yaml.json", actualDefinitions); @@ -101,7 +101,7 @@ void getArrayDefinitions() throws IOException { @Test void getComplexDefinitions() throws IOException { - componentsService.registerSchema(ComplexFoo.class, CONTENT_TYPE_APPLICATION_YAML); + componentsService.resolvePayloadSchema(ComplexFoo.class, CONTENT_TYPE_APPLICATION_YAML); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = loadDefinitions("/schemas/yaml/complex-definitions-yaml.json", actualDefinitions); @@ -112,7 +112,7 @@ void getComplexDefinitions() throws IOException { @Test void getListWrapperDefinitions() throws IOException { - componentsService.registerSchema(ListWrapper.class, CONTENT_TYPE_APPLICATION_YAML); + componentsService.resolvePayloadSchema(ListWrapper.class, CONTENT_TYPE_APPLICATION_YAML); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = loadDefinitions("/schemas/yaml/generics-wrapper-definitions-yaml.json", actualDefinitions); @@ -232,7 +232,7 @@ private static class MyClass { class SchemaWithOneOf { @Test void testSchemaWithOneOf() throws IOException { - componentsService.registerSchema(SchemaAnnotationFoo.class, CONTENT_TYPE_APPLICATION_YAML); + componentsService.resolvePayloadSchema(SchemaAnnotationFoo.class, CONTENT_TYPE_APPLICATION_YAML); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = loadDefinitions("/schemas/yaml/annotation-definitions-yaml.json", actualDefinitions); @@ -278,7 +278,7 @@ public class ImplementationTwo { class JsonSubTypesRecursionTest { @Test void registerSchemaWithoutStackOverflowException() { - componentsService.registerSchema(CriteriaMessage.class, CONTENT_TYPE_APPLICATION_YAML); + componentsService.resolvePayloadSchema(CriteriaMessage.class, CONTENT_TYPE_APPLICATION_YAML); Map schemas = componentsService.getSchemas(); assertThat(schemas) @@ -311,7 +311,8 @@ public class LegacyCriteriaMessage extends CriteriaMessage { class JsonTypeTest { @Test void getJsonTypeDefinitions() throws IOException { - componentsService.registerSchema(JsonTypeTest.JsonTypeInfoPayloadDto.class, CONTENT_TYPE_APPLICATION_YAML); + componentsService.resolvePayloadSchema( + JsonTypeTest.JsonTypeInfoPayloadDto.class, CONTENT_TYPE_APPLICATION_YAML); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); String expected = loadDefinitions("/schemas/yaml/json-type-definitions-yaml.json", actualDefinitions); diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/SwaggerSchemaUtilTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/SwaggerSchemaUtilTest.java index 1a5c9fa5c..0a31fa1d0 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/SwaggerSchemaUtilTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/SwaggerSchemaUtilTest.java @@ -4,6 +4,7 @@ import io.github.springwolf.asyncapi.v3.model.channel.message.MessageReference; import io.github.springwolf.asyncapi.v3.model.components.ComponentSchema; import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject; +import io.github.springwolf.asyncapi.v3.model.schema.SchemaType; import io.github.springwolf.core.asyncapi.schemas.SwaggerSchemaUtil; import io.swagger.v3.oas.models.ExternalDocumentation; import io.swagger.v3.oas.models.media.Discriminator; @@ -40,7 +41,7 @@ void mapReference() { void mapSchema() { // given ObjectSchema schema = new ObjectSchema(); - schema.setType("string"); + schema.setType(SchemaType.STRING); // when ComponentSchema componentSchema = swaggerSchemaUtil.mapSchemaOrRef(schema); @@ -99,7 +100,7 @@ void mapTitle() { void mapType() { // given ObjectSchema schema = new ObjectSchema(); - schema.setType("string"); + schema.setType(SchemaType.STRING); // when SchemaObject componentSchema = swaggerSchemaUtil.mapSchema(schema); @@ -113,7 +114,7 @@ void mapProperties() { // given ObjectSchema schema = new ObjectSchema(); ObjectSchema property = new ObjectSchema(); - property.setType("string"); + property.setType(SchemaType.STRING); schema.addProperty("property", property); // when @@ -321,7 +322,7 @@ void mapAdditionalProperties() { // given ObjectSchema schema = new ObjectSchema(); ObjectSchema additionalProperties = new ObjectSchema(); - additionalProperties.setType("string"); + additionalProperties.setType(SchemaType.STRING); schema.setAdditionalProperties(additionalProperties); // when @@ -365,7 +366,7 @@ void mapAllOf() { // given ObjectSchema schema = new ObjectSchema(); ObjectSchema allOf = new ObjectSchema(); - allOf.setType("string"); + allOf.setType(SchemaType.STRING); schema.addAllOfItem(allOf); // when @@ -381,7 +382,7 @@ void mapOneOf() { // given ObjectSchema schema = new ObjectSchema(); ObjectSchema oneOf = new ObjectSchema(); - oneOf.setType("string"); + oneOf.setType(SchemaType.STRING); schema.addOneOfItem(oneOf); // when @@ -397,7 +398,7 @@ void mapAnyOf() { // given ObjectSchema schema = new ObjectSchema(); ObjectSchema anyOf = new ObjectSchema(); - anyOf.setType("string"); + anyOf.setType(SchemaType.STRING); schema.addAnyOfItem(anyOf); // when @@ -426,7 +427,7 @@ void mapNot() { // given ObjectSchema schema = new ObjectSchema(); ObjectSchema not = new ObjectSchema(); - not.setType("string"); + not.setType(SchemaType.STRING); schema.setNot(not); // when @@ -440,9 +441,9 @@ void mapNot() { void mapItems() { // given ObjectSchema schema = new ObjectSchema(); - schema.type("array"); + schema.type(SchemaType.ARRAY); ObjectSchema item = new ObjectSchema(); - item.setType("string"); + item.setType(SchemaType.STRING); schema.setItems(item); // when @@ -537,7 +538,7 @@ void mapEnum() { void mapType() { // given SchemaObject schema = new SchemaObject(); - schema.setType("string"); + schema.setType(SchemaType.STRING); // when Schema componentSchema = swaggerSchemaUtil.mapToSwagger(schema); diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/channels/annotations/SpringAnnotationClassLevelChannelsScannerTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/channels/annotations/SpringAnnotationClassLevelChannelsScannerTest.java index 7d629bfba..4d2030f7f 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/channels/annotations/SpringAnnotationClassLevelChannelsScannerTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/channels/annotations/SpringAnnotationClassLevelChannelsScannerTest.java @@ -20,8 +20,8 @@ import io.github.springwolf.core.asyncapi.scanners.channels.annotations.SpringAnnotationClassLevelChannelsScannerIntegrationTest.TestBindingFactory; import io.github.springwolf.core.asyncapi.scanners.common.headers.AsyncHeadersNotDocumented; import io.github.springwolf.core.asyncapi.scanners.common.headers.HeaderClassExtractor; -import io.github.springwolf.core.asyncapi.scanners.common.payload.NamedSchemaObject; import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadMethodService; +import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadSchemaObject; import io.swagger.v3.oas.annotations.Hidden; import lombok.Data; import lombok.NoArgsConstructor; @@ -74,7 +74,7 @@ void setUp() { doReturn(defaultMessageBinding).when(bindingFactory).buildMessageBinding(any(), any()); when(payloadMethodService.extractSchema(any())) - .thenReturn(new NamedSchemaObject(String.class.getName(), new SchemaObject())); + .thenReturn(new PayloadSchemaObject(String.class.getName(), new SchemaObject())); doAnswer(invocation -> AsyncHeadersNotDocumented.NOT_DOCUMENTED.getTitle()) .when(componentsService) .registerSchema(any(SchemaObject.class)); diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/channels/annotations/SpringAnnotationMethodLevelChannelsScannerTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/channels/annotations/SpringAnnotationMethodLevelChannelsScannerTest.java index 71c28ccd8..df5dc2b25 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/channels/annotations/SpringAnnotationMethodLevelChannelsScannerTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/channels/annotations/SpringAnnotationMethodLevelChannelsScannerTest.java @@ -20,8 +20,8 @@ import io.github.springwolf.core.asyncapi.scanners.bindings.BindingFactory; import io.github.springwolf.core.asyncapi.scanners.common.headers.AsyncHeadersNotDocumented; import io.github.springwolf.core.asyncapi.scanners.common.headers.HeaderClassExtractor; -import io.github.springwolf.core.asyncapi.scanners.common.payload.NamedSchemaObject; import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadMethodService; +import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadSchemaObject; import io.swagger.v3.oas.annotations.Hidden; import lombok.Data; import lombok.NoArgsConstructor; @@ -74,7 +74,7 @@ void setUp() throws NoSuchMethodException { doReturn(defaultMessageBinding).when(bindingFactory).buildMessageBinding(any(), any()); when(payloadMethodService.extractSchema(any())) - .thenReturn(new NamedSchemaObject(String.class.getName(), new SchemaObject())); + .thenReturn(new PayloadSchemaObject(String.class.getName(), new SchemaObject())); doAnswer(invocation -> AsyncHeadersNotDocumented.NOT_DOCUMENTED.getTitle()) .when(componentsService) .registerSchema(any(SchemaObject.class)); @@ -82,11 +82,11 @@ void setUp() throws NoSuchMethodException { var stringMethod = ClassWithMultipleTestListenerAnnotation.class.getDeclaredMethod("methodWithAnnotation", String.class); when(payloadMethodService.extractSchema(stringMethod)) - .thenReturn(new NamedSchemaObject(String.class.getName(), new SchemaObject())); + .thenReturn(new PayloadSchemaObject(String.class.getName(), new SchemaObject())); var simpleFooMethod = ClassWithMultipleTestListenerAnnotation.class.getDeclaredMethod( "anotherMethodWithAnnotation", SimpleFoo.class); when(payloadMethodService.extractSchema(simpleFooMethod)) - .thenReturn(new NamedSchemaObject(SimpleFoo.class.getName(), new SchemaObject())); + .thenReturn(new PayloadSchemaObject(SimpleFoo.class.getName(), new SchemaObject())); } @Test diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/headers/HeaderClassExtractorTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/headers/HeaderClassExtractorTest.java index 1c7a01237..f0e7825f5 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/headers/HeaderClassExtractorTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/headers/HeaderClassExtractorTest.java @@ -2,7 +2,8 @@ package io.github.springwolf.core.asyncapi.scanners.common.headers; import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject; -import io.github.springwolf.core.asyncapi.scanners.common.payload.NamedSchemaObject; +import io.github.springwolf.asyncapi.v3.model.schema.SchemaType; +import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadSchemaObject; import io.github.springwolf.core.asyncapi.schemas.SwaggerSchemaService; import lombok.val; import org.junit.jupiter.api.Test; @@ -21,11 +22,12 @@ class HeaderClassExtractorTest { private final SwaggerSchemaService schemaService = mock(SwaggerSchemaService.class); private final HeaderClassExtractor headerClassExtractor = new HeaderClassExtractor(schemaService); - private final NamedSchemaObject payloadSchemaName = new NamedSchemaObject("payloadSchemaName", new SchemaObject()); + private final PayloadSchemaObject payloadSchemaName = + new PayloadSchemaObject("payloadSchemaName", new SchemaObject()); private final SchemaObject stringSchema = - SchemaObject.builder().type("string").build(); + SchemaObject.builder().type(SchemaType.STRING).build(); private final SchemaObject stringSwaggerSchema = - SchemaObject.builder().type("string").build(); + SchemaObject.builder().type(SchemaType.STRING).build(); @Test void getNoDocumentedHeaders() throws NoSuchMethodException { @@ -53,6 +55,7 @@ void getHeaderWithSingleHeaderAnnotation() throws NoSuchMethodException { // then SchemaObject expectedHeaders = SchemaObject.builder() + .type(SchemaType.OBJECT) .title("payloadSchemaNameHeaders") .properties(new HashMap<>()) .build(); @@ -73,6 +76,7 @@ void getHeaderWithMultipleHeaderAnnotation() throws NoSuchMethodException { // then SchemaObject expectedHeaders = SchemaObject.builder() + .type(SchemaType.OBJECT) .title("payloadSchemaNameHeaders") .properties(new HashMap<>()) .build(); diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadAsyncOperationServiceTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadAsyncOperationServiceTest.java index dd9e7fadf..e8cae4450 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadAsyncOperationServiceTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadAsyncOperationServiceTest.java @@ -47,7 +47,7 @@ public void shouldUsePayloadFromAsyncOperationAnnotation() { when(asyncOperation.message()).thenReturn(asyncMessage); String schemaName = "my-schema-name"; - when(componentsService.registerSchema(any(), any())).thenReturn(schemaName); + when(componentsService.resolvePayloadSchema(any(), any())).thenReturn(schemaName); SchemaObject schemaObject = SchemaObject.builder().build(); when(componentsService.resolveSchema(schemaName)).thenReturn(schemaObject); @@ -74,7 +74,7 @@ public void shouldExtractPayloadFromMethodWithAnnotation() { when(payloadClassExtractor.extractFrom(method)).thenReturn(Optional.of(String.class)); String schemaName = "my-schema-name"; - when(componentsService.registerSchema(any(), any())).thenReturn(schemaName); + when(componentsService.resolvePayloadSchema(any(), any())).thenReturn(schemaName); SchemaObject schemaObject = SchemaObject.builder().build(); when(componentsService.resolveSchema(schemaName)).thenReturn(schemaObject); diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadMethodParameterServiceTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadMethodParameterServiceTest.java index 048663e44..554a15b20 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadMethodParameterServiceTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadMethodParameterServiceTest.java @@ -42,7 +42,7 @@ public void shouldExtractPayloadFromMethod() { when(payloadClassExtractor.extractFrom(method)).thenReturn(Optional.of(String.class)); String schemaName = "my-schema-name"; - when(componentsService.registerSchema(any(), any())).thenReturn(schemaName); + when(componentsService.resolvePayloadSchema(any(), any())).thenReturn(schemaName); SchemaObject schemaObject = SchemaObject.builder().build(); when(componentsService.resolveSchema(schemaName)).thenReturn(schemaObject); diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadMethodReturnServiceTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadMethodReturnServiceTest.java index b0cd07790..7eaca9205 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadMethodReturnServiceTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/payload/PayloadMethodReturnServiceTest.java @@ -40,7 +40,7 @@ public void shouldExtractPayloadFromMethod() { doReturn(String.class).when(method).getReturnType(); String schemaName = "my-schema-name"; - when(componentsService.registerSchema(any(), any())).thenReturn(schemaName); + when(componentsService.resolvePayloadSchema(any(), any())).thenReturn(schemaName); SchemaObject schemaObject = SchemaObject.builder().build(); when(componentsService.resolveSchema(schemaName)).thenReturn(schemaObject); diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/payload/internal/PayloadServiceTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/payload/internal/PayloadServiceTest.java index 3766f502f..d68d7f555 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/payload/internal/PayloadServiceTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/payload/internal/PayloadServiceTest.java @@ -24,7 +24,7 @@ public void shouldExtractSchemaForInteger() { when(docket.getDefaultContentType()).thenReturn("application/json"); String schemaName = "my-schema-name"; - when(componentsService.registerSchema(any(), any())).thenReturn(schemaName); + when(componentsService.resolvePayloadSchema(any(), any())).thenReturn(schemaName); // when var result = payloadService.buildSchema(Integer.class); diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/operations/annotations/SpringAnnotationClassLevelOperationsScannerTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/operations/annotations/SpringAnnotationClassLevelOperationsScannerTest.java index 8f824b1d7..0e3f0c9dc 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/operations/annotations/SpringAnnotationClassLevelOperationsScannerTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/operations/annotations/SpringAnnotationClassLevelOperationsScannerTest.java @@ -21,8 +21,8 @@ import io.github.springwolf.core.asyncapi.scanners.bindings.BindingFactory; import io.github.springwolf.core.asyncapi.scanners.common.headers.AsyncHeadersNotDocumented; import io.github.springwolf.core.asyncapi.scanners.common.headers.HeaderClassExtractor; -import io.github.springwolf.core.asyncapi.scanners.common.payload.NamedSchemaObject; import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadMethodService; +import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadSchemaObject; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -75,7 +75,7 @@ void setUp() { doReturn(defaultMessageBinding).when(bindingFactory).buildMessageBinding(any(), any()); when(payloadMethodService.extractSchema(any())) - .thenReturn(new NamedSchemaObject(String.class.getName(), new SchemaObject())); + .thenReturn(new PayloadSchemaObject(String.class.getName(), new SchemaObject())); doAnswer(invocation -> AsyncHeadersNotDocumented.NOT_DOCUMENTED.getTitle()) .when(componentsService) .registerSchema(any(SchemaObject.class)); diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/operations/annotations/SpringAnnotationMethodLevelOperationsScannerTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/operations/annotations/SpringAnnotationMethodLevelOperationsScannerTest.java index 99de113a9..faa2bbef3 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/operations/annotations/SpringAnnotationMethodLevelOperationsScannerTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/operations/annotations/SpringAnnotationMethodLevelOperationsScannerTest.java @@ -21,8 +21,8 @@ import io.github.springwolf.core.asyncapi.scanners.bindings.BindingFactory; import io.github.springwolf.core.asyncapi.scanners.common.headers.AsyncHeadersNotDocumented; import io.github.springwolf.core.asyncapi.scanners.common.headers.HeaderClassExtractor; -import io.github.springwolf.core.asyncapi.scanners.common.payload.NamedSchemaObject; import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadMethodParameterService; +import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadSchemaObject; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -74,7 +74,7 @@ void setUp() { doReturn(defaultMessageBinding).when(bindingFactory).buildMessageBinding(any(), any()); when(payloadMethodParameterService.extractSchema(any())) - .thenReturn(new NamedSchemaObject(String.class.getName(), new SchemaObject())); + .thenReturn(new PayloadSchemaObject(String.class.getName(), new SchemaObject())); doAnswer(invocation -> AsyncHeadersNotDocumented.NOT_DOCUMENTED.getTitle()) .when(componentsService) .registerSchema(any(SchemaObject.class)); diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/asyncapi/scanners/common/headers/AsyncHeadersForAmqpBuilder.java b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/asyncapi/scanners/common/headers/AsyncHeadersForAmqpBuilder.java index 979aefe53..485532523 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/asyncapi/scanners/common/headers/AsyncHeadersForAmqpBuilder.java +++ b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/springwolf/plugins/amqp/asyncapi/scanners/common/headers/AsyncHeadersForAmqpBuilder.java @@ -2,21 +2,22 @@ package io.github.springwolf.plugins.amqp.asyncapi.scanners.common.headers; import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject; +import io.github.springwolf.asyncapi.v3.model.schema.SchemaType; import io.github.springwolf.core.asyncapi.scanners.common.headers.AsyncHeadersBuilder; -import io.github.springwolf.core.asyncapi.scanners.common.payload.NamedSchemaObject; +import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadSchemaObject; import java.util.Map; public class AsyncHeadersForAmqpBuilder implements AsyncHeadersBuilder { private static final SchemaObject headers = SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .title("SpringRabbitListenerDefaultHeaders") .properties(Map.of()) .build(); @Override - public SchemaObject buildHeaders(NamedSchemaObject payloadSchema) { + public SchemaObject buildHeaders(PayloadSchemaObject payloadSchema) { return headers; } } diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/asyncapi/components/header/AsyncHeadersForSpringKafkaBuilder.java b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/asyncapi/components/header/AsyncHeadersForSpringKafkaBuilder.java index 28f7d46a3..95a22b8d0 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/asyncapi/components/header/AsyncHeadersForSpringKafkaBuilder.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/asyncapi/components/header/AsyncHeadersForSpringKafkaBuilder.java @@ -2,6 +2,7 @@ package io.github.springwolf.plugins.kafka.asyncapi.components.header; import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject; +import io.github.springwolf.asyncapi.v3.model.schema.SchemaType; import org.springframework.kafka.support.mapping.AbstractJavaTypeMapper; import java.util.HashMap; @@ -16,7 +17,7 @@ public AsyncHeadersForSpringKafkaBuilder() { public AsyncHeadersForSpringKafkaBuilder(String schemaName) { this.headers = SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .title(schemaName) .properties(new HashMap<>()) .build(); @@ -34,7 +35,7 @@ public AsyncHeadersForSpringKafkaBuilder withTypeIdHeader(String exampleTypeId, private AsyncHeadersForSpringKafkaBuilder withHeader( String headerName, List types, String exampleType, String description) { SchemaObject header = new SchemaObject(); - header.setType("string"); + header.setType(SchemaType.STRING); header.setTitle(headerName); header.setDescription(description); header.setExamples(List.of(exampleType)); diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/common/header/AsyncHeadersForKafkaBuilder.java b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/common/header/AsyncHeadersForKafkaBuilder.java index b4aa80f71..8680e22c2 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/common/header/AsyncHeadersForKafkaBuilder.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/main/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/common/header/AsyncHeadersForKafkaBuilder.java @@ -3,12 +3,12 @@ import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject; import io.github.springwolf.core.asyncapi.scanners.common.headers.AsyncHeadersBuilder; -import io.github.springwolf.core.asyncapi.scanners.common.payload.NamedSchemaObject; +import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadSchemaObject; import io.github.springwolf.plugins.kafka.asyncapi.components.header.AsyncHeadersForSpringKafkaBuilder; public class AsyncHeadersForKafkaBuilder implements AsyncHeadersBuilder { @Override - public SchemaObject buildHeaders(NamedSchemaObject payloadSchema) { + public SchemaObject buildHeaders(PayloadSchemaObject payloadSchema) { return new AsyncHeadersForSpringKafkaBuilder("SpringKafkaDefaultHeaders-" + payloadSchema.title()) .withTypeIdHeader(payloadSchema.name()) .build(); diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/common/KafkaListenerUtilTest.java b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/common/KafkaListenerUtilTest.java index 5c1c1cbc3..329bfffa9 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/common/KafkaListenerUtilTest.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/asyncapi/scanners/common/KafkaListenerUtilTest.java @@ -8,6 +8,7 @@ import io.github.springwolf.asyncapi.v3.bindings.kafka.KafkaMessageBinding; import io.github.springwolf.asyncapi.v3.bindings.kafka.KafkaOperationBinding; import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject; +import io.github.springwolf.asyncapi.v3.model.schema.SchemaType; import org.assertj.core.util.Arrays; import org.assertj.core.util.Sets; import org.junit.jupiter.api.Nested; @@ -111,7 +112,8 @@ void buildMessageBinding() { void includeKafkaKeyHeader() { // given SchemaObject headerSchema = new SchemaObject(); - SchemaObject keySchema = SchemaObject.builder().type("string").build(); + SchemaObject keySchema = + SchemaObject.builder().type(SchemaType.STRING).build(); headerSchema.setProperties(Map.of(KafkaHeaders.RECEIVED_KEY, keySchema)); // when diff --git a/springwolf-plugins/springwolf-stomp-plugin/src/main/java/io/github/springwolf/plugins/stomp/asyncapi/scanners/common/header/AsyncHeadersForStompBuilder.java b/springwolf-plugins/springwolf-stomp-plugin/src/main/java/io/github/springwolf/plugins/stomp/asyncapi/scanners/common/header/AsyncHeadersForStompBuilder.java index 450ea9256..9ebc4ba69 100644 --- a/springwolf-plugins/springwolf-stomp-plugin/src/main/java/io/github/springwolf/plugins/stomp/asyncapi/scanners/common/header/AsyncHeadersForStompBuilder.java +++ b/springwolf-plugins/springwolf-stomp-plugin/src/main/java/io/github/springwolf/plugins/stomp/asyncapi/scanners/common/header/AsyncHeadersForStompBuilder.java @@ -2,21 +2,22 @@ package io.github.springwolf.plugins.stomp.asyncapi.scanners.common.header; import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject; +import io.github.springwolf.asyncapi.v3.model.schema.SchemaType; import io.github.springwolf.core.asyncapi.scanners.common.headers.AsyncHeadersBuilder; -import io.github.springwolf.core.asyncapi.scanners.common.payload.NamedSchemaObject; +import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadSchemaObject; import java.util.Map; public class AsyncHeadersForStompBuilder implements AsyncHeadersBuilder { private static final SchemaObject headers = SchemaObject.builder() - .type("object") + .type(SchemaType.OBJECT) .title("SpringStompDefaultHeaders") .properties(Map.of()) .build(); @Override - public SchemaObject buildHeaders(NamedSchemaObject payloadSchema) { + public SchemaObject buildHeaders(PayloadSchemaObject payloadSchema) { return headers; } } diff --git a/springwolf-plugins/springwolf-stomp-plugin/src/test/java/io/github/springwolf/plugins/stomp/asyncapi/scanners/operation/annotations/SendToCustomizerTest.java b/springwolf-plugins/springwolf-stomp-plugin/src/test/java/io/github/springwolf/plugins/stomp/asyncapi/scanners/operation/annotations/SendToCustomizerTest.java index 2347761f0..98af9a0ea 100644 --- a/springwolf-plugins/springwolf-stomp-plugin/src/test/java/io/github/springwolf/plugins/stomp/asyncapi/scanners/operation/annotations/SendToCustomizerTest.java +++ b/springwolf-plugins/springwolf-stomp-plugin/src/test/java/io/github/springwolf/plugins/stomp/asyncapi/scanners/operation/annotations/SendToCustomizerTest.java @@ -4,8 +4,8 @@ import io.github.springwolf.asyncapi.v3.model.channel.ChannelReference; import io.github.springwolf.asyncapi.v3.model.channel.message.MessageReference; import io.github.springwolf.asyncapi.v3.model.operation.Operation; -import io.github.springwolf.core.asyncapi.scanners.common.payload.NamedSchemaObject; import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadMethodReturnService; +import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadSchemaObject; import io.github.springwolf.plugins.stomp.asyncapi.scanners.bindings.StompBindingSendToFactory; import org.junit.jupiter.api.Test; import org.springframework.messaging.handler.annotation.SendTo; @@ -32,7 +32,7 @@ void customize() throws NoSuchMethodException { // given Operation operation = new Operation(); when(bindingFactory.getChannelName(any())).thenReturn(CHANNEL_ID); - when(payloadService.extractSchema(any())).thenReturn(new NamedSchemaObject(MESSAGE_ID, null)); + when(payloadService.extractSchema(any())).thenReturn(new PayloadSchemaObject(MESSAGE_ID, null)); // when sendToCustomizer.customize(operation, this.getClass().getDeclaredMethod("testMethod")); diff --git a/springwolf-plugins/springwolf-stomp-plugin/src/test/java/io/github/springwolf/plugins/stomp/asyncapi/scanners/operation/annotations/SendToUserCustomizerTest.java b/springwolf-plugins/springwolf-stomp-plugin/src/test/java/io/github/springwolf/plugins/stomp/asyncapi/scanners/operation/annotations/SendToUserCustomizerTest.java index 2732d54f3..960973648 100644 --- a/springwolf-plugins/springwolf-stomp-plugin/src/test/java/io/github/springwolf/plugins/stomp/asyncapi/scanners/operation/annotations/SendToUserCustomizerTest.java +++ b/springwolf-plugins/springwolf-stomp-plugin/src/test/java/io/github/springwolf/plugins/stomp/asyncapi/scanners/operation/annotations/SendToUserCustomizerTest.java @@ -4,8 +4,8 @@ import io.github.springwolf.asyncapi.v3.model.channel.ChannelReference; import io.github.springwolf.asyncapi.v3.model.channel.message.MessageReference; import io.github.springwolf.asyncapi.v3.model.operation.Operation; -import io.github.springwolf.core.asyncapi.scanners.common.payload.NamedSchemaObject; import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadMethodReturnService; +import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadSchemaObject; import io.github.springwolf.plugins.stomp.asyncapi.scanners.bindings.StompBindingSendToUserFactory; import org.junit.jupiter.api.Test; import org.springframework.messaging.simp.annotation.SendToUser; @@ -32,7 +32,7 @@ void customize() throws NoSuchMethodException { // given Operation operation = new Operation(); when(bindingFactory.getChannelName(any())).thenReturn(CHANNEL_ID); - when(payloadService.extractSchema(any())).thenReturn(new NamedSchemaObject(MESSAGE_ID, null)); + when(payloadService.extractSchema(any())).thenReturn(new PayloadSchemaObject(MESSAGE_ID, null)); // when sendToCustomizer.customize(operation, this.getClass().getDeclaredMethod("testMethod"));