diff --git a/test/ajv-schemes.js b/test/ajv-schemes.js new file mode 100644 index 00000000..1f145292 --- /dev/null +++ b/test/ajv-schemes.js @@ -0,0 +1,139 @@ +module.exports = schemesV3_0_0; + +function bindingSchemes(ajv) { + ajv.addSchema(require('../bindings/amqp/0.2.0/channel.json')); + ajv.addSchema(require('../bindings/amqp/0.2.0/message.json')); + ajv.addSchema(require('../bindings/amqp/0.2.0/operation.json')); + ajv.addSchema(require('../bindings/amqp/0.3.0/channel.json')); + ajv.addSchema(require('../bindings/amqp/0.3.0/message.json')); + ajv.addSchema(require('../bindings/amqp/0.3.0/operation.json')); + + ajv.addSchema(require('../bindings/anypointmq/0.0.1/channel.json')); + ajv.addSchema(require('../bindings/anypointmq/0.0.1/message.json')); + + ajv.addSchema(require('../bindings/googlepubsub/0.1.0/channel.json')); + ajv.addSchema(require('../bindings/googlepubsub/0.1.0/message.json')); + ajv.addSchema(require('../bindings/googlepubsub/0.2.0/channel.json')); + ajv.addSchema(require('../bindings/googlepubsub/0.2.0/message.json')); + + ajv.addSchema(require('../bindings/http/0.1.0/message.json')); + ajv.addSchema(require('../bindings/http/0.1.0/operation.json')); + ajv.addSchema(require('../bindings/http/0.2.0/message.json')); + ajv.addSchema(require('../bindings/http/0.2.0/operation.json')); + ajv.addSchema(require('../bindings/http/0.3.0/message.json')); + ajv.addSchema(require('../bindings/http/0.3.0/operation.json')); + + ajv.addSchema(require('../bindings/ibmmq/0.1.0/channel.json')); + ajv.addSchema(require('../bindings/ibmmq/0.1.0/message.json')); + ajv.addSchema(require('../bindings/ibmmq/0.1.0/server.json')); + + ajv.addSchema(require('../bindings/jms/0.0.1/channel.json')); + ajv.addSchema(require('../bindings/jms/0.0.1/message.json')); + ajv.addSchema(require('../bindings/jms/0.0.1/server.json')); + + ajv.addSchema(require('../bindings/kafka/0.1.0/message.json')); + ajv.addSchema(require('../bindings/kafka/0.1.0/operation.json')); + ajv.addSchema(require('../bindings/kafka/0.3.0/channel.json')); + ajv.addSchema(require('../bindings/kafka/0.3.0/message.json')); + ajv.addSchema(require('../bindings/kafka/0.3.0/operation.json')); + ajv.addSchema(require('../bindings/kafka/0.3.0/server.json')); + ajv.addSchema(require('../bindings/kafka/0.4.0/channel.json')); + ajv.addSchema(require('../bindings/kafka/0.4.0/message.json')); + ajv.addSchema(require('../bindings/kafka/0.4.0/operation.json')); + ajv.addSchema(require('../bindings/kafka/0.4.0/server.json')); + ajv.addSchema(require('../bindings/kafka/0.5.0/channel.json')); + ajv.addSchema(require('../bindings/kafka/0.5.0/message.json')); + ajv.addSchema(require('../bindings/kafka/0.5.0/operation.json')); + ajv.addSchema(require('../bindings/kafka/0.5.0/server.json')); + + ajv.addSchema(require('../bindings/mqtt/0.1.0/message.json')); + ajv.addSchema(require('../bindings/mqtt/0.1.0/operation.json')); + ajv.addSchema(require('../bindings/mqtt/0.1.0/server.json')); + ajv.addSchema(require('../bindings/mqtt/0.2.0/message.json')); + ajv.addSchema(require('../bindings/mqtt/0.2.0/operation.json')); + ajv.addSchema(require('../bindings/mqtt/0.2.0/server.json')); + + ajv.addSchema(require('../bindings/nats/0.1.0/operation.json')); + + ajv.addSchema(require('../bindings/pulsar/0.1.0/channel.json')); + ajv.addSchema(require('../bindings/pulsar/0.1.0/server.json')); + + ajv.addSchema(require('../bindings/sns/0.1.0/channel.json')); + ajv.addSchema(require('../bindings/sns/0.1.0/operation.json')); + + ajv.addSchema(require('../bindings/solace/0.2.0/operation.json')); + ajv.addSchema(require('../bindings/solace/0.2.0/server.json')); + ajv.addSchema(require('../bindings/solace/0.3.0/operation.json')); + ajv.addSchema(require('../bindings/solace/0.3.0/server.json')); + ajv.addSchema(require('../bindings/solace/0.4.0/operation.json')); + ajv.addSchema(require('../bindings/solace/0.4.0/server.json')); + + ajv.addSchema(require('../bindings/sqs/0.2.0/channel.json')); + ajv.addSchema(require('../bindings/sqs/0.2.0/operation.json')); + + ajv.addSchema(require('../bindings/websockets/0.1.0/channel.json')); + + return ajv; +} + +function schemesV3_0_0(ajv) { + ajv.addSchema(require('../definitions/3.0.0/anySchema.json')); + ajv.addSchema(require('../definitions/3.0.0/apiKey.json')); + ajv.addSchema(require('../definitions/3.0.0/APIKeyHTTPSecurityScheme.json')); + ajv.addSchema(require('../definitions/3.0.0/asymmetricEncryption.json')); + ajv.addSchema(require('../definitions/3.0.0/asyncapi.json')); + ajv.addSchema(require('../definitions/3.0.0/BearerHTTPSecurityScheme.json')); + ajv.addSchema(require('../definitions/3.0.0/channel.json')); + ajv.addSchema(require('../definitions/3.0.0/channelBindingsObject.json')); + ajv.addSchema(require('../definitions/3.0.0/channelMessages.json')); + ajv.addSchema(require('../definitions/3.0.0/channels.json')); + ajv.addSchema(require('../definitions/3.0.0/components.json')); + ajv.addSchema(require('../definitions/3.0.0/contact.json')); + ajv.addSchema(require('../definitions/3.0.0/correlationId.json')); + ajv.addSchema(require('../definitions/3.0.0/externalDocs.json')); + ajv.addSchema(require('../definitions/3.0.0/HTTPSecurityScheme.json')); + ajv.addSchema(require('../definitions/3.0.0/info.json')); + ajv.addSchema(require('../definitions/3.0.0/infoExtensions.json')); + ajv.addSchema(require('../definitions/3.0.0/license.json')); + ajv.addSchema(require('../definitions/3.0.0/messageBindingsObject.json')); + ajv.addSchema(require('../definitions/3.0.0/messageExampleObject.json')); + ajv.addSchema(require('../definitions/3.0.0/messageObject.json')); + ajv.addSchema(require('../definitions/3.0.0/messages.json')); + ajv.addSchema(require('../definitions/3.0.0/messageTrait.json')); + ajv.addSchema(require('../definitions/3.0.0/multiFormatSchema.json')); + ajv.addSchema(require('../definitions/3.0.0/NonBearerHTTPSecurityScheme.json')); + ajv.addSchema(require('../definitions/3.0.0/oauth2Flow.json')); + ajv.addSchema(require('../definitions/3.0.0/oauth2Flows.json')); + ajv.addSchema(require('../definitions/3.0.0/oauth2Scopes.json')); + ajv.addSchema(require('../definitions/3.0.0/openIdConnect.json')); + ajv.addSchema(require('../definitions/3.0.0/operationBindingsObject.json')); + ajv.addSchema(require('../definitions/3.0.0/operationReply.json')); + ajv.addSchema(require('../definitions/3.0.0/operationReplyAddress.json')); + ajv.addSchema(require('../definitions/3.0.0/operations.json')); + ajv.addSchema(require('../definitions/3.0.0/operationTrait.json')); + ajv.addSchema(require('../definitions/3.0.0/parameter.json')); + ajv.addSchema(require('../definitions/3.0.0/parameters.json')); + ajv.addSchema(require('../definitions/3.0.0/Reference.json')); + ajv.addSchema(require('../definitions/3.0.0/ReferenceObject.json')); + ajv.addSchema(require('../definitions/3.0.0/SaslGssapiSecurityScheme.json')); + ajv.addSchema(require('../definitions/3.0.0/SaslPlainSecurityScheme.json')); + ajv.addSchema(require('../definitions/3.0.0/SaslSecurityScheme.json')); + ajv.addSchema(require('../definitions/3.0.0/schema.json')); + ajv.addSchema(require('../definitions/3.0.0/securityRequirements.json')); + ajv.addSchema(require('../definitions/3.0.0/SecurityScheme.json')); + ajv.addSchema(require('../definitions/3.0.0/server.json')); + ajv.addSchema(require('../definitions/3.0.0/serverBindingsObject.json')); + ajv.addSchema(require('../definitions/3.0.0/servers.json')); + ajv.addSchema(require('../definitions/3.0.0/serverVariable.json')); + ajv.addSchema(require('../definitions/3.0.0/serverVariables.json')); + ajv.addSchema(require('../definitions/3.0.0/specificationExtension.json')); + ajv.addSchema(require('../definitions/3.0.0/symmetricEncryption.json')); + ajv.addSchema(require('../definitions/3.0.0/tag.json')); + ajv.addSchema(require('../definitions/3.0.0/userPassword.json')); + ajv.addSchema(require('../definitions/3.0.0/X509.json')); + + ajv.addSchema(require('../common/avroSchema_v1.json')); + ajv.addSchema(require('../common/openapiSchema_3_0.json')); + + return bindingSchemes(ajv); +} diff --git a/test/definitions/3.0.0/models/index.js b/test/definitions/3.0.0/models/index.js index 09133f6f..9040275c 100644 --- a/test/definitions/3.0.0/models/index.js +++ b/test/definitions/3.0.0/models/index.js @@ -1,8 +1,5 @@ describe('Models', () => { - require('./info/info.js'); - require('./info extensions/info-extension.js'); - require('./contact/contact.js'); - require('./license/license.js'); + require('./info'); require('./reference/reference.js'); require('./reference object/reference-object.js'); }); diff --git a/test/definitions/3.0.0/models/contact/contact.js b/test/definitions/3.0.0/models/info/contact/contact.js similarity index 88% rename from test/definitions/3.0.0/models/contact/contact.js rename to test/definitions/3.0.0/models/info/contact/contact.js index 330b2eb2..ea730c6e 100644 --- a/test/definitions/3.0.0/models/contact/contact.js +++ b/test/definitions/3.0.0/models/info/contact/contact.js @@ -13,10 +13,10 @@ const ajv = new Ajv({ }); addFormats(ajv); -const infoJsonSchema = require('../../../../../definitions/3.0.0/contact.json'); +const infoJsonSchema = require('../../../../../../definitions/3.0.0/contact.json'); const validator = ajv - .addMetaSchema(require('../../../../../definitions/3.0.0/schema.json')) - .addSchema(require('../../../../../definitions/3.0.0/specificationExtension.json')) + .addMetaSchema(require('../../../../../../definitions/3.0.0/schema.json')) + .addSchema(require('../../../../../../definitions/3.0.0/specificationExtension.json')) .compile(infoJsonSchema); describe('Contact', () => { diff --git a/test/definitions/3.0.0/models/contact/empty.json b/test/definitions/3.0.0/models/info/contact/empty.json similarity index 100% rename from test/definitions/3.0.0/models/contact/empty.json rename to test/definitions/3.0.0/models/info/contact/empty.json diff --git a/test/definitions/3.0.0/models/contact/extended.json b/test/definitions/3.0.0/models/info/contact/extended.json similarity index 100% rename from test/definitions/3.0.0/models/contact/extended.json rename to test/definitions/3.0.0/models/info/contact/extended.json diff --git a/test/definitions/3.0.0/models/contact/only required properties.json b/test/definitions/3.0.0/models/info/contact/only required properties.json similarity index 100% rename from test/definitions/3.0.0/models/contact/only required properties.json rename to test/definitions/3.0.0/models/info/contact/only required properties.json diff --git a/test/definitions/3.0.0/models/contact/without required properties.json b/test/definitions/3.0.0/models/info/contact/without required properties.json similarity index 100% rename from test/definitions/3.0.0/models/contact/without required properties.json rename to test/definitions/3.0.0/models/info/contact/without required properties.json diff --git a/test/definitions/3.0.0/models/contact/wrongly extended.json b/test/definitions/3.0.0/models/info/contact/wrongly extended.json similarity index 100% rename from test/definitions/3.0.0/models/contact/wrongly extended.json rename to test/definitions/3.0.0/models/info/contact/wrongly extended.json diff --git a/test/definitions/3.0.0/models/info/index.js b/test/definitions/3.0.0/models/info/index.js new file mode 100644 index 00000000..d337805d --- /dev/null +++ b/test/definitions/3.0.0/models/info/index.js @@ -0,0 +1,5 @@ +describe('Info Object', () => { + require('./info.js'); + require('./info extensions/info-extension.js'); + require('./contact/contact.js'); +}); diff --git a/test/definitions/3.0.0/models/info extensions/empty.json b/test/definitions/3.0.0/models/info/info extensions/empty.json similarity index 100% rename from test/definitions/3.0.0/models/info extensions/empty.json rename to test/definitions/3.0.0/models/info/info extensions/empty.json diff --git a/test/definitions/3.0.0/models/info extensions/extended.json b/test/definitions/3.0.0/models/info/info extensions/extended.json similarity index 100% rename from test/definitions/3.0.0/models/info extensions/extended.json rename to test/definitions/3.0.0/models/info/info extensions/extended.json diff --git a/test/definitions/3.0.0/models/info extensions/info-extension.js b/test/definitions/3.0.0/models/info/info extensions/info-extension.js similarity index 86% rename from test/definitions/3.0.0/models/info extensions/info-extension.js rename to test/definitions/3.0.0/models/info/info extensions/info-extension.js index c47db6d9..dc4f4a34 100644 --- a/test/definitions/3.0.0/models/info extensions/info-extension.js +++ b/test/definitions/3.0.0/models/info/info extensions/info-extension.js @@ -13,11 +13,11 @@ const ajv = new Ajv({ }); addFormats(ajv); -const infoJsonSchema = require('../../../../../definitions/3.0.0/infoExtensions.json'); +const infoJsonSchema = require('../../../../../../definitions/3.0.0/infoExtensions.json'); const validator = ajv - .addMetaSchema(require('../../../../../definitions/3.0.0/schema.json')) - .addSchema(require('../../../../../extensions/linkedin/0.1.0/schema.json')) - .addSchema(require('../../../../../extensions/x/0.1.0/schema.json')) + .addMetaSchema(require('../../../../../../definitions/3.0.0/schema.json')) + .addSchema(require('../../../../../../extensions/linkedin/0.1.0/schema.json')) + .addSchema(require('../../../../../../extensions/x/0.1.0/schema.json')) .compile(infoJsonSchema); describe('InfoExtensions', () => { diff --git a/test/definitions/3.0.0/models/info extensions/only required properties.json b/test/definitions/3.0.0/models/info/info extensions/only required properties.json similarity index 100% rename from test/definitions/3.0.0/models/info extensions/only required properties.json rename to test/definitions/3.0.0/models/info/info extensions/only required properties.json diff --git a/test/definitions/3.0.0/models/info extensions/without required properties.json b/test/definitions/3.0.0/models/info/info extensions/without required properties.json similarity index 100% rename from test/definitions/3.0.0/models/info extensions/without required properties.json rename to test/definitions/3.0.0/models/info/info extensions/without required properties.json diff --git a/test/definitions/3.0.0/models/info extensions/wrongly extended.json b/test/definitions/3.0.0/models/info/info extensions/wrongly extended.json similarity index 100% rename from test/definitions/3.0.0/models/info extensions/wrongly extended.json rename to test/definitions/3.0.0/models/info/info extensions/wrongly extended.json diff --git a/test/definitions/3.0.0/models/license/empty.json b/test/definitions/3.0.0/models/info/license/empty.json similarity index 100% rename from test/definitions/3.0.0/models/license/empty.json rename to test/definitions/3.0.0/models/info/license/empty.json diff --git a/test/definitions/3.0.0/models/license/extended.json b/test/definitions/3.0.0/models/info/license/extended.json similarity index 100% rename from test/definitions/3.0.0/models/license/extended.json rename to test/definitions/3.0.0/models/info/license/extended.json diff --git a/test/definitions/3.0.0/models/license/license.js b/test/definitions/3.0.0/models/info/license/license.js similarity index 89% rename from test/definitions/3.0.0/models/license/license.js rename to test/definitions/3.0.0/models/info/license/license.js index 34e08600..9493f08c 100644 --- a/test/definitions/3.0.0/models/license/license.js +++ b/test/definitions/3.0.0/models/info/license/license.js @@ -13,10 +13,10 @@ const ajv = new Ajv({ }); addFormats(ajv); -const infoJsonSchema = require('../../../../../definitions/3.0.0/license.json'); +const infoJsonSchema = require('../../../../../../definitions/3.0.0/license.json'); const validator = ajv - .addMetaSchema(require('../../../../../definitions/3.0.0/schema.json')) - .addSchema(require('../../../../../definitions/3.0.0/specificationExtension.json')) + .addMetaSchema(require('../../../../../../definitions/3.0.0/schema.json')) + .addSchema(require('../../../../../../definitions/3.0.0/specificationExtension.json')) .compile(infoJsonSchema); describe('License', () => { diff --git a/test/definitions/3.0.0/models/license/only required properties.json b/test/definitions/3.0.0/models/info/license/only required properties.json similarity index 100% rename from test/definitions/3.0.0/models/license/only required properties.json rename to test/definitions/3.0.0/models/info/license/only required properties.json diff --git a/test/definitions/3.0.0/models/license/without required properties.json b/test/definitions/3.0.0/models/info/license/without required properties.json similarity index 100% rename from test/definitions/3.0.0/models/license/without required properties.json rename to test/definitions/3.0.0/models/info/license/without required properties.json diff --git a/test/definitions/3.0.0/models/license/wrongly extended.json b/test/definitions/3.0.0/models/info/license/wrongly extended.json similarity index 100% rename from test/definitions/3.0.0/models/license/wrongly extended.json rename to test/definitions/3.0.0/models/info/license/wrongly extended.json