openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG] Missing import in generated DTO

Open alapierre opened this issue 1 year ago • 1 comments

Bug Report Checklist

there is missing java.util.function.Function import for:

public final static Map<String, ProfileEnum> VALUE_MAPPING = Map.copyOf(Arrays.stream(values())
                .collect(Collectors.toMap(v -> v.value, Function.identity())));

it happened in CustomerCreateDTO when I use allOf in that way:

    CustomerCreateDTO:
      type: object
      required:
        - profile
        - nip
      allOf:
        - $ref: '#/components/schemas/CustomerUpdateDTO'
        - type: object
      properties:
        profile:
          type: string
          enum:
            - individual
            - corporate
        nip:
          type: string
          maxLength: 128
          minLength: 8
    CustomerUpdateDTO:
      type: object
      required:
        - street
        - buildingNumber
        - postalCode
        - city
        - email
        - parking
        - licensePlate
      properties:
        firstName:
          type: string
          maxLength: 128
        lastName:
          type: string
          maxLength: 128
        companyName:
          type: string
          maxLength: 256
        street:
          type: string
          maxLength: 512
        buildingNumber:
          type: string
          maxLength: 64
        apartmentNumber:
          type: string
          maxLength: 32
        postalCode:
          type: string
          maxLength: 16
        city:
          type: string
          maxLength: 256
        email:
          type: string
          maxLength: 256
          format: email
        licensePlate:
          type: string
          maxLength: 64
        notes:
          type: string
          maxLength: 512

but similar structure, without enum works with no problem:

    CustomerDTO:
      allOf:
        - $ref: '#/components/schemas/CustomerCreateDTO'
        - type: object
          required:
            - id
            - version
          properties:
            id:
              type: string
              format: uuid
            version:
              type: integer
            cyclicalInvoicing:
              type: boolean
            individual:
              type: boolean

alapierre avatar Aug 08 '24 10:08 alapierre

@alapierre I think, this bug in this project: https://github.com/micronaut-projects/micronaut-openapi

I fixed it here: https://github.com/micronaut-projects/micronaut-openapi/pull/1731

altro3 avatar Aug 25 '24 12:08 altro3