We are attempting to set up Snowtype for a data structure, but we have encountered an issue where the generated TypeScript interface is not adhering to the rules defined in the schema.According to the JSON Schema we provided (see below), additional properties should not be allowed in the data structure. However, when generating the TypeScript interface using Snowtype, we noticed that the interface includes an index signature [property: string]: any;
for the Tv2PlayProduct
, Feature
, and Pricing
interfaces. This index signature allows any additional properties to be added to the objects, which contradicts what is allowed in the console.Here is the relevant part of the generated TypeScript interface:
typescript
export interface Tv2PlayProduct {
disney?: string;
features?: Feature[];
hayu?: boolean;
hvodAlternativeProductId?: string;
id: string;
includedAddOns?: string[];
isActive?: boolean;
name: string;
pricing?: Pricing[];
productType: string;
supportedAddOns?: string[];
[property: string]: any;
}
export interface Feature {
id: string;
name?: string;
[property: string]: any;
}
export interface Pricing {
campaign?: string;
initialPrice: number;
period?: string;
periodId: PeriodID;
recurringPrice: number;
[property: string]: any;
}
The JSON Schema we are using is as follows:
{
"$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
"type": "object",
"self": {
"format": "jsonschema",
"version": "2-0-0"
},
"description": "Schema for a product which can be purchased",
"properties": {
"name": {
"type": "string"
},
"id": {
"type": "string"
},
"productType": {
"type": "string"
},
"includedAddOns": {
"type": "array",
"items": {
"type": "string"
}
},
"supportedAddOns": {
"type": "array",
"items": {
"type": "string"
}
},
"hayu": {
"type": "boolean"
},
"pricing": {
"type": "array",
"items": {
"type": "object",
"required": [
"initialPrice",
"recurringPrice",
"periodId"
],
"properties": {
"initialPrice": {
"type": "number"
},
"recurringPrice": {
"type": "number"
},
"periodId": {
"type": "string",
"enum": [
"h_48",
"day",
"week",
"month",
"year",
"halfyear",
"est",
"unknown"
]
},
"period": {
"type": "string"
},
"campaign": {
"type": "string"
}
}
}
},
"isActive": {
"type": "boolean"
},
"disney": {
"type": "string"
},
"features": {
"type": "array",
"items": {
"type": "object",
"required": [
"id"
],
"properties": {
"name": {
"type": "string"
},
"id": {
"type": "string"
}
}
}
},
"hvodAlternativeProductId": {
"type": "string"
}
},
"required": [
"name",
"id",
"productType"
]
}
console: