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

express-openapi-validator

Package Overview
Dependencies
Maintainers
1
Versions
281
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-openapi-validator - npm Package Compare versions

Comparing version 1.3.0-rc.4 to 1.3.0

2

dist/framework/base.path.d.ts

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

import { OpenAPIV3 } from 'openapi-types';
import { OpenAPIV3 } from './types';
interface ServerUrlVariables {

@@ -3,0 +3,0 @@ [key: string]: ServerUrlValues;

import { Request } from 'express';
import { IJsonSchema, OpenAPIV3 } from 'openapi-types';
import { Logger } from 'ts-log';

@@ -12,2 +11,316 @@ import BasePath from './base.path';

declare type SecurityScope = string;
export declare namespace OpenAPIV3 {
interface Document {
openapi: string;
info: InfoObject;
servers?: ServerObject[];
paths: PathsObject;
components?: ComponentsObject;
security?: SecurityRequirementObject[];
tags?: TagObject[];
externalDocs?: ExternalDocumentationObject;
}
interface InfoObject {
title: string;
description?: string;
termsOfService?: string;
contact?: ContactObject;
license?: LicenseObject;
version: string;
}
interface ContactObject {
name?: string;
url?: string;
email?: string;
}
interface LicenseObject {
name: string;
url?: string;
}
interface ServerObject {
url: string;
description?: string;
variables?: {
[variable: string]: ServerVariableObject;
};
}
interface ServerVariableObject {
enum?: string[];
default: string;
description?: string;
}
interface PathsObject {
[pattern: string]: PathItemObject;
}
interface PathItemObject {
$ref?: string;
summary?: string;
description?: string;
get?: OperationObject;
put?: OperationObject;
post?: OperationObject;
delete?: OperationObject;
options?: OperationObject;
head?: OperationObject;
patch?: OperationObject;
trace?: OperationObject;
servers?: ServerObject[];
parameters?: Array<ReferenceObject | ParameterObject>;
}
interface OperationObject {
tags?: string[];
summary?: string;
description?: string;
externalDocs?: ExternalDocumentationObject;
operationId?: string;
parameters?: Array<ReferenceObject | ParameterObject>;
requestBody?: ReferenceObject | RequestBodyObject;
responses?: ResponsesObject;
callbacks?: {
[callback: string]: ReferenceObject | CallbackObject;
};
deprecated?: boolean;
security?: SecurityRequirementObject[];
servers?: ServerObject[];
}
interface ExternalDocumentationObject {
description?: string;
url: string;
}
interface ParameterObject extends ParameterBaseObject {
name: string;
in: string;
}
interface HeaderObject extends ParameterBaseObject {
}
interface ParameterBaseObject {
description?: string;
required?: boolean;
deprecated?: boolean;
allowEmptyValue?: boolean;
style?: string;
explode?: boolean;
allowReserved?: boolean;
schema?: ReferenceObject | SchemaObject;
example?: any;
examples?: {
[media: string]: ReferenceObject | ExampleObject;
};
content?: {
[media: string]: MediaTypeObject;
};
}
type NonArraySchemaObjectType = 'null' | 'boolean' | 'object' | 'number' | 'string' | 'integer';
type ArraySchemaObjectType = 'array';
type SchemaObject = ArraySchemaObject | NonArraySchemaObject;
interface ArraySchemaObject extends BaseSchemaObject {
type: ArraySchemaObjectType;
items: ReferenceObject | SchemaObject;
}
interface NonArraySchemaObject extends BaseSchemaObject {
type: NonArraySchemaObjectType;
}
interface BaseSchemaObject {
title?: string;
description?: string;
format?: string;
default?: any;
multipleOf?: number;
maximum?: number;
exclusiveMaximum?: boolean;
minimum?: number;
exclusiveMinimum?: boolean;
maxLength?: number;
minLength?: number;
pattern?: string;
additionalProperties?: boolean | ReferenceObject | SchemaObject;
maxItems?: number;
minItems?: number;
uniqueItems?: boolean;
maxProperties?: number;
minProperties?: number;
required?: string[];
enum?: any[];
properties?: {
[name: string]: ReferenceObject | SchemaObject;
};
allOf?: Array<ReferenceObject | SchemaObject>;
oneOf?: Array<ReferenceObject | SchemaObject>;
anyOf?: Array<ReferenceObject | SchemaObject>;
not?: ReferenceObject | SchemaObject;
nullable?: boolean;
discriminator?: DiscriminatorObject;
readOnly?: boolean;
writeOnly?: boolean;
xml?: XMLObject;
externalDocs?: ExternalDocumentationObject;
example?: any;
deprecated?: boolean;
}
interface DiscriminatorObject {
propertyName: string;
mapping?: {
[value: string]: string;
};
}
interface XMLObject {
name?: string;
namespace?: string;
prefix?: string;
attribute?: boolean;
wrapped?: boolean;
}
interface ReferenceObject {
$ref: string;
}
interface ExampleObject {
summary?: string;
description?: string;
value?: any;
externalValue?: string;
}
interface MediaTypeObject {
schema?: ReferenceObject | SchemaObject;
example?: any;
examples?: {
[media: string]: ReferenceObject | ExampleObject;
};
encoding?: {
[media: string]: EncodingObject;
};
}
interface EncodingObject {
contentType?: string;
headers?: {
[header: string]: ReferenceObject | HeaderObject;
};
style?: string;
explode?: boolean;
allowReserved?: boolean;
}
interface RequestBodyObject {
description?: string;
content: {
[media: string]: MediaTypeObject;
};
required?: boolean;
}
interface ResponsesObject {
[code: string]: ReferenceObject | ResponseObject;
}
interface ResponseObject {
description: string;
headers?: {
[header: string]: ReferenceObject | HeaderObject;
};
content?: {
[media: string]: MediaTypeObject;
};
links?: {
[link: string]: ReferenceObject | LinkObject;
};
}
interface LinkObject {
operationRef?: string;
operationId?: string;
parameters?: {
[parameter: string]: any;
};
requestBody?: any;
description?: string;
server?: ServerObject;
}
interface CallbackObject {
[url: string]: PathItemObject;
}
interface SecurityRequirementObject {
[name: string]: string[];
}
interface ComponentsObject {
schemas?: {
[key: string]: ReferenceObject | SchemaObject;
};
responses?: {
[key: string]: ReferenceObject | ResponseObject;
};
parameters?: {
[key: string]: ReferenceObject | ParameterObject;
};
examples?: {
[key: string]: ReferenceObject | ExampleObject;
};
requestBodies?: {
[key: string]: ReferenceObject | RequestBodyObject;
};
headers?: {
[key: string]: ReferenceObject | HeaderObject;
};
securitySchemes?: {
[key: string]: ReferenceObject | SecuritySchemeObject;
};
links?: {
[key: string]: ReferenceObject | LinkObject;
};
callbacks?: {
[key: string]: ReferenceObject | CallbackObject;
};
}
type SecuritySchemeObject = HttpSecurityScheme | ApiKeySecurityScheme | OAuth2SecurityScheme | OpenIdSecurityScheme;
interface HttpSecurityScheme {
type: 'http';
description?: string;
scheme: string;
bearerFormat?: string;
}
interface ApiKeySecurityScheme {
type: 'apiKey';
description?: string;
name: string;
in: string;
}
interface OAuth2SecurityScheme {
type: 'oauth2';
flows: {
implicit?: {
authorizationUrl: string;
refreshUrl?: string;
scopes: {
[scope: string]: string;
};
};
password?: {
tokenUrl: string;
refreshUrl?: string;
scopes: {
[scope: string]: string;
};
};
clientCredentials?: {
tokenUrl: string;
refreshUrl?: string;
scopes: {
[scope: string]: string;
};
};
authorizationCode?: {
authorizationUrl: string;
tokenUrl: string;
refreshUrl?: string;
scopes: {
[scope: string]: string;
};
};
};
}
interface OpenIdSecurityScheme {
type: 'openIdConnect';
description?: string;
openIdConnectUrl: string;
}
interface TagObject {
name: string;
description?: string;
externalDocs?: ExternalDocumentationObject;
}
}
export interface OpenAPIFrameworkPathObject {

@@ -66,2 +379,43 @@ path?: string;

}
export interface IJsonSchema {
id?: string;
$schema?: string;
title?: string;
description?: string;
multipleOf?: number;
maximum?: number;
exclusiveMaximum?: boolean;
minimum?: number;
exclusiveMinimum?: boolean;
maxLength?: number;
minLength?: number;
pattern?: string;
additionalItems?: boolean | IJsonSchema;
items?: IJsonSchema | IJsonSchema[];
maxItems?: number;
minItems?: number;
uniqueItems?: boolean;
maxProperties?: number;
minProperties?: number;
required?: string[];
additionalProperties?: boolean | IJsonSchema;
definitions?: {
[name: string]: IJsonSchema;
};
properties?: {
[name: string]: IJsonSchema;
};
patternProperties?: {
[name: string]: IJsonSchema;
};
dependencies?: {
[name: string]: IJsonSchema | string[];
};
enum?: any[];
type?: string | string[];
allOf?: IJsonSchema[];
anyOf?: IJsonSchema[];
oneOf?: IJsonSchema[];
not?: IJsonSchema;
}
export declare class ConsoleDebugAdapterLogger implements Logger {

@@ -68,0 +422,0 @@ /**

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

import { OpenAPIV3 } from 'openapi-types';
import { OpenAPIV3 } from './types';
import BasePath from './base.path';

@@ -3,0 +3,0 @@ export declare function assertRegExpAndSecurity(framework: any, tuple: any): void;

import { Application } from 'express';
import { OpenAPIV3 } from 'openapi-types';
import { OpenAPIV3 } from './framework/types';
export interface OpenApiValidatorOpts {

@@ -4,0 +4,0 @@ apiSpecPath?: string;

{
"name": "express-openapi-validator",
"version": "1.3.0-rc.4",
"version": "1.3.0",
"description": "Automatically validate API requests using an OpenAPI 3 and Express.",

@@ -11,4 +11,3 @@ "main": "dist/index.js",

"coveralls": "cat coverage/lcov.info | coveralls -v",
"codacy": "cat coverage/lcov.info | codacy-coverage",
"publish": "npm run compile && npm test && npm publish"
"codacy": "cat coverage/lcov.info | codacy-coverage"
},

@@ -35,3 +34,2 @@ "repository": {

"ono": "^5.0.1",
"openapi-types": "^1.3.5",
"path-to-regexp": "^3.0.0",

@@ -38,0 +36,0 @@ "ts-log": "^2.1.4"

@@ -11,3 +11,3 @@ # express-openapi-validator

[express-openapi-validator](https://github.com/cdimascio/express-openapi-validator) is unopinionated and does not impose any coding convention or project structure. Simply, install the validator onto your express app, point it to your OpenAPI 3 specification, then define and implement routes the way you prefer. See an [example](#example-express-api-server).
[express-openapi-validator](https://github.com/cdimascio/express-openapi-validator) is unopinionated and does not impose any coding convention or project structure. Simply, install the validator onto your express app, point it to your OpenAPI 3 specification, then define and implement routes the way you prefer. See an [example](#example-express-api-server).

@@ -30,3 +30,2 @@ ## Install

Then, register an error handler to customize errors

@@ -44,4 +43,5 @@

#### Alternatively...
The `apiSpec` option may be specified as the spec object itself, rather than a path e.g.
The `apiSpec` option may be specified as the spec object itself, rather than a path e.g.
```javascript

@@ -62,3 +62,2 @@ const apiSpec = {

## Example Express API Server

@@ -130,2 +129,3 @@

res.status(err.status).json({
message: err.message,
errors: err.errors,

@@ -191,3 +191,3 @@ });

"name": "test"
}' |jq
}' |jq
{

@@ -194,0 +194,0 @@ "errors": [

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