jskov / openapi-jaxrs-client

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

Inheritance does not include extends in generated model when properties is nested inside allOf #572

Closed lyngze closed 6 months ago

lyngze commented 6 months ago

I am experiencing issues when generating DTO models from a spec with properties nested inside the allOf tag for models with inhertiance. If I move properties and tags other than " $ref" outside the allOf tag it seems to work. Concretely extends is missing on model with nested properties in allOf, but present as it should be when properties is moved outside of allOf tag. This exact combination is used in Swaggers own example for inheritance in their documentation, so I think this should be supported? https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/

I have included the snippet for the models with inheritance below (file upload did not seem to work properly?) SMSMailIdentification has the problem (original spec) VirkPersonIdentification works as it should (identation modified)

VirkPersonIdentification:
  allOf:
    - $ref: '#/components/schemas/Identification'
  properties:
    virkUnitNumber:
      description: 'DA: Virk.dk person id<br/>The id for a person at virk.dk'
      type: string
  description: 'DA: Virk.dk registreret person-id. <br/>Virk.dk registered personId'
  type: object
SMSMailIdentification:
  allOf:
    - $ref: '#/components/schemas/Identification'
    - type: object
      properties:
        countryCode:
          description: 'DA: Landekode for telefonnummeret<br/>The country code of
            the phone number'
          example: +45
          type: string
        phoneNumber:
          description: 'DA: Telefonnummer til brug ved SMS login<br/>The phone number
            to use for SMS login. Maximum of 30 digits excluding spaces allowed.'
          example: 12345678
          maxLength: 40
          type: string
      description: 'DA: SMS og mail identifikation<br/>SMS and mail identification'
IdentificationType:
  enum:
    - VIRK_PERSON
    - SMS_MAIL
  type: string
Identification:
  required:
    - type
  properties:
    type:
      $ref: '#/components/schemas/IdentificationType'
    locked:
      default: false
      description: If identification is protected by a secret, this field is true.<br>When
        true the following operations can only be done when the known secret is
        supplied in header x-locked-secret.<ul><li>PATCH of contact with a different
        identification type than already set.</li></ul>
      readOnly: true
      type: boolean
    loginId:
      description: 'DA: Login id<br/>Login id, from the security token.'
      readOnly: true
      type: string
  description: '
    <b>NOTE: Discriminator mapping is not shown in Swagger UI (as of september 2023). 
    Read the .yaml spec file directly for the discriminator mapping or use an alternative UI, for example Redoc.</b>
    <br/><br/>
    The identification of the contact. Can only be changed when identification.loginId
    is not set.
    '
  discriminator:
    mapping:
      VIRK_PERSON: '#/components/schemas/VirkPersonIdentification'
      SMS_MAIL: '#/components/schemas/SMSMailIdentification'
    propertyName: type
  oneOf:
    - $ref: '#/components/schemas/VirkPersonIdentification'
    - $ref: '#/components/schemas/SMSMailIdentification'
  nullable: true
  type: object