jskov / openapi-jaxrs-client

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

Map bad/missing value-type #596

Closed jskov-jyskebank-dk closed 7 months ago

jskov-jyskebank-dk commented 7 months ago
    FlagDto:
      type: object
      properties:
        property:
          type: string
          nullable: true
        name:
          type: string
          nullable: true
        description:
          type: string
          nullable: true
        flagSeverity:
          $ref: '#/components/schemas/FlagSeverityEnum'
        isTriggered:
          type: boolean
        data:
          type: object
          additionalProperties: {}
          nullable: true
      additionalProperties: false
    FlagSeverityEnum:
      enum:
        - disabled
        - info
        - riskIndicator
        - warning
      type: string

results in this code:

@JsonSerialize(include = com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion.NON_NULL)
@javax.annotation.processing.Generated(value = "dk.mada.jaxrs.Generator")
public class FlagDto implements Serializable {
  public static final String JSON_PROPERTY_DATA = "data";
  @JsonProperty(JSON_PROPERTY_DATA)
  @Schema(nullable = true)
  private Map<String, <VALIDATION>> data;

  public static final String JSON_PROPERTY_DESCRIPTION = "description";
  @JsonProperty(JSON_PROPERTY_DESCRIPTION)
  @Schema(nullable = true)
  private String description;

So the map data type is not processed correctly.

(claus)

jskov-jyskebank-dk commented 7 months ago
content:
    application/json:
      schema:
        type: object
        additionalProperties:
          type: string

Workaround is to specify a type for the properties

So generator should probably have an option to control a default fall-back type (Object, prolly)

jskov commented 7 months ago

fixed by #611