From 921cd0e751eb52a59ddc5ca8e1a941b0869053bd Mon Sep 17 00:00:00 2001 From: Warded120 Date: Fri, 6 Dec 2024 10:48:02 +0200 Subject: [PATCH 1/2] added custom swagger schema for FilterEventDto --- .../java/greencity/controller/EventController.java | 6 +++++- .../java/greencity/dto/filter/FilterEventDto.java | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/greencity/controller/EventController.java b/core/src/main/java/greencity/controller/EventController.java index 737a95d14..dfef735cc 100644 --- a/core/src/main/java/greencity/controller/EventController.java +++ b/core/src/main/java/greencity/controller/EventController.java @@ -179,7 +179,11 @@ public ResponseEntity getEvent( public ResponseEntity> getEvents( @Parameter(hidden = true) Pageable pageable, @RequestParam(required = false, name = "user-id") Long userId, - FilterEventDto filterEventDto) { + @Schema( + description = "Filters for events", + name = "FilterEventDto", + type = "object", + example = FilterEventDto.defaultJson) FilterEventDto filterEventDto) { if (filterEventDto != null && filterEventDto.getStatuses() != null) { validateStatusesRequireUserId(filterEventDto.getStatuses(), userId); } diff --git a/service-api/src/main/java/greencity/dto/filter/FilterEventDto.java b/service-api/src/main/java/greencity/dto/filter/FilterEventDto.java index 4320a709b..e6c35f90d 100644 --- a/service-api/src/main/java/greencity/dto/filter/FilterEventDto.java +++ b/service-api/src/main/java/greencity/dto/filter/FilterEventDto.java @@ -23,4 +23,17 @@ public class FilterEventDto { private EventType type; private ZonedDateTime from; private ZonedDateTime to; + + public static final String defaultJson = """ + { + "time": null, + "cities": [], + "statuses": [], + "tags": [], + "title": null, + "type": null, + "from": null, + "to": null + } + """; } From 9e169fd06e02cb487a1cf9c22ff9b1312fd3a868 Mon Sep 17 00:00:00 2001 From: Warded120 Date: Fri, 6 Dec 2024 10:55:04 +0200 Subject: [PATCH 2/2] formatted files --- .../greencity/controller/EventController.java | 8 +++---- .../greencity/dto/filter/FilterEventDto.java | 22 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/core/src/main/java/greencity/controller/EventController.java b/core/src/main/java/greencity/controller/EventController.java index dfef735cc..efe4cdb49 100644 --- a/core/src/main/java/greencity/controller/EventController.java +++ b/core/src/main/java/greencity/controller/EventController.java @@ -180,10 +180,10 @@ public ResponseEntity> getEvents( @Parameter(hidden = true) Pageable pageable, @RequestParam(required = false, name = "user-id") Long userId, @Schema( - description = "Filters for events", - name = "FilterEventDto", - type = "object", - example = FilterEventDto.defaultJson) FilterEventDto filterEventDto) { + description = "Filters for events", + name = "FilterEventDto", + type = "object", + example = FilterEventDto.defaultJson) FilterEventDto filterEventDto) { if (filterEventDto != null && filterEventDto.getStatuses() != null) { validateStatusesRequireUserId(filterEventDto.getStatuses(), userId); } diff --git a/service-api/src/main/java/greencity/dto/filter/FilterEventDto.java b/service-api/src/main/java/greencity/dto/filter/FilterEventDto.java index e6c35f90d..b0edd77f0 100644 --- a/service-api/src/main/java/greencity/dto/filter/FilterEventDto.java +++ b/service-api/src/main/java/greencity/dto/filter/FilterEventDto.java @@ -25,15 +25,15 @@ public class FilterEventDto { private ZonedDateTime to; public static final String defaultJson = """ - { - "time": null, - "cities": [], - "statuses": [], - "tags": [], - "title": null, - "type": null, - "from": null, - "to": null - } - """; + { + "time": null, + "cities": [], + "statuses": [], + "tags": [], + "title": null, + "type": null, + "from": null, + "to": null + } + """; }