Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG APEX] Code Generation in OAS.cls #7500

Closed
henryh-force opened this issue Sep 24, 2020 · 2 comments · Fixed by #7515
Closed

[BUG APEX] Code Generation in OAS.cls #7500

henryh-force opened this issue Sep 24, 2020 · 2 comments · Fixed by #7515

Comments

@henryh-force
Copy link
Contributor

henryh-force commented Sep 24, 2020

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;
}

@wing328
Copy link
Member

wing328 commented Sep 24, 2020

Your suggestion sounds good to me May I know if you've time to submit a PR with the suggested change?

@henryh-force
Copy link
Contributor Author

Sure I can submit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants