Date-time in OpenAPI has problems when generating Java code

Hey folks!

I created a Java client using the OpenAPI.json and try to use this from a Java application towards Camunda Run 7.5.2-ee.

For convenience, I stripped the code down and pushed it here: GitHub - berndruecker/camunda-7-openapi-demo

I get an exception when I deploy a process definition (and it parses the response, respectively the date fields):

Exception in thread "main" org.threeten.bp.format.DateTimeParseException: Text '2021-06-09T16:36:24.807+0200' could not be parsed at index 23
	at org.threeten.bp.format.DateTimeFormatter.parseToBuilder(DateTimeFormatter.java:1588)
	at org.threeten.bp.format.DateTimeFormatter.parse(DateTimeFormatter.java:1491)
	at org.threeten.bp.OffsetDateTime.parse(OffsetDateTime.java:359)
	at org.openapitools.client.JSON$OffsetDateTimeTypeAdapter.read(JSON.java:226)
	at org.openapitools.client.JSON$OffsetDateTimeTypeAdapter.read(JSON.java:190)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
	at com.google.gson.Gson.fromJson(Gson.java:932)
	at com.google.gson.Gson.fromJson(Gson.java:897)
	at com.google.gson.Gson.fromJson(Gson.java:846)
	at org.openapitools.client.JSON.deserialize(JSON.java:146)
	at org.openapitools.client.ApiClient.deserialize(ApiClient.java:793)
	at org.openapitools.client.ApiClient.handleResponse(ApiClient.java:999)
	at org.openapitools.client.ApiClient.execute(ApiClient.java:923)
	at org.openapitools.client.api.DeploymentApi.createDeploymentWithHttpInfo(DeploymentApi.java:190)
	at org.openapitools.client.api.DeploymentApi.createDeployment(DeploymentApi.java:165)
	at io.berndruecker.demo.App.main(App.java:36)

Seems the time zone offset “+0200” is not a valid “date-time” according to Data Types - but it is what Camunda Run returns for me. I deleted all

          "format": "date-time"

from the openapi.json and re-generated, then it works. It seems to be some additional format validation.

Is this a bug and should be fixed? It is a bit annoying as it does not work out to the box.

And as a bonus - the generated test case does not compile without manual fixes:

grafik

Thanks!
Bernd

1 Like

@StephenOTT just pointed me to this list of possible issues with the current status of OpenAPI: OpenApi Bug Tracking (Camunda's OpenAPI Spec) · Issue #27 · StephenOTT/Cammand · GitHub

Hi @BerndRuecker,

Providing the answers, in case someone else has these problems:
for the openapi-generator-maven-plugin, the legacy property needs to be set in the configOptions. This solution is not Camunda Platform specific, it will vary based on the generator.

Regarding the failing test cases, CAM-13647 has been created.

Dan

Thanks Dan for adding this!

This is how that property looks like in real-life: Added legacy date library option · berndruecker/camunda-platform-openapi-demo@417dc6b · GitHub

Note that there was also oa bug with the "jobDefinitionID " that is fixed on master and the 7.15.3 EE patch level.

Best
Bernd