diff --git a/src/openAPIGenerator.js b/src/openAPIGenerator.js index 65a2392..65d8386 100644 --- a/src/openAPIGenerator.js +++ b/src/openAPIGenerator.js @@ -71,30 +71,38 @@ class OpenAPIGenerator { this.customVars = this.serverless.variables.service.custom; - this.serverless.configSchemaHandler.defineFunctionEventProperties('aws', 'http', { - properties: { - documentation: { type: 'object' }, - }, - required: ['documentation'], - }); + if (this.getServerlessVersion() > 1) { + this.serverless.configSchemaHandler.defineFunctionEventProperties('aws', 'http', { + properties: { + documentation: { type: 'object' }, + }, + required: ['documentation'], + }); - this.serverless.configSchemaHandler.defineFunctionEventProperties('aws', 'httpApi', { - properties: { - documentation: { type: 'object' }, - }, - required: ['documentation'], - }); - - this.serverless.configSchemaHandler.defineFunctionProperties('aws', { - properties: { - summary: {type: 'string'}, - servers: {anyOf: [{type:'object'}, {type:'array'}]}, - } - }) + + this.serverless.configSchemaHandler.defineFunctionEventProperties('aws', 'httpApi', { + properties: { + documentation: { type: 'object' }, + }, + required: ['documentation'], + }); + + + this.serverless.configSchemaHandler.defineFunctionProperties('aws', { + properties: { + summary: {type: 'string'}, + servers: {anyOf: [{type:'object'}, {type:'array'}]}, + } + }) + } + } + + getServerlessVersion() { + return this.serverless.version[0]; } log(str, type = this.defaultLog) { - switch(this.serverless.version[0]) { + switch(this.getServerlessVersion()) { case '2': let colouredString = str if (type === 'error') { @@ -111,7 +119,7 @@ class OpenAPIGenerator { break default: - process.stdout.write(str.join(' ')) + process.stdout.write(str) break } } diff --git a/test/serverless-tests/serverless 1/serverless.yml b/test/serverless-tests/serverless 1/serverless.yml index 6b5d3f5..1e59978 100644 --- a/test/serverless-tests/serverless 1/serverless.yml +++ b/test/serverless-tests/serverless 1/serverless.yml @@ -13,7 +13,7 @@ functions: handler: handler.create events: - http: - path: create + path: create/{username} method: post documentation: summary: Create User