Skip to content

Compile error on arrays of objects with additionalPropertiesOption: strict #37

Open
@gino-m

Description

@gino-m

At compile-time we see the following when setting additionalPropertiesOption: strict in the config:

Cannot check for instance of erased type: List<Bar.Foo>

For a schema containing an array of objects:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "bar.schema.json",
  "properties": {
    "foos": {
      "type": "array",
      "items": {
        "id": "foo",
        "type": "object"
      }
    }
  }
}

The offending generated code in Bar.kt:

if (cg_map.containsKey("foos"))
  require(cg_map["foos"] is List<Foo>) { "foos is not the correct type, expecting List<Foo>?" }

This is a blocker for us, since our schema required pattern properties, thus iiuc we need to enable additionalPropertiesOption: strict for the relevant code the generated.

Applying via json-kotlin-gradle plugin 0.102.

@pwall567 Do you have bandwidth to provide a fix? 🙏

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