jskov / openapi-jaxrs-client

An OpenAPI JAX-RS client code generator
Apache License 2.0
1 stars 4 forks source link

Jsonb property field naming problematic #580

Closed jskov-jyskebank-dk closed 6 months ago

jskov-jyskebank-dk commented 6 months ago

It seems that fields in the generated classes named with _ (default?) will not work correctly with jsonb.

Problem is (it seems) that the getter/setter does not match the expected bean-naming for the field.

This is not a problem (that I know of) with jackson. So may be jsonb-specific.

Works if the property naming annotation is moved to the setter (for deserialization)

https://javaee.github.io/jsonb-spec/docs/user-guide.html#changing-property-names

(Allan)

jskov-jyskebank-dk commented 6 months ago

This is how it looks with the old generator:

  public static final String JSON_PROPERTY_INDBERETNINGS_DATO = "indberetnings_dato";
  @JsonProperty(JSON_PROPERTY_INDBERETNINGS_DATO)
  @JsonDeserialize(using = _LocalDateJacksonDeserializer.class)
  @JsonSerialize(using = _LocalDateJacksonSerializer.class)
  private LocalDate indberetningsDato;

And the new:


  public static final String JSON_PROPERTY_INDBERETNINGS_DATO = "indberetnings_dato";
  @Schema(description = "Dato for hvornår der indberettes")
  @JsonbProperty(JSON_PROPERTY_INDBERETNINGS_DATO)
  private LocalDate indberetnings_dato;

Property naming rule should probably not change - to _ before type fixing

jskov-jyskebank-dk commented 6 months ago

Yes, getter/setter naming must match property

jskov-jyskebank-dk commented 6 months ago

naming-rules-property = REGEXP/_/-/; PROPERTYNAME

should probably be the default - or PROPERTYNAME should default to camelcasing on _ (but then it breaks for enums)