swagger-typescript-api
    Preparing search index...

    Interface GenerateApiConfiguration

    interface GenerateApiConfiguration {
        apiConfig: {
            baseUrl: string;
            description: string[];
            hasDescription: boolean;
            title: string;
            version: string;
        };
        config: {
            addReadonly: boolean;
            anotherArrayType: boolean;
            apiClassName: string;
            authorizationToken?: string;
            cleanOutput: boolean;
            codeGenConstructs?: (
                struct: CodeGenConstruct,
            ) => Partial<CodeGenConstruct>;
            compilerTsConfig: Record<string, unknown>;
            componentsMap: Record<string, SchemaComponent>;
            componentTypeNameResolver: ComponentTypeNameResolver;
            constants: constants;
            convertedFromSwagger2: boolean;
            customTranslator?: new () => Translator;
            debug: boolean;
            defaultResponseAsSuccess: boolean;
            defaultResponseType: string;
            disableThrowOnError: boolean;
            enumKeyPrefix: string;
            enumKeyResolverName: string;
            enumKeySuffix: string;
            enumNamesAsValues: boolean;
            extractEnums: boolean;
            extractingOptions: Partial<ExtractingOptions>;
            extractRequestBody: boolean;
            extractRequestParams: boolean;
            extractResponseBody: boolean;
            extractResponseError: boolean;
            extractResponses: boolean;
            extraTemplates: { name: string; path: string }[];
            fileName: string;
            fileNames: {
                dataContracts: string;
                httpClient: string;
                outOfModuleApi: string;
                routeTypes: string;
            };
            fixInvalidEnumKeyPrefix: string;
            fixInvalidTypeNamePrefix: string;
            generateClient: boolean;
            generateResponses: boolean;
            generateRouteTypes: boolean;
            generateUnionEnums: boolean;
            hooks: Partial<Hooks>;
            httpClientType: "fetch" | "axios";
            input: string;
            internalTemplateOptions: { addUtilRequiredKeysType: boolean };
            modular: boolean;
            moduleNameFirstTag: boolean;
            moduleNameIndex: number;
            originalSchema: object;
            output: string | false;
            patch: boolean;
            primitiveTypeConstructs?: (
                struct: PrimitiveTypeStruct,
            ) => Partial<PrimitiveTypeStruct>;
            primitiveTypes: PrimitiveTypeStruct;
            requestOptions?: Partial<RequestInit>;
            routeNameDuplicatesMap: Map<string, string>;
            schemaParsers?: {
                array?: MonoSchemaParser;
                complex?: MonoSchemaParser;
                complexAllOf?: MonoSchemaParser;
                complexAnyOf?: MonoSchemaParser;
                complexNot?: MonoSchemaParser;
                complexOneOf?: MonoSchemaParser;
                discriminator?: MonoSchemaParser;
                enum?: MonoSchemaParser;
                object?: MonoSchemaParser;
                primitive?: MonoSchemaParser;
            };
            silent: boolean;
            singleHttpClient: boolean;
            sortRoutes: boolean;
            sortTypes: boolean;
            spec: unknown;
            specificArgNameResolverName: string;
            successResponseStatusRange: [number, number];
            swaggerSchema: object;
            templateExtensions: string[];
            templateInfos: { fileName: string; name: string }[];
            templatePaths: {
                base: string;
                custom: null | string;
                default: string;
                modular: string;
                original: string;
            };
            templates: string;
            templatesToRender: {
                api: string;
                dataContractJsDoc: string;
                dataContracts: string;
                enumDataContract: string;
                httpClient: string;
                interfaceDataContract: string;
                objectFieldJsDoc: string;
                routeName: string;
                routeTypes: string;
                typeDataContract: string;
            };
            toJS: boolean;
            Ts: CodeGenConstruct;
            typeNameResolverName: string;
            typePrefix: string;
            typeSuffix: string;
            unwrapResponseData: boolean;
            update: (update: Partial<GenerateApiConfiguration["config"]>) => void;
            url: string;
            version: string;
        };
        generateResponses: boolean;
        hasFormDataRoutes: boolean;
        hasQueryRoutes: boolean;
        hasSecurityRoutes: boolean;
        modelTypes: ModelType[];
        requestOptions?: Partial<RequestInit>;
        routes: {
            combined?: { moduleName: string; routes: ParsedRoute[] }[];
            outOfModule: ParsedRoute[];
        };
        utils: {
            _: LoDashStatic;
            classNameCase: (value: string) => string;
            fmtToJSDocLine: (line: string, params?: { eol?: boolean }) => string;
            formatDescription: (description: string, inline?: boolean) => string;
            formatModelName: (name: string) => string;
            formatters: Record<
                MAIN_SCHEMA_TYPES,
                (content: string | object | string[] | object[]) => string,
            >;
            getComponentByRef: (ref: string) => SchemaComponent;
            getInlineParseContent: (
                rawTypeData:
                    | undefined
                    | {
                        $parsed: ParsedSchema<
                            | SchemaTypeObjectContent
                            | SchemaTypeEnumContent
                            | SchemaTypePrimitiveContent,
                        >;
                        discriminator?: { propertyName?: string };
                        properties?: Record<
                            string,
                            {
                                $parsed?: SchemaTypePrimitiveContent;
                                name?: string;
                                required: boolean;
                                type: string;
                            },
                        >;
                        required?: string[];
                        type: string;
                    },
                typeName?: string,
            ) => string;
            getParseContent: (
                rawTypeData:
                    | undefined
                    | {
                        $parsed: ParsedSchema<
                            | SchemaTypeObjectContent
                            | SchemaTypeEnumContent
                            | SchemaTypePrimitiveContent,
                        >;
                        discriminator?: { propertyName?: string };
                        properties?: Record<
                            string,
                            {
                                $parsed?: SchemaTypePrimitiveContent;
                                name?: string;
                                required: boolean;
                                type: string;
                            },
                        >;
                        required?: string[];
                        type: string;
                    },
                typeName?: string,
            ) => ModelType;
            inlineExtraFormatters: Record<
                Exclude<MAIN_SCHEMA_TYPES, PRIMITIVE>,
                (schema: ModelType) => string,
            >;
            internalCase: (value: string) => string;
            parseSchema: (
                rawSchema:
                    | undefined
                    | string
                    | {
                        $parsed: ParsedSchema<
                            | SchemaTypeObjectContent
                            | SchemaTypeEnumContent
                            | SchemaTypePrimitiveContent,
                        >;
                        discriminator?: { propertyName?: string };
                        properties?: Record<
                            string,
                            {
                                $parsed?: SchemaTypePrimitiveContent;
                                name?: string;
                                required: boolean;
                                type: string;
                            },
                        >;
                        required?: string[];
                        type: string;
                    },
                typeName?: string,
                formattersMap?: Record<MAIN_SCHEMA_TYPES, (content: ModelType) => string>,
            ) => ModelType;
            pascalCase: (value: string) => string;
            require: (path: string) => unknown;
        };
    }
    Index

    Properties

    apiConfig: {
        baseUrl: string;
        description: string[];
        hasDescription: boolean;
        title: string;
        version: string;
    }

    Type Declaration

    • baseUrl: string

      base url from schema

    • description: string[]

      description split into lines

    • hasDescription: boolean

      flag that description is present

    • title: string

      document title

    • version: string

      document version

    config: {
        addReadonly: boolean;
        anotherArrayType: boolean;
        apiClassName: string;
        authorizationToken?: string;
        cleanOutput: boolean;
        codeGenConstructs?: (struct: CodeGenConstruct) => Partial<CodeGenConstruct>;
        compilerTsConfig: Record<string, unknown>;
        componentsMap: Record<string, SchemaComponent>;
        componentTypeNameResolver: ComponentTypeNameResolver;
        constants: constants;
        convertedFromSwagger2: boolean;
        customTranslator?: new () => Translator;
        debug: boolean;
        defaultResponseAsSuccess: boolean;
        defaultResponseType: string;
        disableThrowOnError: boolean;
        enumKeyPrefix: string;
        enumKeyResolverName: string;
        enumKeySuffix: string;
        enumNamesAsValues: boolean;
        extractEnums: boolean;
        extractingOptions: Partial<ExtractingOptions>;
        extractRequestBody: boolean;
        extractRequestParams: boolean;
        extractResponseBody: boolean;
        extractResponseError: boolean;
        extractResponses: boolean;
        extraTemplates: { name: string; path: string }[];
        fileName: string;
        fileNames: {
            dataContracts: string;
            httpClient: string;
            outOfModuleApi: string;
            routeTypes: string;
        };
        fixInvalidEnumKeyPrefix: string;
        fixInvalidTypeNamePrefix: string;
        generateClient: boolean;
        generateResponses: boolean;
        generateRouteTypes: boolean;
        generateUnionEnums: boolean;
        hooks: Partial<Hooks>;
        httpClientType: "fetch" | "axios";
        input: string;
        internalTemplateOptions: { addUtilRequiredKeysType: boolean };
        modular: boolean;
        moduleNameFirstTag: boolean;
        moduleNameIndex: number;
        originalSchema: object;
        output: string | false;
        patch: boolean;
        primitiveTypeConstructs?: (
            struct: PrimitiveTypeStruct,
        ) => Partial<PrimitiveTypeStruct>;
        primitiveTypes: PrimitiveTypeStruct;
        requestOptions?: Partial<RequestInit>;
        routeNameDuplicatesMap: Map<string, string>;
        schemaParsers?: {
            array?: MonoSchemaParser;
            complex?: MonoSchemaParser;
            complexAllOf?: MonoSchemaParser;
            complexAnyOf?: MonoSchemaParser;
            complexNot?: MonoSchemaParser;
            complexOneOf?: MonoSchemaParser;
            discriminator?: MonoSchemaParser;
            enum?: MonoSchemaParser;
            object?: MonoSchemaParser;
            primitive?: MonoSchemaParser;
        };
        silent: boolean;
        singleHttpClient: boolean;
        sortRoutes: boolean;
        sortTypes: boolean;
        spec: unknown;
        specificArgNameResolverName: string;
        successResponseStatusRange: [number, number];
        swaggerSchema: object;
        templateExtensions: string[];
        templateInfos: { fileName: string; name: string }[];
        templatePaths: {
            base: string;
            custom: null | string;
            default: string;
            modular: string;
            original: string;
        };
        templates: string;
        templatesToRender: {
            api: string;
            dataContractJsDoc: string;
            dataContracts: string;
            enumDataContract: string;
            httpClient: string;
            interfaceDataContract: string;
            objectFieldJsDoc: string;
            routeName: string;
            routeTypes: string;
            typeDataContract: string;
        };
        toJS: boolean;
        Ts: CodeGenConstruct;
        typeNameResolverName: string;
        typePrefix: string;
        typeSuffix: string;
        unwrapResponseData: boolean;
        update: (update: Partial<GenerateApiConfiguration["config"]>) => void;
        url: string;
        version: string;
    }

    Type Declaration

    • addReadonly: boolean

      generate readonly properties

    • anotherArrayType: boolean

      generate array types as Array

      false
      
    • apiClassName: string

      name of the main exported class

    • OptionalauthorizationToken?: string

      authorisation token for private swagger schema access

    • cleanOutput: boolean

      remove output directory before generating

    • OptionalcodeGenConstructs?: (struct: CodeGenConstruct) => Partial<CodeGenConstruct>

      customise code generation constructs

    • compilerTsConfig: Record<string, unknown>

      ts compiler configuration object (for --to-js option)

    • componentsMap: Record<string, SchemaComponent>

      map of schema component references

    • componentTypeNameResolver: ComponentTypeNameResolver

      resolver for component type names

    • constants: constants

      internal constants

    • convertedFromSwagger2: boolean

      flag indicating the schema was converted from Swagger 2.0

    • OptionalcustomTranslator?: new () => Translator

      custom ts->* translator do not use constructor args, just send class reference

    • debug: boolean

      output debug messages

    • defaultResponseAsSuccess: boolean

      use "default" response status code as success response. some swagger schemas treat "default" as a successful response.

    • defaultResponseType: string

      default type for empty response schema

      "void"
      
    • disableThrowOnError: boolean

      disable throwing on a non-successful response

    • enumKeyPrefix: string

      prefix string value for enum keys

    • enumKeyResolverName: string

      enum key resolver name

    • enumKeySuffix: string

      suffix string value for enum keys

    • enumNamesAsValues: boolean

      use enum names as values

    • extractEnums: boolean

      extract all enums from nested types/interfaces to enum construction

    • extractingOptions: Partial<ExtractingOptions>

      extra configuration for extracting type names operations

    • extractRequestBody: boolean

      extract request body type to data contract

    • extractRequestParams: boolean

      extract request params to data contract

    • extractResponseBody: boolean

      extract response body type to data contract

    • extractResponseError: boolean

      extract response error type to data contract

    • extractResponses: boolean

      extract all enums from inline interface/type content to typescript enum construction

    • extraTemplates: { name: string; path: string }[]

      extra templates

    • fileName: string

      file name for the generated API module

      'Api.ts'
      
    • fileNames: {
          dataContracts: string;
          httpClient: string;
          outOfModuleApi: string;
          routeTypes: string;
      }

      generated file names

    • fixInvalidEnumKeyPrefix: string

      prefix string value needed to fix invalid enum keys

      "Value"
      
    • fixInvalidTypeNamePrefix: string

      prefix string value needed to fix invalid type names

      "Type"
      
    • generateClient: boolean

      generate an API client

    • generateResponses: boolean

      generate additional information about request responses and error typings

    • generateRouteTypes: boolean

      generate type definitions for API routes

    • generateUnionEnums: boolean

      generate all "enum" types as union types (T1 | T2 | TN)

    • hooks: Partial<Hooks>

      hooks for customising the generation process

    • httpClientType: "fetch" | "axios"

      generated http client type

    • input: string

      path to swagger schema

    • internalTemplateOptions: { addUtilRequiredKeysType: boolean }

      internal options for templates

    • modular: boolean

      generate separated files for http client, data contracts, and routes

      false
      
    • moduleNameFirstTag: boolean

      use the first tag for the module name

    • moduleNameIndex: number

      determines which path index should be used for routes separation

    • originalSchema: object

      original swagger schema

    • output: string | false

      path to folder where the created api module will be placed. may be set to false to skip writing content to disk; in this case the files array on the return value will contain the generated contents.

    • patch: boolean

      fix up small errors in the swagger source definition

    • OptionalprimitiveTypeConstructs?: (struct: PrimitiveTypeStruct) => Partial<PrimitiveTypeStruct>

      customise primitive type mappings

    • primitiveTypes: PrimitiveTypeStruct
    • OptionalrequestOptions?: Partial<RequestInit>

      configuration for fetching swagger schema requests

    • routeNameDuplicatesMap: Map<string, string>

      map of duplicate route names

    • OptionalschemaParsers?: {
          array?: MonoSchemaParser;
          complex?: MonoSchemaParser;
          complexAllOf?: MonoSchemaParser;
          complexAnyOf?: MonoSchemaParser;
          complexNot?: MonoSchemaParser;
          complexOneOf?: MonoSchemaParser;
          discriminator?: MonoSchemaParser;
          enum?: MonoSchemaParser;
          object?: MonoSchemaParser;
          primitive?: MonoSchemaParser;
      }

      custom schema parsers

    • silent: boolean

      output only errors to console

      false
      
    • singleHttpClient: boolean

      ability to send HttpClient instance to Api constructor

    • sortRoutes: boolean

      sort routes in alphabetical order

    • sortTypes: boolean

      sort data contracts in alphabetical order

    • spec: unknown

      swagger schema JSON

    • specificArgNameResolverName: string

      specific argument name resolver name

    • successResponseStatusRange: [number, number]

      range of HTTP status codes treated as success

    • swaggerSchema: object

      parsed swagger schema

    • templateExtensions: string[]

      supported template file extensions

    • templateInfos: { fileName: string; name: string }[]

      built-in template info

    • templatePaths: {
          base: string;
          custom: null | string;
          default: string;
          modular: string;
          original: string;
      }
      • base: string

        templates/base

      • custom: null | string

        custom path to templates (--templates)

      • default: string

        templates/default

      • modular: string

        templates/modular

      • original: string

        usage path if --templates option is not set

    • templates: string

      path to folder containing custom templates

      ""
      
    • templatesToRender: {
          api: string;
          dataContractJsDoc: string;
          dataContracts: string;
          enumDataContract: string;
          httpClient: string;
          interfaceDataContract: string;
          objectFieldJsDoc: string;
          routeName: string;
          routeTypes: string;
          typeDataContract: string;
      }

      Record<templateName, templateContent>

    • toJS: boolean

      generate js api module with declaration file

      false
      
    • Ts: CodeGenConstruct

      code generation constructs for TypeScript

    • typeNameResolverName: string

      type name resolver name

    • typePrefix: string

      prefix string value for type names

    • typeSuffix: string

      suffix string value for type names

    • unwrapResponseData: boolean

      unwrap the data item from the response

    • update: (update: Partial<GenerateApiConfiguration["config"]>) => void

      update configuration object during generation

    • url: string

      url to swagger schema

    • version: string

      package version

    generateResponses: boolean
    hasFormDataRoutes: boolean
    hasQueryRoutes: boolean
    hasSecurityRoutes: boolean
    modelTypes: ModelType[]
    requestOptions?: Partial<RequestInit>
    routes: {
        combined?: { moduleName: string; routes: ParsedRoute[] }[];
        outOfModule: ParsedRoute[];
    }
    utils: {
        _: LoDashStatic;
        classNameCase: (value: string) => string;
        fmtToJSDocLine: (line: string, params?: { eol?: boolean }) => string;
        formatDescription: (description: string, inline?: boolean) => string;
        formatModelName: (name: string) => string;
        formatters: Record<
            MAIN_SCHEMA_TYPES,
            (content: string | object | string[] | object[]) => string,
        >;
        getComponentByRef: (ref: string) => SchemaComponent;
        getInlineParseContent: (
            rawTypeData:
                | undefined
                | {
                    $parsed: ParsedSchema<
                        | SchemaTypeObjectContent
                        | SchemaTypeEnumContent
                        | SchemaTypePrimitiveContent,
                    >;
                    discriminator?: { propertyName?: string };
                    properties?: Record<
                        string,
                        {
                            $parsed?: SchemaTypePrimitiveContent;
                            name?: string;
                            required: boolean;
                            type: string;
                        },
                    >;
                    required?: string[];
                    type: string;
                },
            typeName?: string,
        ) => string;
        getParseContent: (
            rawTypeData:
                | undefined
                | {
                    $parsed: ParsedSchema<
                        | SchemaTypeObjectContent
                        | SchemaTypeEnumContent
                        | SchemaTypePrimitiveContent,
                    >;
                    discriminator?: { propertyName?: string };
                    properties?: Record<
                        string,
                        {
                            $parsed?: SchemaTypePrimitiveContent;
                            name?: string;
                            required: boolean;
                            type: string;
                        },
                    >;
                    required?: string[];
                    type: string;
                },
            typeName?: string,
        ) => ModelType;
        inlineExtraFormatters: Record<
            Exclude<MAIN_SCHEMA_TYPES, PRIMITIVE>,
            (schema: ModelType) => string,
        >;
        internalCase: (value: string) => string;
        parseSchema: (
            rawSchema:
                | undefined
                | string
                | {
                    $parsed: ParsedSchema<
                        | SchemaTypeObjectContent
                        | SchemaTypeEnumContent
                        | SchemaTypePrimitiveContent,
                    >;
                    discriminator?: { propertyName?: string };
                    properties?: Record<
                        string,
                        {
                            $parsed?: SchemaTypePrimitiveContent;
                            name?: string;
                            required: boolean;
                            type: string;
                        },
                    >;
                    required?: string[];
                    type: string;
                },
            typeName?: string,
            formattersMap?: Record<MAIN_SCHEMA_TYPES, (content: ModelType) => string>,
        ) => ModelType;
        pascalCase: (value: string) => string;
        require: (path: string) => unknown;
    }

    Type Declaration

    • _: LoDashStatic
    • classNameCase: (value: string) => string
    • fmtToJSDocLine: (line: string, params?: { eol?: boolean }) => string
    • formatDescription: (description: string, inline?: boolean) => string
    • formatModelName: (name: string) => string
    • formatters: Record<
          MAIN_SCHEMA_TYPES,
          (content: string | object | string[] | object[]) => string,
      >
    • getComponentByRef: (ref: string) => SchemaComponent
    • getInlineParseContent: (
          rawTypeData:
              | undefined
              | {
                  $parsed: ParsedSchema<
                      | SchemaTypeObjectContent
                      | SchemaTypeEnumContent
                      | SchemaTypePrimitiveContent,
                  >;
                  discriminator?: { propertyName?: string };
                  properties?: Record<
                      string,
                      {
                          $parsed?: SchemaTypePrimitiveContent;
                          name?: string;
                          required: boolean;
                          type: string;
                      },
                  >;
                  required?: string[];
                  type: string;
              },
          typeName?: string,
      ) => string
    • getParseContent: (
          rawTypeData:
              | undefined
              | {
                  $parsed: ParsedSchema<
                      | SchemaTypeObjectContent
                      | SchemaTypeEnumContent
                      | SchemaTypePrimitiveContent,
                  >;
                  discriminator?: { propertyName?: string };
                  properties?: Record<
                      string,
                      {
                          $parsed?: SchemaTypePrimitiveContent;
                          name?: string;
                          required: boolean;
                          type: string;
                      },
                  >;
                  required?: string[];
                  type: string;
              },
          typeName?: string,
      ) => ModelType
    • inlineExtraFormatters: Record<Exclude<MAIN_SCHEMA_TYPES, PRIMITIVE>, (schema: ModelType) => string>
    • internalCase: (value: string) => string
    • parseSchema: (
          rawSchema:
              | undefined
              | string
              | {
                  $parsed: ParsedSchema<
                      | SchemaTypeObjectContent
                      | SchemaTypeEnumContent
                      | SchemaTypePrimitiveContent,
                  >;
                  discriminator?: { propertyName?: string };
                  properties?: Record<
                      string,
                      {
                          $parsed?: SchemaTypePrimitiveContent;
                          name?: string;
                          required: boolean;
                          type: string;
                      },
                  >;
                  required?: string[];
                  type: string;
              },
          typeName?: string,
          formattersMap?: Record<MAIN_SCHEMA_TYPES, (content: ModelType) => string>,
      ) => ModelType
    • pascalCase: (value: string) => string
    • require: (path: string) => unknown