Skip to content

Commit 492c84d

Browse files
committed
consolidate swagger produces to main request mapping
1 parent eb31784 commit 492c84d

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package com.pnuema.java.barcode.barcodeapi.controllers.v1;
22

3+
import org.springframework.http.MediaType;
34
import org.springframework.web.bind.annotation.RequestMapping;
45

5-
@RequestMapping("/v1")
6+
@RequestMapping(
7+
name = "/v1",
8+
produces = { MediaType.IMAGE_PNG_VALUE, MediaType.IMAGE_GIF_VALUE }
9+
)
610
public abstract class AbstractV1Resource {}

src/main/java/com/pnuema/java/barcode/barcodeapi/controllers/v1/BarcodeController.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
public class BarcodeController extends AbstractV1Resource {
2525

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

4443
@GetMapping(
4544
name = "barcode",
46-
value = "/barcode/{type}/data/{data}",
47-
produces = { MediaType.IMAGE_PNG_VALUE, MediaType.IMAGE_JPEG_VALUE, MediaType.IMAGE_GIF_VALUE }
45+
value = "/barcode/{type}/data/{data}"
4846
)
4947
@Cacheable("barcodes")
5048
public ResponseEntity<byte[]> getBarcodeImage(
@@ -56,7 +54,7 @@ public ResponseEntity<byte[]> getBarcodeImage(
5654
@PathVariable(name = "data")
5755
String data,
5856

59-
@Schema(example = "png", allowableValues = { "png", "jpg", "gif" }, defaultValue = "png")
57+
@Schema(example = "png", allowableValues = { "png", "gif" }, defaultValue = "png")
6058
@RequestParam(name = "imageFormat")
6159
Optional<String> imageFormat,
6260

0 commit comments

Comments
 (0)