Skip to content

[BUG] [JAVA] Property "useOneOfInterfaces" seems to be ignored during generation since version v7.13 #21234

@neffets74

Description

@neffets74

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • 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

In my specification I have a "oneOf" relation between two components, a interface ExINterface and a class ExObject1 implementing this interface (see specification snippet below).

When generating the code out of the specification with plugin version 7.12.0 I get the expected result:

public class ExObject1 implements ExInterface

But when generating the code with plugin version 7.13.0, the generated class does not implement the interface:

public class ExObject1

The interface class itself is not even generated.

openapi-generator version

v7.13.0

OpenAPI declaration file content or url
openapi: 3.0.3
info:
    title: Example API
    description: This is an example API specification serving as error reproducer
    version: 1.0.0
paths:
  /example:
    get:
      summary: Example endpoint
      description: This is an example endpoint
      operationId: getExample
      parameters:
        - name: exampleParam
          in: query
          required: true
          description: An example query parameter
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExInterface'
components:
  schemas:
    ExInterface:
      oneOf:
        - $ref: '#/components/schemas/ExObject1'
    ExObject1:
      type: object
      properties:
        name:
          type: string
          description: The name of the object
Generation Details

Using the following code gen options:

{
  "generatorName": "java",
  "library": "google-api-client",

  "sourceFolder": ".",
  "basePackage": "sk.example.base",
  "configPackage": "sk.example.config",
  "modelPackage": "sk.example.model",
  "apiPackage": "sk.example.client",

  "disallowAdditionalPropertiesIfNotPresent": true,
  "interfaceOnly": true,
  "legacyDiscriminatorBehavior": false,
  "openApiNullable": false,
  "useBeanValidation": true,
  "useEnumCaseInsensitive": true,
  "useJakartaEe": true,
  "useOneOfInterfaces": true,
  "useOptional": false
}
Steps to reproduce

Calling "./gradlew openapiGenerate" and reviewing the generated class "ExObject1".

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