Closed
Description
I am not sure whether this is a configuration problem, expected behaviour or a bug but...
I declare a json schema file id.schema.json containing:
{
"title": "TId",
"type": "string"
}
Running json-schema-to-typescript.compileFromFile( id.schema.json ) generates:
export type TId = string
I create a second json schema file example.schema.json referencing id.schema.json and containing:
{
"title": "IExample",
"type": "object",
"properties": {
"id": {
"$ref": "id.schema.json"
},
"name": {
"type": "string"
}
},
"required":[
"id"
],
"additionalProperties": false
}
Running json-schema-to-typescript.compileFromFile( example.schema.json ) generates:
export type TId = string
export interface IExample {
id: TId
name?: string
}
Here the type TId is generated in addition to the interface IExample. i.e. TId is defined twice, once in each file.
This makes it impossible to use the generated code in a typescript program with out manual editing to remove the second definition of TId.