{"version":3,"file":"SwaggerV2.mjs","sources":["../src/SwaggerV2.ts"],"sourcesContent":["import { IJsonSchemaAttribute } from \"./structures/IJsonSchemaAttribute\";\n\n/**\n * Swagger v2.0 definition.\n *\n * @author Jeongho Nam - https://github.com/samchon\n */\nexport namespace SwaggerV2 {\n  export type Method =\n    | \"get\"\n    | \"post\"\n    | \"put\"\n    | \"delete\"\n    | \"options\"\n    | \"head\"\n    | \"patch\"\n    | \"trace\";\n\n  /** @internal */\n  export const is = (input: any): input is IDocument =>\n    typeof input === \"object\" &&\n    input !== null &&\n    typeof input.swagger === \"string\" &&\n    input.swagger.startsWith(\"2.0\");\n\n  /* -----------------------------------------------------------\n    DOCUMENTS\n  ----------------------------------------------------------- */\n  export interface IDocument {\n    swagger: \"2.0\" | `2.0.${number}`;\n    info?: IDocument.IInfo;\n    host?: string;\n    basePath?: string;\n    consumes?: string[];\n    produces?: string[];\n    definitions?: Record<string, IJsonSchema>;\n    parameters?: Record<string, IOperation.IParameter>;\n    responses?: Record<string, IOperation.IResponse>;\n    securityDefinitions?: Record<string, ISecurityDefinition>;\n    security?: Record<string, string[]>[];\n    paths?: Record<string, IPath>;\n    tags?: IDocument.ITag[];\n  }\n  export namespace IDocument {\n    export interface IInfo {\n      title: string;\n      description?: string;\n      termsOfService?: string;\n      contact?: IContact;\n      license?: ILicense;\n      version: string;\n    }\n    export interface IContact {\n      name?: string;\n      url?: string;\n      email?: string;\n    }\n    export interface ILicense {\n      name: string;\n      url?: string;\n    }\n    export interface ITag {\n      name: string;\n      description?: string;\n    }\n  }\n\n  /* -----------------------------------------------------------\n    OPERATORS\n  ----------------------------------------------------------- */\n  export interface IPath\n    extends Partial<Record<Method, IOperation | undefined>> {\n    parameters?: Array<\n      IOperation.IParameter | IJsonSchema.IReference<`#/parameters/${string}`>\n    >;\n  }\n\n  export interface IOperation {\n    operationId?: string;\n    parameters?: Array<\n      | IOperation.IParameter\n      | IJsonSchema.IReference<`#/definitions/parameters/${string}`>\n    >;\n    responses?: Record<\n      string,\n      | IOperation.IResponse\n      | IJsonSchema.IReference<`#/definitions/responses/${string}`>\n    >;\n    summary?: string;\n    description?: string;\n    security?: Record<string, string[]>[];\n    tags?: string[];\n    deprecated?: boolean;\n  }\n  export namespace IOperation {\n    export type IParameter = IGeneralParameter | IBodyParameter;\n    export type IGeneralParameter = IJsonSchema & {\n      name: string;\n      in: string;\n      description?: string;\n    };\n    export interface IBodyParameter {\n      schema: IJsonSchema;\n      name: string;\n      in: string;\n      description?: string;\n      required?: boolean;\n    }\n    export interface IResponse {\n      description?: string;\n      headers?: Record<string, IJsonSchema>;\n      schema?: IJsonSchema;\n      example?: any;\n    }\n  }\n\n  /* -----------------------------------------------------------\n    DEFINITIONS\n  ----------------------------------------------------------- */\n  export type IJsonSchema =\n    | IJsonSchema.IBoolean\n    | IJsonSchema.IInteger\n    | IJsonSchema.INumber\n    | IJsonSchema.IString\n    | IJsonSchema.IArray\n    | IJsonSchema.IObject\n    | IJsonSchema.IReference\n    | IJsonSchema.IAnyOf\n    | IJsonSchema.IOneOf\n    | IJsonSchema.INullOnly\n    | IJsonSchema.IUnknown;\n  export namespace IJsonSchema {\n    export interface IBoolean\n      extends Omit<IJsonSchemaAttribute.IBoolean, \"examples\">,\n        __ISignificant<\"boolean\"> {\n      default?: boolean | null;\n      enum?: Array<boolean | null>;\n    }\n    export interface IInteger\n      extends Omit<IJsonSchemaAttribute.IInteger, \"examples\">,\n        __ISignificant<\"integer\"> {\n      /** @type int64 */ default?: number | null;\n      /** @type int64 */ enum?: Array<number | null>;\n      /** @type int64 */ minimum?: number;\n      /** @type int64 */ maximum?: number;\n      exclusiveMinimum?: number | boolean;\n      exclusiveMaximum?: number | boolean;\n      /**\n       * @type uint64\n       * @exclusiveMinimum 0\n       */\n      multipleOf?: number;\n    }\n    export interface INumber\n      extends Omit<IJsonSchemaAttribute.INumber, \"examples\">,\n        __ISignificant<\"number\"> {\n      default?: number | null;\n      enum?: Array<number | null>;\n      minimum?: number;\n      maximum?: number;\n      exclusiveMinimum?: number | boolean;\n      exclusiveMaximum?: number | boolean;\n      /** @exclusiveMinimum 0 */ multipleOf?: number;\n    }\n    export interface IString\n      extends Omit<IJsonSchemaAttribute.IString, \"examples\">,\n        __ISignificant<\"string\"> {\n      default?: string | null;\n      enum?: Array<string | null>;\n      format?:\n        | \"binary\"\n        | \"byte\"\n        | \"password\"\n        | \"regex\"\n        | \"uuid\"\n        | \"email\"\n        | \"hostname\"\n        | \"idn-email\"\n        | \"idn-hostname\"\n        | \"iri\"\n        | \"iri-reference\"\n        | \"ipv4\"\n        | \"ipv6\"\n        | \"uri\"\n        | \"uri-reference\"\n        | \"uri-template\"\n        | \"url\"\n        | \"date-time\"\n        | \"date\"\n        | \"time\"\n        | \"duration\"\n        | \"json-pointer\"\n        | \"relative-json-pointer\"\n        | (string & {});\n      pattern?: string;\n      /** @type uint64 */ minLength?: number;\n      /** @type uint64 */ maxLength?: number;\n    }\n\n    export interface IArray\n      extends Omit<IJsonSchemaAttribute.IArray, \"examples\">,\n        __ISignificant<\"array\"> {\n      items: IJsonSchema;\n      uniqueItems?: boolean;\n      /** @type uint64 */ minItems?: number;\n      /** @type uint64 */ maxItems?: number;\n    }\n    export interface IObject\n      extends Omit<IJsonSchemaAttribute.IObject, \"examples\">,\n        __ISignificant<\"object\"> {\n      properties?: Record<string, IJsonSchema>;\n      required?: string[];\n      additionalProperties?: boolean | IJsonSchema;\n      maxProperties?: number;\n      minProperties?: number;\n    }\n    export interface IReference<Key = string> extends __IAttribute {\n      $ref: Key;\n    }\n\n    export interface IAllOf extends __IAttribute {\n      allOf: IJsonSchema[];\n    }\n    export interface IAnyOf extends __IAttribute {\n      \"x-anyOf\": IJsonSchema[];\n    }\n    export interface IOneOf extends __IAttribute {\n      \"x-oneOf\": IJsonSchema[];\n    }\n\n    export interface INullOnly extends __IAttribute {\n      type: \"null\";\n      default?: null;\n    }\n    export interface IUnknown extends __IAttribute {\n      type?: undefined;\n    }\n\n    export interface __ISignificant<Type extends string> extends __IAttribute {\n      type: Type;\n      \"x-nullable\"?: boolean;\n    }\n    export interface __IAttribute\n      extends Omit<IJsonSchemaAttribute, \"examples\" | \"writeOnly\"> {\n      examples?: any[];\n    }\n  }\n\n  export type ISecurityDefinition =\n    | ISecurityDefinition.IApiKey\n    | ISecurityDefinition.IBasic\n    | ISecurityDefinition.IOauth2Implicit\n    | ISecurityDefinition.IOauth2AccessCode\n    | ISecurityDefinition.IOauth2Password\n    | ISecurityDefinition.IOauth2Application;\n  export namespace ISecurityDefinition {\n    export interface IApiKey {\n      type: \"apiKey\";\n      in?: \"header\" | \"query\" | \"cookie\";\n      name?: string;\n      description?: string;\n    }\n    export interface IBasic {\n      type: \"basic\";\n      name?: string;\n      description?: string;\n    }\n\n    export interface IOauth2Implicit {\n      type: \"oauth2\";\n      flow: \"implicit\";\n      authorizationUrl?: string;\n      scopes?: Record<string, string>;\n      description?: string;\n    }\n    export interface IOauth2AccessCode {\n      type: \"oauth2\";\n      flow: \"accessCode\";\n      authorizationUrl?: string;\n      tokenUrl?: string;\n      scopes?: Record<string, string>;\n      description?: string;\n    }\n    export interface IOauth2Password {\n      type: \"oauth2\";\n      flow: \"password\";\n      tokenUrl?: string;\n      scopes?: Record<string, string>;\n      description?: string;\n    }\n    export interface IOauth2Application {\n      type: \"oauth2\";\n      flow: \"application\";\n      tokenUrl?: string;\n      scopes?: Record<string, string>;\n      description?: string;\n    }\n  }\n}\n"],"names":["SwaggerV2","is","input","swagger","startsWith"],"mappings":"AAOM,IAAWA;;CAAjB,SAAiBA;IAYFA,UAAAC,KAAMC,gBACVA,UAAU,YACjBA,UAAU,eACHA,MAAMC,YAAY,YACzBD,MAAMC,QAAQC,WAAW;AAmR5B,EAnSD,CAAiBJ,cAAAA,YAAS,CAAA;;"}