From 6f40d7c9cb0216cab467cb9afbb2afc90845dbac Mon Sep 17 00:00:00 2001 From: Vincenzo Chianese Date: Mon, 20 May 2019 16:09:15 -0500 Subject: [PATCH] Narrow down security types for OAS2 (#35416) * Narrow down security types for OAS2 * whoops fixes --- types/swagger-schema-official/index.d.ts | 37 +++++++++++++++--------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/types/swagger-schema-official/index.d.ts b/types/swagger-schema-official/index.d.ts index 11cfd05520..b10e76dffc 100644 --- a/types/swagger-schema-official/index.d.ts +++ b/types/swagger-schema-official/index.d.ts @@ -97,7 +97,7 @@ export interface Path { // ----------------------------- Operation ----------------------------------- export interface Operation { - responses: { [responseName: string]: Response | Reference}; + responses: { [responseName: string]: Response | Reference }; summary?: string; description?: string; externalDocs?: ExternalDocs; @@ -129,7 +129,7 @@ export interface BaseSchema { format?: string; title?: string; description?: string; - default?: string|boolean|number|{}; + default?: string | boolean | number | {}; multipleOf?: number; maximum?: number; exclusiveMaximum?: boolean; @@ -145,14 +145,14 @@ export interface BaseSchema { minProperties?: number; enum?: Array; type?: string; - items?: Schema|Schema[]; + items?: Schema | Schema[]; } export interface Schema extends BaseSchema { $ref?: string; allOf?: Schema[]; additionalProperties?: Schema; - properties?: {[propertyName: string]: Schema}; + properties?: { [propertyName: string]: Schema }; discriminator?: string; readOnly?: boolean; xml?: XML; @@ -171,39 +171,48 @@ export interface XML { // ----------------------------- Security ------------------------------------ export interface BaseSecurity { - type: string; + type: 'basic' | 'apiKey' | 'oauth2'; description?: string; } -// tslint:disable-next-line no-empty-interface export interface BasicAuthenticationSecurity extends BaseSecurity { - // It's the exact same interface as BaseSecurity + type: 'basic'; } export interface ApiKeySecurity extends BaseSecurity { + type: 'apiKey'; name: string; in: string; } export interface BaseOAuthSecuirty extends BaseSecurity { - flow: string; + type: 'oauth2'; + flow: 'accessCode' | 'application' | 'implicit' | 'password'; } export interface OAuth2ImplicitSecurity extends BaseOAuthSecuirty { + type: 'oauth2'; + flow: 'implicit'; authorizationUrl: string; } export interface OAuth2PasswordSecurity extends BaseOAuthSecuirty { + type: 'oauth2'; + flow: 'password'; tokenUrl: string; scopes?: OAuthScope[]; } export interface OAuth2ApplicationSecurity extends BaseOAuthSecuirty { + type: 'oauth2'; + flow: 'application'; tokenUrl: string; scopes?: OAuthScope[]; } export interface OAuth2AccessCodeSecurity extends BaseOAuthSecuirty { + type: 'oauth2'; + flow: 'accessCode'; tokenUrl: string; authorizationUrl: string; scopes?: OAuthScope[]; @@ -231,11 +240,11 @@ export interface Spec { schemes?: string[]; consumes?: string[]; produces?: string[]; - paths: {[pathName: string]: Path}; - definitions?: {[definitionsName: string]: Schema }; - parameters?: {[parameterName: string]: BodyParameter|QueryParameter}; - responses?: {[responseName: string]: Response }; - security?: Array<{[securityDefinitionName: string]: string[]}>; - securityDefinitions?: { [securityDefinitionName: string]: Security}; + paths: { [pathName: string]: Path }; + definitions?: { [definitionsName: string]: Schema }; + parameters?: { [parameterName: string]: BodyParameter | QueryParameter }; + responses?: { [responseName: string]: Response }; + security?: Array<{ [securityDefinitionName: string]: string[] }>; + securityDefinitions?: { [securityDefinitionName: string]: Security }; tags?: Tag[]; }