openapi-generator/modules/openapi-generator/src/main/resources/apex/OAS.cls
If you send a response that contains anything in addition to "application/json" nothing is returned.
Set the toReturnValue to validate for more than just application/json e.g. UTF-8 within the Content Type.
@testvisible
protected virtual Object toReturnValue(String body, Type returnType, String contentType) {
Original ---> if (contentType == 'application/json') {
Desired ---> if (contentType.contains('application/json')) {
Object o = returnType.newInstance();
if (o instanceof MappedProperties) {
Map<String, String> propertyMappings = ((MappedProperties) o).getPropertyMappings();
for (String baseName : propertyMappings.keySet()) {
body = body.replaceAll('"' + baseName + '"\s*:',
'"' + propertyMappings.get(baseName) + '":');
}
}
JsonParser parser = Json.createParser(body);
parser.nextToken();
return parser.readValueAs(returnType);
}
return body;
}
openapi-generator/modules/openapi-generator/src/main/resources/apex/OAS.cls
If you send a response that contains anything in addition to "application/json" nothing is returned.
Set the toReturnValue to validate for more than just application/json e.g. UTF-8 within the Content Type.
@testvisible
protected virtual Object toReturnValue(String body, Type returnType, String contentType) {
Original ---> if (contentType == 'application/json') {
Desired ---> if (contentType.contains('application/json')) {
Object o = returnType.newInstance();
if (o instanceof MappedProperties) {
Map<String, String> propertyMappings = ((MappedProperties) o).getPropertyMappings();
for (String baseName : propertyMappings.keySet()) {
body = body.replaceAll('"' + baseName + '"\s*:',
'"' + propertyMappings.get(baseName) + '":');
}
}
JsonParser parser = Json.createParser(body);
parser.nextToken();
return parser.readValueAs(returnType);
}
return body;
}