@@ -60,12 +60,14 @@ exports.convert = function (data) {
60
60
} ,
61
61
termsOfService : 'https://developers.google.com/terms/'
62
62
} ,
63
- host : rootUrl . host ( ) ,
64
- basePath : '/' + data . servicePath . replace ( / ^ \/ | \/ $ / , '' ) ,
65
- schemes : [ rootUrl . scheme ( ) ] ,
66
- definitions : processDefinitions ( data . schemas ) ,
67
- parameters : srGlobalParameters ,
68
- securityDefinitions : processAuth ( data . auth )
63
+ servers : [ {
64
+ url : rootUrl . scheme ( ) + rootUrl . host ( ) + '/' + data . servicePath . replace ( / ^ \/ | \/ $ / , '' )
65
+ } ] ,
66
+ components : {
67
+ schemas : processDefinitions ( data . schemas ) ,
68
+ parameters : srGlobalParameters ,
69
+ securitySchemes : processAuth ( data . auth )
70
+ }
69
71
} , processResource ( data , srGlobalRefParameters ) ) ;
70
72
71
73
if ( data . documentationLink )
@@ -88,17 +90,23 @@ function processAuth(auth) {
88
90
Oauth2 : {
89
91
type : 'oauth2' ,
90
92
description : 'Oauth 2.0 implicit authentication' ,
91
- flow : 'implicit' ,
92
- authorizationUrl : 'https://accounts.google.com/o/oauth2/auth' ,
93
- scopes : _ . mapValues ( auth . oauth2 . scopes , 'description' )
93
+ flows : {
94
+ implicit : {
95
+ authorizationUrl : 'https://accounts.google.com/o/oauth2/auth' ,
96
+ scopes : _ . mapValues ( auth . oauth2 . scopes , 'description' )
97
+ }
98
+ }
94
99
} ,
95
100
Oauth2c : {
96
101
type : 'oauth2' ,
97
- description : 'Oauth 2.0 accessCode authentication' ,
98
- flow : 'accessCode' ,
99
- authorizationUrl : 'https://accounts.google.com/o/oauth2/auth' ,
100
- tokenUrl : 'https://accounts.google.com/o/oauth2/token' ,
101
- scopes : _ . mapValues ( auth . oauth2 . scopes , 'description' )
102
+ description : 'Oauth 2.0 authorizationCode authentication' ,
103
+ flows : {
104
+ authorizationCode : {
105
+ authorizationUrl : 'https://accounts.google.com/o/oauth2/auth' ,
106
+ tokenUrl : 'https://accounts.google.com/o/oauth2/token' ,
107
+ scopes : _ . mapValues ( auth . oauth2 . scopes , 'description' )
108
+ }
109
+ }
102
110
}
103
111
} ;
104
112
}
@@ -107,14 +115,14 @@ function processGlobalParameters(parameters, srGlobalRefParameters) {
107
115
let srGlobalParameters = { } ;
108
116
_ . each ( parameters , function ( param , name ) {
109
117
srGlobalParameters [ name ] = processParameter ( name , param ) ;
110
- srGlobalRefParameters . push ( { $ref : '#/parameters/' + name } ) ;
118
+ srGlobalRefParameters . push ( { $ref : '#/components/ parameters/' + name } ) ;
111
119
} ) ;
112
120
return srGlobalParameters ;
113
121
}
114
122
115
123
function fixRef ( ref ) {
116
124
if ( ref . indexOf ( '.json' ) === - 1 ) {
117
- return '#/definitions /' + ref ;
125
+ return '#/components/schemas /' + ref ;
118
126
} else {
119
127
return ref ;
120
128
}
0 commit comments