Skip to content

Commit 0915907

Browse files
committed
feat: WIP more openapi3 work, schemas still todo
1 parent cfc828d commit 0915907

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

src/index.js

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,14 @@ exports.convert = function (data) {
6060
},
6161
termsOfService: 'https://developers.google.com/terms/'
6262
},
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+
}
6971
}, processResource(data, srGlobalRefParameters));
7072

7173
if (data.documentationLink)
@@ -88,17 +90,23 @@ function processAuth(auth) {
8890
Oauth2: {
8991
type: 'oauth2',
9092
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+
}
9499
},
95100
Oauth2c: {
96101
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+
}
102110
}
103111
};
104112
}
@@ -107,14 +115,14 @@ function processGlobalParameters(parameters, srGlobalRefParameters) {
107115
let srGlobalParameters = {};
108116
_.each(parameters, function (param, name) {
109117
srGlobalParameters[name] = processParameter(name, param);
110-
srGlobalRefParameters.push({$ref: '#/parameters/' + name});
118+
srGlobalRefParameters.push({$ref: '#/components/parameters/' + name});
111119
});
112120
return srGlobalParameters;
113121
}
114122

115123
function fixRef(ref) {
116124
if (ref.indexOf('.json') === -1) {
117-
return '#/definitions/' + ref;
125+
return '#/components/schemas/' + ref;
118126
} else {
119127
return ref;
120128
}

0 commit comments

Comments
 (0)