Initial commit

This commit is contained in:
2025-03-07 19:22:02 +01:00
commit 4a98255d83
55743 changed files with 5280367 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
# openapi-types Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## 1.4.0 - 2021-01-05
### Added
- Added an index signature to `OperationObject` to allow access to extensions.
### Fixed
- Added `undefined` to the index signature for `PathsObject` to prevent unsafe null access when `strictNullChecks` is enabled.
## 1.3.5 - 2019-05-13
### Fixed
- Amended missing usage of PathsObject in OpenAPIV3.Document interface.
## 1.3.4 - 2019-01-31
### Fixed
- OpenAPIV3: relax security requirement object types (#327)
## 1.3.3 - 2019-01-22
### Fixed
- Allowing to set a property of BaseSchemaObject as a reference to another SchemaObject (#312)
## 1.3.2 - 2018-10-17
### Added
- Added `Operation` to `OpenAPI` namespace.
## 1.3.1 - 2018-10-03
### Fixed
- Updating .npmignore to publish `dist`
## 1.3.0 - 2018-10-03
### Added
- `OpenAPI.Parameter` - Represents a parameter across all OpenAPI versions that have the notion of a parameter.
## 1.2.0 - 2018-09-29
### Added
- `OpenAPI.Parameters` - Represents parameters across all OpenAPI versions that have the notion of parameters.
- exporting `OpenAPIV2.Parameters` and `OpenAPIV2.Parameter`.
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2018 Kogo Softare LLC
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+50
View File
@@ -0,0 +1,50 @@
# openapi-types [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]
> Types for OpenAPI documents.
## Usage
```typescript
import { OpenAPIV2, OpenAPIV3 } from "openapi-types";
function processV2(doc: OpenAPIV2.Document) {}
function processV3(doc: OpenAPIV3.Document) {}
```
## LICENSE
``````
The MIT License (MIT)
Copyright (c) 2018 Kogo Software LLC
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
``````
[downloads-image]: http://img.shields.io/npm/dm/openapi-types.svg
[npm-url]: https://npmjs.org/package/openapi-types
[npm-image]: http://img.shields.io/npm/v/openapi-types.svg
[travis-url]: https://travis-ci.org/kogosoftwarellc/open-api
[travis-image]: https://api.travis-ci.org/kogosoftwarellc/open-api.svg?branch=master
[coveralls-url]: https://coveralls.io/r/kogosoftwarellc/open-api
[coveralls-image]: https://coveralls.io/repos/github/kogosoftwarellc/open-api/badge.svg?branch=master
[gitter-url]: https://gitter.im/kogosoftwarellc/open-api
[gitter-image]: https://badges.gitter.im/kogosoftwarellc/open-api.png
+586
View File
@@ -0,0 +1,586 @@
export declare namespace OpenAPI {
type Document<T extends {} = {}> = OpenAPIV2.Document<T> | OpenAPIV3.Document<T>;
type Operation<T extends {} = {}> = OpenAPIV2.OperationObject<T> | OpenAPIV3.OperationObject<T>;
type Parameter = OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject | OpenAPIV2.ReferenceObject | OpenAPIV2.Parameter;
type Parameters = (OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject)[] | (OpenAPIV2.ReferenceObject | OpenAPIV2.Parameter)[];
interface Request {
body?: any;
headers?: object;
params?: object;
query?: object;
}
}
export declare namespace OpenAPIV3 {
interface Document<T extends {} = {}> {
openapi: string;
info: InfoObject;
servers?: ServerObject[];
paths: PathsObject<T>;
components?: ComponentsObject;
security?: SecurityRequirementObject[];
tags?: TagObject[];
externalDocs?: ExternalDocumentationObject;
'x-express-openapi-additional-middleware'?: (((request: any, response: any, next: any) => Promise<void>) | ((request: any, response: any, next: any) => void))[];
'x-express-openapi-validation-strict'?: boolean;
}
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<T extends {} = {}> {
[pattern: string]: PathItemObject<T> | undefined;
}
interface PathItemObject<T extends {} = {}> {
$ref?: string;
summary?: string;
description?: string;
get?: OperationObject<T>;
put?: OperationObject<T>;
post?: OperationObject<T>;
delete?: OperationObject<T>;
options?: OperationObject<T>;
head?: OperationObject<T>;
patch?: OperationObject<T>;
trace?: OperationObject<T>;
servers?: ServerObject[];
parameters?: (ReferenceObject | ParameterObject)[];
}
type OperationObject<T extends {} = {}> = {
tags?: string[];
summary?: string;
description?: string;
externalDocs?: ExternalDocumentationObject;
operationId?: string;
parameters?: (ReferenceObject | ParameterObject)[];
requestBody?: ReferenceObject | RequestBodyObject;
responses?: ResponsesObject;
callbacks?: {
[callback: string]: ReferenceObject | CallbackObject;
};
deprecated?: boolean;
security?: SecurityRequirementObject[];
servers?: ServerObject[];
} & T;
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 = '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?: (ReferenceObject | SchemaObject)[];
oneOf?: (ReferenceObject | SchemaObject)[];
anyOf?: (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 declare namespace OpenAPIV2 {
interface Document<T extends {} = {}> {
basePath?: string;
consumes?: MimeTypes;
definitions?: DefinitionsObject;
externalDocs?: ExternalDocumentationObject;
host?: string;
info: InfoObject;
parameters?: ParametersDefinitionsObject;
paths: PathsObject<T>;
produces?: MimeTypes;
responses?: ResponsesDefinitionsObject;
schemes?: string[];
security?: SecurityRequirementObject[];
securityDefinitions?: SecurityDefinitionsObject;
swagger: string;
tags?: TagObject[];
'x-express-openapi-additional-middleware'?: (((request: any, response: any, next: any) => Promise<void>) | ((request: any, response: any, next: any) => void))[];
'x-express-openapi-validation-strict'?: boolean;
}
interface TagObject {
name: string;
description?: string;
externalDocs?: ExternalDocumentationObject;
}
interface SecuritySchemeObjectBase {
type: 'basic' | 'apiKey' | 'oauth2';
description?: string;
}
interface SecuritySchemeBasic extends SecuritySchemeObjectBase {
type: 'basic';
}
interface SecuritySchemeApiKey extends SecuritySchemeObjectBase {
type: 'apiKey';
name: string;
in: string;
}
type SecuritySchemeOauth2 = SecuritySchemeOauth2Implicit | SecuritySchemeOauth2AccessCode | SecuritySchemeOauth2Password | SecuritySchemeOauth2Application;
interface ScopesObject {
[index: string]: any;
}
interface SecuritySchemeOauth2Base extends SecuritySchemeObjectBase {
type: 'oauth2';
flow: 'implicit' | 'password' | 'application' | 'accessCode';
scopes: ScopesObject;
}
interface SecuritySchemeOauth2Implicit extends SecuritySchemeOauth2Base {
flow: 'implicit';
authorizationUrl: string;
}
interface SecuritySchemeOauth2AccessCode extends SecuritySchemeOauth2Base {
flow: 'accessCode';
authorizationUrl: string;
tokenUrl: string;
}
interface SecuritySchemeOauth2Password extends SecuritySchemeOauth2Base {
flow: 'password';
tokenUrl: string;
}
interface SecuritySchemeOauth2Application extends SecuritySchemeOauth2Base {
flow: 'application';
tokenUrl: string;
}
type SecuritySchemeObject = SecuritySchemeBasic | SecuritySchemeApiKey | SecuritySchemeOauth2;
interface SecurityDefinitionsObject {
[index: string]: SecuritySchemeObject;
}
interface SecurityRequirementObject {
[index: string]: string[];
}
interface ReferenceObject {
$ref: string;
}
type Response = ResponseObject | ReferenceObject;
interface ResponsesDefinitionsObject {
[index: string]: ResponseObject;
}
type Schema = SchemaObject | ReferenceObject;
interface ResponseObject {
description: string;
schema?: Schema;
headers?: HeadersObject;
examples?: ExampleObject;
}
interface HeadersObject {
[index: string]: HeaderObject;
}
interface HeaderObject extends ItemsObject {
}
interface ExampleObject {
[index: string]: any;
}
interface ResponseObject {
description: string;
schema?: Schema;
headers?: HeadersObject;
examples?: ExampleObject;
}
type OperationObject<T extends {} = {}> = {
tags?: string[];
summary?: string;
description?: string;
externalDocs?: ExternalDocumentationObject;
operationId?: string;
consumes?: MimeTypes;
produces?: MimeTypes;
parameters?: Parameters;
responses: ResponsesObject;
schemes?: string[];
deprecated?: boolean;
security?: SecurityRequirementObject[];
} & T;
interface ResponsesObject {
[index: string]: Response | any;
default?: Response;
}
type Parameters = (ReferenceObject | Parameter)[];
type Parameter = InBodyParameterObject | GeneralParameterObject;
interface InBodyParameterObject extends ParameterObject {
schema: Schema;
}
interface GeneralParameterObject extends ParameterObject, ItemsObject {
allowEmptyValue?: boolean;
}
interface PathItemObject<T extends {} = {}> {
$ref?: string;
get?: OperationObject<T>;
put?: OperationObject<T>;
post?: OperationObject<T>;
del?: OperationObject<T>;
delete?: OperationObject<T>;
options?: OperationObject<T>;
head?: OperationObject<T>;
patch?: OperationObject<T>;
parameters?: Parameters;
}
interface PathsObject<T extends {} = {}> {
[index: string]: PathItemObject<T> | any;
}
interface ParametersDefinitionsObject {
[index: string]: ParameterObject;
}
interface ParameterObject {
name: string;
in: string;
description?: string;
required?: boolean;
[index: string]: any;
}
type MimeTypes = string[];
interface DefinitionsObject {
[index: string]: SchemaObject;
}
interface SchemaObject extends IJsonSchema {
[index: string]: any;
discriminator?: string;
readOnly?: boolean;
xml?: XMLObject;
externalDocs?: ExternalDocumentationObject;
example?: any;
default?: any;
items?: ItemsObject;
properties?: {
[name: string]: SchemaObject;
};
}
interface ExternalDocumentationObject {
[index: string]: any;
description?: string;
url: string;
}
interface ItemsObject {
type: string;
format?: string;
items?: ItemsObject;
collectionFormat?: string;
default?: any;
maximum?: number;
exclusiveMaximum?: boolean;
minimum?: number;
exclusiveMinimum?: boolean;
maxLength?: number;
minLength?: number;
pattern?: string;
maxItems?: number;
minItems?: number;
uniqueItems?: boolean;
enum?: any[];
multipleOf?: number;
$ref?: string;
}
interface XMLObject {
[index: string]: any;
name?: string;
namespace?: string;
prefix?: string;
attribute?: boolean;
wrapped?: boolean;
}
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;
}
}
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;
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
exports.__esModule = true;
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":""}
+25
View File
@@ -0,0 +1,25 @@
{
"name": "openapi-types",
"version": "7.2.3",
"description": "Types for OpenAPI documents.",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"prepare": "../../bin/tsc",
"test-watch": "../../bin/tsc"
},
"keywords": [
"openapi",
"swagger",
"types",
"typescript"
],
"author": "Joseph Spencer",
"bugs": {
"url": "https://github.com/kogosoftwarellc/open-api/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3Aopenapi-types"
},
"repository": "https://github.com/kogosoftwarellc/open-api/tree/master/packages/openapi-types",
"homepage": "https://github.com/kogosoftwarellc/open-api/tree/master/packages/openapi-types#readme",
"license": "MIT",
"gitHead": "25d0114680050efe3b4f9b7d0cca9f9e88057daa"
}