Skip to content

[BUG] kotlin-spring does not play well with Any type #14137

@piotrpolak

Description

@piotrpolak

Bug Report Checklist

Description

A structure accepting any valid JSON described at https://swagger.io/docs/specification/data-models/data-types/#any generates unusable Model code.

Example:

components:
  schemas:
    AnyValue:
      description: Accepts any valid JSON value
      anyOf:
        - type: string
        - type: number
        - type: integer
        - type: boolean
        - type: array
          items:
            $ref: "#/components/schemas/AnyValue"
        - type: object
          additionalProperties: true

gets translated to

/**
 * Accepts any valid JSON value
*/
@javax.annotation.Generated
class AnyValueDto(

) {

}
openapi-generator version

6.2.2

OpenAPI declaration file content or url
components:
  schemas:
    AnyValue:
      description: Accepts any valid JSON value
      anyOf:
        - type: string
        - type: number
        - type: integer
        - type: boolean
        - type: array
          items:
            $ref: "#/components/schemas/AnyValue"
        - type: object
          additionalProperties: true
Generation Details
Steps to reproduce

Generate code using the described schema.

Related issues/PRs
Suggest a fix

A complex combination anyOf should be translated to Any (Java Object) and should not try to generate custom empty Model class.

It should generate the same code as

components:
  schemas:
    AnyValue: { }

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