Created
July 23, 2020 06:11
-
-
Save krnbr/191e85b2e701817afde3e81bb2d75b55 to your computer and use it in GitHub Desktop.
Custom tags and info open api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.swagger.v3.oas.annotations.Operation; | |
import io.swagger.v3.oas.annotations.Parameter; | |
import io.swagger.v3.oas.annotations.enums.ParameterIn; | |
import io.swagger.v3.oas.annotations.tags.Tag; | |
import org.springframework.web.bind.annotation.*; | |
import org.springframework.web.server.ServerWebExchange; | |
import reactor.core.publisher.Mono; | |
import javax.validation.Valid; | |
/** | |
* @author Karanbir Singh on 07/23/2020 | |
*/ | |
@RestController | |
@Tag(name = "Test APIs", description = "Test APIs for demo purpose") | |
public class TestController { | |
@GetMapping("test") | |
@Operation(description = "Get a test model demo", parameters = { | |
@Parameter(name = "name", in = ParameterIn.QUERY, required = true, description = "name parameter") | |
}) | |
public Mono<TestDto> getTestDto(final @RequestParam String name, | |
final ServerWebExchange exchange) { | |
TestDto testDto = new TestDto(); | |
testDto.setName(name); | |
testDto.setAge(0); | |
testDto.setName("Welcome "+name); | |
return Mono.just(testDto); | |
} | |
@PostMapping("test") | |
@Operation(description = "Create a test model demo", requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody()) | |
public Mono<TestDto> postTestDto(@Valid @RequestBody final TestDto testDto, | |
final ServerWebExchange exchange) { | |
return Mono.just(testDto); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment