From 366bdad31e127faef7bd66b2be5ffae500be48c9 Mon Sep 17 00:00:00 2001 From: dseydel Date: Wed, 30 Nov 2022 09:48:39 +0100 Subject: [PATCH] Add versioning --- .../azplace/rest/api/AuthAPI.java | 11 +++------ .../azplace/rest/api/BoardAPI.java | 8 +++---- .../azplace/rest/api/BotAPI.java | 8 +++---- .../azplace/rest/api/OperationAPI.java | 24 +++++++++---------- .../azplace/rest/api/PunishmentAPI.java | 6 ++--- .../azplace/rest/api/StatisticsAPI.java | 4 ++-- .../azplace/rest/api/UserAPI.java | 4 ++-- 7 files changed, 30 insertions(+), 35 deletions(-) diff --git a/src/main/java/de/abstractolotl/azplace/rest/api/AuthAPI.java b/src/main/java/de/abstractolotl/azplace/rest/api/AuthAPI.java index 7edbf60..aad567e 100644 --- a/src/main/java/de/abstractolotl/azplace/rest/api/AuthAPI.java +++ b/src/main/java/de/abstractolotl/azplace/rest/api/AuthAPI.java @@ -4,7 +4,6 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpRequest; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; @@ -13,10 +12,6 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; -import org.springframework.web.servlet.resource.HttpResource; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import static org.springframework.http.MediaType.TEXT_HTML_VALUE; @@ -41,7 +36,7 @@ public interface AuthAPI { @Operation(summary = "Start login and redirect to CAS") - @GetMapping(path = "/login", produces = MediaType.TEXT_HTML_VALUE) + @GetMapping(path = "/login", produces = { MediaType.TEXT_HTML_VALUE, "text/v1+html" } ) String login(@RequestHeader(HttpHeaders.HOST) String hostName); @Operation( @@ -56,7 +51,7 @@ public interface AuthAPI { - Backend caches SessionKey and User via Spring session - It redirect to the frontend """) - @GetMapping(path = "/verify", produces = MediaType.TEXT_HTML_VALUE) + @GetMapping(path = "/verify", produces = { MediaType.TEXT_HTML_VALUE, "text/v1+html" }) @ResponseBody ResponseEntity verify(@RequestParam("ticket") String ticket); @@ -68,7 +63,7 @@ public interface AuthAPI { @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK") }) - @GetMapping(path = "/logout", produces = MediaType.TEXT_HTML_VALUE) + @GetMapping(path = "/logout", produces = { MediaType.TEXT_HTML_VALUE, "text/v1+html" }) @ResponseBody ResponseEntity logout(HttpSession httpSession); diff --git a/src/main/java/de/abstractolotl/azplace/rest/api/BoardAPI.java b/src/main/java/de/abstractolotl/azplace/rest/api/BoardAPI.java index 9dfb606..900c59e 100644 --- a/src/main/java/de/abstractolotl/azplace/rest/api/BoardAPI.java +++ b/src/main/java/de/abstractolotl/azplace/rest/api/BoardAPI.java @@ -35,7 +35,7 @@ @RequestMapping("board") public interface BoardAPI { - @PostMapping(value = "{canvasId}/place", consumes = APPLICATION_JSON_VALUE) + @PostMapping(value = "{canvasId}/place", consumes = { APPLICATION_JSON_VALUE, "application/v1+json" }) @Operation( summary = "Place a Pixel", requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody( @@ -44,7 +44,7 @@ public interface BoardAPI { ) void place(@PathVariable int canvasId, @RequestBody PlaceRequest request); - @GetMapping(value = "{canvasId}/pixel/{x}/{y}", produces = APPLICATION_JSON_VALUE) + @GetMapping(value = "{canvasId}/pixel/{x}/{y}", produces = { APPLICATION_JSON_VALUE, "application/v1+json" }) @Operation(summary = "Get Information about a pixel") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "PixelInfo returned", @@ -56,7 +56,7 @@ public interface BoardAPI { @Operation(summary = "Get the current board data") byte[] boardData(@PathVariable int canvasId); - @GetMapping(value = "/{canvasId}/cooldown", produces = APPLICATION_JSON_VALUE) + @GetMapping(value = "/{canvasId}/cooldown", produces = { APPLICATION_JSON_VALUE, "application/v1+json" }) @Operation(summary = "Get your current cooldown information" ) @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "Current user cooldown returned", @@ -64,7 +64,7 @@ public interface BoardAPI { }) CooldownView cooldown(@PathVariable int canvasId); - @GetMapping(value = "/{canvasId}/config", produces = APPLICATION_JSON_VALUE) + @GetMapping(value = "/{canvasId}/config", produces = { APPLICATION_JSON_VALUE, "application/v1+json" }) @Operation(summary = "Get board configuration" ) @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "Current user cooldown returned", diff --git a/src/main/java/de/abstractolotl/azplace/rest/api/BotAPI.java b/src/main/java/de/abstractolotl/azplace/rest/api/BotAPI.java index 5e6494c..5eda2d9 100644 --- a/src/main/java/de/abstractolotl/azplace/rest/api/BotAPI.java +++ b/src/main/java/de/abstractolotl/azplace/rest/api/BotAPI.java @@ -34,7 +34,7 @@ @RequestMapping("bot") public interface BotAPI { - @PostMapping(value = "/create") + @PostMapping(value = "/create", produces = { APPLICATION_JSON_VALUE, "application/v1+json" }) @Operation(summary = "Create a new bot token") @ApiResponses(value = { @ApiResponse(responseCode = "200", @@ -43,7 +43,7 @@ public interface BotAPI { }) BotView createBotToken(); - @GetMapping(value = "/info") + @GetMapping(value = "/info", produces = { APPLICATION_JSON_VALUE, "application/v1+json" }) @Operation(summary = "Get your current bot token") @ApiResponses(value = { @ApiResponse(responseCode = "200", @@ -52,7 +52,7 @@ public interface BotAPI { }) BotView getBotToken(); - @PostMapping(value = "/refresh") + @PostMapping(value = "/refresh", produces = { APPLICATION_JSON_VALUE, "application/v1+json" }) @Operation(summary = "Regenerate your current bot token") @ApiResponses(value = { @ApiResponse(responseCode = "200", @@ -61,7 +61,7 @@ public interface BotAPI { }) BotView refreshToken(); - @PostMapping(value = "/{canvasId}/place") + @PostMapping(value = "/{canvasId}/place", consumes = { APPLICATION_JSON_VALUE, "application/v1+json" }) @Operation( summary = "Place a pixel via bot token", requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody( diff --git a/src/main/java/de/abstractolotl/azplace/rest/api/OperationAPI.java b/src/main/java/de/abstractolotl/azplace/rest/api/OperationAPI.java index 2c84825..fa2df72 100644 --- a/src/main/java/de/abstractolotl/azplace/rest/api/OperationAPI.java +++ b/src/main/java/de/abstractolotl/azplace/rest/api/OperationAPI.java @@ -36,7 +36,7 @@ @RequestMapping(value = "operation") public interface OperationAPI { - @GetMapping(value = "/canvas/{id}", produces = APPLICATION_JSON_VALUE) + @GetMapping(value = "/canvas/{id}", produces = { APPLICATION_JSON_VALUE, "application/v1+json" }) @Operation(method = "GET", summary = "Get current canvas data") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Canvas found and returned", @@ -45,8 +45,8 @@ public interface OperationAPI { Canvas getCanvas(@PathVariable Integer id); @PostMapping(value = "/canvas", - consumes = APPLICATION_JSON_VALUE, - produces = APPLICATION_JSON_VALUE) + consumes = { APPLICATION_JSON_VALUE, "application/v1+json" }, + produces = { APPLICATION_JSON_VALUE, "application/v1+json" }) @Operation(method = "POST", summary = "Create new canvas", requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody( content = @Content(schema = @Schema(implementation = CanvasRequest.class)) @@ -60,8 +60,8 @@ public interface OperationAPI { Canvas createCanvas(@RequestBody CanvasRequest canvasRequest); @PatchMapping(value = "/canvas/{id}", - consumes = APPLICATION_JSON_VALUE, - produces = APPLICATION_JSON_VALUE) + consumes = { APPLICATION_JSON_VALUE, "application/v1+json" }, + produces = { APPLICATION_JSON_VALUE, "application/v1+json" }) @Operation(method = "PATCH", summary = "Update an existing canvas", requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody( content = @Content(schema = @Schema(implementation = CanvasRequest.class)) @@ -74,7 +74,7 @@ public interface OperationAPI { Canvas updateCanvas(@PathVariable Integer id, @RequestBody CanvasRequest canvasRequest); @DeleteMapping(value = "/canvas/{id}", - produces = APPLICATION_JSON_VALUE) + produces = { APPLICATION_JSON_VALUE, "application/v1+json" }) @Operation(method = "DELETE", summary = "Delete an existing canvas") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Canvas deleted successfully", @@ -82,7 +82,7 @@ public interface OperationAPI { }) ResponseEntity deleteCanvas(@PathVariable Integer id); - @GetMapping(value = "/palette/{id}", produces = APPLICATION_JSON_VALUE) + @GetMapping(value = "/palette/{id}", produces = { APPLICATION_JSON_VALUE, "application/v1+json" }) @Operation(method = "GET", summary = "Get current palette data") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Palette found and returned", @@ -91,8 +91,8 @@ public interface OperationAPI { ColorPalette getPalette(@PathVariable Integer id); @PostMapping(value = "/palette", - consumes = APPLICATION_JSON_VALUE, - produces = APPLICATION_JSON_VALUE) + consumes = { APPLICATION_JSON_VALUE, "application/v1+json" }, + produces = { APPLICATION_JSON_VALUE, "application/v1+json" }) @Operation(method = "POST", summary = "Create new palette", requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody( content = @Content(schema = @Schema(implementation = PaletteRequest.class)) @@ -106,8 +106,8 @@ public interface OperationAPI { ColorPalette createPalette(@RequestBody PaletteRequest paletteRequest); @PatchMapping(value = "/palette/{id}", - consumes = APPLICATION_JSON_VALUE, - produces = APPLICATION_JSON_VALUE) + consumes = { APPLICATION_JSON_VALUE, "application/v1+json" }, + produces = { APPLICATION_JSON_VALUE, "application/v1+json" }) @Operation(method = "PATCH", summary = "Update an existing palette", requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody( content = @Content(schema = @Schema(implementation = PaletteRequest.class)) @@ -120,7 +120,7 @@ public interface OperationAPI { ColorPalette updatePalette(@PathVariable Integer id, @RequestBody PaletteRequest paletteRequest); @DeleteMapping(value = "/palette/{id}", - produces = APPLICATION_JSON_VALUE) + produces = { APPLICATION_JSON_VALUE, "application/v1+json" }) @Operation(method = "DELETE", summary = "Delete an existing palette") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Palette deleted successfully", diff --git a/src/main/java/de/abstractolotl/azplace/rest/api/PunishmentAPI.java b/src/main/java/de/abstractolotl/azplace/rest/api/PunishmentAPI.java index fd360e7..74746c1 100644 --- a/src/main/java/de/abstractolotl/azplace/rest/api/PunishmentAPI.java +++ b/src/main/java/de/abstractolotl/azplace/rest/api/PunishmentAPI.java @@ -39,8 +39,8 @@ public interface PunishmentAPI { @PostMapping( value = "/ban", - consumes = APPLICATION_JSON_VALUE, - produces = APPLICATION_JSON_VALUE + consumes = { APPLICATION_JSON_VALUE, "application/v1+json" }, + produces = { APPLICATION_JSON_VALUE, "application/v1+json" } ) @Operation( method = "POST", @@ -62,7 +62,7 @@ public interface PunishmentAPI { @PostMapping( value = "/pardon/{banId}", - produces = APPLICATION_JSON_VALUE + produces = { APPLICATION_JSON_VALUE, "application/v1+json" } ) @Operation(method = "POST", summary = "Pardon a user") @ApiResponses(value = { diff --git a/src/main/java/de/abstractolotl/azplace/rest/api/StatisticsAPI.java b/src/main/java/de/abstractolotl/azplace/rest/api/StatisticsAPI.java index 453c27a..6749bd6 100644 --- a/src/main/java/de/abstractolotl/azplace/rest/api/StatisticsAPI.java +++ b/src/main/java/de/abstractolotl/azplace/rest/api/StatisticsAPI.java @@ -33,7 +33,7 @@ @RequestMapping("statistics") public interface StatisticsAPI { - @GetMapping(value = "/pixels", produces = APPLICATION_JSON_VALUE) + @GetMapping(value = "/pixels", produces = { APPLICATION_JSON_VALUE, "application/v1+json" }) @Operation(summary = "Get placed pixels in the last 24h") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Pixel statistics calculated and returned", @@ -41,7 +41,7 @@ public interface StatisticsAPI { }) CountView pixels(); - @GetMapping(value = "/online", produces = APPLICATION_JSON_VALUE) + @GetMapping(value = "/online", produces = { APPLICATION_JSON_VALUE, "application/v1+json" }) @Operation(summary = "Get amount of currently online users") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Amount of currently online users returned", diff --git a/src/main/java/de/abstractolotl/azplace/rest/api/UserAPI.java b/src/main/java/de/abstractolotl/azplace/rest/api/UserAPI.java index 53e8cb9..ef7bed3 100644 --- a/src/main/java/de/abstractolotl/azplace/rest/api/UserAPI.java +++ b/src/main/java/de/abstractolotl/azplace/rest/api/UserAPI.java @@ -35,7 +35,7 @@ @RequestMapping("user") public interface UserAPI { - @GetMapping(value = "/", produces = APPLICATION_JSON_VALUE) + @GetMapping(value = "/", produces = { APPLICATION_JSON_VALUE, "application/v1+json" }) @Operation(summary = "Get Profile of current user") @ApiResponses(value = { @ApiResponse( @@ -52,7 +52,7 @@ public interface UserAPI { @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Settings updated successfully") }) - @PutMapping(value = "/settings", consumes = APPLICATION_JSON_VALUE) + @PutMapping(value = "/settings", consumes = { APPLICATION_JSON_VALUE, "application/v1+json" }) void setSettings(@RequestBody UserSettings userSettings); }