Remove charset from pact sample contract media type. Switch to explicitly
returning charset media type for other samples.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.example.fraud;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.CookieValue;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
@@ -40,7 +41,7 @@ class FraudNameController {
|
||||
this.fraudVerifier = fraudVerifier;
|
||||
}
|
||||
|
||||
@PutMapping(value = "/frauds/name")
|
||||
@PutMapping(value = "/frauds/name", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
public NameResponse checkByName(@RequestBody NameRequest request) {
|
||||
boolean fraud = this.fraudVerifier.isFraudByName(request.getName());
|
||||
if (fraud) {
|
||||
@@ -50,7 +51,7 @@ class FraudNameController {
|
||||
"Don't worry " + request.getName() + " you're not a fraud");
|
||||
}
|
||||
|
||||
@GetMapping(value = "/frauds/name")
|
||||
@GetMapping(value = "/frauds/name", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
public String checkByName(@CookieValue("name") String value,
|
||||
@CookieValue("name2") String value2) {
|
||||
return value + " " + value2;
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
"response": {
|
||||
"status": 200,
|
||||
"headers": {
|
||||
"Content-Type": "application/vnd.fraud.v1+json;charset=UTF-8"
|
||||
"Content-Type": "application/vnd.fraud.v1+json"
|
||||
},
|
||||
"body": {
|
||||
"fraudCheckStatus": "FRAUD",
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
"response": {
|
||||
"status": 200,
|
||||
"headers": {
|
||||
"Content-Type": "application/vnd.fraud.v1+json;charset=UTF-8"
|
||||
"Content-Type": "application/vnd.fraud.v1+json"
|
||||
},
|
||||
"body": {
|
||||
"fraudCheckStatus": "OK",
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"response": {
|
||||
"status": 200,
|
||||
"headers": {
|
||||
"Content-Type": "application/vnd.fraud.v1+json;charset=UTF-8"
|
||||
"Content-Type": "application/vnd.fraud.v1+json"
|
||||
},
|
||||
"body": {
|
||||
"count": 100
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"response": {
|
||||
"status": 200,
|
||||
"headers": {
|
||||
"Content-Type": "application/vnd.fraud.v1+json;charset=UTF-8"
|
||||
"Content-Type": "application/vnd.fraud.v1+json"
|
||||
},
|
||||
"body": {
|
||||
"count": 200
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.example.fraud.model.FraudCheck;
|
||||
import com.example.fraud.model.FraudCheckResult;
|
||||
import com.example.fraud.model.FraudCheckStatus;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -38,7 +39,7 @@ public class FraudDetectionController {
|
||||
private static final BigDecimal MAX_AMOUNT = new BigDecimal("5000");
|
||||
|
||||
// tag::server_api[]
|
||||
@RequestMapping(value = "/fraudcheck", method = PUT)
|
||||
@RequestMapping(value = "/fraudcheck", method = PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
public FraudCheckResult fraudCheck(@RequestBody FraudCheck fraudCheck) {
|
||||
// end::server_api[]
|
||||
// tag::new_impl[]
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.example.fraud;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -38,7 +39,7 @@ class FraudNameController {
|
||||
this.fraudVerifier = fraudVerifier;
|
||||
}
|
||||
|
||||
@PutMapping(value = "/frauds/name")
|
||||
@PutMapping(value = "/frauds/name", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
public NameResponse checkByName(@RequestBody NameRequest request) {
|
||||
boolean fraud = this.fraudVerifier.isFraudByName(request.getName());
|
||||
if (fraud) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.example.fraud;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -40,12 +41,12 @@ public class FraudStatsController {
|
||||
this.statsProvider = statsProvider;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/frauds")
|
||||
@GetMapping(value = "/frauds", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
public Response countAllFrauds() {
|
||||
return new Response(this.statsProvider.count(FraudType.ALL));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/drunks")
|
||||
@GetMapping(value = "/drunks", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
public Response countAllDrunks() {
|
||||
return new Response(this.statsProvider.count(FraudType.DRUNKS));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user