Converting Claim Graph to POJO classes for IG app

94 Views Asked by At

From Claimcenter Claim Cloud API, I can get the JSON SCHEMA for Claim Graph. I would like to convert the Claim Graph schema to POJO classes to be used in IG apps. Is there any easy way to generate?

I used the jsonschema2pojo gradle plugin) (https://github.com/joelittlejohn/jsonschema2pojo/tree/master/jsonschema2pojo-gradle-plugin but not seeing the expected result. when i use the sourceType as 'jsonschema' then i don't see any files getting generated but when i use the sourceType as 'json' then it is creating multiple duplicate classes with _.

are there any other tools to convert the Guidewire schema to POJO classes? Screen Shot of Duplicate Classes

1

There are 1 best solutions below

1
Domenick Doran On

I've used openAPI for this purpose in the past in IG apps which want to consume IS APIs. There's some nonstandard tags which end up in the openAPI docs generated by IS apps which require some manual tweaks. Let me document them here for you.

To install the OpenAPI code generator, these instructions were followed: https://openapi-generator.tech/docs/installation/

If the default generator commands are used, GSON will be used, which is not supported in Guidewire Cloud. To use Jackson instead, the following commands were run.

npx @openapitools/openapi-generator-cli generate -i openapi-account.json -g java -o account --additional-properties=library=jersey3,serializationLibrary=jackson

npx @openapitools/openapi-generator-cli generate -i openapi-composite.json -g java -o composite --additional-properties=library=jersey3,serializationLibrary=jackson

npx @openapitools/openapi-generator-cli generate -i openapi-job.json -g java -o account --additional-properties=library=jersey3,serializationLibrary=jackson

1)When using the openapi file (i.e. http://localhost:8180/pc/rest/job/v1/openapi.json), POJOs attributes which are date datatypes are built with a datatype of JsonNullable. Meanwhile, the methods that deserialize and serialize them are built using simple LocalDate. This presents an error at compile time. All instances had to be manually fixed.

2)The default ObjectMapper instance was serializing non-consumable payloads. It was including all null attributes, and adding in an attribute named "present" with a value of false for all nulls. It was also including all null arrays. Finally, it was serializing dates to a very long structured format. To address these issues, a custom ObjectMapper was initialized and used for all serializations.

The custom object mapper was built as such:

//Set the default mapper to behave with the necessary options
        public JacksonDataFormat customDataFormatter;
        customDataFormatter = new JacksonDataFormat();
        _mapper = new ObjectMapper();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        _mapper = _mapper
                .setSerializationInclusion(JsonInclude.Include.NON_NULL)
                .setSerializationInclusion(JsonInclude.Include.NON_ABSENT)
                .setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
                .setDateFormat(sdf)
                .registerModule(new JavaTimeModule())
                .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
                .registerModule(new JsonNullableModule());
        customDataFormatter.setObjectMapper(_mapper);