Skip to content

Commit 0e587eb

Browse files
committed
fix: add in api name and version to grab apis
1 parent 5df0628 commit 0e587eb

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src/generator/download.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export async function downloadDiscoveryDocs(
8383
options.downloadPath,
8484
api.id.replace(':', '-') + '.json'
8585
);
86-
const url = api.discoveryRestUrl;
86+
const url = `${options.discoveryUrl}/${api.name}.${api.version}.json`;
8787
const changeSet: ChangeSet = {api, changes: []};
8888
try {
8989
const res = await request<{}>({url});

test/fixtures/index.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"items": [
33
{
44
"id": "fake:v1",
5-
"discoveryRestUrl": "http://localhost:3030/path"
5+
"discoveryRestUrl": "http://localhost:3030/path",
6+
"name": "fake",
7+
"version": "v1"
68
}
79
]
810
}

test/test.download.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ describe(__filename, () => {
8787
.reply(200, JSON.stringify(fs.readFileSync(fakeIndexPath, 'utf8')), {
8888
'Content-Type': 'application/json',
8989
}),
90-
nock('http://localhost:3030').get('/path').reply(200),
90+
nock(
91+
'https://raw.githubusercontent.com/googleapis/discovery-artifact-manager/master/discoveries'
92+
)
93+
.get('/fake.v1.json')
94+
.reply(200),
9195
];
9296
const mkdirpStub = sandbox.stub(dn.gfs, 'mkdir').resolves();
9397
const writeFileStub = sandbox.stub(dn.gfs, 'writeFile');
@@ -109,9 +113,13 @@ describe(__filename, () => {
109113
.reply(200, JSON.stringify(fs.readFileSync(fakeIndexPath, 'utf8')), {
110114
'Content-Type': 'application/json',
111115
}),
112-
nock('http://localhost:3030').get('/path').reply(200, {
113-
revision: '1234',
114-
}),
116+
nock(
117+
'https://raw.githubusercontent.com/googleapis/discovery-artifact-manager/master/discoveries'
118+
)
119+
.get('/fake.v1.json')
120+
.reply(200, {
121+
revision: '1234',
122+
}),
115123
];
116124
const writeFileStub = sandbox.stub(dn.gfs, 'writeFile');
117125
const readFileStub = sandbox.stub(dn.gfs, 'readFile').callsFake(() => {

0 commit comments

Comments
 (0)