
Research
GemStuffer Campaign Abuses RubyGems as Exfiltration Channel Targeting UK Local Government
GemStuffer abuses RubyGems as an exfiltration channel, packaging scraped UK council portal data into junk gems published from new accounts.
@redocly/openapi-core
Advanced tools
See https://github.com/Redocly/redocly-cli
[!IMPORTANT] The
openapi-core packageis designed for our internal use; the interfaces that are considered safe to use are documented below. Some of the function arguments are not documented below because they are not intended for public use. Avoid using any functions or features that are not documented below. If your use case is not documented below, please open an issue.
Lint a file.
import { lint, loadConfig } from '@redocly/openapi-core';
const pathToApi = 'openapi.yaml';
const config = await loadConfig({ configPath: 'optional/path/to/redocly.yaml' });
const lintResults = await lint({ ref: pathToApi, config });
The content of lintResults describes any errors or warnings found during linting; an empty array means no problems were found.
For each problem, the rule, severity, feedback message and a location object are provided.
To learn more, check the lint function section.
Bundle an API description into a single structure.
import { bundle, loadConfig } from '@redocly/openapi-core';
const pathToApi = 'openapi.yaml';
const config = await loadConfig({ configPath: 'optional/path/to/redocly.yaml' });
const bundleResults = await bundle({ ref: pathToApi, config });
In bundleResults, the bundle.parsed field has the bundled API description.
For more information, check the bundle function section.
Lint an API description, with configuration defined. This is useful if the API description you're working with isn't a file on disk.
import { lintFromString, createConfig, stringifyYaml } from '@redocly/openapi-core';
const config = await createConfig(
{
extends: ['minimal'],
rules: {
'operation-description': 'error',
},
},
{
// optionally provide config path for resolving $refs and proper error locations
configPath: 'optional/path/to/redocly.yaml',
}
);
const source = stringifyYaml({ openapi: '3.0.1' /* ... */ }); // you can also use JSON.stringify
const lintResults = await lintFromString({
source,
// optionally pass path to the file for resolving $refs and proper error locations
absoluteRef: 'optional/path/to/openapi.yaml',
config,
});
Lint an API description, with configuration including a custom plugin to define a rule.
import { lintFromString, createConfig, stringifyYaml } from '@redocly/openapi-core';
const CustomRule = (ruleOptions) => {
return {
Operation() {
// some rule logic
},
};
};
const config = await createConfig({
extends: ['recommended'],
plugins: [
{
id: 'pluginId',
rules: {
oas3: {
customRule1: CustomRule,
},
oas2: {
customRule1: CustomRule, // if the same rule can handle both oas3 and oas2
},
},
decorators: {
// ...
},
},
],
// enable rule
rules: {
'pluginId/customRule1': 'error',
},
decorators: {
// ...
},
});
const source = stringifyYaml({ openapi: '3.0.1' /* ... */ }); // you can also use JSON.stringify
const lintResults = await lintFromString({
source,
// optionally pass path to the file for resolving $refs and proper error locations
absoluteRef: 'optional/path/to/openapi.yaml',
config,
});
Bundle an API description into a single structure, using default configuration.
import { bundleFromString, createConfig } from '@redocly/openapi-core';
const config = await createConfig({}); // create empty config
const source = stringifyYaml({ openapi: '3.0.1' /* ... */ }); // you can also use JSON.stringify
const bundleResults = await bundleFromString({
source,
// optionally pass path to the file for resolving $refs and proper error locations
absoluteRef: 'optional/path/to/openapi.yaml',
config,
});
Lint a configuration file to validate its structure and rules.
import { lintConfig, loadConfig } from '@redocly/openapi-core';
const config = await loadConfig({ configPath: 'redocly.yaml' });
const configProblems = await lintConfig({ config });
createConfigCreates a config object from a JSON or YAML string or JS object.
Resolves remote config from extends (if there are URLs or local fs paths).
async function createConfig(
// JSON or YAML string or object with Redocly config
config: string | RawUniversalConfig,
options?: {
// optional path to the config file for resolving $refs and proper error locations
configPath?: string;
}
): Promise<Config>;
loadConfigLoads a config object from a file system. If configPath is not provided,
it tries to find redocly.yaml in the current working directory.
async function loadConfig(options?: {
// optional path to the config file for resolving $refs and proper error locations
configPath?: string;
// allows to add custom `extends` instead of the one from the config file
customExtends?: string[];
}): Promise<Config>;
lintConfigLint a configuration file to validate its structure and rules.
async function lintConfig(options: {
// config object to validate
config: Config;
// optional severity level for validation
severity?: ProblemSeverity;
// optional external reference resolver
externalRefResolver?: BaseResolver;
// optional override for config types
externalConfigTypes?: Record<string, NodeType>;
}): Promise<NormalizedProblem[]>;
lintLint an OpenAPI document from the file system.
async function lint(options: {
// path to the OpenAPI document root
ref: string;
// config object
config: Config;
// optional external reference resolver
externalRefResolver?: BaseResolver;
}): Promise<NormalizedProblem[]>;
lintFromStringLint an OpenAPI document from a string.
async function lintFromString(options: {
// OpenAPI document string
source: string;
// optional path to the OpenAPI document for resolving $refs and proper error locations
absoluteRef?: string;
// config object
config: Config;
// optional external reference resolver
externalRefResolver?: BaseResolver;
}): Promise<NormalizedProblem[]>;
bundleBundle an OpenAPI document from the file system.
async function bundle(options: {
// path to the OpenAPI document root
ref?: string;
// optional document object (alternative to ref)
doc?: Document;
// config object
config: Config;
// whether to fully dereference $refs, resulting document won't have any $ref
// warning: this can produce circular objects
dereference?: boolean;
// whether to remove unused components (schemas, parameters, responses, etc)
removeUnusedComponents?: boolean;
// whether to keep $ref pointers to the http URLs and resolve only local fs $refs
keepUrlRefs?: boolean;
// optional external reference resolver
externalRefResolver?: BaseResolver;
// optional base path for resolution
base?: string | null;
}): Promise<{
bundle: {
parsed: object; // OpenAPI document object as js object
};
problems: NormalizedProblem[]
fileDependencies
rootType
refTypes
visitorsData
}>;
bundleFromStringBundle an OpenAPI document from a string.
async function bundleFromString(options: {
// OpenAPI document string
source: string;
// optional path to the OpenAPI document for resolving $refs and proper error locations
absoluteRef?: string;
// config object
config: Config;
// whether to fully dereference $refs, resulting document won't have any $ref
// warning: this can produce circular objects
dereference?: boolean;
// whether to remove unused components (schemas, parameters, responses, etc)
removeUnusedComponents?: boolean;
// whether to keep $ref pointers to the http URLs and resolve only local fs $refs
keepUrlRefs?: boolean;
// optional external reference resolver
externalRefResolver?: BaseResolver;
}): Promise<{
bundle: {
parsed: object; // OpenAPI document object as js object
};
problems: NormalizedProblem[]
fileDependencies
rootType
refTypes
visitorsData
}>;
stringifyYamlHelper function to stringify a javascript object to YAML.
function stringifyYaml(obj: object): string;
swagger-parser is a powerful tool for parsing, validating, and dereferencing Swagger and OpenAPI documents. It provides similar functionalities to @redocly/openapi-core, such as validation and dereferencing, but it does not offer as extensive transformation capabilities.
openapi-validator is a package focused on validating OpenAPI documents. It provides comprehensive validation features but lacks the bundling and transformation functionalities offered by @redocly/openapi-core.
swagger-jsdoc is a tool for generating Swagger (OpenAPI) definitions from JSDoc comments in your code. While it focuses on generating OpenAPI documents rather than validating or transforming them, it can be used in conjunction with @redocly/openapi-core for a complete workflow.
FAQs
See https://github.com/Redocly/redocly-cli
The npm package @redocly/openapi-core receives a total of 5,186,030 weekly downloads. As such, @redocly/openapi-core popularity was classified as popular.
We found that @redocly/openapi-core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
GemStuffer abuses RubyGems as an exfiltration channel, packaging scraped UK council portal data into junk gems published from new accounts.

Company News
Socket was named to the Rising in Cyber 2026 list, recognizing 30 private cybersecurity startups selected by CISOs and security executives.

Research
Socket detected 84 compromised TanStack npm package artifacts modified with suspected CI credential-stealing malware.