'JSONSchema to TypeScript - Defining a record of strings to strings
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
Solution 1:[1]
items is an array keyword, but you have specified "type": "object". Have you tried changing that to "type": "array" and removing additionalProperties?
Solution 2:[2]
I did it by removing the items property and changing to "additionalProperties": { "type": "string" }
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ether |
| Solution 2 | Rui Rego |
