반응형
swagger ui와 함께 @RequestParam 주석 메서드 사용
사용하고 있다Springfox라이브러리를 사용하여 REST 서비스 설명서를 생성하고 이를 Swagger UI에 표시합니다.저는 Springfox 설명서의 지침을 따랐습니다.
1개의 컨트롤러가 있으며, 이 컨트롤러는 쿼리 문자열의 파라미터를 사용하며 메서드는 다음과 같이 매핑됩니다.
@ApiOperation(value = "")
@RequestMapping(method = GET, value = "/customcollection/{id}/data")
public Iterable<CustomeType> getData(@ApiParam(value = "The identifier of the time series.")
@PathVariable String id,
@ApiParam(name = "startDate", value = "start date", defaultValue = "")
@RequestParam("startDate") String startDate,
@ApiParam(name = "endDate", value = "end date", defaultValue = "")
@RequestParam("endDate") String endDate)
swagger-ui의 결과 매퍼는 다음과 같이 표시됩니다.
GET /customcollection/{id}/data{?startDate,endDate}
파라미터가 UI에 올바르게 표시됩니다.
그러나 [Try it Out]를 클릭하면 요청 URL의 형식이 잘못되었습니다.
http://localhost:8080/customlection/1/data{?startDate,endDate}?startDate=1&endDate=2
어떻게 고칠 수 있을까요?
이것은 회선으로 인해 발생하였습니다.
enableUrlTemplating(true)
에Docket예를 들어 복사하고 삭제하는 것을 잊은 Configuration입니다.
이 라인을 제거하면 모든 것이 예상대로 작동합니다.
언급URL : https://stackoverflow.com/questions/33377388/using-requestparam-annotated-method-with-swagger-ui
반응형
'codememo' 카테고리의 다른 글
| jQuery UI 대화 상자에서 닫기 버튼을 제거하는 방법 (0) | 2023.04.08 |
|---|---|
| 오류 수정 방법 - nodeemon.ps1은 이 시스템에서 실행 중인 스크립트를 사용하지 않도록 설정되었기 때문에 로드할 수 없습니다(보안 위험 없음). (0) | 2023.04.08 |
| 템플릿 파일 내에서 WordPress의 "기본 URL"을 얻을 수 있습니까? (0) | 2023.04.03 |
| TypeScript의 setTimeout에 사용할 반환 유형을 선택하십시오. (0) | 2023.04.03 |
| Wordpress: WP_post_name에 대한 검색 조건 쿼리 (0) | 2023.04.03 |