mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-02-04 16:02:50 +00:00
yet other fixes for swagger types (#36164)
* Update index.d.ts * Update index.d.ts * Update index.d.ts * Update index.d.ts * Update index.d.ts * tweak stuff * chore: simplify and put any
This commit is contained in:
parent
43b735cdf0
commit
a59cd46314
109
types/swagger-schema-official/index.d.ts
vendored
109
types/swagger-schema-official/index.d.ts
vendored
@ -2,6 +2,7 @@
|
||||
// Project: https://swagger.io/specification/
|
||||
// Definitions by: Mohsen Azimi <https://github.com/mohsen1>, Ben Southgate <https://github.com/bsouthga>, Nicholas Merritt <https://github.com/nimerritt>, Mauri Edo <https://github.com/mauriedo>, Vincenzo Chianese <https://github.com/XVincentX>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
export interface Info {
|
||||
title: string;
|
||||
@ -35,56 +36,76 @@ export interface Tag {
|
||||
}
|
||||
|
||||
export interface Header extends BaseSchema {
|
||||
type: string;
|
||||
type: ParameterType;
|
||||
}
|
||||
|
||||
// ----------------------------- Parameter -----------------------------------
|
||||
|
||||
export type ParameterType = 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'file';
|
||||
export type ParameterType = 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
|
||||
|
||||
export interface BaseParameter {
|
||||
export type BaseParameter = {
|
||||
name: string;
|
||||
in: 'body' | 'query' | 'path' | 'header' | 'formData' | 'body';
|
||||
required?: boolean;
|
||||
description?: string;
|
||||
}
|
||||
};
|
||||
|
||||
export interface BodyParameter extends BaseParameter {
|
||||
export type BodyParameter = BaseParameter & {
|
||||
in: 'body';
|
||||
schema?: Schema;
|
||||
}
|
||||
};
|
||||
|
||||
export interface QueryParameter extends BaseParameter, BaseSchema {
|
||||
in: 'query';
|
||||
type: ParameterType;
|
||||
allowEmptyValue?: boolean;
|
||||
collectionFormat?: 'csv' | 'ssv' | 'tsv' | 'pipes' | 'multi';
|
||||
}
|
||||
export type GenericFormat = {
|
||||
type?: ParameterType;
|
||||
format?: string;
|
||||
};
|
||||
|
||||
export interface PathParameter extends BaseParameter, BaseSchema {
|
||||
in: 'path';
|
||||
type: ParameterType;
|
||||
required: boolean;
|
||||
}
|
||||
export type IntegerFormat = {
|
||||
type: 'integer';
|
||||
format?: 'int32' | 'int64';
|
||||
};
|
||||
|
||||
export interface HeaderParameter extends BaseParameter, BaseSchema {
|
||||
in: 'header';
|
||||
type: ParameterType;
|
||||
}
|
||||
export type NumberFormat = {
|
||||
type: 'number';
|
||||
format?: 'float' | 'double';
|
||||
};
|
||||
|
||||
export interface FormDataParameter extends BaseParameter, BaseSchema {
|
||||
in: 'formData';
|
||||
type: ParameterType;
|
||||
collectionFormat?: 'csv' | 'ssv' | 'tsv' | 'pipes' | 'multi';
|
||||
allowEmptyValue?: boolean;
|
||||
}
|
||||
export type StringFormat = {
|
||||
type: 'string';
|
||||
format?: '' | 'byte' | 'binary' | 'date' | 'date-time' | 'password';
|
||||
};
|
||||
|
||||
export type Parameter =
|
||||
BodyParameter |
|
||||
FormDataParameter |
|
||||
QueryParameter |
|
||||
PathParameter |
|
||||
HeaderParameter;
|
||||
export type SchemaFormatConstraints = GenericFormat | IntegerFormat | NumberFormat | StringFormat;
|
||||
export type BaseFormatContrainedParameter = BaseParameter & SchemaFormatConstraints;
|
||||
export type ParameterCollectionFormat = 'csv' | 'ssv' | 'tsv' | 'pipes' | 'multi';
|
||||
|
||||
export type QueryParameter = BaseFormatContrainedParameter &
|
||||
BaseSchema & {
|
||||
in: 'query';
|
||||
allowEmptyValue?: boolean;
|
||||
collectionFormat?: ParameterCollectionFormat;
|
||||
};
|
||||
|
||||
export type PathParameter = BaseFormatContrainedParameter &
|
||||
BaseSchema & {
|
||||
in: 'path';
|
||||
required: true;
|
||||
};
|
||||
|
||||
export type HeaderParameter = BaseFormatContrainedParameter &
|
||||
BaseSchema & {
|
||||
in: 'header';
|
||||
};
|
||||
|
||||
export type FormDataParameter = BaseFormatContrainedParameter &
|
||||
BaseSchema & {
|
||||
in: 'formData';
|
||||
type: ParameterType | 'file';
|
||||
allowEmptyValue?: boolean;
|
||||
collectionFormat?: ParameterCollectionFormat;
|
||||
};
|
||||
|
||||
export type Parameter = BodyParameter | FormDataParameter | QueryParameter | PathParameter | HeaderParameter;
|
||||
|
||||
// ------------------------------- Path --------------------------------------
|
||||
export interface Path {
|
||||
@ -129,11 +150,12 @@ export interface Response {
|
||||
}
|
||||
|
||||
// ------------------------------ Schema -------------------------------------
|
||||
export interface BaseSchema {
|
||||
export type BaseSchema = {
|
||||
type?: ParameterType;
|
||||
format?: string;
|
||||
title?: string;
|
||||
description?: string;
|
||||
default?: string | boolean | number | {};
|
||||
default?: any;
|
||||
multipleOf?: number;
|
||||
maximum?: number;
|
||||
exclusiveMaximum?: boolean;
|
||||
@ -147,10 +169,9 @@ export interface BaseSchema {
|
||||
uniqueItems?: boolean;
|
||||
maxProperties?: number;
|
||||
minProperties?: number;
|
||||
enum?: Array<string | boolean | number | {}>;
|
||||
type?: string;
|
||||
enum?: any[];
|
||||
items?: Schema | Schema[];
|
||||
}
|
||||
};
|
||||
|
||||
export interface Schema extends BaseSchema {
|
||||
$ref?: string;
|
||||
@ -225,12 +246,12 @@ export interface OAuthScope {
|
||||
}
|
||||
|
||||
export type Security =
|
||||
BasicAuthenticationSecurity |
|
||||
OAuth2AccessCodeSecurity |
|
||||
OAuth2ApplicationSecurity |
|
||||
OAuth2ImplicitSecurity |
|
||||
OAuth2PasswordSecurity |
|
||||
ApiKeySecurity;
|
||||
| BasicAuthenticationSecurity
|
||||
| OAuth2AccessCodeSecurity
|
||||
| OAuth2ApplicationSecurity
|
||||
| OAuth2ImplicitSecurity
|
||||
| OAuth2PasswordSecurity
|
||||
| ApiKeySecurity;
|
||||
|
||||
// --------------------------------- Spec ------------------------------------
|
||||
export interface Spec {
|
||||
|
||||
@ -1329,7 +1329,7 @@ const uber: swagger.Spec = {
|
||||
|
||||
const basic_auth: swagger.Spec = {
|
||||
"swagger": "2.0",
|
||||
"info": { "version": "1.0.0", "title": "Minimal example with basic auth"},
|
||||
"info": { "version": "1.0.0", "title": "Minimal example with basic auth" },
|
||||
"schemes": [
|
||||
"https"
|
||||
],
|
||||
@ -1337,74 +1337,74 @@ const basic_auth: swagger.Spec = {
|
||||
"securityDefinitions": {
|
||||
basicAuth: { type: 'basic' },
|
||||
},
|
||||
"security": [{basicAuth: []}]
|
||||
"security": [{ basicAuth: [] }]
|
||||
};
|
||||
|
||||
const reference_support: swagger.Spec = {
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"version": "1.0.0",
|
||||
"title": "Swagger Petstore"
|
||||
},
|
||||
"definitions": {
|
||||
"stringSchema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"parameters": {
|
||||
"operationParameter": {
|
||||
"in": "query",
|
||||
"name": "operationParameter",
|
||||
"type": "integer",
|
||||
"description": "A sample operation parameter"
|
||||
},
|
||||
"pathParameter": {
|
||||
"in": "query",
|
||||
"name": "pathParameter",
|
||||
"type": "string",
|
||||
"description": "A sample path parameter"
|
||||
}
|
||||
},
|
||||
"paths": {
|
||||
"/path": {
|
||||
"get": {
|
||||
"parameters": [
|
||||
{"$ref": "#/parameters/operationParameter"},
|
||||
{
|
||||
"in": "body",
|
||||
"name": "bodyParameter",
|
||||
"description": "The body parameter"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/responses/sampleResponse"
|
||||
},
|
||||
"404": {
|
||||
"description": "A sample response with a Schema reference.",
|
||||
"schema": {
|
||||
"$ref": "stringSchema"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{"$ref": "#/parameters/pathParameter"},
|
||||
{
|
||||
"in": "query",
|
||||
"name": "queryParameter",
|
||||
"type": "string",
|
||||
"description": "Another query parameter"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"sampleResponse" : {
|
||||
"description": "A sample response.",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"version": "1.0.0",
|
||||
"title": "Swagger Petstore"
|
||||
},
|
||||
"definitions": {
|
||||
"stringSchema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"parameters": {
|
||||
"operationParameter": {
|
||||
"in": "query",
|
||||
"name": "operationParameter",
|
||||
"type": "integer",
|
||||
"description": "A sample operation parameter"
|
||||
},
|
||||
"pathParameter": {
|
||||
"in": "query",
|
||||
"name": "pathParameter",
|
||||
"type": "string",
|
||||
"description": "A sample path parameter"
|
||||
}
|
||||
},
|
||||
"paths": {
|
||||
"/path": {
|
||||
"get": {
|
||||
"parameters": [
|
||||
{ "$ref": "#/parameters/operationParameter" },
|
||||
{
|
||||
"in": "body",
|
||||
"name": "bodyParameter",
|
||||
"description": "The body parameter"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/responses/sampleResponse"
|
||||
},
|
||||
"404": {
|
||||
"description": "A sample response with a Schema reference.",
|
||||
"schema": {
|
||||
"$ref": "stringSchema"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{ "$ref": "#/parameters/pathParameter" },
|
||||
{
|
||||
"in": "query",
|
||||
"name": "queryParameter",
|
||||
"type": "string",
|
||||
"description": "Another query parameter"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"sampleResponse": {
|
||||
"description": "A sample response.",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"max-line-length": false,
|
||||
"object-literal-key-quotes": false
|
||||
"object-literal-key-quotes": false,
|
||||
"interface-over-type-literal": false
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user