Home > Back-end >  JSONSchema to TypeScript - Defining a record of strings to strings
JSONSchema to TypeScript - Defining a record of strings to strings

Time:04-07

I'm using json-schema-to-typescript and would like to specify an array of strings.

Currently, I have the following:

      "type": "object",
      "description": "...",
      "additionalProperties": true,
      "items": {
        "type": "string"
      }

When converted to TS, it returns [k: string]: unknown;

I'd like for it to return [k: string]: string; instead.

Thanks in advance

CodePudding user response:

items is an array keyword, but you have specified "type": "object". Have you tried changing that to "type": "array" and removing additionalProperties?

CodePudding user response:

I did it by removing the items property and changing to "additionalProperties": { "type": "string" }

  • Related