
Я попробовал использовать аннотацию @Hidden, в результате чего фактические конечные точки скрылись, оставив ненужный материал. Я также попробовал @API.
Это зависимость для используемого Springdoc-openapi.
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.1.0
а это файл конфигурации.
package com.bma.directory.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
@Configuration
public class StudentDirectorySwaggerConfig {
@Bean
public OpenAPI apiInfo() {
return new OpenAPI().info(new Info().title("StudentDirectory_V1").description(readSwaggerDocument().toString())
.version("v1").contact(new Contact().name("John deere").email("abcd@gmail.com")).license(new License().name("Student Directory Document")
.url("https://github.com")));
}
private StringBuilder readSwaggerDocument() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(
"StudentDirectory_v1 api is a CRUD application that "
+ "posts and retrieves information about one or more student at a time"
);
return stringBuilder;
}
}
package com.bma.directory.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.bma.directory.service.StudentDirectoryServiceImpl;
import com.bma.directory.vo.error.CommonErrorVO;
import com.bma.directory.vo.input.StudentDetailsRequestVO;
import com.bma.directory.vo.output.StudentDetailsResponseVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
@RestController
@RequestMapping(value = "student/directory")
public class StudentDirectoryServiceController {
@Autowired
private StudentDirectoryServiceImpl studentDirectoryServiceImpl;
@Operation(method = "POST", summary = "Gets the students details."
+ "Sample URL -http://{....}/bma/studentdirectory/abc", description = "Gets the student information")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successful", content = {
@Content(mediaType = "applicayion/json", schema = @Schema(implementation = StudentDetailsResponseVO.class)) }),
@ApiResponse(responseCode = "500", description = "Internal Server Error", content = {
@Content(mediaType = "applicayion/json", schema = @Schema(implementation = CommonErrorVO.class)) }),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = {
@Content(mediaType = "applicayion/json", schema = @Schema(implementation = CommonErrorVO.class)) }),
@ApiResponse(responseCode = "403", description = "Forbidden", content = {
@Content(mediaType = "applicayion/json", schema = @Schema(implementation = CommonErrorVO.class)) }),
@ApiResponse(responseCode = "404", description = "Not Found", content = {
@Content(mediaType = "applicayion/json", schema = @Schema(implementation = CommonErrorVO.class)) }),
@ApiResponse(responseCode = "400", description = "Bad Request", content = {
@Content(mediaType = "applicayion/json", schema = @Schema(implementation = CommonErrorVO.class)) }), })
@PostMapping(value = "/read/studentdetails")
@ResponseBody
public ResponseEntity getStudentDetails(
@RequestBody StudentDetailsRequestVO studentDetailsInputVO) {
StudentDetailsResponseVO studentDetailsOutputVO = studentDirectoryServiceImpl
.getStudentDetails(studentDetailsInputVO);
return new ResponseEntity(studentDetailsOutputVO, HttpStatus.CREATED);
}
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... on-jargons
Мобильная версия