mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-09 19:22:51 +00:00
test: adjust schema test for broader use cases
This commit is contained in:
@@ -14,6 +14,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* This is a simple interface declaration for
|
||||||
|
* testing the schema generation and validation.
|
||||||
|
*
|
||||||
* @validatable
|
* @validatable
|
||||||
*/
|
*/
|
||||||
export interface Foo {
|
export interface Foo {
|
||||||
@@ -21,4 +24,15 @@ export interface Foo {
|
|||||||
* Dummy parameter
|
* Dummy parameter
|
||||||
*/
|
*/
|
||||||
lorem: 'ipsum';
|
lorem: 'ipsum';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* String literal type property
|
||||||
|
*/
|
||||||
|
type: FooType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a simple type declaration for
|
||||||
|
* usage in the Foo interace.
|
||||||
|
*/
|
||||||
|
export type FooType = 'Foo';
|
||||||
|
|||||||
@@ -30,13 +30,20 @@ export class SchemaSpec {
|
|||||||
const converter = new Converter(join(__dirname, '..', 'src', 'resources'));
|
const converter = new Converter(join(__dirname, '..', 'src', 'resources'));
|
||||||
|
|
||||||
const schema = converter.getSchema('Foo', '0.0.1');
|
const schema = converter.getSchema('Foo', '0.0.1');
|
||||||
|
|
||||||
expect(schema).to.be.deep.equal({
|
expect(schema).to.be.deep.equal({
|
||||||
$schema: 'http://json-schema.org/draft-06/schema#',
|
$schema: 'http://json-schema.org/draft-06/schema#',
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
definitions: {
|
definitions: {
|
||||||
|
FooType: {
|
||||||
|
description: 'This is a simple type declaration for\nusage in the Foo interace.',
|
||||||
|
enum: [
|
||||||
|
'Foo',
|
||||||
|
],
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
SCFoo: {
|
SCFoo: {
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
|
description: 'This is a simple interface declaration for\ntesting the schema generation and validation.',
|
||||||
properties: {
|
properties: {
|
||||||
lorem: {
|
lorem: {
|
||||||
description: 'Dummy parameter',
|
description: 'Dummy parameter',
|
||||||
@@ -45,13 +52,19 @@ export class SchemaSpec {
|
|||||||
],
|
],
|
||||||
type: 'string',
|
type: 'string',
|
||||||
},
|
},
|
||||||
|
type: {
|
||||||
|
$ref: '#/definitions/FooType',
|
||||||
|
description: 'String literal type property',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
required: [
|
required: [
|
||||||
'lorem',
|
'lorem',
|
||||||
|
'type',
|
||||||
],
|
],
|
||||||
type: 'object',
|
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',
|
id: 'https://core.stapps.tu-berlin.de/v0.0.1/lib/schema/Foo.json',
|
||||||
properties: {
|
properties: {
|
||||||
lorem: {
|
lorem: {
|
||||||
@@ -61,9 +74,14 @@ export class SchemaSpec {
|
|||||||
],
|
],
|
||||||
type: 'string',
|
type: 'string',
|
||||||
},
|
},
|
||||||
|
type: {
|
||||||
|
$ref: '#/definitions/FooType',
|
||||||
|
description: 'String literal type property',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
required: [
|
required: [
|
||||||
'lorem',
|
'lorem',
|
||||||
|
'type',
|
||||||
],
|
],
|
||||||
type: 'object',
|
type: 'object',
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user