diff --git a/lib/apidocToSwagger.js b/lib/apidocToSwagger.js index a9a0966..3702461 100644 --- a/lib/apidocToSwagger.js +++ b/lib/apidocToSwagger.js @@ -419,6 +419,9 @@ function createAwsParameters(parameters) { continue; case 'body': continue; + case 'header': + type = 'header'; + break; default: break; } diff --git a/package.json b/package.json index 087babe..930df75 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "steplix-apidoc-swagger", - "version": "0.4.6", + "version": "0.4.7", "description": "Convert api doc json to swagger json, including aws api-gateway attributes", "author": "Bahman Fakhr Sabahi", "license": "MIT", diff --git a/test/simple/expectedObject.js b/test/simple/expectedObject.js index 81fbb62..92ccd66 100644 --- a/test/simple/expectedObject.js +++ b/test/simple/expectedObject.js @@ -7,7 +7,7 @@ const expectedObject = 'info': { 'title': 'steplix-apidoc-swagger', 'description': 'Convert api doc json to swagger json, including aws api-gateway attributes', - 'version': '0.4.6', + 'version': '0.4.7', }, 'paths': { '/user/id': { @@ -28,6 +28,14 @@ const expectedObject = 'required': true, 'type': 'number', 'description': 'Users unique ID.' + }, + { + 'name': 'Authorization', + 'in': 'header', + 'required': true, + 'type': 'string', + 'description': 'Bearer token authorization. Example Auhorization=\'bearer eyJhbGciOiJIUzI....wdgMI\'', + 'group': 'Header' } ], 'responses': { @@ -54,7 +62,8 @@ const expectedObject = } }, 'requestParameters': { - 'integration.request.path.id': 'method.request.path.id' + 'integration.request.path.id': 'method.request.path.id', + 'integration.request.header.Authorization': 'method.request.header.Authorization' } } } diff --git a/test/simple/input/simpleDoc.js b/test/simple/input/simpleDoc.js index a804ae3..e814bda 100644 --- a/test/simple/input/simpleDoc.js +++ b/test/simple/input/simpleDoc.js @@ -4,6 +4,8 @@ * @apiGroup User * * @apiParam {Number} id Users unique ID. + * + * @apiHeader {string} Authorization Bearer token authorization. Example `Auhorization='bearer eyJhbGciOiJIUzI....wdgMI'` * * @apiSuccess {String} firstname Firstname of the User. * @apiSuccess {String} lastname Lastname of the User. diff --git a/test/simple/output/swagger.json b/test/simple/output/swagger.json index 973b129..6ead16c 100644 --- a/test/simple/output/swagger.json +++ b/test/simple/output/swagger.json @@ -1 +1 @@ -{"swagger":"2.0","info":{"title":"steplix-apidoc-swagger","version":"0.4.6","description":"Convert api doc json to swagger json, including aws api-gateway attributes"},"servers":[{"url":"http://localhost"}],"paths":{"/user/id":{"get":{"tags":["User"],"consumes":["application/json"],"produces":["application/json"],"parameters":[{"name":"id","in":"path","required":true,"type":"number","description":"Users unique ID."}],"responses":{"200":{"description":"successful operation","schema":{"type":"String","items":{"$ref":"#/definitions/GetUser"}}}},"x-amazon-apigateway-integration":{"uri":"http://localhost/user/id","passthroughBehavior":"when_no_match","httpMethod":"GET","type":"http","connectionType":"VPC_LINK","connectionId":"${stageVariables.idVpcLink}","responses":{"default":{"statusCode":"200"}},"requestParameters":{"integration.request.path.id":"method.request.path.id"}}}}},"definitions":{"GetUser":{"properties":{"id":{"type":"number","description":"Users unique ID."},"firstname":{"type":"string","description":"Firstname of the User."},"lastname":{"type":"string","description":"Lastname of the User."}},"required":["id","firstname","lastname"]}}} \ No newline at end of file +{"swagger":"2.0","info":{"title":"steplix-apidoc-swagger","version":"0.4.7","description":"Convert api doc json to swagger json, including aws api-gateway attributes"},"servers":[{"url":"http://localhost"}],"paths":{"/user/id":{"get":{"tags":["User"],"consumes":["application/json"],"produces":["application/json"],"parameters":[{"name":"id","in":"path","required":true,"type":"number","description":"Users unique ID."},{"name":"Authorization","in":"header","required":true,"type":"string","description":"Bearer token authorization. Example Auhorization='bearer eyJhbGciOiJIUzI....wdgMI'","group":"Header"}],"responses":{"200":{"description":"successful operation","schema":{"type":"String","items":{"$ref":"#/definitions/GetUser"}}}},"x-amazon-apigateway-integration":{"uri":"http://localhost/user/id","passthroughBehavior":"when_no_match","httpMethod":"GET","type":"http","connectionType":"VPC_LINK","connectionId":"${stageVariables.idVpcLink}","responses":{"default":{"statusCode":"200"}},"requestParameters":{"integration.request.path.id":"method.request.path.id","integration.request.header.Authorization":"method.request.header.Authorization"}}}}},"definitions":{"GetUser":{"properties":{"id":{"type":"number","description":"Users unique ID."},"firstname":{"type":"string","description":"Firstname of the User."},"lastname":{"type":"string","description":"Lastname of the User."}},"required":["id","firstname","lastname"]}}} \ No newline at end of file