@mintlify/validation
Advanced tools
Comparing version 0.1.89 to 0.1.90
@@ -7,4 +7,2 @@ import { OpenAPIV3_1 } from 'openapi-types'; | ||
}; | ||
export declare const basicDescription = "Basic authentication header of the form `Basic <encoded-value>`, where `<encoded-value>` is the base64-encoded string `username:password`."; | ||
export declare const bearerDescription = "Bearer authentication header of the form `Bearer <token>`, where `<token>` is your auth token."; | ||
export declare const convertSecurity: ({ securityRequirements, securitySchemes, }: ConvertSecurityParams) => SecurityOption[]; | ||
@@ -11,0 +9,0 @@ type AddSecurityParametersParams = { |
import { InvalidSchemaError } from './convertOpenApi.js'; | ||
export const basicDescription = 'Basic authentication header of the form `Basic <encoded-value>`, where `<encoded-value>` is the base64-encoded string `username:password`.'; | ||
export const bearerDescription = 'Bearer authentication header of the form `Bearer <token>`, where `<token>` is your auth token.'; | ||
import { copyKeyIfDefined } from './convertSchema.js'; | ||
export const convertSecurity = ({ securityRequirements, securitySchemes, }) => { | ||
@@ -39,5 +38,4 @@ if (securityRequirements === undefined || securityRequirements.length === 0) { | ||
export const addSecurityParameters = ({ securityName, securityScheme, parameterSections, }) => { | ||
var _a; | ||
switch (securityScheme.type) { | ||
case 'apiKey': | ||
case 'apiKey': { | ||
if (!['header', 'query', 'cookie'].includes(securityScheme.in)) { | ||
@@ -47,22 +45,16 @@ throw new InvalidSchemaError(['#', 'components', 'securitySchemes', securityName], `invalid security scheme location provided: '${securityScheme.in}'`); | ||
const paramGroup = securityScheme.in; | ||
parameterSections[paramGroup][securityScheme.name] = { | ||
type: 'apiKey', | ||
schema: [ | ||
{ | ||
type: 'string', | ||
required: true, | ||
description: securityScheme.description, | ||
deprecated: false, | ||
}, | ||
], | ||
}; | ||
const schema = { type: 'apiKey' }; | ||
copyKeyIfDefined('description', securityScheme, schema); | ||
parameterSections[paramGroup][securityScheme.name] = schema; | ||
return; | ||
case 'http': | ||
} | ||
case 'http': { | ||
const scheme = securityScheme.scheme; | ||
if (scheme === 'basic' || scheme === 'bearer') { | ||
parameterSections.header['Authorization'] = { | ||
const schema = { | ||
type: 'http', | ||
schema: scheme, | ||
description: (_a = securityScheme.description) !== null && _a !== void 0 ? _a : (scheme === 'basic' ? basicDescription : bearerDescription), | ||
scheme, | ||
}; | ||
copyKeyIfDefined('description', securityScheme, schema); | ||
parameterSections.header['Authorization'] = schema; | ||
} | ||
@@ -73,6 +65,13 @@ else { | ||
return; | ||
case 'oauth2': | ||
case 'openIdConnect': | ||
} | ||
case 'oauth2': { | ||
const schema = { type: 'oauth2' }; | ||
copyKeyIfDefined('description', securityScheme, schema); | ||
parameterSections.header['Authorization'] = schema; | ||
return; | ||
} | ||
case 'openIdConnect': { | ||
return; | ||
} | ||
} | ||
}; |
@@ -53,10 +53,14 @@ export type Endpoint = { | ||
type: 'apiKey'; | ||
schema: DataSchemaArray; | ||
description?: string; | ||
}; | ||
type HttpParameterSchema = { | ||
type: 'http'; | ||
schema: 'bearer' | 'basic'; | ||
scheme: 'bearer' | 'basic'; | ||
description?: string; | ||
}; | ||
export type SecurityParameterSchema = ApiKeyParameterSchema | HttpParameterSchema; | ||
type OAuth2ParameterSchema = { | ||
type: 'oauth2'; | ||
description?: string; | ||
}; | ||
export type SecurityParameterSchema = ApiKeyParameterSchema | HttpParameterSchema | OAuth2ParameterSchema; | ||
export type SecurityParameterGroup = { | ||
@@ -63,0 +67,0 @@ [name: string]: SecurityParameterSchema; |
{ | ||
"name": "@mintlify/validation", | ||
"version": "0.1.89", | ||
"version": "0.1.90", | ||
"description": "Validates mint.json files", | ||
@@ -73,3 +73,3 @@ "author": "Mintlify, Inc.", | ||
}, | ||
"gitHead": "12c530b6325dc609b79ef6bce6a61a8f7a99dedd" | ||
"gitHead": "88d77dd15c60e95b6e9fc9b6cefa13dc04d328d9" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3468
191571