Skip to content

Generate typealias $className = Any when type cannot be determined #28

Open
@cmpaul

Description

@cmpaul

Hi @pwall567 👋

We are generating a schema that will support any valid JSON and would love to have Kotlin codegen support for this.

As an example, consider the following Untyped type:

$defs:
  MyType:
    type: object
    properties:
      data:
        "$ref": "#/$defs/Untyped"
  Untyped:
    type:
    - array
    - boolean
    - integer
    - number
    - object
    - string

There is no error, but this simply fails to generate a data class for Untyped, and therefore the resulting Kotlin code does not compile.

In cases like this where a single type cannot be determined, one option is to generate a class with a typealias:

// Untyped.kt
typealias Untyped = Any

I have drafted a PR to demonstrate what we are looking for here: #27

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions