Skip to content

Commit 53afbef

Browse files
authored
support to show openapi (#19)
Co-authored-by: rick <LinuxSuRen@users.noreply.github.com>
1 parent 02a8c15 commit 53afbef

5 files changed

Lines changed: 42 additions & 0 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ Run E2E testing:
77
make build-image test-e2e
88
```
99

10+
## OpenAPI definition
11+
You can visit it via: http://localhost:8080/v3/api-docs
12+
13+
or visit Swagger UI via: http://localhost:8080/swagger-ui/index.html
14+
1015
## GraphQL
1116
You can visit it via: http://localhost:8080/graphiql?path=/graphql
1217

e2e/test-suite.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ items:
99
- name: health
1010
request:
1111
api: /health
12+
- name: healthJson
13+
request:
14+
api: /health.json
15+
header:
16+
Authorization: "{{ .param.auth }}"
17+
expect:
18+
body: |
19+
{"message":"OK"}
1220
- name: toLowerWithoutParam
1321
request:
1422
api: /lower

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@
4747
<version>1.1.0</version>
4848
</dependency>
4949

50+
<dependency>
51+
<groupId>org.springdoc</groupId>
52+
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
53+
<version>2.2.0</version>
54+
</dependency>
55+
5056
<dependency>
5157
<groupId>org.springframework.boot</groupId>
5258
<artifactId>spring-boot-starter-test</artifactId>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package io.github.devopsws.demo.model;
2+
3+
public class Message {
4+
private String message;
5+
6+
public Message(String message) {
7+
this.message = message;
8+
}
9+
10+
public String getMessage() {
11+
return this.message;
12+
}
13+
14+
public void setMessage(String message) {
15+
this.message=message;
16+
}
17+
}

src/main/java/io/github/devopsws/demo/service/HealthService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22

33
import org.springframework.web.bind.annotation.GetMapping;
44
import org.springframework.web.bind.annotation.RestController;
5+
import io.github.devopsws.demo.model.Message;
56

67
@RestController
78
public class HealthService {
89
@GetMapping("/health")
910
public String health() {
1011
return "OK";
1112
}
13+
14+
@GetMapping("/health.json")
15+
public Message healthJSON() {
16+
return new Message("OK");
17+
}
1218
}

0 commit comments

Comments
 (0)