Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 5 additions & 5 deletions packages/cli/src/__tests__/commands/bundle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
bundle,
getTotals,
logger,
Config,
createConfig,
type ResolvedApiConfig,
type ResolvedConfig,
} from '@redocly/openapi-core';
Expand Down Expand Up @@ -160,7 +160,7 @@ describe('bundle', () => {
} as ResolvedApiConfig,
},
};
const config = new Config(resolvedConfigMock);
const config = await createConfig(resolvedConfigMock);

vi.mocked(getFallbackApisOrExit).mockResolvedValueOnce(
Object.entries(resolvedConfigMock.apis!).map(([alias, { root, ...api }]) => ({
Expand Down Expand Up @@ -198,7 +198,7 @@ describe('bundle', () => {
} as ResolvedApiConfig,
},
};
const config = new Config(resolvedConfigMock);
const config = await createConfig(resolvedConfigMock);

vi.mocked(getFallbackApisOrExit).mockResolvedValueOnce(
Object.entries(resolvedConfigMock.apis!).map(([alias, { root, ...api }]) => ({
Expand Down Expand Up @@ -233,7 +233,7 @@ describe('bundle', () => {
} as ResolvedApiConfig,
},
};
const config = new Config(resolvedConfigMock);
const config = await createConfig(resolvedConfigMock);

vi.mocked(getFallbackApisOrExit).mockResolvedValueOnce([{ path: 'openapi.yaml' }]);
vi.mocked(getTotals).mockReturnValue({
Expand Down Expand Up @@ -266,7 +266,7 @@ describe('bundle', () => {
},
};

const config = new Config(resolvedConfigMock);
const config = await createConfig(resolvedConfigMock);

vi.mocked(getFallbackApisOrExit).mockResolvedValueOnce(
Object.entries(resolvedConfigMock.apis!).map(([alias, { root, ...api }]) => ({
Expand Down
16 changes: 4 additions & 12 deletions packages/cli/src/__tests__/commands/generate-arazzo.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GenerateArazzoCommandArgv, handleGenerateArazzo } from '../../commands/generate-arazzo.js';
import { generate } from '@redocly/respect-core';
import { vi, describe, it, expect, beforeEach } from 'vitest';
import { Config } from '@redocly/openapi-core';
import * as openapiCore from '@redocly/openapi-core';

vi.mock('@redocly/respect-core', async () => {
const actual = await vi.importActual<typeof import('@redocly/respect-core')>(
Expand All @@ -13,14 +13,6 @@ vi.mock('@redocly/respect-core', async () => {
};
});

vi.mock('node:fs', async () => {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't needed at all.

return {
writeFileSync: vi.fn(),
existsSync: vi.fn(() => true),
readFileSync: vi.fn(() => ''),
};
});

vi.mock('@redocly/openapi-core', async () => {
const actual = await vi.importActual('@redocly/openapi-core');
return {
Expand All @@ -39,7 +31,7 @@ describe('handleGenerateArazzo', () => {
});

it('should call generate with the correct arguments', async () => {
const mockConfig = new Config({});
const mockConfig = await openapiCore.createConfig({});
const commandArgs = {
argv: {
descriptionPath: 'openapi.yaml',
Expand All @@ -61,7 +53,7 @@ describe('handleGenerateArazzo', () => {
});

it('should use custom output file when provided', async () => {
const mockConfig = new Config({});
const mockConfig = await openapiCore.createConfig({});
const commandArgs = {
argv: {
descriptionPath: 'openapi.yaml',
Expand All @@ -84,7 +76,7 @@ describe('handleGenerateArazzo', () => {
});

it('should throw an error if the openapi file is not valid', async () => {
const mockConfig = new Config({});
const mockConfig = await openapiCore.createConfig({});
const commandArgs = {
argv: {
descriptionPath: 'openapi.yaml',
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/__tests__/commands/respect/respect.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { handleRespect, type RespectArgv } from '../../../commands/respect/index.js';
import { run } from '@redocly/respect-core';
import { Config } from '@redocly/openapi-core';
import * as openapiCore from '@redocly/openapi-core';

// Mock node:fs
vi.mock('node:fs', async () => {
Expand Down Expand Up @@ -52,7 +52,7 @@ describe('handleRespect', () => {
vi.clearAllMocks();
});
it('should call run with the correct arguments', async () => {
const mockConfig = new Config({});
const mockConfig = await openapiCore.createConfig({});
const commandArgs = {
argv: {
files: ['test.arazzo.yaml'],
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ export * from './builtIn.js';
export * from './load.js';
export * from './utils.js';
export * from './config-resolvers.js';
export * from './constants.js';
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

121 changes: 57 additions & 64 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly moving exports around. No real changes here.

type CollectFn,
type Exact,
keysOf,
readFileFromUrl,
slash,
Expand All @@ -13,6 +11,8 @@ export {
isEmptyObject,
isNotEmptyArray,
isNotEmptyObject,
type CollectFn,
type Exact,
} from './utils.js';
export { dequal } from './utils/dequal.js';
export { Oas3_1Types } from './types/oas3_1.js';
Expand All @@ -22,75 +22,33 @@ export { Oas2Types } from './types/oas2.js';
export { AsyncApi2Types } from './types/asyncapi2.js';
export { AsyncApi3Types } from './types/asyncapi3.js';
export { ConfigTypes, createConfigTypes } from './types/redocly-yaml.js';

export type {
Oas3Definition,
Oas3_1Definition,
Oas3Components,
Oas3_1Components,
Oas3PathItem,
Oas3Paths,
Oas3ComponentName,
Oas3Schema,
Oas3_1Schema,
Oas3Tag,
Referenced,
OasRef,
Oas3Parameter,
Oas3Server,
Oas3Operation,
Oas3Responses,
ApiKeyAuth,
HttpAuth,
BasicAuth,
BearerAuth,
DigestAuth,
MutualTLSAuth,
OAuth2Auth,
OpenIDAuth,
Oas3SecurityScheme,
Oas3SecurityRequirement,
} from './typings/openapi.js';
export type { Oas2Definition } from './typings/swagger.js';
export type { Async3Definition } from './typings/asyncapi3.js';
export type { Async2Definition } from './typings/asyncapi.js';
export type {
ArazzoDefinition,
ExtendedOperation,
ExtendedSecurity,
ResolvedSecurity,
} from './typings/arazzo.js';
export type { StatsAccumulator, StatsName } from './typings/common.js';
export { type NormalizedNodeType, type NodeType, normalizeTypes } from './types/index.js';
export { normalizeTypes, type NormalizedNodeType, type NodeType } from './types/index.js';
export { Stats } from './rules/other/stats.js';

export {
loadConfig,
createConfig,
findConfig,
resolvePlugins,
ConfigValidationError,
Config, // FIXME: export it as a type
type RawUniversalConfig,
type RawUniversalApiConfig,
type ResolvedConfig,
type ResolvedApiConfig,
type Plugin,
type RuleConfig,
Config, // FIXME: export it as a type
IGNORE_FILE,
loadConfig,
findConfig,
CONFIG_FILE_NAME,
type RuleSeverity,
createConfig,
ConfigValidationError,
resolvePlugins,
} from './config/index.js';

export * from './config/constants.js';
export {
type ResolvedRefMap,
Source,
BaseResolver,
Document,
resolveDocument,
ResolveError,
YamlParseError,
resolveDocument,
makeDocumentFromString,
type ResolvedRefMap,
} from './resolve.js';
export { parseYaml, stringifyYaml } from './js-yaml/index.js';
export {
Expand All @@ -101,11 +59,11 @@ export {
type Location,
} from './ref-utils.js';
export {
type SpecMajorVersion,
getMajorSpecVersion,
type SpecVersion,
detectSpec,
getMajorSpecVersion,
getTypes,
type SpecVersion,
type SpecMajorVersion,
} from './oas-types.js';
export {
normalizeVisitors,
Expand Down Expand Up @@ -134,31 +92,66 @@ export {
type Arazzo1Preprocessor,
type Overlay1Preprocessor,
} from './visitors.js';

export {
WalkContext,
walkDocument,
NormalizedProblem,
ProblemSeverity,
LineColLocationObject,
LocationObject,
Loc,
walkDocument,
type UserContext,
} from './walk.js';

export { getAstNodeByPointer, getLineColLocation, getCodeframe } from './format/codeframes.js';
export { formatProblems, OutputFormat, getTotals, Totals } from './format/format.js';
export { formatProblems, getTotals, type OutputFormat, type Totals } from './format/format.js';
export { lint, lint as validate, lintDocument, lintFromString, lintConfig } from './lint.js';
export {
type BundleResult,
bundle,
bundleDocument,
mapTypeToComponent,
bundleFromString,
type BundleResult,
} from './bundle.js';

export { type Assertions, type Assertion } from './rules/common/assertions/index.js';

export { logger, type LoggerInterface } from './logger.js';
export { HandledError } from './utils/error.js';
export { isBrowser } from './env.js';

export type {
Oas3Definition,
Oas3_1Definition,
Oas3Components,
Oas3_1Components,
Oas3PathItem,
Oas3Paths,
Oas3ComponentName,
Oas3Schema,
Oas3_1Schema,
Oas3Tag,
Referenced,
OasRef,
Oas3Parameter,
Oas3Server,
Oas3Operation,
Oas3Responses,
ApiKeyAuth,
HttpAuth,
BasicAuth,
BearerAuth,
DigestAuth,
MutualTLSAuth,
OAuth2Auth,
OpenIDAuth,
Oas3SecurityScheme,
Oas3SecurityRequirement,
} from './typings/openapi.js';
export type { Oas2Definition } from './typings/swagger.js';
export type { Async3Definition } from './typings/asyncapi3.js';
export type { Async2Definition } from './typings/asyncapi.js';
export type {
ArazzoDefinition,
ExtendedOperation,
ExtendedSecurity,
ResolvedSecurity,
} from './typings/arazzo.js';
export type { StatsAccumulator, StatsName } from './typings/common.js';
Loading