Skip to content

Commit 9fb4cb0

Browse files
authored
Merge pull request #8 from kasramp/hide-endpoint
Example of how to hide an endpoint
2 parents a42c72a + f510188 commit 9fb4cb0

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.madadipouya.springkafkatest.controller;
2+
3+
import io.swagger.v3.oas.annotations.Hidden;
4+
import io.swagger.v3.oas.annotations.media.Content;
5+
import io.swagger.v3.oas.annotations.media.Schema;
6+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
7+
import io.swagger.v3.oas.annotations.responses.ApiResponses;
8+
import java.util.Map;
9+
import org.springframework.http.HttpStatus;
10+
import org.springframework.http.ResponseEntity;
11+
import org.springframework.web.bind.annotation.GetMapping;
12+
import org.springframework.web.bind.annotation.RequestMapping;
13+
import org.springframework.web.bind.annotation.ResponseStatus;
14+
import org.springframework.web.bind.annotation.RestController;
15+
16+
@RestController
17+
@RequestMapping("/v1/hidden")
18+
public class HiddenController {
19+
20+
@GetMapping("/test")
21+
@ResponseStatus(HttpStatus.OK)
22+
// Hide the entire endpoint
23+
@Hidden
24+
// Just to hide the response object
25+
@ApiResponses(value = {@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(hidden = true))) })
26+
public ResponseEntity<TestResponse> getTestResponse() {
27+
return ResponseEntity.ok(new TestResponse(Map.of("key1", "value1")));
28+
}
29+
30+
public record TestResponse(Map<String, String> data) {
31+
32+
}
33+
}

0 commit comments

Comments
 (0)