OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.8k stars 6.58k forks source link

[BUG] Missing import in generated DTO #19324

Open alapierre opened 3 months ago

alapierre commented 3 months ago

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
altro3 commented 2 months ago

@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