BAEL-6529 springwolf (#14204)

* [BAEL-6529] Add spring boot springwolf article

Co-authored-by: David Müller <david.mueller@codecentric.de>

* [BAEL-6529] Remove README.md

Co-authored-by: David Müller <david.mueller@codecentric.de>

* Bael 6529 springwolf 0.12.0 (#2)

* [BAEL-6529] Bump springwolf-kafka to 0.12.0

Co-authored-by: David Müller <david.mueller@codecentric.de>

* [BAEL-6529] Bump springwolf-kafka to 0.12.1

Co-authored-by: David Müller <david.mueller@codecentric.de>

---------

Co-authored-by: David Müller <david.mueller@codecentric.de>
This commit is contained in:
Timon Back
2023-07-10 17:27:56 +02:00
committed by GitHub
parent 612a42286a
commit bf1edf8d51
13 changed files with 581 additions and 0 deletions
@@ -0,0 +1,41 @@
package com.baeldung.boot.documentation.springwolf;
import org.json.JSONException;
import org.junit.jupiter.api.Test;
import org.skyscreamer.jsonassert.JSONAssert;
import org.skyscreamer.jsonassert.JSONCompareMode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.kafka.test.context.EmbeddedKafka;
import org.springframework.test.annotation.DirtiesContext;
import org.testcontainers.shaded.org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
@SpringBootTest(classes = {SpringwolfApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@EmbeddedKafka(
partitions = 1, brokerProperties = {
"listeners=PLAINTEXT://localhost:9092",
"port=9092",
})
@DirtiesContext
public class ApiIntegrationTest {
@Autowired
private TestRestTemplate restTemplate;
@Test
public void asyncApiResourceArtifactTest() throws JSONException, IOException {
// given
InputStream s = this.getClass().getResourceAsStream("/asyncapi.json");
String expected = IOUtils.toString(s, StandardCharsets.UTF_8);
String url = "/springwolf/docs";
String actual = restTemplate.getForObject(url, String.class);
JSONAssert.assertEquals(expected, actual, JSONCompareMode.STRICT);
}
}
@@ -0,0 +1,168 @@
{
"asyncapi": "2.6.0",
"info": {
"title": "Baeldung Tutorial Springwolf Application",
"version": "1.0.0",
"description": "Baeldung Tutorial Application to Demonstrate AsyncAPI Documentation using Springwolf"
},
"defaultContentType": "application/json",
"servers": {
"kafka": {
"url": "localhost:9092",
"protocol": "kafka"
}
},
"channels": {
"incoming-topic": {
"publish": {
"operationId": "incoming-topic_publish",
"description": "More details for the incoming topic",
"bindings": {
"kafka": { }
},
"message": {
"schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0",
"name": "com.baeldung.boot.documentation.springwolf.dto.IncomingPayloadDto",
"title": "IncomingPayloadDto",
"description": "Incoming payload model",
"payload": {
"$ref": "#/components/schemas/IncomingPayloadDto"
},
"headers": {
"$ref": "#/components/schemas/SpringKafkaDefaultHeadersIncomingPayloadDto"
},
"bindings": {
"kafka": { }
}
}
}
},
"outgoing-topic": {
"subscribe": {
"operationId": "outgoing-topic_subscribe",
"description": "More details for the outgoing topic",
"bindings": {
"kafka": { }
},
"message": {
"schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0",
"name": "com.baeldung.boot.documentation.springwolf.dto.OutgoingPayloadDto",
"title": "OutgoingPayloadDto",
"description": "Outgoing payload model",
"payload": {
"$ref": "#/components/schemas/OutgoingPayloadDto"
},
"headers": {
"$ref": "#/components/schemas/SpringKafkaDefaultHeadersOutgoingPayloadDto"
},
"bindings": {
"kafka": { }
}
}
}
}
},
"components": {
"schemas": {
"HeadersNotDocumented": {
"type": "object",
"properties": { },
"example": { }
},
"IncomingPayloadDto": {
"required": [
"someEnum",
"someString"
],
"type": "object",
"properties": {
"someEnum": {
"type": "string",
"description": "Some enum field",
"example": "FOO2",
"enum": [
"FOO1",
"FOO2",
"FOO3"
]
},
"someLong": {
"type": "integer",
"description": "Some long field",
"format": "int64",
"example": 5
},
"someString": {
"type": "string",
"description": "Some string field",
"example": "some string value"
}
},
"description": "Incoming payload model",
"example": {
"someEnum": "FOO2",
"someLong": 5,
"someString": "some string value"
}
},
"OutgoingPayloadDto": {
"required": [
"incomingWrapped"
],
"type": "object",
"properties": {
"foo": {
"type": "string",
"description": "Foo field",
"example": "bar"
},
"incomingWrapped": {
"$ref": "#/components/schemas/IncomingPayloadDto"
}
},
"description": "Outgoing payload model",
"example": {
"foo": "bar",
"incomingWrapped": {
"someEnum": "FOO2",
"someLong": 5,
"someString": "some string value"
}
}
},
"SpringKafkaDefaultHeadersIncomingPayloadDto": {
"type": "object",
"properties": {
"__TypeId__": {
"type": "string",
"description": "Spring Type Id Header",
"example": "com.baeldung.boot.documentation.springwolf.dto.IncomingPayloadDto",
"enum": [
"com.baeldung.boot.documentation.springwolf.dto.IncomingPayloadDto"
]
}
},
"example": {
"__TypeId__": "com.baeldung.boot.documentation.springwolf.dto.IncomingPayloadDto"
}
},
"SpringKafkaDefaultHeadersOutgoingPayloadDto": {
"type": "object",
"properties": {
"__TypeId__": {
"type": "string",
"description": "Spring Type Id Header",
"example": "com.baeldung.boot.documentation.springwolf.dto.OutgoingPayloadDto",
"enum": [
"com.baeldung.boot.documentation.springwolf.dto.OutgoingPayloadDto"
]
}
},
"example": {
"__TypeId__": "com.baeldung.boot.documentation.springwolf.dto.OutgoingPayloadDto"
}
}
}
},
"tags": [ ]
}