-
Notifications
You must be signed in to change notification settings - Fork 9
Closed
Description
Given the following typescript file:
interface A {
a: string;
}
interface B {
b: string;
}
export type C = A & B;
typeconv produces the following json schema:
{
"definitions": {
"C": {
"allOf": [
{
"$ref": "#/definitions/A"
},
{
"$ref": "#/definitions/B"
}
],
"title": "C"
},
"A": {
"type": "object",
"properties": {
"a": {
"type": "string",
"title": "A.a"
}
},
"required": [
"a"
],
"additionalProperties": false,
"title": "A"
},
"B": {
"type": "object",
"properties": {
"b": {
"type": "string",
"title": "B.b"
}
},
"required": [
"b"
],
"additionalProperties": false,
"title": "B"
}
},
"$id": "dummy.json",
"$comment": "Generated from src/api/dummy.ts by core-types-json-schema (https://github.com/grantila/core-types-json-schema) on behalf of typeconv (https://github.com/grantila/typeconv)"
}
However, the following json will not validate against type C in the schema:
{
"a": "hello",
"b": "world"
}
You can check it only at https://www.jsonschemavalidator.net/. You should add the following lines to the beginning of the json schema:
"type": "object",
"$ref": "#/definitions/C",
Metadata
Metadata
Assignees
Labels
No labels