Onto-Med / top-api

REST API of the TOP Framework
https://onto-med.github.io/top-api/
MIT License
0 stars 1 forks source link

Mapping of date-time values to Java class #68

Closed ChristophB closed 2 years ago

ChristophB commented 2 years ago

Requested Changes

Some properties in the top-api schema are timezone independent. They should be mapped to java.time.LocalDateTime.

e.g.: date-time value in a derived phenotype's expression

Problems

This timezone independence does not apply to all date-time values. Some values exchanged via API indeed need a timezone! (e.g. create/update date-time of phenotypes)

We can only set the mapping to a Java class via global generator configuration option <dateLibrary>java8-localdatetime</dateLibrary> and this is not recommended for JDK 1.8+ (see java spring generator docs).

ChristophB commented 2 years ago

For selected properties, we could introduce a custom time mapping:

DateTimeValue:
  allOf:
    - $ref: "#/components/schemas/Value"
    - type: object
      properties:
        value:
          type: string
          format: x-local-date-time # <= custom format

And in pom.xml:

<typeMappings>
  <typeMapping>x-local-date-time=java.time.LocalDateTime</typeMapping>
</typeMappings>
ChristophB commented 2 years ago

relevant properties for custom format mapping: