diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaService.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaService.java index 8ef9a69d6..365787adb 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaService.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaService.java @@ -16,7 +16,6 @@ import io.swagger.v3.core.util.Json; import io.swagger.v3.core.util.PrimitiveType; import io.swagger.v3.core.util.RefUtils; -import io.swagger.v3.oas.models.media.ObjectSchema; import io.swagger.v3.oas.models.media.Schema; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -29,7 +28,6 @@ import java.util.List; import java.util.Map; import java.util.function.Function; -import java.util.stream.Collectors; import static io.github.springwolf.core.configuration.properties.SpringwolfConfigProperties.ConfigDocket.DEFAULT_CONTENT_TYPE; @@ -69,25 +67,10 @@ public record ExtractedSchemas(ComponentSchema rootSchema, Map properties = headers.getProperties().entrySet().stream() - .map((property) -> - Map.entry(property.getKey(), (Schema) swaggerSchemaUtil.mapToSwagger(property.getValue()))) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - headerSchema.setProperties(properties); + Schema headerSchema = swaggerSchemaUtil.mapToSwagger(headers); // call postprocessors - Map newSchemasToProcess = Map.of(schemaName, headerSchema); + Map newSchemasToProcess = Map.of(headerSchema.getName(), headerSchema); postProcessSchemas(newSchemasToProcess, new HashMap<>(newSchemasToProcess), DEFAULT_CONTENT_TYPE); // convert Swagger schema back to an AsnycApi SchemaObject diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaUtil.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaUtil.java index fb17b35ea..09e4d3427 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaUtil.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaUtil.java @@ -8,9 +8,9 @@ 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.swagger.v3.oas.models.media.ObjectSchema; import io.swagger.v3.oas.models.media.Schema; import lombok.RequiredArgsConstructor; -import org.springframework.lang.Nullable; import java.util.ArrayList; import java.util.HashSet; @@ -204,7 +204,7 @@ private static void assignType(Schema value, SchemaObject.SchemaObjectBuilder bu * @param schema * @return */ - public Object unwrapSchema(Object schema) { + private Object unwrapSchema(Object schema) { if (schema instanceof ComponentSchema componentSchema) { Object unwrappedSchema = componentSchema.getSchema(); if (unwrappedSchema == null) { @@ -238,7 +238,6 @@ public Object unwrapSchema(Object schema) { * @param schema Object representing an schema. * @return the resulting Schema */ - @Nullable public Schema mapToSwagger(Object schema) { // first unwrap ComponentSchema and MultiFormatSchema: Object unwrappedSchema = unwrapSchema(schema); @@ -246,13 +245,13 @@ public Schema mapToSwagger(Object schema) { if (unwrappedSchema instanceof Schema swaggerSchema) { return swaggerSchema; } - if (unwrappedSchema instanceof SchemaObject schemaObject) { return mapSchemaObjectToSwagger(schemaObject); } if (unwrappedSchema instanceof SchemaReference schemaReference) { return mapSchemaReferenceToSwagger(schemaReference); } + throw new RuntimeException("Could not convert '" + schema + "' to a Swagger Schema"); } @@ -260,13 +259,15 @@ public Schema mapToSwagger(Object schema) { * transforms the given asyncApiSchema {@link SchemaObject} to a Swagger schema object. *

Note

* This method does not perform a 'deep' transformation, only the root attributes of asyncApiSchema - * are mapped to the Swagger schema. The properties of asyncApiSchema will not be mapped to the - * Swagger schema. + * are mapped to the Swagger schema (best effort). * @param asyncApiSchema - * @return + * @return swagger Schema */ private Schema mapSchemaObjectToSwagger(SchemaObject asyncApiSchema) { - Schema swaggerSchema = new Schema(); + Schema swaggerSchema = new ObjectSchema(); + swaggerSchema.setName(asyncApiSchema.getTitle()); + swaggerSchema.setTitle(asyncApiSchema.getTitle()); + if (asyncApiSchema.getType() != null) { swaggerSchema.setType(asyncApiSchema.getType().stream() .filter(type -> !type.equals(SchemaType.NULL)) @@ -274,11 +275,18 @@ private Schema mapSchemaObjectToSwagger(SchemaObject asyncApiSchema) { .orElse(null)); swaggerSchema.setTypes(asyncApiSchema.getType()); } - // swaggerSchema.setFormat(asyncApiSchema.getFormat()); + swaggerSchema.setFormat(asyncApiSchema.getFormat()); swaggerSchema.setDescription(asyncApiSchema.getDescription()); swaggerSchema.setExamples(asyncApiSchema.getExamples()); swaggerSchema.setEnum(asyncApiSchema.getEnumValues()); + if (asyncApiSchema.getProperties() != null) { + Map properties = asyncApiSchema.getProperties().entrySet().stream() + .map((property) -> Map.entry(property.getKey(), (Schema) mapToSwagger(property.getValue()))) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + swaggerSchema.setProperties(properties); + } + return swaggerSchema; } 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 4216ca489..af81d92b9 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 @@ -2,6 +2,8 @@ package io.github.springwolf.core.asyncapi.components; import io.github.springwolf.asyncapi.v3.model.components.ComponentSchema; +import io.github.springwolf.asyncapi.v3.model.schema.MultiFormatSchema; +import io.github.springwolf.asyncapi.v3.model.schema.SchemaFormat; 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; @@ -15,6 +17,7 @@ import java.math.BigDecimal; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.stream.Stream; @@ -497,6 +500,20 @@ void mapMaxItems() { @Nested class MapToSwagger { + @Test + void mapNameAndTitle() { + // given + SchemaObject schema = new SchemaObject(); + schema.setTitle("title"); + + // when + Schema result = swaggerSchemaUtil.mapToSwagger(schema); + + // then + assertThat(result.getTitle()).isEqualTo(schema.getTitle()); + assertThat(result.getName()).isEqualTo(schema.getTitle()); + } + @Test void mapDescription() { // given @@ -504,10 +521,10 @@ void mapDescription() { schema.setDescription("description"); // when - Schema componentSchema = swaggerSchemaUtil.mapToSwagger(schema); + Schema result = swaggerSchemaUtil.mapToSwagger(schema); // then - assertThat(componentSchema.getDescription()).isEqualTo(schema.getDescription()); + assertThat(result.getDescription()).isEqualTo(schema.getDescription()); } @Test @@ -517,10 +534,10 @@ void mapExamples() { schema.setExamples(List.of("example1", "example2")); // when - Schema componentSchema = swaggerSchemaUtil.mapToSwagger(schema); + Schema result = swaggerSchemaUtil.mapToSwagger(schema); // then - assertThat(componentSchema.getExamples()).isEqualTo(schema.getExamples()); + assertThat(result.getExamples()).isEqualTo(schema.getExamples()); } @Test @@ -530,10 +547,10 @@ void mapEnum() { schema.setEnumValues(List.of("enum1", "enum2")); // when - Schema componentSchema = swaggerSchemaUtil.mapToSwagger(schema); + Schema result = swaggerSchemaUtil.mapToSwagger(schema); // then - assertThat(componentSchema.getEnum()).isEqualTo(schema.getEnumValues()); + assertThat(result.getEnum()).isEqualTo(schema.getEnumValues()); } @Test @@ -544,11 +561,11 @@ void mapNullableEnum() { schema.setTypes(Set.of(SchemaType.STRING, SchemaType.NULL)); // nullable // when - Schema componentSchema = swaggerSchemaUtil.mapToSwagger(schema); + Schema result = swaggerSchemaUtil.mapToSwagger(schema); // then - assertThat(componentSchema.getEnum()).isEqualTo(schema.getEnumValues()); - assertThat(componentSchema.getTypes()).isEqualTo(schema.getType()); + assertThat(result.getEnum()).isEqualTo(schema.getEnumValues()); + assertThat(result.getTypes()).isEqualTo(schema.getType()); } @Test @@ -558,10 +575,99 @@ void mapType() { schema.setType(SchemaType.STRING); // when - Schema componentSchema = swaggerSchemaUtil.mapToSwagger(schema); + Schema result = swaggerSchemaUtil.mapToSwagger(schema); + + // then + assertThat(result.getType()).isEqualTo(SchemaType.STRING); + } + + @Test + void mapFormat() { + // given + SchemaObject schema = new SchemaObject(); + schema.setType(SchemaType.STRING); + schema.setFormat("email"); + + // when + Schema result = swaggerSchemaUtil.mapToSwagger(schema); + + // then + assertThat(result.getType()).isEqualTo(SchemaType.STRING); + assertThat(result.getFormat()).isEqualTo("email"); + } + + @Test + void mapProperties() { + // given + SchemaObject property = new SchemaObject(); + property.setType(SchemaType.STRING); + + SchemaObject schema = new SchemaObject(); + schema.setProperties(Map.of("property", ComponentSchema.of(property))); + + // when + Schema result = swaggerSchemaUtil.mapToSwagger(schema); + + // then + assertThat(result.getProperties()).hasSize(1).containsKey("property"); + assertThat(((Schema) result.getProperties().get("property")).getType()) + .isEqualTo(SchemaType.STRING); + } + + @Test + void mapComponentSchemaSchema() { + // given + SchemaObject schema = new SchemaObject(); + schema.setType(SchemaType.STRING); + + MultiFormatSchema multiFormatSchema = new MultiFormatSchema(SchemaFormat.DEFAULT.toString(), schema); + ComponentSchema componentSchema = ComponentSchema.of(multiFormatSchema); + + // when + Schema result = swaggerSchemaUtil.mapToSwagger(componentSchema); + + // then + assertThat(result.getType()).isEqualTo(SchemaType.STRING); + } + + @Test + void mapMultiFormatSchema() { + // given + SchemaObject schema = new SchemaObject(); + schema.setType(SchemaType.STRING); + + MultiFormatSchema multiFormatSchema = new MultiFormatSchema(SchemaFormat.DEFAULT.toString(), schema); + + // when + Schema result = swaggerSchemaUtil.mapToSwagger(multiFormatSchema); + + // then + assertThat(result.getType()).isEqualTo(SchemaType.STRING); + } + + @Test + void mapReference() { + // given + SchemaReference reference = new SchemaReference("#/components/schemas/MySchema"); + + // when + Schema result = swaggerSchemaUtil.mapToSwagger(reference); + + // then + assertThat(result.get$ref()).isEqualTo(reference.getRef()); + } + + @Test + void doNotMapAlreadyMappedSchema() { + // given + Schema schema = new Schema(); + schema.setType(SchemaType.STRING); + + // when + Schema result = swaggerSchemaUtil.mapToSwagger(schema); // then - assertThat(componentSchema.getType()).isEqualTo(SchemaType.STRING); + assertThat(result).isSameAs(schema); } } } diff --git a/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.json b/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.json index f1eda6a7b..21d14f869 100644 --- a/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.json +++ b/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.json @@ -268,6 +268,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -278,6 +279,7 @@ ] }, "ce_id": { + "title": "ce_id", "type": "string", "description": "CloudEvent Id Header", "enum": [ @@ -288,6 +290,7 @@ ] }, "ce_source": { + "title": "ce_source", "type": "string", "description": "CloudEvent Source Header", "enum": [ @@ -298,6 +301,7 @@ ] }, "ce_specversion": { + "title": "ce_specversion", "type": "string", "description": "CloudEvent Spec Version Header", "enum": [ @@ -308,6 +312,7 @@ ] }, "ce_subject": { + "title": "ce_subject", "type": "string", "description": "CloudEvent Subject Header", "enum": [ @@ -318,6 +323,7 @@ ] }, "ce_time": { + "title": "ce_time", "type": "string", "description": "CloudEvent Time Header", "enum": [ @@ -328,6 +334,7 @@ ] }, "ce_type": { + "title": "ce_type", "type": "string", "description": "CloudEvent Payload Type Header", "enum": [ @@ -338,6 +345,7 @@ ] }, "content-type": { + "title": "content-type", "type": "string", "description": "CloudEvent Content-Type Header", "enum": [ @@ -370,6 +378,7 @@ "enum": [ "io.github.springwolf.examples.kafka.dtos.NestedPayloadDto" ], + "title": "__TypeId__", "type": "string" }, "ce_id": { @@ -377,6 +386,7 @@ "enum": [ "2c60089e-6f39-459d-8ced-2d6df7e4c03a" ], + "title": "ce_id", "type": "string" }, "ce_source": { @@ -384,6 +394,7 @@ "enum": [ "http://localhost" ], + "title": "ce_source", "type": "string" }, "ce_specversion": { @@ -391,6 +402,7 @@ "enum": [ "1.0" ], + "title": "ce_specversion", "type": "string" }, "ce_subject": { @@ -398,6 +410,7 @@ "enum": [ "Springwolf example project - Kafka" ], + "title": "ce_subject", "type": "string" }, "ce_time": { @@ -405,6 +418,7 @@ "enum": [ "2023-10-28 20:01:23+00:00" ], + "title": "ce_time", "type": "string" }, "ce_type": { @@ -412,6 +426,7 @@ "enum": [ "NestedPayloadDto.v1" ], + "title": "ce_type", "type": "string" }, "content-type": { @@ -419,6 +434,7 @@ "enum": [ "application/json" ], + "title": "content-type", "type": "string" } }, @@ -431,6 +447,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -454,6 +471,7 @@ "enum": [ "io.github.springwolf.examples.kafka.dto.avro.AnotherPayloadAvroDto" ], + "title": "__TypeId__", "type": "string" } }, @@ -466,6 +484,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -489,6 +508,7 @@ "enum": [ "io.github.springwolf.examples.kafka.dtos.AnotherPayloadDto" ], + "title": "__TypeId__", "type": "string" } }, @@ -501,6 +521,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -512,6 +533,7 @@ }, "kafka_offset": { "type": "integer", + "format": "int32", "examples": [ 0 ] @@ -523,6 +545,7 @@ ] }, "kafka_recordMetadata": { + "title": "ConsumerRecordMetadata", "type": "object", "examples": [ { } @@ -531,10 +554,10 @@ }, "examples": [ { + "ConsumerRecordMetadata": { }, "__TypeId__": "io.github.springwolf.examples.kafka.dtos.ExamplePayloadDto", "kafka_offset": 0, - "kafka_receivedMessageKey": "string", - "kafka_recordMetadata": { } + "kafka_receivedMessageKey": "string" } ], "x-json-schema": { @@ -545,15 +568,18 @@ "enum": [ "io.github.springwolf.examples.kafka.dtos.ExamplePayloadDto" ], + "title": "__TypeId__", "type": "string" }, "kafka_offset": { + "format": "int32", "type": "integer" }, "kafka_receivedMessageKey": { "type": "string" }, "kafka_recordMetadata": { + "title": "ConsumerRecordMetadata", "type": "object" } }, @@ -566,6 +592,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -589,6 +616,7 @@ "enum": [ "io.github.springwolf.examples.kafka.dto.proto.ExamplePayloadProtobufDto.Message" ], + "title": "__TypeId__", "type": "string" } }, @@ -601,6 +629,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -624,6 +653,7 @@ "enum": [ "javax.money.MonetaryAmount" ], + "title": "__TypeId__", "type": "string" } }, @@ -636,6 +666,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -659,6 +690,7 @@ "enum": [ "PayloadNotUsed" ], + "title": "__TypeId__", "type": "string" } }, @@ -671,6 +703,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -694,6 +727,7 @@ "enum": [ "io.github.springwolf.examples.kafka.dtos.RequiredAndNullablePayloadDto" ], + "title": "__TypeId__", "type": "string" } }, @@ -706,6 +740,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -729,6 +764,7 @@ "enum": [ "io.github.springwolf.examples.kafka.dtos.discriminator.VehicleBase" ], + "title": "__TypeId__", "type": "string" } }, @@ -741,6 +777,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -764,6 +801,7 @@ "enum": [ "io.github.springwolf.examples.kafka.dtos.XmlPayloadDto" ], + "title": "__TypeId__", "type": "string" } }, @@ -776,6 +814,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -799,6 +838,7 @@ "enum": [ "io.github.springwolf.examples.kafka.dtos.YamlPayloadDto" ], + "title": "__TypeId__", "type": "string" } }, @@ -811,6 +851,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -834,6 +875,7 @@ "enum": [ "java.lang.Integer" ], + "title": "__TypeId__", "type": "string" } }, @@ -846,6 +888,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -869,6 +912,7 @@ "enum": [ "java.lang.String" ], + "title": "__TypeId__", "type": "string" } }, diff --git a/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.yaml b/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.yaml index b0c056945..25b58406b 100644 --- a/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.yaml +++ b/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.yaml @@ -182,6 +182,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -189,6 +190,7 @@ components: examples: - io.github.springwolf.examples.kafka.dtos.NestedPayloadDto ce_id: + title: ce_id type: string description: CloudEvent Id Header enum: @@ -196,6 +198,7 @@ components: examples: - 2c60089e-6f39-459d-8ced-2d6df7e4c03a ce_source: + title: ce_source type: string description: CloudEvent Source Header enum: @@ -203,6 +206,7 @@ components: examples: - http://localhost ce_specversion: + title: ce_specversion type: string description: CloudEvent Spec Version Header enum: @@ -210,6 +214,7 @@ components: examples: - "1.0" ce_subject: + title: ce_subject type: string description: CloudEvent Subject Header enum: @@ -217,6 +222,7 @@ components: examples: - Springwolf example project - Kafka ce_time: + title: ce_time type: string description: CloudEvent Time Header enum: @@ -224,6 +230,7 @@ components: examples: - 2023-10-28 20:01:23+00:00 ce_type: + title: ce_type type: string description: CloudEvent Payload Type Header enum: @@ -231,6 +238,7 @@ components: examples: - NestedPayloadDto.v1 content-type: + title: content-type type: string description: CloudEvent Content-Type Header enum: @@ -255,41 +263,49 @@ components: description: Spring Type Id Header enum: - io.github.springwolf.examples.kafka.dtos.NestedPayloadDto + title: __TypeId__ type: string ce_id: description: CloudEvent Id Header enum: - 2c60089e-6f39-459d-8ced-2d6df7e4c03a + title: ce_id type: string ce_source: description: CloudEvent Source Header enum: - http://localhost + title: ce_source type: string ce_specversion: description: CloudEvent Spec Version Header enum: - "1.0" + title: ce_specversion type: string ce_subject: description: CloudEvent Subject Header enum: - Springwolf example project - Kafka + title: ce_subject type: string ce_time: description: CloudEvent Time Header enum: - 2023-10-28 20:01:23+00:00 + title: ce_time type: string ce_type: description: CloudEvent Payload Type Header enum: - NestedPayloadDto.v1 + title: ce_type type: string content-type: description: CloudEvent Content-Type Header enum: - application/json + title: content-type type: string title: SpringDefaultHeaderAndCloudEvent type: object @@ -298,6 +314,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -313,6 +330,7 @@ components: description: Spring Type Id Header enum: - io.github.springwolf.examples.kafka.dto.avro.AnotherPayloadAvroDto + title: __TypeId__ type: string title: SpringKafkaDefaultHeaders-AnotherPayloadAvroDto type: object @@ -321,6 +339,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -336,6 +355,7 @@ components: description: Spring Type Id Header enum: - io.github.springwolf.examples.kafka.dtos.AnotherPayloadDto + title: __TypeId__ type: string title: SpringKafkaDefaultHeaders-AnotherPayloadDto type: object @@ -344,6 +364,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -352,6 +373,7 @@ components: - io.github.springwolf.examples.kafka.dtos.ExamplePayloadDto kafka_offset: type: integer + format: int32 examples: - 0 kafka_receivedMessageKey: @@ -359,14 +381,15 @@ components: examples: - '"string"' kafka_recordMetadata: + title: ConsumerRecordMetadata type: object examples: - {} examples: - - __TypeId__: io.github.springwolf.examples.kafka.dtos.ExamplePayloadDto + - ConsumerRecordMetadata: {} + __TypeId__: io.github.springwolf.examples.kafka.dtos.ExamplePayloadDto kafka_offset: 0 kafka_receivedMessageKey: string - kafka_recordMetadata: {} x-json-schema: $schema: https://json-schema.org/draft-04/schema# properties: @@ -374,12 +397,15 @@ components: description: Spring Type Id Header enum: - io.github.springwolf.examples.kafka.dtos.ExamplePayloadDto + title: __TypeId__ type: string kafka_offset: + format: int32 type: integer kafka_receivedMessageKey: type: string kafka_recordMetadata: + title: ConsumerRecordMetadata type: object title: SpringKafkaDefaultHeaders-ExamplePayloadDto-546532105 type: object @@ -388,6 +414,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -403,6 +430,7 @@ components: description: Spring Type Id Header enum: - io.github.springwolf.examples.kafka.dto.proto.ExamplePayloadProtobufDto.Message + title: __TypeId__ type: string title: SpringKafkaDefaultHeaders-Message type: object @@ -411,6 +439,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -426,6 +455,7 @@ components: description: Spring Type Id Header enum: - javax.money.MonetaryAmount + title: __TypeId__ type: string title: SpringKafkaDefaultHeaders-MonetaryAmount type: object @@ -434,6 +464,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -449,6 +480,7 @@ components: description: Spring Type Id Header enum: - PayloadNotUsed + title: __TypeId__ type: string title: SpringKafkaDefaultHeaders-PayloadNotUsed type: object @@ -457,6 +489,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -472,6 +505,7 @@ components: description: Spring Type Id Header enum: - io.github.springwolf.examples.kafka.dtos.RequiredAndNullablePayloadDto + title: __TypeId__ type: string title: SpringKafkaDefaultHeaders-RequiredAndNullablePayloadDto type: object @@ -480,6 +514,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -495,6 +530,7 @@ components: description: Spring Type Id Header enum: - io.github.springwolf.examples.kafka.dtos.discriminator.VehicleBase + title: __TypeId__ type: string title: SpringKafkaDefaultHeaders-VehicleBase type: object @@ -503,6 +539,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -518,6 +555,7 @@ components: description: Spring Type Id Header enum: - io.github.springwolf.examples.kafka.dtos.XmlPayloadDto + title: __TypeId__ type: string title: SpringKafkaDefaultHeaders-XmlPayloadDto type: object @@ -526,6 +564,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -541,6 +580,7 @@ components: description: Spring Type Id Header enum: - io.github.springwolf.examples.kafka.dtos.YamlPayloadDto + title: __TypeId__ type: string title: SpringKafkaDefaultHeaders-YamlPayloadDto type: object @@ -549,6 +589,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -564,6 +605,7 @@ components: description: Spring Type Id Header enum: - java.lang.Integer + title: __TypeId__ type: string title: SpringKafkaDefaultHeaders-integer type: object @@ -572,6 +614,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -587,6 +630,7 @@ components: description: Spring Type Id Header enum: - java.lang.String + title: __TypeId__ type: string title: SpringKafkaDefaultHeaders-string type: object diff --git a/springwolf-examples/springwolf-kafka-example/src/test/resources/groups/vehicles.json b/springwolf-examples/springwolf-kafka-example/src/test/resources/groups/vehicles.json index c12aae7ee..024c7856d 100644 --- a/springwolf-examples/springwolf-kafka-example/src/test/resources/groups/vehicles.json +++ b/springwolf-examples/springwolf-kafka-example/src/test/resources/groups/vehicles.json @@ -45,6 +45,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -68,6 +69,7 @@ "enum": [ "io.github.springwolf.examples.kafka.dtos.discriminator.VehicleBase" ], + "title": "__TypeId__", "type": "string" } },