OpenAPITools / OpenAPITools/openapi-generator

[BUG] Missing import in generated DTO

Open
#19,324 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the generated Java DTO from the supplied CustomerCreateDTO and CustomerUpdateDTO schemas, focusing on the allOf combination and enum-generated VALUE_MAPPING. Inspect how imports are collected for generated DTOs and verify that Function is included when Function.identity() is emitted. Done means the generated CustomerCreateDTO compiles without a missing-import error; no test file is named in the report.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.