diff --git a/src/resources/foo.ts b/src/resources/foo.ts index b5b09c70..b2d5357c 100644 --- a/src/resources/foo.ts +++ b/src/resources/foo.ts @@ -14,6 +14,9 @@ */ /** + * This is a simple interface declaration for + * testing the schema generation and validation. + * * @validatable */ export interface Foo { @@ -21,4 +24,15 @@ export interface Foo { * Dummy parameter */ lorem: 'ipsum'; + + /** + * String literal type property + */ + type: FooType; } + +/** + * This is a simple type declaration for + * usage in the Foo interace. + */ +export type FooType = 'Foo'; diff --git a/test/Schema.spec.ts b/test/Schema.spec.ts index a04a8bc0..6251f561 100644 --- a/test/Schema.spec.ts +++ b/test/Schema.spec.ts @@ -30,13 +30,20 @@ export class SchemaSpec { const converter = new Converter(join(__dirname, '..', 'src', 'resources')); const schema = converter.getSchema('Foo', '0.0.1'); - expect(schema).to.be.deep.equal({ $schema: 'http://json-schema.org/draft-06/schema#', additionalProperties: false, definitions: { + FooType: { + description: 'This is a simple type declaration for\nusage in the Foo interace.', + enum: [ + 'Foo', + ], + type: 'string', + }, SCFoo: { additionalProperties: false, + description: 'This is a simple interface declaration for\ntesting the schema generation and validation.', properties: { lorem: { description: 'Dummy parameter', @@ -45,13 +52,19 @@ export class SchemaSpec { ], type: 'string', }, + type: { + $ref: '#/definitions/FooType', + description: 'String literal type property', + }, }, required: [ 'lorem', + 'type', ], type: 'object', }, }, + description: 'This is a simple interface declaration for\ntesting the schema generation and validation.', id: 'https://core.stapps.tu-berlin.de/v0.0.1/lib/schema/Foo.json', properties: { lorem: { @@ -61,9 +74,14 @@ export class SchemaSpec { ], type: 'string', }, + type: { + $ref: '#/definitions/FooType', + description: 'String literal type property', + }, }, required: [ 'lorem', + 'type', ], type: 'object', });