@@ -28,7 +28,7 @@ function _mapToObj(map) {
28
28
29
29
var autoVersion ;
30
30
31
- module . exports = function ( AWS ) {
31
+ module . exports = function ( ) {
32
32
return {
33
33
_createDocumentationPart : function _createDocumentationPart ( part , def , knownLocation ) {
34
34
const location = part . locationProps . reduce ( ( loc , property ) => {
@@ -75,12 +75,11 @@ module.exports = function(AWS) {
75
75
} ,
76
76
77
77
_updateDocumentation : function _updateDocumentation ( ) {
78
- const apiGateway = new AWS . APIGateway ( this . serverless . providers . aws . getCredentials ( ) ) ;
79
- return apiGateway . getDocumentationVersion ( {
78
+ const aws = this . serverless . providers . aws ;
79
+ return aws . request ( 'APIGateway' , 'getDocumentationVersion' , {
80
80
restApiId : this . restApiId ,
81
81
documentationVersion : this . getDocumentationVersion ( ) ,
82
- } ) . promise ( )
83
- . then ( ( ) => {
82
+ } ) . then ( ( ) => {
84
83
const msg = 'documentation version already exists, skipping upload' ;
85
84
console . info ( '-------------------' ) ;
86
85
console . info ( msg ) ;
@@ -92,26 +91,30 @@ module.exports = function(AWS) {
92
91
93
92
return Promise . reject ( err ) ;
94
93
} )
95
- . then ( ( ) => apiGateway . getDocumentationParts ( {
96
- restApiId : this . restApiId ,
97
- limit : 9999 ,
98
- } ) . promise ( ) )
99
- . then ( results => results . items . map ( part => apiGateway . deleteDocumentationPart ( {
100
- documentationPartId : part . id ,
101
- restApiId : this . restApiId ,
102
- } ) . promise ( ) ) )
94
+ . then ( ( ) =>
95
+ aws . request ( 'APIGateway' , 'getDocumentationParts' , {
96
+ restApiId : this . restApiId ,
97
+ limit : 9999 ,
98
+ } )
99
+ )
100
+ . then ( results => results . items . map (
101
+ part => aws . request ( 'APIGateway' , 'deleteDocumentationPart' , {
102
+ documentationPartId : part . id ,
103
+ restApiId : this . restApiId ,
104
+ } )
105
+ ) )
103
106
. then ( promises => Promise . all ( promises ) )
104
107
. then ( ( ) => this . documentationParts . reduce ( ( promise , part ) => {
105
108
return promise . then ( ( ) => {
106
109
part . properties = JSON . stringify ( part . properties ) ;
107
- return apiGateway . createDocumentationPart ( part ) . promise ( ) ;
110
+ return aws . request ( 'APIGateway' , 'createDocumentationPart' , part ) ;
108
111
} ) ;
109
112
} , Promise . resolve ( ) ) )
110
- . then ( ( ) => apiGateway . createDocumentationVersion ( {
113
+ . then ( ( ) => aws . request ( 'APIGateway' , 'createDocumentationVersion' , {
111
114
restApiId : this . restApiId ,
112
115
documentationVersion : this . getDocumentationVersion ( ) ,
113
116
stageName : this . options . stage ,
114
- } ) . promise ( ) ) ;
117
+ } ) ) ;
115
118
} ,
116
119
117
120
getGlobalDocumentationParts : function getGlobalDocumentationParts ( ) {
0 commit comments