Skip to content

[BUG] [Java] Client generated oneOf model broken if data-type is complexType #11836

@bgong-mdsol

Description

@bgong-mdsol

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

The oneOf & anyOf models for the java-client generator are broken because of missing import class for complex data type

openapi-generator version

The version 6.1.x and the latest master branch (6.2.0)

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: oneOf schemas
  version: "1.0.0"
paths:
  /:
    get:
      summary: Empty Route
      responses:
        "200":
          description: Good Request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReturnValue'
        "400":
          description: Bad Request.
components:
  schemas:
    ReturnValue:
      oneOf:
      - type: string
      - type: string
        format: date-time
      - type: integer
Generation Details

Command line used for generation

openapi-generator-cli generate \
  -g java --library native \
  -i name_of_file.yaml \
  -o myApi
Steps to reproduce
  • Issues in the generated client:
public class ReturnValue extends AbstractOpenApiSchema {
    ...
            // deserialize OffsetDateTime
            ...
                deserialized = tree.traverse(jp.getCodec()).readValueAs(OffsetDateTime.class);
   ...
}
  • Maven build failed "illegal start of type"
Related issues/PRs
Suggest a fix

Should add import java.time.OffsetDateTime; for OffsetDateTime

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