Skip to content

Commit

Permalink
consolidate swagger produces to main request mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
barnhill committed Jul 1, 2024
1 parent eb31784 commit 492c84d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.pnuema.java.barcode.barcodeapi.controllers.v1;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;

@RequestMapping("/v1")
@RequestMapping(
name = "/v1",
produces = { MediaType.IMAGE_PNG_VALUE, MediaType.IMAGE_GIF_VALUE }
)
public abstract class AbstractV1Resource {}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
public class BarcodeController extends AbstractV1Resource {

@PostMapping(value = "/barcode/",
consumes = { MediaType.APPLICATION_JSON_VALUE },
produces = { MediaType.IMAGE_PNG_VALUE, MediaType.IMAGE_JPEG_VALUE, MediaType.IMAGE_GIF_VALUE }
consumes = { MediaType.APPLICATION_JSON_VALUE }
)
@Cacheable("barcodes")
public ResponseEntity<byte[]> getBarcodeImage(@RequestBody BarcodeBody body) throws IOException {
Expand All @@ -43,8 +42,7 @@ public ResponseEntity<byte[]> getBarcodeImage(@RequestBody BarcodeBody body) thr

@GetMapping(
name = "barcode",
value = "/barcode/{type}/data/{data}",
produces = { MediaType.IMAGE_PNG_VALUE, MediaType.IMAGE_JPEG_VALUE, MediaType.IMAGE_GIF_VALUE }
value = "/barcode/{type}/data/{data}"
)
@Cacheable("barcodes")
public ResponseEntity<byte[]> getBarcodeImage(
Expand All @@ -56,7 +54,7 @@ public ResponseEntity<byte[]> getBarcodeImage(
@PathVariable(name = "data")
String data,

@Schema(example = "png", allowableValues = { "png", "jpg", "gif" }, defaultValue = "png")
@Schema(example = "png", allowableValues = { "png", "gif" }, defaultValue = "png")
@RequestParam(name = "imageFormat")
Optional<String> imageFormat,

Expand Down

0 comments on commit 492c84d

Please sign in to comment.