/* ============================================================================ * Copyright (c) Palo Alto Networks * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * ========================================================================== */ type Omit = Pick>; export interface OpenAPISpec { openapi: string; info: OpenAPIInfo; servers?: OpenAPIServer[]; paths: OpenAPIPaths; components?: OpenAPIComponents; security?: OpenAPISecurityRequirement[]; tags?: OpenAPITag[]; externalDocs?: OpenAPIExternalDocumentation; "x-webhooks"?: OpenAPIPaths; webhooks?: OpenAPIPaths; } export interface OpenAPIInfo { title: string; version: string; description?: string; summary?: string; termsOfService?: string; contact?: OpenAPIContact; license?: OpenAPILicense; } export interface OpenAPIServer { url: string; description?: string; variables?: { [name: string]: OpenAPIServerVariable }; } export interface OpenAPIServerVariable { enum?: string[]; default: string; description?: string; } export interface OpenAPIPaths { [path: string]: OpenAPIPath; } export interface OpenAPIRef { $ref: string; } export type Referenced = OpenAPIRef | T; export interface OpenAPIPath { summary?: string; description?: string; get?: OpenAPIOperation; put?: OpenAPIOperation; post?: OpenAPIOperation; delete?: OpenAPIOperation; options?: OpenAPIOperation; head?: OpenAPIOperation; patch?: OpenAPIOperation; trace?: OpenAPIOperation; servers?: OpenAPIServer[]; parameters?: Array>; $ref?: string; } export interface OpenAPIXCodeSample { lang: string; label?: string; source: string; } export interface OpenAPIOperation { tags?: string[]; summary?: string; description?: string; externalDocs?: OpenAPIExternalDocumentation; operationId?: string; parameters?: Array>; requestBody?: Referenced; responses: OpenAPIResponses; callbacks?: { [name: string]: Referenced }; deprecated?: boolean; security?: OpenAPISecurityRequirement[]; servers?: OpenAPIServer[]; "x-codeSamples"?: OpenAPIXCodeSample[]; "x-code-samples"?: OpenAPIXCodeSample[]; // deprecated } export interface OpenAPIParameter { name: string; in?: OpenAPIParameterLocation; description?: string; required?: boolean; deprecated?: boolean; allowEmptyValue?: boolean; style?: OpenAPIParameterStyle; explode?: boolean; allowReserved?: boolean; schema?: Referenced; example?: any; examples?: { [media: string]: Referenced }; content?: { [media: string]: OpenAPIMediaType }; encoding?: Record; const?: any; } export interface OpenAPIExample { value: any; summary?: string; description?: string; externalValue?: string; } export interface OpenAPISchema { $ref?: string; type?: string | string[]; properties?: { [name: string]: OpenAPISchema }; patternProperties?: { [name: string]: OpenAPISchema }; additionalProperties?: boolean | OpenAPISchema; unevaluatedProperties?: boolean | OpenAPISchema; description?: string; default?: any; items?: OpenAPISchema | OpenAPISchema[] | boolean; required?: string[]; readOnly?: boolean; writeOnly?: boolean; deprecated?: boolean; format?: string; externalDocs?: OpenAPIExternalDocumentation; discriminator?: OpenAPIDiscriminator; nullable?: boolean; oneOf?: OpenAPISchema[]; anyOf?: OpenAPISchema[]; allOf?: OpenAPISchema[]; not?: OpenAPISchema; title?: string; multipleOf?: number; maximum?: number; exclusiveMaximum?: boolean | number; minimum?: number; exclusiveMinimum?: boolean | number; maxLength?: number; minLength?: number; pattern?: string; maxItems?: number; minItems?: number; uniqueItems?: boolean; maxProperties?: number; minProperties?: number; enum?: any[]; example?: any; if?: OpenAPISchema; else?: OpenAPISchema; then?: OpenAPISchema; examples?: any[]; const?: string; contentEncoding?: string; contentMediaType?: string; prefixItems?: OpenAPISchema[]; additionalItems?: OpenAPISchema | boolean; } export interface OpenAPIDiscriminator { propertyName: string; mapping?: { [name: string]: string }; "x-explicitMappingOnly"?: boolean; } export interface OpenAPIMediaType { schema?: Referenced; example?: any; examples?: { [name: string]: Referenced }; encoding?: { [field: string]: OpenAPIEncoding }; } export interface OpenAPIEncoding { contentType: string; headers?: { [name: string]: Referenced }; style: OpenAPIParameterStyle; explode: boolean; allowReserved: boolean; } export type OpenAPIParameterLocation = "query" | "header" | "path" | "cookie"; export type OpenAPIParameterStyle = | "matrix" | "label" | "form" | "simple" | "spaceDelimited" | "pipeDelimited" | "deepObject"; export interface OpenAPIRequestBody { description?: string; required?: boolean; content: { [mime: string]: OpenAPIMediaType }; "x-examples"?: { [mime: string]: { [name: string]: Referenced }; }; "x-example"?: { [mime: string]: any }; } export interface OpenAPIResponses { [code: string]: Referenced; } export interface OpenAPIResponse extends Pick { headers?: { [name: string]: Referenced }; links?: { [name: string]: Referenced }; content?: { [mime: string]: OpenAPIMediaType }; } export interface OpenAPILink { $ref?: string; } export type OpenAPIHeader = Omit; export interface OpenAPICallback { [name: string]: OpenAPIPath; } export interface OpenAPIComponents { schemas?: { [name: string]: Referenced }; responses?: { [name: string]: Referenced }; parameters?: { [name: string]: Referenced }; examples?: { [name: string]: Referenced }; requestBodies?: { [name: string]: Referenced }; headers?: { [name: string]: Referenced }; securitySchemes?: { [name: string]: Referenced }; links?: { [name: string]: Referenced }; callbacks?: { [name: string]: Referenced }; } export interface OpenAPISecurityRequirement { [name: string]: string[]; } export interface OpenAPISecurityScheme { type: "apiKey" | "http" | "oauth2" | "openIdConnect"; description?: string; name?: string; in?: "query" | "header" | "cookie"; scheme?: string; bearerFormat: string; flows: { implicit?: { refreshUrl?: string; scopes: Record; authorizationUrl: string; }; password?: { refreshUrl?: string; scopes: Record; tokenUrl: string; }; clientCredentials?: { refreshUrl?: string; scopes: Record; tokenUrl: string; }; authorizationCode?: { refreshUrl?: string; scopes: Record; tokenUrl: string; }; }; openIdConnectUrl?: string; } export interface OpenAPITag { name: string; description?: string; externalDocs?: OpenAPIExternalDocumentation; "x-displayName"?: string; } export interface OpenAPIExternalDocumentation { description?: string; url: string; } export interface OpenAPIContact { name?: string; url?: string; email?: string; } export interface OpenAPILicense { name: string; url?: string; identifier?: string; }