Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added getOpenApiSpecification() to BuildClient #626

Merged
merged 4 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/resource_clients/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ export class BuildClient extends ResourceClient {
return this._delete();
}

/**
* https://docs.apify.com/api/v2/actor-build-openapi-specification-get
*/
async getOpenApiSpecification() {
const response = await this.httpClient.call({
url: this._url('openapi-specification'),
method: 'GET',
params: this._params(),
});

return response.data;
}

/**
* Returns a promise that resolves with the finished Build object when the provided actor build finishes
* or with the unfinished Build object when the `waitSecs` timeout lapses. The promise is NOT rejected
Expand Down
12 changes: 12 additions & 0 deletions test/builds.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ describe('Build methods', () => {
validateRequest({}, { buildId });
});

test('getOpenApiSpecification() works', async () => {
const buildId = 'some-build-id';

const res = await client.build(buildId).getOpenApiSpecification();
expect(res.data.id).toEqual('build-openapi-specification');
validateRequest({}, { buildId });

const browserRes = await page.evaluate((bId) => client.build(bId).getOpenApiSpecification(), buildId);
expect(browserRes).toEqual(res);
validateRequest({}, { buildId });
});

test('waitForFinish() works', async () => {
const buildId = 'some-build-id';
const waitSecs = 0.1;
Expand Down
1 change: 1 addition & 0 deletions test/mock_server/routes/builds.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const ROUTES = [
{ id: 'get-build', method: 'GET', path: '/:buildId', type: 'responseJsonMock' },
{ id: 'abort-build', method: 'POST', path: '/:buildId/abort' },
{ id: 'build-log', method: 'GET', path: '/:buildId/log', type: 'text' },
{ id: 'build-openapi-specification', method: 'GET', path: '/:buildId/openapi-specification', type: 'responseJsonMock' },
];

addRoutes(builds, ROUTES);
Expand Down
Loading