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

@mintlify/validation

Package Overview
Dependencies
Maintainers
4
Versions
219
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mintlify/validation - npm Package Compare versions

Comparing version 0.1.178 to 0.1.179

dist/openapi/stripComponents.d.ts

4

./dist/index.js

@@ -5,4 +5,4 @@ import { zodToJsonSchema } from 'zod-to-json-schema';

export * from './openapi/types/endpoint.js';
export * from './openapi/types/incrementalEndpoint.js';
export { OpenApiToEndpointConverter } from './openapi/OpenApiToEndpointConverter.js';
export * from './openapi/OpenApiToEndpointConverter.js';
export { stripComponents } from './openapi/stripComponents.js';
export { SchemaConverter } from './openapi/SchemaConverter.js';

@@ -9,0 +9,0 @@ export { generateExampleFromSchema } from './openapi/generateExampleFromSchema.js';

export * from './openapi/types/endpoint.js';
export * from './openapi/types/incrementalEndpoint.js';
export { OpenApiToEndpointConverter } from './openapi/OpenApiToEndpointConverter.js';
export * from './openapi/OpenApiToEndpointConverter.js';
export { stripComponents } from './openapi/stripComponents.js';
export { SchemaConverter } from './openapi/SchemaConverter.js';

@@ -5,0 +5,0 @@ export { generateExampleFromSchema } from './openapi/generateExampleFromSchema.js';

@@ -5,4 +5,4 @@ import { zodToJsonSchema } from 'zod-to-json-schema';

export * from './openapi/types/endpoint.js';
export * from './openapi/types/incrementalEndpoint.js';
export { OpenApiToEndpointConverter } from './openapi/OpenApiToEndpointConverter.js';
export * from './openapi/OpenApiToEndpointConverter.js';
export { stripComponents } from './openapi/stripComponents.js';
export { SchemaConverter } from './openapi/SchemaConverter.js';

@@ -9,0 +9,0 @@ export { generateExampleFromSchema } from './openapi/generateExampleFromSchema.js';

import { OpenAPIV3_1 } from 'openapi-types';
import { IncrementalDataSchemaArray } from './types/incrementalEndpoint.js';
import { IncrementalDataSchemaArray } from './types/endpoint.js';
type Schema3_1 = OpenAPIV3_1.SchemaObject;

@@ -4,0 +4,0 @@ type Ref = OpenAPIV3_1.ReferenceObject;

@@ -41,3 +41,5 @@ import lcm from 'lcm';

}
if (!schema.oneOf && !schema.allOf && !schema.anyOf && !Array.isArray(schema.type)) {
// handle v3 `nullable` property
const nullable = schema.nullable;
if (!schema.oneOf && !schema.allOf && !schema.anyOf && !Array.isArray(schema.type) && !nullable) {
return [[schema]];

@@ -50,6 +52,8 @@ }

delete baseSchema.not;
const baseSchemaTypes = Array.isArray(baseSchema.type) ? [...baseSchema.type] : [baseSchema.type];
if (nullable && !baseSchemaTypes.includes('null')) {
baseSchemaTypes.push('null');
}
const baseSchemaArr = Object.keys(baseSchema).length > 0
? Array.isArray(baseSchema.type)
? [baseSchema.type.map((type) => [Object.assign(Object.assign({}, baseSchema), { type })])]
: [[[baseSchema]]]
? [baseSchemaTypes.map((type) => [Object.assign(Object.assign({}, baseSchema), { type })])]
: [];

@@ -161,2 +165,3 @@ const reducedOneOfs = (_a = schema.oneOf) === null || _a === void 0 ? void 0 : _a.map((subschema) => reduceToSumOfProducts(subschema, componentSchemas));

copyKeyIfDefined('format', curr, acc);
copyKeyIfDefined('default', curr, acc);
combineKeyIfDefined('multipleOf', curr, acc, lcm);

@@ -163,0 +168,0 @@ combineKeyIfDefined('maxLength', curr, acc, Math.min);

import { OpenAPIV3_1 } from 'openapi-types';
import { BaseConverter } from './BaseConverter.js';
import type { ContentSchema, DataSchemaArray, Endpoint, ExampleSchema, HttpMethod, ParameterSections, ResponseSchema } from './types/endpoint.js';
import { IncrementalDataSchemaArray, IncrementalEndpoint } from './types/incrementalEndpoint.js';
export declare abstract class BaseOpenApiToEndpointConverter<D> extends BaseConverter {
import type { ContentSchema, DataSchemaArray, Endpoint, ExampleSchema, HttpMethod, IncrementalDataSchemaArray, ParameterSections, ResponseSchema } from './types/endpoint.js';
export declare abstract class BaseOpenApiToEndpointConverter<D extends DataSchemaArray | IncrementalDataSchemaArray> extends BaseConverter {
readonly document: OpenAPIV3_1.Document;

@@ -34,4 +33,3 @@ readonly path: string;

convertContent(debugPath: string[], rawContent: Record<string, OpenAPIV3_1.MediaTypeObject> | undefined, dereferencedContent: Record<string, OpenAPIV3_1.MediaTypeObject> | undefined, location: 'request' | 'response', required?: boolean): Record<string, ContentSchema<IncrementalDataSchemaArray>>;
private convertWithSchemas;
static convert(rawDocument: OpenAPIV3_1.Document, resolvedDocument: OpenAPIV3_1.Document, path: string, method: HttpMethod, safeParse?: boolean): IncrementalEndpoint;
static convert(rawDocument: OpenAPIV3_1.Document, resolvedDocument: OpenAPIV3_1.Document, path: string, method: HttpMethod, safeParse?: boolean): Endpoint<IncrementalDataSchemaArray>;
}

@@ -8,3 +8,2 @@ import { BaseConverter } from './BaseConverter.js';

import { InvalidSchemaError } from './errors.js';
import { findRefsUsed } from './findRefsUsed.js';
import { generateExampleFromSchema } from './generateExampleFromSchema.js';

@@ -229,14 +228,5 @@ import { dereference } from './utils.js';

}
convertWithSchemas() {
var _a, _b, _c;
const endpointWithoutSchemas = this.convert();
const refsUsed = new Set();
findRefsUsed(endpointWithoutSchemas, (_a = this.rawDocument.components) === null || _a === void 0 ? void 0 : _a.schemas, refsUsed);
const newEntries = Object.entries((_c = (_b = this.rawDocument.components) === null || _b === void 0 ? void 0 : _b.schemas) !== null && _c !== void 0 ? _c : {}).filter(([schemaName]) => refsUsed.has(schemaName));
const schemas = Object.fromEntries(newEntries);
return Object.assign(Object.assign({}, endpointWithoutSchemas), { schemas });
}
static convert(rawDocument, resolvedDocument, path, method, safeParse) {
return new OpenApiToIncrementalEndpointConverter(rawDocument, resolvedDocument, path, method, safeParse).convertWithSchemas();
return new OpenApiToIncrementalEndpointConverter(rawDocument, resolvedDocument, path, method, safeParse).convert();
}
}
import { OpenAPIV3_1 } from 'openapi-types';
import { BaseConverter } from './BaseConverter.js';
import { DataSchemaArray, ParameterSections } from './types/endpoint.js';
import { IncrementalDataSchemaArray } from './types/incrementalEndpoint.js';
import { DataSchemaArray, IncrementalDataSchemaArray, ParameterSections } from './types/endpoint.js';
export declare class ParametersConverter extends BaseConverter {

@@ -6,0 +5,0 @@ readonly method: string;

@@ -1,2 +0,3 @@

export type Endpoint<D = DataSchemaArray> = {
import { OpenAPIV3_1 } from 'openapi-types';
export type Endpoint<D extends DataSchemaArray | IncrementalDataSchemaArray = DataSchemaArray | IncrementalDataSchemaArray> = {
title?: string;

@@ -32,3 +33,3 @@ description?: string;

export type HttpMethod = (typeof httpMethods)[number];
export type RequestSchema<D> = {
export type RequestSchema<D extends DataSchemaArray | IncrementalDataSchemaArray = DataSchemaArray | IncrementalDataSchemaArray> = {
security: SecurityOption[];

@@ -44,6 +45,6 @@ parameters: ParameterSections<D>;

};
export type BodySchema<D> = {
export type BodySchema<D extends DataSchemaArray | IncrementalDataSchemaArray = DataSchemaArray | IncrementalDataSchemaArray> = {
[contentType: string]: ContentSchema<D>;
};
export type ContentSchema<D> = {
export type ContentSchema<D extends DataSchemaArray | IncrementalDataSchemaArray = DataSchemaArray | IncrementalDataSchemaArray> = {
schemaArray: D;

@@ -59,6 +60,6 @@ examples: {

};
export type ParameterSchema<D> = {
export type ParameterSchema<D extends DataSchemaArray | IncrementalDataSchemaArray = DataSchemaArray | IncrementalDataSchemaArray> = {
schema: D;
};
export type ParameterGroup<D> = {
export type ParameterGroup<D extends DataSchemaArray | IncrementalDataSchemaArray = DataSchemaArray | IncrementalDataSchemaArray> = {
[name: string]: ParameterSchema<D>;

@@ -68,3 +69,3 @@ };

type NonPathParameterLocation = Exclude<ParameterLocation, 'path'>;
export type ParameterSections<D> = Record<ParameterLocation, ParameterGroup<D>>;
export type ParameterSections<D extends DataSchemaArray | IncrementalDataSchemaArray = DataSchemaArray | IncrementalDataSchemaArray> = Record<ParameterLocation, ParameterGroup<D>>;
export type SecurityOption = {

@@ -92,9 +93,7 @@ title: string;

export type SecurityParameterSections = Record<NonPathParameterLocation, SecurityParameterGroup>;
export type ResponseSchema<D> = {
export type ResponseSchema<D extends DataSchemaArray | IncrementalDataSchemaArray = DataSchemaArray | IncrementalDataSchemaArray> = {
[code: string]: BodySchema<D>;
};
export type DataSchemaArray = [DataSchema, ...DataSchema[]];
export declare const typeList: readonly ["boolean", "string", "number", "integer", "object", "array", "enum<string>", "enum<number>", "enum<integer>", "file", "null", "any"];
export type SchemaType = (typeof typeList)[number];
export type DataSchema = BooleanSchema | StringSchema | NumberSchema | ObjectSchema | ArraySchema | StringEnumSchema | NumberEnumSchema | FileSchema | NullSchema | AnySchema;
export type BaseSchema<T> = {

@@ -129,14 +128,15 @@ type: SchemaType;

} & BaseSchema<number>;
export type ObjectSchema = {
type BaseObjectSchema<R> = {
type: 'object';
additionalProperties?: boolean | DataSchemaArray;
additionalProperties?: boolean | R;
maxProperties?: number;
minProperties?: number;
properties: {
[key: string]: DataSchemaArray;
[key: string]: R;
};
requiredProperties?: string[];
} & BaseSchema<Record<string, unknown>>;
export type ArraySchema = {
type BaseArraySchema<R> = {
type: 'array';
items: DataSchemaArray;
items: R;
maxItems?: number;

@@ -165,2 +165,10 @@ minItems?: number;

} & BaseSchema<unknown>;
export type ObjectSchema = BaseObjectSchema<DataSchemaArray>;
export type ArraySchema = BaseArraySchema<DataSchemaArray>;
export type DataSchema = BooleanSchema | StringSchema | NumberSchema | ObjectSchema | ArraySchema | StringEnumSchema | NumberEnumSchema | FileSchema | NullSchema | AnySchema;
export type DataSchemaArray = [DataSchema, ...DataSchema[]];
export type IncrementalObjectSchema = BaseObjectSchema<OpenAPIV3_1.SchemaObject>;
export type IncrementalArraySchema = BaseArraySchema<OpenAPIV3_1.SchemaObject>;
export type IncrementalDataSchema = BooleanSchema | StringSchema | NumberSchema | IncrementalObjectSchema | IncrementalArraySchema | StringEnumSchema | NumberEnumSchema | FileSchema | NullSchema | AnySchema;
export type IncrementalDataSchemaArray = [IncrementalDataSchema, ...IncrementalDataSchema[]];
export {};

@@ -12,2 +12,3 @@ // Request types

];
// Schema types
export const typeList = [

@@ -14,0 +15,0 @@ 'boolean',

@@ -6,3 +6,3 @@ import { OpenAPIV3_1 } from 'openapi-types';

type ComponentsSection = keyof OpenAPIV3_1.ComponentsObject;
export declare function dereference<S extends ComponentsSection>(section: S, $ref: string, components: Record<string, NonNullable<OpenAPIV3_1.ComponentsObject[S]>[string]> | undefined): NonNullable<OpenAPIV3_1.ComponentsObject[S]>[string] | undefined;
export declare function dereference<S extends ComponentsSection>(section: S, $ref: string, components: Record<string, NonNullable<OpenAPIV3_1.ComponentsObject[S]>[string]> | undefined, maxDepth?: number): NonNullable<OpenAPIV3_1.ComponentsObject[S]>[string] | undefined;
export declare const addKeyIfDefined: <D, K extends keyof D>(key: K, value: D[K] | undefined, destination: D) => void;

@@ -9,0 +9,0 @@ export declare const copyKeyIfDefined: <D, K extends keyof D>(key: K, source: Pick<D, K>, destination: D) => void;

@@ -7,3 +7,5 @@ export const stringFileFormats = ['binary', 'base64'];

];
export function dereference(section, $ref, components) {
// the number of times a $ref can point to another $ref before we give up
const MAX_DEREFERENCE_DEPTH = 5;
export function dereference(section, $ref, components, maxDepth = MAX_DEREFERENCE_DEPTH) {
const sectionPrefix = `#/components/${section}/`;

@@ -14,5 +16,9 @@ if (!$ref.startsWith(sectionPrefix))

const value = components === null || components === void 0 ? void 0 : components[key];
// if a $ref points to another $ref, just fall back
if (value && '$ref' in value)
// if a $ref points to another $ref, keep resolving until we hit our max depth
if (value && '$ref' in value) {
if (maxDepth > 0 && typeof value.$ref === 'string') {
return dereference(section, value.$ref, components, maxDepth - 1);
}
return undefined;
}
return value;

@@ -19,0 +25,0 @@ }

{
"name": "@mintlify/validation",
"version": "0.1.178",
"version": "0.1.179",
"description": "Validates mint.json files",

@@ -71,3 +71,3 @@ "author": "Mintlify, Inc.",

},
"gitHead": "f1089c8f5867d118199b939f8eede5fa7b08aaf7"
"gitHead": "c78a2d75f350b2a7dbd4d479d9ef60d5a09e2dc2"
}

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