Skip to content

Commit

Permalink
OKTA-803484: Fix deserialization issue with `BrandsApi::listBrandDoma…
Browse files Browse the repository at this point in the history
…ins()` response (#1566)

OKTA-803484: Fix deserialization issue with BrandsApi::listBrandDomains() response
  • Loading branch information
arvindkrishnakumar-okta authored Oct 4, 2024
1 parent 79dc906 commit 882a1fe
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions api/src/main/resources/custom_templates/ApiClient.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
objectMapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
{{#joda}}
objectMapper.registerModule(new JodaModule());
{{/joda}}
Expand Down Expand Up @@ -900,6 +901,16 @@ protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>
return null;
}

// some responses of list type contain a root element that need to be stripped before passing to ObjectMapper
if (valueRawType.getTypeName().contains("java.util.List")) {
if (content.startsWith("{\"")) {
// remove leading {"blahblah":
content = content.substring(content.indexOf(":") + 1);
// remove trailing }
content = content.substring(0, content.length() - 1);
}
}

T value = objectMapper.readValue(content, valueType);
return value instanceof List ? PagedList.constructPagedList(response, value) : value;
} else if ("text/plain".equalsIgnoreCase(mimeType)) {
Expand Down

0 comments on commit 882a1fe

Please sign in to comment.