diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaMapper.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaMapper.java index ea920ff4f..95df2db2f 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaMapper.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaMapper.java @@ -9,9 +9,9 @@ import io.github.springwolf.asyncapi.v3.model.schema.SchemaType; import io.github.springwolf.core.configuration.properties.PayloadSchemaFormat; import io.github.springwolf.core.configuration.properties.SpringwolfConfigProperties; +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; @@ -220,7 +220,7 @@ private static void assignType(Schema swaggerSchema, SchemaObject.SchemaObjectBu * @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) { @@ -250,7 +250,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); @@ -258,13 +257,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"); } @@ -272,14 +271,16 @@ 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)) @@ -292,6 +293,13 @@ private Schema mapSchemaObjectToSwagger(SchemaObject asyncApiSchema) { 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/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 c518df12c..6fa45085e 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 @@ -15,7 +15,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.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -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; @@ -59,25 +57,10 @@ public record ExtractedSchemas(ComponentSchema rootSchema, Map properties = schemaWithoutRef.getProperties().entrySet().stream() - .map((property) -> - Map.entry(property.getKey(), (Schema) swaggerSchemaMapper.mapToSwagger(property.getValue()))) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - headerSchema.setProperties(properties); + Schema headerSchema = swaggerSchemaMapper.mapToSwagger(schemaWithoutRef); // 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 AsyncApi SchemaObject diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/SwaggerSchemaMapperTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/SwaggerSchemaMapperTest.java index ada1865f2..771c703bc 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/SwaggerSchemaMapperTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/components/SwaggerSchemaMapperTest.java @@ -20,6 +20,7 @@ import java.math.BigDecimal; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.stream.Stream; @@ -638,6 +639,20 @@ void mapMaxItems() { @Nested class MapToSwagger { + @Test + void mapNameAndTitle() { + // given + SchemaObject schema = new SchemaObject(); + schema.setTitle("title"); + + // when + Schema swaggerSchema = swaggerSchemaMapper.mapToSwagger(schema); + + // then + assertThat(swaggerSchema.getTitle()).isEqualTo(schema.getTitle()); + assertThat(swaggerSchema.getName()).isEqualTo(schema.getTitle()); + } + @Test void mapDescription() { // given @@ -651,6 +666,21 @@ void mapDescription() { assertThat(swaggerSchema.getDescription()).isEqualTo(schema.getDescription()); } + @Test + void mapFormat() { + // given + SchemaObject schema = new SchemaObject(); + schema.setType(SchemaType.STRING); + schema.setFormat("email"); + + // when + Schema swaggerSchema = swaggerSchemaMapper.mapToSwagger(schema); + + // then + assertThat(swaggerSchema.getType()).isEqualTo(SchemaType.STRING); + assertThat(swaggerSchema.getFormat()).isEqualTo("email"); + } + @Test void mapExamples() { // given @@ -704,5 +734,79 @@ void mapType() { // then assertThat(swaggerSchema.getType()).isEqualTo(SchemaType.STRING); } + + @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 swaggerSchema = swaggerSchemaMapper.mapToSwagger(schema); + + // then + assertThat(swaggerSchema.getProperties()).hasSize(1).containsKey("property"); + assertThat((swaggerSchema.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 swaggerSchema = swaggerSchemaMapper.mapToSwagger(componentSchema); + + // then + assertThat(swaggerSchema.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 swaggerSchema = swaggerSchemaMapper.mapToSwagger(multiFormatSchema); + + // then + assertThat(swaggerSchema.getType()).isEqualTo(SchemaType.STRING); + } + + @Test + void mapReference() { + // given + SchemaReference reference = new SchemaReference("#/components/schemas/MySchema"); + + // when + Schema swaggerSchema = swaggerSchemaMapper.mapToSwagger(reference); + + // then + assertThat(swaggerSchema.get$ref()).isEqualTo(reference.getRef()); + } + + @Test + void doNotMapAlreadyMappedSchema() { + // given + Schema schema = new Schema<>(); + schema.setType(SchemaType.STRING); + + // when + Schema swaggerSchema = swaggerSchemaMapper.mapToSwagger(schema); + + // then + assertThat(swaggerSchema).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 60518b6bb..a08bbe78f 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,10 +521,12 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Type ID" }, "my_uuid_field": { + "title": "my_uuid_field", "type": "string", "description": "Event identifier", "format": "uuid" @@ -521,11 +543,13 @@ "properties": { "__TypeId__": { "description": "Type ID", + "title": "__TypeId__", "type": "string" }, "my_uuid_field": { "description": "Event identifier", "format": "uuid", + "title": "my_uuid_field", "type": "string" } }, @@ -538,6 +562,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -561,6 +586,7 @@ ] }, "kafka_recordMetadata": { + "title": "ConsumerRecordMetadata", "type": "object", "examples": [ { } @@ -569,10 +595,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": { @@ -583,6 +609,7 @@ "enum": [ "io.github.springwolf.examples.kafka.dtos.ExamplePayloadDto" ], + "title": "__TypeId__", "type": "string" }, "kafka_offset": { @@ -593,6 +620,7 @@ "type": "string" }, "kafka_recordMetadata": { + "title": "ConsumerRecordMetadata", "type": "object" } }, @@ -605,6 +633,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -628,6 +657,7 @@ "enum": [ "io.github.springwolf.examples.kafka.dto.proto.ExamplePayloadProtobufDto.Message" ], + "title": "__TypeId__", "type": "string" } }, @@ -640,6 +670,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -663,6 +694,7 @@ "enum": [ "javax.money.MonetaryAmount" ], + "title": "__TypeId__", "type": "string" } }, @@ -675,6 +707,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -698,6 +731,7 @@ "enum": [ "PayloadNotUsed" ], + "title": "__TypeId__", "type": "string" } }, @@ -710,6 +744,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -733,6 +768,7 @@ "enum": [ "io.github.springwolf.examples.kafka.dtos.RequiredAndNullablePayloadDto" ], + "title": "__TypeId__", "type": "string" } }, @@ -745,6 +781,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -768,6 +805,7 @@ "enum": [ "io.github.springwolf.examples.kafka.dtos.discriminator.VehicleBase" ], + "title": "__TypeId__", "type": "string" } }, @@ -780,6 +818,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -803,6 +842,7 @@ "enum": [ "io.github.springwolf.examples.kafka.dtos.XmlPayloadDto" ], + "title": "__TypeId__", "type": "string" } }, @@ -815,6 +855,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -838,6 +879,7 @@ "enum": [ "io.github.springwolf.examples.kafka.dtos.YamlPayloadDto" ], + "title": "__TypeId__", "type": "string" } }, @@ -850,6 +892,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -873,6 +916,7 @@ "enum": [ "java.lang.Integer" ], + "title": "__TypeId__", "type": "string" } }, @@ -885,6 +929,7 @@ "type": "object", "properties": { "__TypeId__": { + "title": "__TypeId__", "type": "string", "description": "Spring Type Id Header", "enum": [ @@ -908,6 +953,7 @@ "enum": [ "java.lang.String" ], + "title": "__TypeId__", "type": "string" } }, diff --git a/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.openapiv31.json b/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.openapiv31.json index 6e5451b02..a341ec25f 100644 --- a/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.openapiv31.json +++ b/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.openapiv31.json @@ -272,7 +272,8 @@ ], "examples": [ "io.github.springwolf.examples.kafka.dtos.NestedPayloadDto" - ] + ], + "title": "__TypeId__" }, "ce_id": { "type": "string", @@ -282,7 +283,8 @@ ], "examples": [ "2c60089e-6f39-459d-8ced-2d6df7e4c03a" - ] + ], + "title": "ce_id" }, "ce_source": { "type": "string", @@ -292,7 +294,8 @@ ], "examples": [ "http://localhost" - ] + ], + "title": "ce_source" }, "ce_specversion": { "type": "string", @@ -302,7 +305,8 @@ ], "examples": [ "1.0" - ] + ], + "title": "ce_specversion" }, "ce_subject": { "type": "string", @@ -312,7 +316,8 @@ ], "examples": [ "Springwolf example project - Kafka" - ] + ], + "title": "ce_subject" }, "ce_time": { "type": "string", @@ -322,7 +327,8 @@ ], "examples": [ "2023-10-28 20:01:23+00:00" - ] + ], + "title": "ce_time" }, "ce_type": { "type": "string", @@ -332,7 +338,8 @@ ], "examples": [ "NestedPayloadDto.v1" - ] + ], + "title": "ce_type" }, "content-type": { "type": "string", @@ -342,7 +349,8 @@ ], "examples": [ "application/json" - ] + ], + "title": "content-type" } }, "title": "SpringDefaultHeaderAndCloudEvent" @@ -364,7 +372,8 @@ ], "examples": [ "io.github.springwolf.examples.kafka.dto.avro.AnotherPayloadAvroDto" - ] + ], + "title": "__TypeId__" } }, "title": "SpringKafkaDefaultHeaders-AnotherPayloadAvroDto" @@ -386,7 +395,8 @@ ], "examples": [ "io.github.springwolf.examples.kafka.dtos.AnotherPayloadDto" - ] + ], + "title": "__TypeId__" } }, "title": "SpringKafkaDefaultHeaders-AnotherPayloadDto" @@ -403,12 +413,14 @@ "properties": { "__TypeId__": { "type": "string", - "description": "Type ID" + "description": "Type ID", + "title": "__TypeId__" }, "my_uuid_field": { "type": "string", "format": "uuid", - "description": "Event identifier" + "description": "Event identifier", + "title": "my_uuid_field" } }, "title": "SpringKafkaDefaultHeaders-AnotherTopic" @@ -433,7 +445,8 @@ ], "examples": [ "io.github.springwolf.examples.kafka.dtos.ExamplePayloadDto" - ] + ], + "title": "__TypeId__" }, "kafka_offset": { "type": "integer", @@ -468,7 +481,8 @@ ], "examples": [ "io.github.springwolf.examples.kafka.dto.proto.ExamplePayloadProtobufDto.Message" - ] + ], + "title": "__TypeId__" } }, "title": "SpringKafkaDefaultHeaders-Message" @@ -490,7 +504,8 @@ ], "examples": [ "javax.money.MonetaryAmount" - ] + ], + "title": "__TypeId__" } }, "title": "SpringKafkaDefaultHeaders-MonetaryAmount" @@ -512,7 +527,8 @@ ], "examples": [ "PayloadNotUsed" - ] + ], + "title": "__TypeId__" } }, "title": "SpringKafkaDefaultHeaders-PayloadNotUsed" @@ -534,7 +550,8 @@ ], "examples": [ "io.github.springwolf.examples.kafka.dtos.RequiredAndNullablePayloadDto" - ] + ], + "title": "__TypeId__" } }, "title": "SpringKafkaDefaultHeaders-RequiredAndNullablePayloadDto" @@ -556,7 +573,8 @@ ], "examples": [ "io.github.springwolf.examples.kafka.dtos.discriminator.VehicleBase" - ] + ], + "title": "__TypeId__" } }, "title": "SpringKafkaDefaultHeaders-VehicleBase" @@ -578,7 +596,8 @@ ], "examples": [ "io.github.springwolf.examples.kafka.dtos.XmlPayloadDto" - ] + ], + "title": "__TypeId__" } }, "title": "SpringKafkaDefaultHeaders-XmlPayloadDto" @@ -600,7 +619,8 @@ ], "examples": [ "io.github.springwolf.examples.kafka.dtos.YamlPayloadDto" - ] + ], + "title": "__TypeId__" } }, "title": "SpringKafkaDefaultHeaders-YamlPayloadDto" @@ -622,7 +642,8 @@ ], "examples": [ "java.lang.Integer" - ] + ], + "title": "__TypeId__" } }, "title": "SpringKafkaDefaultHeaders-integer" @@ -644,7 +665,8 @@ ], "examples": [ "java.lang.String" - ] + ], + "title": "__TypeId__" } }, "title": "SpringKafkaDefaultHeaders-string" @@ -1682,4 +1704,4 @@ ] } } -} +} \ No newline at end of file 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 7af9075df..c02de4d7f 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,9 +364,11 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Type ID my_uuid_field: + title: my_uuid_field type: string description: Event identifier format: uuid @@ -358,10 +380,12 @@ components: properties: __TypeId__: description: Type ID + title: __TypeId__ type: string my_uuid_field: description: Event identifier format: uuid + title: my_uuid_field type: string title: SpringKafkaDefaultHeaders-AnotherTopic type: object @@ -370,6 +394,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -386,14 +411,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: @@ -401,6 +427,7 @@ components: description: Spring Type Id Header enum: - io.github.springwolf.examples.kafka.dtos.ExamplePayloadDto + title: __TypeId__ type: string kafka_offset: format: int32 @@ -408,6 +435,7 @@ components: kafka_receivedMessageKey: type: string kafka_recordMetadata: + title: ConsumerRecordMetadata type: object title: SpringKafkaDefaultHeaders-ExamplePayloadDto-546532105 type: object @@ -416,6 +444,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -431,6 +460,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 @@ -439,6 +469,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -454,6 +485,7 @@ components: description: Spring Type Id Header enum: - javax.money.MonetaryAmount + title: __TypeId__ type: string title: SpringKafkaDefaultHeaders-MonetaryAmount type: object @@ -462,6 +494,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -477,6 +510,7 @@ components: description: Spring Type Id Header enum: - PayloadNotUsed + title: __TypeId__ type: string title: SpringKafkaDefaultHeaders-PayloadNotUsed type: object @@ -485,6 +519,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -500,6 +535,7 @@ components: description: Spring Type Id Header enum: - io.github.springwolf.examples.kafka.dtos.RequiredAndNullablePayloadDto + title: __TypeId__ type: string title: SpringKafkaDefaultHeaders-RequiredAndNullablePayloadDto type: object @@ -508,6 +544,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -523,6 +560,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 @@ -531,6 +569,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -546,6 +585,7 @@ components: description: Spring Type Id Header enum: - io.github.springwolf.examples.kafka.dtos.XmlPayloadDto + title: __TypeId__ type: string title: SpringKafkaDefaultHeaders-XmlPayloadDto type: object @@ -554,6 +594,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -569,6 +610,7 @@ components: description: Spring Type Id Header enum: - io.github.springwolf.examples.kafka.dtos.YamlPayloadDto + title: __TypeId__ type: string title: SpringKafkaDefaultHeaders-YamlPayloadDto type: object @@ -577,6 +619,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -592,6 +635,7 @@ components: description: Spring Type Id Header enum: - java.lang.Integer + title: __TypeId__ type: string title: SpringKafkaDefaultHeaders-integer type: object @@ -600,6 +644,7 @@ components: type: object properties: __TypeId__: + title: __TypeId__ type: string description: Spring Type Id Header enum: @@ -615,6 +660,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" } },