diff --git a/test/bindings/http/0.1.0/message/example.json b/test/bindings/http/0.1.0/message/example.json deleted file mode 100644 index bdf5759a..00000000 --- a/test/bindings/http/0.1.0/message/example.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "headers": { - "type": "object", - "properties": { - "Content-Type": { - "type": "string", - "enum": [ - "application/json" - ] - } - } - } -} \ No newline at end of file diff --git a/test/bindings/http/0.1.0/message/extended.json b/test/bindings/http/0.1.0/message/extended.json deleted file mode 100644 index 2da8cc79..00000000 --- a/test/bindings/http/0.1.0/message/extended.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "x-number": 0, - "x-string": "", - "x-object": { - "property": {} - } -} \ No newline at end of file diff --git a/test/bindings/http/0.1.0/message/only required properties.json b/test/bindings/http/0.1.0/message/only required properties.json deleted file mode 100644 index 9e26dfee..00000000 --- a/test/bindings/http/0.1.0/message/only required properties.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/bindings/http/0.1.0/message/without required properties.json b/test/bindings/http/0.1.0/message/without required properties.json deleted file mode 100644 index 9e26dfee..00000000 --- a/test/bindings/http/0.1.0/message/without required properties.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/bindings/http/0.1.0/message/wrongly extended.json b/test/bindings/http/0.1.0/message/wrongly extended.json deleted file mode 100644 index e6738ad9..00000000 --- a/test/bindings/http/0.1.0/message/wrongly extended.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "x-number": 0, - "x-string": "", - "x-object": { - "property": {} - }, - "ext-number": 1 -} \ No newline at end of file diff --git a/test/bindings/http/0.1.0/operation/example.json b/test/bindings/http/0.1.0/operation/example.json deleted file mode 100644 index 9f22ccba..00000000 --- a/test/bindings/http/0.1.0/operation/example.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "type": "request", - "method": "GET", - "query": { - "type": "object", - "required": [ - "companyId" - ], - "properties": { - "companyId": { - "type": "number", - "minimum": 1, - "description": "The Id of the company." - } - }, - "additionalProperties": false - } -} \ No newline at end of file diff --git a/test/bindings/http/0.1.0/operation/extended.json b/test/bindings/http/0.1.0/operation/extended.json deleted file mode 100644 index 3d6a78a1..00000000 --- a/test/bindings/http/0.1.0/operation/extended.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "type": "request", - "method": "GET", - "x-number": 0, - "x-string": "", - "x-object": { - "property": {} - } -} \ No newline at end of file diff --git a/test/bindings/http/0.1.0/operation/only required properties.json b/test/bindings/http/0.1.0/operation/only required properties.json deleted file mode 100644 index 4197fa3b..00000000 --- a/test/bindings/http/0.1.0/operation/only required properties.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "type": "request", - "method": "GET" -} \ No newline at end of file diff --git a/test/bindings/http/0.1.0/operation/without required properties.json b/test/bindings/http/0.1.0/operation/without required properties.json deleted file mode 100644 index 9e26dfee..00000000 --- a/test/bindings/http/0.1.0/operation/without required properties.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/bindings/http/0.1.0/operation/wrongly extended.json b/test/bindings/http/0.1.0/operation/wrongly extended.json deleted file mode 100644 index 9244f9e8..00000000 --- a/test/bindings/http/0.1.0/operation/wrongly extended.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "type": "request", - "method": "GET", - "x-number": 0, - "x-string": "", - "x-object": { - "property": {} - }, - "ext-number": 1 -} \ No newline at end of file diff --git a/test/bindings/http/0.2.0/message/example.json b/test/bindings/http/0.2.0/message/example.json deleted file mode 100644 index bdf5759a..00000000 --- a/test/bindings/http/0.2.0/message/example.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "headers": { - "type": "object", - "properties": { - "Content-Type": { - "type": "string", - "enum": [ - "application/json" - ] - } - } - } -} \ No newline at end of file diff --git a/test/bindings/http/0.2.0/message/extended.json b/test/bindings/http/0.2.0/message/extended.json deleted file mode 100644 index 2da8cc79..00000000 --- a/test/bindings/http/0.2.0/message/extended.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "x-number": 0, - "x-string": "", - "x-object": { - "property": {} - } -} \ No newline at end of file diff --git a/test/bindings/http/0.2.0/message/only required properties.json b/test/bindings/http/0.2.0/message/only required properties.json deleted file mode 100644 index 9e26dfee..00000000 --- a/test/bindings/http/0.2.0/message/only required properties.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/bindings/http/0.2.0/message/without required properties.json b/test/bindings/http/0.2.0/message/without required properties.json deleted file mode 100644 index 9e26dfee..00000000 --- a/test/bindings/http/0.2.0/message/without required properties.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/bindings/http/0.2.0/message/wrongly extended.json b/test/bindings/http/0.2.0/message/wrongly extended.json deleted file mode 100644 index e6738ad9..00000000 --- a/test/bindings/http/0.2.0/message/wrongly extended.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "x-number": 0, - "x-string": "", - "x-object": { - "property": {} - }, - "ext-number": 1 -} \ No newline at end of file diff --git a/test/bindings/http/0.2.0/operation/example.json b/test/bindings/http/0.2.0/operation/example.json deleted file mode 100644 index 6b36a705..00000000 --- a/test/bindings/http/0.2.0/operation/example.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "method": "GET", - "query": { - "type": "object", - "required": [ - "companyId" - ], - "properties": { - "companyId": { - "type": "number", - "minimum": 1, - "description": "The Id of the company." - } - }, - "additionalProperties": false - } -} \ No newline at end of file diff --git a/test/bindings/http/0.2.0/operation/extended.json b/test/bindings/http/0.2.0/operation/extended.json deleted file mode 100644 index 2da8cc79..00000000 --- a/test/bindings/http/0.2.0/operation/extended.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "x-number": 0, - "x-string": "", - "x-object": { - "property": {} - } -} \ No newline at end of file diff --git a/test/bindings/http/0.2.0/operation/only required properties.json b/test/bindings/http/0.2.0/operation/only required properties.json deleted file mode 100644 index 9e26dfee..00000000 --- a/test/bindings/http/0.2.0/operation/only required properties.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/bindings/http/0.2.0/operation/without required properties.json b/test/bindings/http/0.2.0/operation/without required properties.json deleted file mode 100644 index 9e26dfee..00000000 --- a/test/bindings/http/0.2.0/operation/without required properties.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/bindings/http/0.2.0/operation/wrongly extended.json b/test/bindings/http/0.2.0/operation/wrongly extended.json deleted file mode 100644 index e6738ad9..00000000 --- a/test/bindings/http/0.2.0/operation/wrongly extended.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "x-number": 0, - "x-string": "", - "x-object": { - "property": {} - }, - "ext-number": 1 -} \ No newline at end of file diff --git a/test/bindings/http/0.3.0/message/example.json b/test/bindings/http/0.3.0/message/example.json deleted file mode 100644 index ea047d8c..00000000 --- a/test/bindings/http/0.3.0/message/example.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "headers": { - "type": "object", - "properties": { - "Content-Type": { - "type": "string", - "enum": [ - "application/json" - ] - } - } - }, - "statusCode": 200 -} \ No newline at end of file diff --git a/test/bindings/http/0.3.0/message/extended.json b/test/bindings/http/0.3.0/message/extended.json deleted file mode 100644 index 2da8cc79..00000000 --- a/test/bindings/http/0.3.0/message/extended.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "x-number": 0, - "x-string": "", - "x-object": { - "property": {} - } -} \ No newline at end of file diff --git a/test/bindings/http/0.3.0/message/only required properties.json b/test/bindings/http/0.3.0/message/only required properties.json deleted file mode 100644 index 9e26dfee..00000000 --- a/test/bindings/http/0.3.0/message/only required properties.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/bindings/http/0.3.0/message/without required properties.json b/test/bindings/http/0.3.0/message/without required properties.json deleted file mode 100644 index 9e26dfee..00000000 --- a/test/bindings/http/0.3.0/message/without required properties.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/bindings/http/0.3.0/message/wrongly extended.json b/test/bindings/http/0.3.0/message/wrongly extended.json deleted file mode 100644 index e6738ad9..00000000 --- a/test/bindings/http/0.3.0/message/wrongly extended.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "x-number": 0, - "x-string": "", - "x-object": { - "property": {} - }, - "ext-number": 1 -} \ No newline at end of file diff --git a/test/bindings/http/0.3.0/operation/example.json b/test/bindings/http/0.3.0/operation/example.json deleted file mode 100644 index 6b36a705..00000000 --- a/test/bindings/http/0.3.0/operation/example.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "method": "GET", - "query": { - "type": "object", - "required": [ - "companyId" - ], - "properties": { - "companyId": { - "type": "number", - "minimum": 1, - "description": "The Id of the company." - } - }, - "additionalProperties": false - } -} \ No newline at end of file diff --git a/test/bindings/http/0.3.0/operation/extended.json b/test/bindings/http/0.3.0/operation/extended.json deleted file mode 100644 index 2da8cc79..00000000 --- a/test/bindings/http/0.3.0/operation/extended.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "x-number": 0, - "x-string": "", - "x-object": { - "property": {} - } -} \ No newline at end of file diff --git a/test/bindings/http/0.3.0/operation/only required properties.json b/test/bindings/http/0.3.0/operation/only required properties.json deleted file mode 100644 index 9e26dfee..00000000 --- a/test/bindings/http/0.3.0/operation/only required properties.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/bindings/http/0.3.0/operation/without required properties.json b/test/bindings/http/0.3.0/operation/without required properties.json deleted file mode 100644 index 9e26dfee..00000000 --- a/test/bindings/http/0.3.0/operation/without required properties.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/bindings/http/0.3.0/operation/wrongly extended.json b/test/bindings/http/0.3.0/operation/wrongly extended.json deleted file mode 100644 index e6738ad9..00000000 --- a/test/bindings/http/0.3.0/operation/wrongly extended.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "x-number": 0, - "x-string": "", - "x-object": { - "property": {} - }, - "ext-number": 1 -} \ No newline at end of file diff --git a/test/bindings/http/http message binding.test.mjs b/test/bindings/http/http message binding.test.mjs new file mode 100644 index 00000000..4ef2bdae --- /dev/null +++ b/test/bindings/http/http message binding.test.mjs @@ -0,0 +1,130 @@ +import { + JsonSchemaTestSuite, + JsonSchemaTestSuiteConfig, + JsonSchemaTestSuiteData +} from '@test/definitions/base-schema-test.mjs'; +import {describe} from 'vitest'; + +const config = new JsonSchemaTestSuiteConfig( + false, + [], + true, + [] +); + +let data = { + "0.1.0": new JsonSchemaTestSuiteData( + require(`@bindings/http/0.1.0/message.json`), + [ + { + "headers": { + "type": "object", + "properties": { + "Content-Type": { + "type": "string", + "enum": [ + "application/json" + ] + } + } + } + } + ], + {}, + {}, + { + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + } + }, + { + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + }, + "ext-number": 1 + } + ), + "0.2.0": new JsonSchemaTestSuiteData( + require(`@bindings/http/0.2.0/message.json`), + [ + { + "headers": { + "type": "object", + "properties": { + "Content-Type": { + "type": "string", + "enum": [ + "application/json" + ] + } + } + } + } + ], + {}, + {}, + { + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + } + }, + { + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + }, + "ext-number": 1 + } + ), + "0.3.0": new JsonSchemaTestSuiteData( + require(`@bindings/http/0.3.0/message.json`), + [ + { + "headers": { + "type": "object", + "properties": { + "Content-Type": { + "type": "string", + "enum": [ + "application/json" + ] + } + } + }, + "statusCode": 200 + } + ], + {}, + {}, + { + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + } + }, + { + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + }, + "ext-number": 1 + } + ) +} + +describe.each([ + '0.1.0', + '0.2.0', + '0.3.0', +])('HTTP message binding v%s', (bindingVersion) => { + new JsonSchemaTestSuite(data[bindingVersion], config[bindingVersion]).testSuite() +}) diff --git a/test/bindings/http/http operation binding.test.mjs b/test/bindings/http/http operation binding.test.mjs new file mode 100644 index 00000000..f96c5dab --- /dev/null +++ b/test/bindings/http/http operation binding.test.mjs @@ -0,0 +1,162 @@ +import { + JsonSchemaTestSuite, + JsonSchemaTestSuiteConfig, + JsonSchemaTestSuiteData +} from '@test/definitions/base-schema-test.mjs'; +import {describe} from 'vitest'; + +const config = { + "0.1.0": new JsonSchemaTestSuiteConfig( + true, + [ + 'must have required property \'type\'' + ], + true, + [] + ), + "0.2.0": new JsonSchemaTestSuiteConfig( + false, + [], + true, + [] + ), + "0.3.0": new JsonSchemaTestSuiteConfig( + false, + [], + true, + [] + ) +} + +let data = { + "0.1.0": new JsonSchemaTestSuiteData( + require(`@bindings/http/0.1.0/operation.json`), + [ + { + "type": "request", + "method": "GET", + "query": { + "type": "object", + "required": [ + "companyId" + ], + "properties": { + "companyId": { + "type": "number", + "minimum": 1, + "description": "The Id of the company." + } + }, + "additionalProperties": false + } + } + ], + { + "type": "request", + }, + {}, + { + "type": "request", + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + } + }, + { + "type": "request", + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + }, + "ext-number": 1 + } + ), + "0.2.0": new JsonSchemaTestSuiteData( + require(`@bindings/http/0.2.0/operation.json`), + [ + { + "method": "GET", + "query": { + "type": "object", + "required": [ + "companyId" + ], + "properties": { + "companyId": { + "type": "number", + "minimum": 1, + "description": "The Id of the company." + } + }, + "additionalProperties": false + } + } + ], + {}, + {}, + { + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + } + }, + { + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + }, + "ext-number": 1 + } + ), + "0.3.0": new JsonSchemaTestSuiteData( + require(`@bindings/http/0.3.0/operation.json`), + [ + { + "method": "GET", + "query": { + "type": "object", + "required": [ + "companyId" + ], + "properties": { + "companyId": { + "type": "number", + "minimum": 1, + "description": "The Id of the company." + } + }, + "additionalProperties": false + } + } + ], + {}, + {}, + { + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + } + }, + { + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + }, + "ext-number": 1 + } + ) +} + +describe.each([ + '0.1.0', + '0.2.0', + '0.3.0', +])('HTTP message binding v%s', (bindingVersion) => { + new JsonSchemaTestSuite(data[bindingVersion], config[bindingVersion]).testSuite() +}) diff --git a/test/bindings/http/http.test.mjs b/test/bindings/http/http.test.mjs deleted file mode 100644 index d550083c..00000000 --- a/test/bindings/http/http.test.mjs +++ /dev/null @@ -1,97 +0,0 @@ -import {it} from 'vitest'; -import TestHelper from '@test/test-helper.mjs'; -import path from 'path'; - -describe.each([ - '0.1.0', - '0.2.0', - '0.3.0', -])('HTTP bindings v%s', async (bindingVersion) => { - - const messageSchema = await import(`@bindings/http/${bindingVersion}/message.json`); - const operationSchema = await import(`@bindings/http/${bindingVersion}/operation.json`); - - describe('message', () => { - it(TestHelper.exampleIsValidTestName, () => TestHelper.objectIsValid( - messageSchema, - path.resolve(__dirname, `./${bindingVersion}/message/example.json`), - )); - - it(TestHelper.canBeEmptyTestName, () => TestHelper.objectIsValid( - messageSchema, - {} - )); - - it(TestHelper.isValidWithoutRequiredPropertiesTestName, () => TestHelper.objectIsValid( - messageSchema, - path.resolve(__dirname, `./${bindingVersion}/message/without required properties.json`), - )); - - it(TestHelper.isValidWithOnlyRequiredPropertiesTestName, () => TestHelper.objectIsValid( - messageSchema, - path.resolve(__dirname, `./${bindingVersion}/message/only required properties.json`), - )); - - it(TestHelper.isValidWhenIsExtendedTestName, () => TestHelper.objectIsValid( - messageSchema, - path.resolve(__dirname, `./${bindingVersion}/message/extended.json`), - )); - - it(TestHelper.isNotValidWhenIsWronglyExtendedTestName, () => TestHelper.wronglyExtended( - messageSchema, - path.resolve(__dirname, `./${bindingVersion}/message/wrongly extended.json`), - )); - }) - - describe('operation', () => { - it(TestHelper.exampleIsValidTestName, () => TestHelper.objectIsValid( - operationSchema, - path.resolve(__dirname, `./${bindingVersion}/operation/example.json`), - )); - - it(`${bindingVersion === '0.1.0' ? TestHelper.cannotBeEmptyTestName : TestHelper.canBeEmptyTestName}`, () => { - if (bindingVersion === '0.1.0') { - TestHelper.objectIsNotValid( - operationSchema, - {}, - ['must have required property \'type\''] - ) - } else { - TestHelper.objectIsValid( - operationSchema, - {}, - ) - } - }) - - it(`${bindingVersion === '0.1.0' ? TestHelper.isNotValidWithoutRequiredPropertiesTestName : TestHelper.isValidWithoutRequiredPropertiesTestName}`, () => { - if (bindingVersion === '0.1.0') { - TestHelper.objectIsNotValid( - operationSchema, - path.resolve(__dirname, `./${bindingVersion}/operation/without required properties.json`), - ['must have required property \'type\''] - ) - } else { - TestHelper.objectIsValid( - operationSchema, - path.resolve(__dirname, `./${bindingVersion}/operation/without required properties.json`), - ) - } - }) - - it(TestHelper.isValidWithOnlyRequiredPropertiesTestName, () => TestHelper.objectIsValid( - operationSchema, - path.resolve(__dirname, `./${bindingVersion}/operation/only required properties.json`), - )); - - it(TestHelper.isValidWhenIsExtendedTestName, () => TestHelper.objectIsValid( - operationSchema, - path.resolve(__dirname, `./${bindingVersion}/operation/extended.json`), - )); - - it(TestHelper.isNotValidWhenIsWronglyExtendedTestName, () => TestHelper.wronglyExtended( - operationSchema, - path.resolve(__dirname, `./${bindingVersion}/operation/wrongly extended.json`), - )); - }) -}) \ No newline at end of file