Skip to content

[BUG][JAVA] While using java 17 and openapi-generator-maven-plugin with version 7.10.0 there is a compilation error while using allOf #20135

Closed
@oleksandr-ionov-mark43

Description

@oleksandr-ionov-mark43

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

While using java 17 and openapi-generator-maven-plugin with version 7.10.0 there is a compilation error while using allOf.
Example:

openapi: '3.0.3'
info:
  version: '2.0'
paths: {}
components:
  schemas:
    ExamplesCreateRequest:
      type: 'object'
      properties:
        examples:
          type: 'array'
          items:
            $ref: './ExampleCreateRequest.yaml#/components/schemas/ExampleCreateRequest'
          description: 'List of examples to create.'
      required:
        - 'examples'

and ExampleCreateRequest is next:

openapi: '3.0.3'
info:
  version: '2.0'
paths: {}
components:
  schemas:
    ExampleCreateRequest:
      type: 'object'
      allOf:
        - $ref: './Example.yaml#/components/schemas/Example'

the next java code was generated

public ExamplesCreateRequest addExamplesItem(Example examplesItem) {
    if (this.examples == null) {
      this.examples = new ArrayList<>();
    }
    this.examples.add(examplesItem); <--- Compilation error 
    return this;
  }
openapi-generator version
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions