Skip to content

UNNAMED_SCHEMA should be treated like ANY #654

Open
@tomwidmer

Description

@tomwidmer

The following schema:

{
  title: "Foo",
  properties: {
    foo: { description: 'Foo is untyped, should allow anything' }
  }
}

should become:

interface Foo {
  foo: unknown; // or any, depending on options
}

But instead is rendered as:

interface Foo {
  foo: { [k: string]: unknown }
}

This is because the fallback for a schema that has no other typescript type is UNNAMED_SCHEMA, and this is treated as an interface, not an unknown type like ANY.

My workaround for now is:

{
  title: "Foo",
  properties: {
    foo: { type: 'any', description: 'Foo is untyped' }
  }
}

but the 'any' type isn't valid JSON schema, so I'd prefer to avoid this and just leave type out.

Great tool BTW!

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