Skip to content

Commit f5ce2e8

Browse files
feat: introduced minimal bundleOas export function (#2365)
1 parent 4f854c1 commit f5ce2e8

File tree

109 files changed

+1760
-1060
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+1760
-1060
lines changed

.changeset/old-steaks-talk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@redocly/openapi-core": minor
3+
---
4+
5+
Added new `bundleOas` export: a lightweight function for bundling OpenAPI specifications.

__tests__/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { readFileSync } from 'node:fs';
22
import { join } from 'node:path';
33
import { spawnSync } from 'node:child_process';
4-
import { parseYaml } from '../packages/core/src/utils.js'; // not able to import from @redocly/openapi-core
4+
import { parseYaml } from '../packages/core/src/utils/yaml-fs-helper.js'; // not able to import from @redocly/openapi-core
55

66
export function getParams(indexEntryPoint: string, args: string[] = []): string[] {
77
return [indexEntryPoint, ...args];

__tests__/respect/local-json-server/local-json-server.test.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,19 @@ describe('local-json-server', () => {
2020
});
2121

2222
afterAll(() => {
23-
// Kill the process group to ensure child processes are cleaned up
24-
process.kill(-serverProcess.pid);
23+
try {
24+
if (process.platform === 'win32') {
25+
spawn('taskkill', ['/pid', serverProcess.pid.toString(), '/f', '/t']);
26+
} else {
27+
spawn('kill', ['-TERM', `-${serverProcess.pid}`]);
28+
}
29+
} catch (error) {
30+
try {
31+
serverProcess.kill('SIGTERM');
32+
} catch (e) {
33+
// Process may have already exited
34+
}
35+
}
2536

2637
// Restore original state
2738
if (originalData) {

package-lock.json

Lines changed: 36 additions & 175 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/src/__tests__/commands/join.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ describe('handleJoin', () => {
158158

159159
it('should call exitWithError if mixing OpenAPI 3.0 and 3.1', async () => {
160160
vi.mocked(detectSpec)
161+
.mockImplementationOnce(() => 'oas3_0')
162+
.mockImplementationOnce(() => 'oas3_1')
161163
.mockImplementationOnce(() => 'oas3_0')
162164
.mockImplementationOnce(() => 'oas3_1');
163165
await handleJoin({

packages/cli/src/commands/join.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
isPlainObject,
1515
keysOf,
1616
isEmptyObject,
17+
getTypes,
1718
} from '@redocly/openapi-core';
1819
import {
1920
getFallbackApisOrExit,
@@ -133,6 +134,7 @@ export async function handleJoin({
133134
document,
134135
config,
135136
externalRefResolver: new BaseResolver(config.resolve),
137+
types: getTypes(detectSpec(document.parsed)),
136138
}).catch((e) => {
137139
exitWithError(`${e.message}: ${blue(document.source.absoluteRef)}`);
138140
})

0 commit comments

Comments
 (0)