Skip to content

Commit

Permalink
Fix header param case
Browse files Browse the repository at this point in the history
  • Loading branch information
aremonda committed Oct 21, 2020
1 parent 5048153 commit eb7e3a2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
3 changes: 3 additions & 0 deletions lib/apidocToSwagger.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,9 @@ function createAwsParameters(parameters) {
continue;
case 'body':
continue;
case 'header':
type = 'header';
break;
default:
break;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
13 changes: 11 additions & 2 deletions test/simple/expectedObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand All @@ -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': {
Expand All @@ -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'
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions test/simple/input/simpleDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion test/simple/output/swagger.json
Original file line number Diff line number Diff line change
@@ -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"]}}}
{"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"]}}}

0 comments on commit eb7e3a2

Please sign in to comment.