두가지 추가적인 코드 공유드립니다.
379
작성한 질문수 5
1. rest docs 문서에 반환될 값들의 타입을 강하게 걸어서 확실한 테스트를 하고 싶으시다면 아래와 같이 type에 JsonFieldType을 추가하여 테스트할 수 있습니다.
2. 그리고 json의 특정 값이 리턴될 수 있고 안될 수 있는 결과라면.. 예를 들어, response에 description 필드가 있을 경우, 없을 경우를 하나의 문서로 만들기 위해서는 optional()을 붙여주면 됩니다. 결과적으로는 relaxed랑 비슷해졌지만.. 개개의 필드를 설정할 수 있다는 점이 강점인것 같네요.
responseFields(
fieldWithPath("id").type(JsonFieldType.NUMBER).description("event id"),
fieldWithPath("name").type(JsonFieldType.STRING).description("Name of new event"),
fieldWithPath("description").type(JsonFieldType.STRING).description("event description"),
fieldWithPath("beginEnrollmentDateTime").type(JsonFieldType.STRING).description("event enroll start date"),
fieldWithPath("closeEnrollmentDateTime").type(JsonFieldType.STRING).description("devnet enroll end date"),
fieldWithPath("beginEventDateTime").type(JsonFieldType.STRING).description("event start date"),
fieldWithPath("endEventDateTime").type(JsonFieldType.STRING).description("event end date"),
fieldWithPath("location").type(JsonFieldType.STRING).description("event location"),
fieldWithPath("basePrice").type(JsonFieldType.NUMBER).description("event basePrice"),
fieldWithPath("maxPrice").type(JsonFieldType.NUMBER).description("event maxPrice"),
fieldWithPath("limitOfEnrollment").type(JsonFieldType.NUMBER).description("limit enrollment"),
fieldWithPath("free").type(JsonFieldType.BOOLEAN).description("the event is free"),
fieldWithPath("offline").type(JsonFieldType.BOOLEAN).description("the event is offline"),
fieldWithPath("eventStatus").type(JsonFieldType.STRING).description("event status"),
//optional fields
fieldWithPath("_links.self.href").type(JsonFieldType.STRING).description("my href").optional(),
fieldWithPath("_links.query-events.href").type(JsonFieldType.STRING).description("my href").optional(),
fieldWithPath("_links.update-event.href").type(JsonFieldType.STRING).description("my href").optional()
)
Spring 시큐리티 관련해서 WebSecurityConfigurationAdapter
0
73
1
junit5 사용하시는 분들
0
88
1
자바 빈 스펙을 준수하는지 체크하는 테스트
0
236
2
REST API 개발 중 비즈니스 로직 적용 부분의 JSON 에러
0
243
1
스프링 부트 3버전에서의 실습
0
190
1
java.lang.AssertionError: Status
0
532
2
spring doc 관련 파일 생성 관련 배포 관련 질문 드립니다.
0
287
1
섹션2 201응답받기 부분 테스트 404에러 질문입니다
0
741
1
강의 자료가 404입니다 확인 부탁 드려요!
0
477
1
연동 DB문의
0
358
1
이벤트 Repository강의 중 Event 클래스에 private Integer Id; 위치 질문
0
505
1
(Mac) postgressql 관련하여 port kill 해도 다시 살아나는 경우
0
380
0
maven으로 생성한 docs파일(index.html)에서의 not found 오류 질문
0
621
1
테스트 오류 질문드립니다.
0
512
1
docs 요청값이 반영이 안되네요... (해결)
-1
394
1
psql 적용 후 에러
0
818
2
mvn package 시 다음과 같은 에러가 나시면
0
765
2
Event에 Account manager를 추가했으면 문서화 필요
0
274
1
2년 훨씬 전 부터 Restlet-> Talend API 로 바뀌었습니다~
1
473
1
asciidoc 추가 스니펫 에러 해결법
0
400
1
_links 는 현재 fieldWithPath 를 해주지 않아도 됩니다.
0
424
3
깃랩 처음 사용자를 위한 index.adoc raw 보는 법
0
332
1
eclipse 쓰시는 분을 위한 maven-resources-plugin 팁
0
333
1
부트 + jupiter 인 경우 설정법
0
342
1





