-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathgithub.js
More file actions
31 lines (30 loc) · 1.03 KB
/
Copy pathgithub.js
File metadata and controls
31 lines (30 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
let removeParam = require('./util/remove-parameter');
module.exports = (spec) => {
for (let path in spec.paths) {
for (let method in spec.paths[path]) {
let op = spec.paths[path][method];
if (method === 'get' && path.endsWith('s')) {
op.parameters.push({
name: 'page',
in: 'query',
type: 'integer',
})
}
// Lots of parameters that are optional are listed as required
(op.parameters || [])
.filter(p => p.in !== 'path' && p.in !== 'body')
.forEach(p => delete p.required);
(op.parameters || [])
.forEach(p => {
if (p.name === 'state') p.enum = ['open', 'closed', 'all'];
});
}
}
spec.definitions.postGist.properties.files.additionalProperties = true;
removeParam(spec, 'X-GitHub-Media-Type');
removeParam(spec, 'Accept');
removeParam(spec, 'X-RateLimit-Limit');
removeParam(spec, 'X-RateLimit-Remaining');
removeParam(spec, 'X-RateLimit-Reset');
removeParam(spec, 'X-GitHub-Request-Id');
}