Skip to content

Commit

Permalink
support to show openapi (#19)
Browse files Browse the repository at this point in the history
Co-authored-by: rick <[email protected]>
  • Loading branch information
LinuxSuRen and LinuxSuRen authored Jan 17, 2024
1 parent 02a8c15 commit 53afbef
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Run E2E testing:
make build-image test-e2e
```

## OpenAPI definition
You can visit it via: http://localhost:8080/v3/api-docs

or visit Swagger UI via: http://localhost:8080/swagger-ui/index.html

## GraphQL
You can visit it via: http://localhost:8080/graphiql?path=/graphql

Expand Down
8 changes: 8 additions & 0 deletions e2e/test-suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ items:
- name: health
request:
api: /health
- name: healthJson
request:
api: /health.json
header:
Authorization: "{{ .param.auth }}"
expect:
body: |
{"message":"OK"}
- name: toLowerWithoutParam
request:
api: /lower
Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
<version>1.1.0</version>
</dependency>

<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.2.0</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/io/github/devopsws/demo/model/Message.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.github.devopsws.demo.model;

public class Message {
private String message;

public Message(String message) {
this.message = message;
}

public String getMessage() {
return this.message;
}

public void setMessage(String message) {
this.message=message;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import io.github.devopsws.demo.model.Message;

@RestController
public class HealthService {
@GetMapping("/health")
public String health() {
return "OK";
}

@GetMapping("/health.json")
public Message healthJSON() {
return new Message("OK");
}
}

0 comments on commit 53afbef

Please sign in to comment.