Skip to content

Commit 7416f77

Browse files
authored
docs: add unit test (#95)
* docs: add unit test * docs: linting * docs: update to springwolf version 1.7.0 * docs: improve faq for using springwolf-ui only * docs: re-order homepage feature
1 parent f5edc12 commit 7416f77

13 files changed

+73
-19
lines changed

docs/behind-the-scenes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@ They follow the same plugin model.
5151

5252
## Putting it all together
5353

54-
The `AsyncApiService` collects all the channels, schemas and general info and builds the AsyncApi document.
54+
The `AsyncApiService` collects all the channels, schemas and general info and builds the AsyncAPI document.
5555
The controller access this services to serve the document to the UI.

docs/faq.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,45 @@ You can use `springwolf-ui` without any other Springwolf dependency.
1616
`springwolf-ui` will fetch any documentation available at the `springwolf/docs` path.
1717
It must be in `json` format (`yaml` isn't supported).
1818

19-
Either create a custom spring controller to serve the file or [serve static resources with spring](https://spring.io/guides/gs/serving-web-content/) and place your AsyncAPI document into `resources/springwolf/docs` (without file extension).
19+
Either create a custom spring controller to serve the file or [serve static resources with spring](https://spring.io/guides/gs/serving-web-content/) and place AsyncAPI document file called `docs` (without file extension) into the folder `resources/springwolf`.
2020

2121
Note: `springwolf-ui` doesn't support the full AsyncAPI spec.
2222

23+
### Unit test verification
24+
25+
With the AsyncAPI artifact checked into the repository at `src/test/resources/asyncapi.json`,
26+
a unit test can verify that the current code still matches the expected AsyncAPI specification.
27+
Additionally, a diff reveals (un)expected changes.
28+
29+
Example unit test:
30+
31+
```java
32+
@SpringBootTest(
33+
classes = {SpringwolfKafkaExampleApplication.class},
34+
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
35+
class ApiIntegrationTest {
36+
37+
@Autowired
38+
private TestRestTemplate restTemplate;
39+
40+
@Test
41+
void asyncApiResourceArtifactTest() throws IOException {
42+
String url = "/springwolf/docs";
43+
String actual = restTemplate.getForObject(url, String.class);
44+
45+
// writing the actual file can be useful for debugging (remember: gitignore)
46+
Files.writeString(Path.of("src", "test", "resources", "asyncapi.actual.json"), actual);
47+
48+
InputStream s = this.getClass().getResourceAsStream("/asyncapi.json");
49+
String expected = new String(s.readAllBytes(), StandardCharsets.UTF_8).trim();
50+
51+
assertEquals(expected, actual);
52+
}
53+
}
54+
```
55+
56+
For a full example, check the [springwolf-kafka-example ApiIntegrationTest](https://github.com/springwolf/springwolf-core/blob/master/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/springwolf/examples/kafka/ApiIntegrationTest.java)
57+
2358
## Troubleshooting
2459

2560
### Show `debug` output in the logs
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
dependencies {
2-
implementation 'io.github.springwolf:springwolf-common-model-converters:1.4.0'
2+
implementation 'io.github.springwolf:springwolf-common-model-converters:1.7.0'
33
}

docs/snippets/_springwolf_common_model_converters_maven.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<dependency>
33
<groupId>io.github.springwolf</groupId>
44
<artifactId>springwolf-common-model-converters</artifactId>
5-
<version>1.4.0</version>
5+
<version>1.7.0</version>
66
</dependency>
77
</dependencies>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
dependencies {
2-
implementation 'io.github.springwolf:springwolf-generic-binding:1.4.0'
2+
implementation 'io.github.springwolf:springwolf-generic-binding:1.7.0'
33
}

docs/snippets/_springwolf_generic_binding_maven.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<dependency>
33
<groupId>io.github.springwolf</groupId>
44
<artifactId>springwolf-generic-binding</artifactId>
5-
<version>1.4.0</version>
5+
<version>1.7.0</version>
66
</dependency>
77
</dependencies>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dependencies {
22
// Provides the documentation API
3-
implementation 'io.github.springwolf:springwolf-kafka:1.4.0'
3+
implementation 'io.github.springwolf:springwolf-kafka:1.7.0'
44

55
// Provides the UI - optional (recommended)
6-
runtimeOnly 'io.github.springwolf:springwolf-ui:1.4.0'
6+
runtimeOnly 'io.github.springwolf:springwolf-ui:1.7.0'
77
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
dependencies {
2-
implementation 'io.github.springwolf:springwolf-json-schema:1.4.0'
2+
implementation 'io.github.springwolf:springwolf-json-schema:1.7.0'
33
}

docs/snippets/_springwolf_json_schema_maven.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<dependency>
33
<groupId>io.github.springwolf</groupId>
44
<artifactId>springwolf-json-schema</artifactId>
5-
<version>1.4.0</version>
5+
<version>1.7.0</version>
66
</dependency>
77
</dependencies>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
dependencies {
2-
implementation 'io.github.springwolf:springwolf-kotlinx-serialization-model-converter:1.4.0'
2+
implementation 'io.github.springwolf:springwolf-kotlinx-serialization-model-converter:1.7.0'
33
}

docs/snippets/_springwolf_kotlinx_serialization_model_converter_maven.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<dependency>
33
<groupId>io.github.springwolf</groupId>
44
<artifactId>springwolf-kotlinx-serialization-model-converter</artifactId>
5-
<version>1.4.0</version>
5+
<version>1.7.0</version>
66
</dependency>
77
</dependencies>

docs/snippets/_springwolf_maven.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
<dependency>
44
<groupId>io.github.springwolf</groupId>
55
<artifactId>springwolf-kafka</artifactId>
6-
<version>1.4.0</version>
6+
<version>1.7.0</version>
77
</dependency>
88
<!-- Provides the UI - optional (recommended) -->
99
<dependency>
1010
<groupId>io.github.springwolf</groupId>
1111
<artifactId>springwolf-ui</artifactId>
12-
<version>1.4.0</version>
12+
<version>1.7.0</version>
1313
</dependency>
1414
</dependencies>

src/components/HomepageFeatures.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const FeatureList = [
88
title: 'Effortless API documentation',
99
description: (
1010
<>
11-
Springwolf uses metadata already provided in the code
11+
Springwolf uses metadata already provided in the code
1212
to automatically create documentation.
1313
</>
1414
),
@@ -26,15 +26,25 @@ const FeatureList = [
2626
title: 'Powered by AsyncAPI v3',
2727
description: (
2828
<>
29-
The generated documentation is compliant with the <Link to='https://www.asyncapi.com/'>AsyncAPI specification</Link>.
29+
The generated documentation is compliant with the
30+
<Link to='https://www.asyncapi.com/'>AsyncAPI specification</Link>.
3031
</>
3132
),
3233
},
3334
{
3435
title: 'Optional web-ui',
3536
description: (
3637
<>
37-
Single dependency ui for API testing including event publishing.
38+
Single dependency for API testing including event publishing
39+
(<Link to={'https://demo.springwolf.dev'}>demo</Link>).
40+
</>
41+
),
42+
},
43+
{
44+
title: 'Integrate',
45+
description: (
46+
<>
47+
Generate documentation in your CI/CD pipeline and publish to tools like <Link to="https://backstage.io">Backstage</Link>.
3848
</>
3949
),
4050
},
@@ -47,13 +57,22 @@ const FeatureList = [
4757
),
4858
},
4959
{
50-
title: 'Integrate',
60+
title: 'Participate',
5161
description: (
5262
<>
53-
Generate documentation in your CI/CD pipeline and publish to tools like <Link to="https://backstage.io">Backstage</Link>.
63+
Something missing? Features requests and contributions are welcome.
5464
</>
5565
),
5666
},
67+
{ },
68+
{
69+
title: 'Verify',
70+
description: (
71+
<>
72+
Use an unit test to check for (un)expected changes.
73+
</>
74+
),
75+
}
5776
];
5877

5978
function Feature({Svg, title, description}) {

0 commit comments

Comments
 (0)