Skip to content

Instantly share code, notes, and snippets.

@krnbr
Created July 23, 2020 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krnbr/191e85b2e701817afde3e81bb2d75b55 to your computer and use it in GitHub Desktop.
Save krnbr/191e85b2e701817afde3e81bb2d75b55 to your computer and use it in GitHub Desktop.
Custom tags and info open api
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