diff --git a/springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/addons/common_model_converters/converters/monetaryamount/MonetaryAmount.java b/springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/addons/common_model_converters/converters/monetaryamount/MonetaryAmount.java index ea6d52de3..25d76d649 100644 --- a/springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/addons/common_model_converters/converters/monetaryamount/MonetaryAmount.java +++ b/springwolf-add-ons/springwolf-common-model-converters/src/main/java/io/github/stavshamir/springwolf/addons/common_model_converters/converters/monetaryamount/MonetaryAmount.java @@ -10,7 +10,7 @@ class MonetaryAmount { @JsonProperty("amount") - @Schema(example = "99.99") + @Schema(example = "99.99", minimum = "0.1") private BigDecimal amount; @JsonProperty("currency") diff --git a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/stavshamir/springwolf/example/kafka/consumers/ExampleConsumer.java b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/stavshamir/springwolf/example/kafka/consumers/ExampleConsumer.java index 784f6b5eb..a9d9791c2 100644 --- a/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/stavshamir/springwolf/example/kafka/consumers/ExampleConsumer.java +++ b/springwolf-examples/springwolf-kafka-example/src/main/java/io/github/stavshamir/springwolf/example/kafka/consumers/ExampleConsumer.java @@ -29,6 +29,11 @@ public void receiveExamplePayload(ExamplePayloadDto payload) { anotherProducer.sendMessage(example); } + @KafkaListener(topics = "primitive-topic") + public void receivePrimitivePayload(String primitivePayload) { + log.info("Received new messages in primitive-topic: {}", primitivePayload); + } + @KafkaListener(topics = "another-topic", groupId = "example-group-id", batch = "true") public void receiveAnotherPayloadBatched(List payloads) { log.info("Received new messages in another-topic: {}", payloads.toString()); diff --git a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/SpringContextIntegrationTest.java b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/SpringContextIntegrationTest.java index 67f22580d..9d0274d23 100644 --- a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/SpringContextIntegrationTest.java +++ b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/SpringContextIntegrationTest.java @@ -48,7 +48,7 @@ void testContextWithApplicationProperties() { @Test void testAllChannelsAreFound() { - assertThat(asyncApiService.getAsyncAPI().getChannels()).hasSize(4); + assertThat(asyncApiService.getAsyncAPI().getChannels()).hasSize(5); } } 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 51d971788..a952aa847 100644 --- a/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.json +++ b/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.json @@ -172,6 +172,38 @@ } } }, + "primitive-topic": { + "publish": { + "operationId": "primitive-topic_publish_receivePrimitivePayload", + "description": "Auto-generated description", + "bindings": { + "kafka": { + "bindingVersion": "0.4.0" + } + }, + "message": { + "schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0", + "name": "java.lang.String", + "title": "String", + "payload": { + "$ref": "#/components/schemas/String" + }, + "headers": { + "$ref": "#/components/schemas/HeadersNotDocumented" + }, + "bindings": { + "kafka": { + "bindingVersion": "0.4.0" + } + } + } + }, + "bindings": { + "kafka": { + "bindingVersion": "0.4.0" + } + } + }, "topic-defined-via-asyncPublisher-annotation": { "subscribe": { "operationId": "topic-defined-via-asyncPublisher-annotation_subscribe", @@ -456,10 +488,19 @@ "type": "object" } }, + "String": { + "type": "string", + "example": "string", + "x-json-schema": { + "$schema": "https://json-schema.org/draft-04/schema#", + "type": "string" + } + }, "io.github.stavshamir.springwolf.addons.common_model_converters.converters.monetaryamount.MonetaryAmount": { "type": "object", "properties": { "amount": { + "minimum": 0.1, "type": "number", "example": 99.99 }, @@ -477,6 +518,7 @@ "name": "io.github.stavshamir.springwolf.addons.common_model_converters.converters.monetaryamount.MonetaryAmount", "properties": { "amount": { + "minimum": 0.1, "name": "amount", "type": "number" }, diff --git a/springwolf-ui/src/app/components/schemas/schema/schema.component.css b/springwolf-ui/src/app/components/schemas/schema/schema.component.css index 92adde268..19d2fefe5 100644 --- a/springwolf-ui/src/app/components/schemas/schema/schema.component.css +++ b/springwolf-ui/src/app/components/schemas/schema/schema.component.css @@ -12,6 +12,10 @@ color: red; } +.type-content { + display: flex; +} + .type { color: #55a; } @@ -20,3 +24,11 @@ color: #6b6b6b; font-style: italic; } + +.range { + background-color: rgb(128, 90, 213); + color: rgb(255, 255, 255); + margin: 0 8 0 8; + padding: 2 4 2 4; + border-radius: 4px; +} diff --git a/springwolf-ui/src/app/components/schemas/schema/schema.component.html b/springwolf-ui/src/app/components/schemas/schema/schema.component.html index 4057dd0bd..67af11ea9 100644 --- a/springwolf-ui/src/app/components/schemas/schema/schema.component.html +++ b/springwolf-ui/src/app/components/schemas/schema/schema.component.html @@ -1,6 +1,15 @@ + + + + + +
{{ property.key }} @@ -21,25 +30,53 @@ > - {{ - property.value.type - }} - - {{ property.value.refTitle }} - - ({{ property.value.format }}) -
{{ property.value.description }}
- example: {{ property.value.example.value }} - - {{ - enum - }} - +
+ + +
+ {{ value.type }} + + + +
+ + + {{ value.refTitle }} + + ({{ value.format }}) +
{{ value.description }}
+ example: {{ value.example.value }} + + {{ enum }} + + +
+ + + + >= {{ minimum }} + + + <= {{ maximum }} + + + [ {{ minimum }} .. {{ maximum }} ] + + diff --git a/springwolf-ui/src/app/components/schemas/schemas.component.css b/springwolf-ui/src/app/components/schemas/schemas.component.css index 575231555..0eae36c5b 100644 --- a/springwolf-ui/src/app/components/schemas/schemas.component.css +++ b/springwolf-ui/src/app/components/schemas/schemas.component.css @@ -9,3 +9,14 @@ h3 { padding: 6px; font-weight: normal; } + +.badge { +} + +.type-badge { + background-color: #e0e0e0; + border-radius: 4px; + padding: 4px; + font-weight: normal; + font-size: small; +} diff --git a/springwolf-ui/src/app/components/schemas/schemas.component.html b/springwolf-ui/src/app/components/schemas/schemas.component.html index 4c8dc4563..3e2ac7500 100644 --- a/springwolf-ui/src/app/components/schemas/schemas.component.html +++ b/springwolf-ui/src/app/components/schemas/schemas.component.html @@ -11,8 +11,12 @@

Schemas

{{ schema.value.title }}

- - {{ schema.value.description }} + +
{{ schema.value.description }}
+
{{ schema.value.type }}

diff --git a/springwolf-ui/src/app/models/schema.model.ts b/springwolf-ui/src/app/models/schema.model.ts index f854ac8a1..7ec71e02c 100644 --- a/springwolf-ui/src/app/models/schema.model.ts +++ b/springwolf-ui/src/app/models/schema.model.ts @@ -21,4 +21,6 @@ export interface Schema { required?: string[]; enum?: string[]; example?: Example; + minimum?: number; + maximum?: number; } diff --git a/springwolf-ui/src/app/service/asyncapi/asyncapi-mapper.service.ts b/springwolf-ui/src/app/service/asyncapi/asyncapi-mapper.service.ts index 490aca6d4..2bc155d75 100644 --- a/springwolf-ui/src/app/service/asyncapi/asyncapi-mapper.service.ts +++ b/springwolf-ui/src/app/service/asyncapi/asyncapi-mapper.service.ts @@ -270,6 +270,8 @@ export class AsyncApiMapperService { properties, required: schema.required, example, + minimum: schema.minimum, + maximum: schema.maximum, }; } diff --git a/springwolf-ui/src/app/service/asyncapi/models/schema.model.ts b/springwolf-ui/src/app/service/asyncapi/models/schema.model.ts index bd34aa40a..f205a8891 100644 --- a/springwolf-ui/src/app/service/asyncapi/models/schema.model.ts +++ b/springwolf-ui/src/app/service/asyncapi/models/schema.model.ts @@ -12,5 +12,7 @@ export interface ServerAsyncApiSchema { } | string; required?: string[]; + minimum?: number; + maximum?: number; $ref?: string; }