Skip to content

Generating invalid code from Record #20

@stwiname

Description

@stwiname

I have this type on my server:

const Metadata = Type.Record(
  Type.String(),
  Type.Union([Type.String(), Type.Number(), Type.Boolean(), Type.Null()]),
  {
    description: `Metadata is for your internal use. It is not exposed to users through passes.\n The metadata is limited to ${METADATA_MAX_LENGTH} characters when serialized to JSON.`,
  },
)

Which results in the following openapi spec (full spec here passform-api.json)

"metadata": {
  "description": "Metadata is for your internal use. It is not exposed to users through passes.\n The metadata is limited to 5000 characters when serialized to JSON.",
  "type": "object",
  "additionalProperties": {
    "anyOf": [
      {
        "type": "string"
      },
      {
        "type": "number"
      },
      {
        "type": "boolean"
      },
      {
        "type": "null"
      }
    ]
  }
},

And the resulting generated code is invalid:

metadata: T.Optional(
  T.Object(
    {},
    {
      additionalProperties: {
        anyOf: [
          { type: 'string' },
          { type: 'number' },
          { type: 'boolean' },
          { type: 'null' }
        ]
      }
    }
  )
),

Im using "@sinclair/typebox": "^0.34.38"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions