Closed
Description
Hey,
I tried to externalize some complex properties from my main schema Person.json
to use the (sub) interfaces separately in the code.
For example my Person.json
schema has an account
property and I put the schema from this into components/Account.json
.
It would be cool to re-use the declared interfaces for these types. E.g.
export type Person = {
name?: string;
account?: Account[];
[k: string]: any;
};
For all the used schemas etc see below. Please note that I simplified the schema, if something doesn't match please let me know.
Person.json
{
"$schema": "http://json-schema.org/schema#",
"type": "object",
"properties": {
"name": { "type": "string" },
"account": {
"type": "array",
"items": {
"allOf": [{ "$ref": "components/Account.json" }]
}
}
}
}
components/Account.json
{
"$schema": "http://json-schema.org/schema#",
"type": "object",
"properties": {
"@type": { "type": "string" },
"role": { "type": "string" },
"service": { "type": "string" },
"identifier": { "type": "string" },
"proofType": { "type": "string" },
"proofUrl": { "type": "string" },
"proofMessage": { "type": "string" },
"proofSignature": { "type": "string" }
}
}
Person.json.d.ts
export type Person = {
name?: string;
account?: {
'@type'?: string;
role?: string;
service?: string;
identifier?: string;
proofType?: string;
proofUrl?: string;
proofMessage?: string;
proofSignature?: string;
[k: string]: any;
}[];
[k: string]: any;
};
components/Account.json.d.ts
export interface Account {
'@type'?: string;
role?: string;
service?: string;
identifier?: string;
proofType?: string;
proofUrl?: string;
proofMessage?: string;
proofSignature?: string;
[k: string]: any;
}