Narrow down security types for OAS2 (#35416)

* Narrow down security types for OAS2

* whoops fixes
This commit is contained in:
Vincenzo Chianese 2019-05-20 16:09:15 -05:00 committed by Ryan Cavanaugh
parent cc34d23ba3
commit 6f40d7c9cb

View File

@ -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<string | boolean | number | {}>;
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[];
}