Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@scalar/openapi-parser

Package Overview
Dependencies
Maintainers
8
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scalar/openapi-parser - npm Package Compare versions

Comparing version 0.8.10 to 0.9.0

6

CHANGELOG.md
# @scalar/openapi-parser
## 0.9.0
### Minor Changes
- 6fef2f3: feat(openapi-parser): support `onDereference` option on `dereference`
## 0.8.10

@@ -4,0 +10,0 @@

5

dist/utils/dereference.d.ts

@@ -1,3 +0,4 @@

import type { AnyApiDefinitionFormat, DereferenceResult, Filesystem, ThrowOnErrorOption } from '../types';
export type DereferenceOptions = ThrowOnErrorOption;
import type { AnyApiDefinitionFormat, DereferenceResult, Filesystem } from '../types';
import { type ResolveReferencesOptions } from './resolveReferences.js';
export type DereferenceOptions = ResolveReferencesOptions;
/**

@@ -4,0 +5,0 @@ * Resolves all references in an OpenAPI document

8

dist/utils/resolveReferences.d.ts

@@ -8,6 +8,12 @@ import type { OpenAPI } from '@scalar/openapi-types';

};
export type ResolveReferencesOptions = ThrowOnErrorOption & {
onDereference?: (data: {
schema: AnyObject;
ref: string;
}) => void;
};
/**
* Takes a specification and resolves all references.
*/
export declare function resolveReferences(input: AnyObject | Filesystem, options?: ThrowOnErrorOption, file?: FilesystemEntry, errors?: ErrorObject[]): ResolveReferencesResult;
export declare function resolveReferences(input: AnyObject | Filesystem, options?: ResolveReferencesOptions, file?: FilesystemEntry, errors?: ErrorObject[]): ResolveReferencesResult;
//# sourceMappingURL=resolveReferences.d.ts.map

@@ -29,6 +29,6 @@ import { ERRORS } from '../configuration/index.js';

// Recursively resolve all references
resolve(file?.specification ?? entrypoint.specification, filesystem, file ?? entrypoint);
resolve(file?.specification ?? entrypoint.specification, filesystem, file ?? entrypoint, options?.onDereference);
// If we replace references with content, that includes a reference, we can’t deal with that right-away.
// That’s why we need a second run.
resolve(file?.specification ?? entrypoint.specification, filesystem, file ?? entrypoint);
resolve(file?.specification ?? entrypoint.specification, filesystem, file ?? entrypoint, options?.onDereference);
// Remove duplicats (according to message) from errors

@@ -47,3 +47,3 @@ errors = errors.filter((error, index, self) => index ===

*/
function resolve(schema, resolveFilesystem, resolveFile) {
function resolve(schema, resolveFilesystem, resolveFile, onResolve) {
let result;

@@ -59,2 +59,3 @@ // Iterate over the whole objecct

}
onResolve?.({ schema, ref: schema.$ref });
// Get rid of the reference

@@ -71,3 +72,3 @@ delete schema.$ref;

if (typeof value === 'object' && !isCircular(value)) {
result = resolve(value, resolveFilesystem, resolveFile);
result = resolve(value, resolveFilesystem, resolveFile, onResolve);
}

@@ -74,0 +75,0 @@ });

@@ -20,3 +20,3 @@ {

],
"version": "0.8.10",
"version": "0.9.0",
"engines": {

@@ -23,0 +23,0 @@ "node": ">=18"

@@ -66,2 +66,16 @@ # Scalar OpenAPI Parser

### Track references
The `dereference` function accepts an `onDereference` callback option that gets called whenever a reference is resolved. This can be useful for tracking which schemas are being dereferenced:
```ts
import { dereference } from '@scalar/openapi-parser'
const { schema, errors } = await dereference(specification, {
onDereference: ({ schema, ref }) => {
//
},
})
```
### Modify an OpenAPI document

@@ -68,0 +82,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc