jskov / openapi-jaxrs-client

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

Discriminator mapped subtypes do not extend abstract super #556

Closed jskov-jyskebank-dk closed 6 months ago

jskov-jyskebank-dk commented 7 months ago

This example (customerRoomV3) renders Identification as abstract, but the three subtypes does not extend it.

    PrivateIdentification:
      allOf:
        - $ref: '#/components/schemas/Identification'
        - properties:
            sevenFirstCprDigits:
              type: string
          type: object
    VirkPersonIdentification:
      allOf:
        - $ref: '#/components/schemas/Identification'
        - properties:
            virkUnitNumber:
              type: string
          type: object
    SMSMailIdentification:
      allOf:
        - $ref: '#/components/schemas/Identification'
        - properties:
            countryCode:
              type: string
          type: object
    IdentificationType:
      enum:
        - PRIVATE
        - VIRK_PERSON
        - SMS_MAIL
      type: string
    Identification:
      required:
        - type
      properties:
        type:
          $ref: '#/components/schemas/IdentificationType'
        locked:
          default: false
          readOnly: true
          type: boolean
        loginId:
          readOnly: true
          type: string
      discriminator:
        mapping:
          PRIVATE: '#/components/schemas/PrivateIdentification'
          VIRK_PERSON: '#/components/schemas/VirkPersonIdentification'
          SMS_MAIL: '#/components/schemas/SMSMailIdentification'
        propertyName: type
      nullable: true
      type: object

(MM)

jskov-jyskebank-dk commented 7 months ago

Identification is invalid, as it is missing anyof for binding to sub-types. Discriminator alone is not enough (according to spec and editor.swagger.io)

jskov-jyskebank-dk commented 6 months ago

Spec contains an example without:

components:
  schemas:
    Pet:
      type: object
      required:
      - petType
      properties:
        petType:
          type: string
      discriminator:
        propertyName: petType
        mapping:
          dog: Dog
    Cat:
      allOf:
      - $ref: '#/components/schemas/Pet'
      - type: object
        # all other properties specific to a `Cat`
        properties:
          name:
            type: string
    Dog:
      allOf:
      - $ref: '#/components/schemas/Pet'
      - type: object
        # all other properties specific to a `Dog`
        properties:
          bark:
            type: string
    Lizard:
      allOf:
      - $ref: '#/components/schemas/Pet'
      - type: object
        # all other properties specific to a `Lizard`
        properties:
          lovesRocks:
            type: boolean

So should probably just do it without option (not sure if parser finds the binding, but can make a reverse binding)

jskov-jyskebank-dk commented 6 months ago

Fixed via list->set parent change in 0.10.10