Skip to content

Latest commit

 

History

History
658 lines (448 loc) · 27.7 KB

File metadata and controls

658 lines (448 loc) · 27.7 KB

api-typescript-generator / Modules / openapi-client

Module: openapi-client

Table of contents

Classes

Interfaces

Type Aliases

Type Aliases

CommonHttpClientFetchResponseBody

Ƭ CommonHttpClientFetchResponseBody: { data: unknown ; type: "json" } | { data: Blob ; type: "blob" } | { data: ReadableStream<Uint8Array> ; type: "readableStream" }


CommonHttpClientRequest

Ƭ CommonHttpClientRequest: Omit<CommonHttpClientFetchRequest, "body" | "headers" | "cache" | "credentials" | "redirect"> & { body?: unknown ; headers?: CommonHttpClientRequestHeaders ; parameters?: CommonHttpClientRequestParameters ; path: string ; pathParams?: Record<string, unknown> ; query?: Record<string, unknown> } & Partial<Pick<CommonHttpClientFetchRequest, "cache" | "credentials">>

Request in terms of OpenAPI.


CommonHttpClientRequestParameterLocation

Ƭ CommonHttpClientRequestParameterLocation: "path" | "query" | "header" | "cookie"

Request parameter location.


CommonHttpClientRequestParameterSerializeStyle

Ƭ CommonHttpClientRequestParameterSerializeStyle: "simple" | "label" | "matrix" | "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"

Parameter serialization style.


CommonHttpClientRequestParameters

Ƭ CommonHttpClientRequestParameters: { [K in CommonHttpClientRequestParameterLocation]?: Record<string, CommonHttpClientRequestParameterSerializeInfo> }

Request parameters.


CommonHttpClientResponseHeaders

Ƭ CommonHttpClientResponseHeaders: Record<string, string> & { set-cookie?: string[] }


GenerateClientErrorJsDoc

Ƭ GenerateClientErrorJsDoc: (params: { info: OpenApiInfo ; suggestedJsDoc: JsDocBlock }) => JsDocBlock

Type declaration

▸ (params): JsDocBlock

Callback for generating the JSDoc of a client.

Parameters
Name Type Description
params Object -
params.info OpenApiInfo OpenAPI Info Object.
params.suggestedJsDoc JsDocBlock Suggested JSDoc block. Used by default if the callback is not specified.
Returns

JsDocBlock

Example

function generateClientErrorJsDoc({suggestedJsDoc, info}) {
        return {
            ...suggestedJsDoc,
            title: 'Error Class for ' + info.summary
        };
    }

GenerateClientJsDoc

Ƭ GenerateClientJsDoc: (params: { info: OpenApiInfo ; suggestedJsDoc: JsDocBlock }) => JsDocBlock

Type declaration

▸ (params): JsDocBlock

Callback for generating the JSDoc of a client.

Parameters
Name Type Description
params Object -
params.info OpenApiInfo OpenAPI Info Object.
params.suggestedJsDoc JsDocBlock Suggested JSDoc block. Used by default if the callback is not specified.
Returns

JsDocBlock

Example

function generateClientJsDoc({suggestedJsDoc, info}) {
        return {
            title: info.summary,
            description: info.description,
            tags: [{name: 'version', value: info.version}]
        };
    }

GenerateCoreJsDoc

Ƭ GenerateCoreJsDoc: (params: { memberName?: string ; suggestedJsDoc: JsDocBlock ; typeName: string }) => JsDocBlock

Type declaration

▸ (params): JsDocBlock

Callback for generating the JSDoc for core classes.

Parameters
Name Type Description
params Object -
params.memberName? string Name of the member of the core class. Empty if the JSDoc is for the class itself.
params.suggestedJsDoc JsDocBlock Suggested JSDoc block. Used by default if the callback is not specified.
params.typeName string Name of the core class.
Returns

JsDocBlock

Example

function GenerateCoreJsDoc({suggestedJsDoc}) {
        return {
            ...suggestedJsDoc,
            tags: [...suggestedJsDoc.tags, {name: 'internal'}]
        };
    }

GenerateModelJsDoc

Ƭ GenerateModelJsDoc: (params: { fieldPath: OpenApiSchemaFieldPathItem[] ; schema: OpenApiSchema ; schemaName: string ; suggestedJsDoc: JsDocBlock }) => JsDocBlock

Type declaration

▸ (params): JsDocBlock

Callback for generating the JSDoc of a model.

Parameters
Name Type Description
params Object -
params.fieldPath OpenApiSchemaFieldPathItem[] Path to the field in the schema. Empty if the schema is a model schema.
params.schema OpenApiSchema OpenAPISchema of the model schema (if fieldPath is empty) or the field schema.
params.schemaName string Name of the schema.
params.suggestedJsDoc JsDocBlock Suggested JSDoc block. Used by default if the callback is not specified.
Returns

JsDocBlock

Example

function generateModelJsDoc({suggestedJsDoc, schemaName, fieldPath}) {
        if (fieldPath.length === 0) {
            return {
                title: schemaName,
                ...suggestedJsDoc
            };
        } else {
            return suggestedJsDoc;
        }
    }

GenerateModelNameCallback

Ƭ GenerateModelNameCallback: (context: { schemaName: string ; suggestedName: string }) => string

Type declaration

▸ (context): string

Callback for generating the name of a model.

Parameters
Name Type Description
context Object -
context.schemaName string OpenAPI Schema name.
context.suggestedName string Suggested name of the model. Used by default if the callback is not specified.
Returns

string

Example

function generateModelName({suggestedName, schemaName, fieldPath}) {
        if (fieldPath.length === 0) {
            return schemaName + 'Model';
        } else {
            return suggestedName;
        }
    }

GenerateOperationJsDoc

Ƭ GenerateOperationJsDoc: (params: { httpMethod: string ; operation: OpenApiOperation ; path: string ; pathItem: OpenApiPathItem ; serviceName?: string ; suggestedJsDoc: JsDocBlock }) => JsDocBlock

Type declaration

▸ (params): JsDocBlock

Callback for generating the JSDoc of an operation.

Parameters
Name Type Description
params Object -
params.httpMethod string HTTP method of the operation. I.e. get.
params.operation OpenApiOperation OpenAPI Operation Object. See https://swagger.io/specification/#operation-object
params.path string Path of the operation. I.e. /orders/{orderId}.
params.pathItem OpenApiPathItem OpenAPI Path Item Object. See https://swagger.io/specification/#path-item-object
params.serviceName? string Name of the service.
params.suggestedJsDoc JsDocBlock Suggested JSDoc block. Used by default if the callback is not specified.
Returns

JsDocBlock

Example

function generateOperationJsDoc({suggestedJsDoc, path, httpMethod}) {
        return {
            ...suggestedJsDoc,
            tags: [...suggestedJsDoc.tags, {name: 'path', value: `{${httpMethod}} ${path}`}]
        };
    }

GenerateOperationName

Ƭ GenerateOperationName: (params: { httpMethod: string ; operation: OpenApiOperation ; path: string ; pathItem: OpenApiPathItem ; serviceName?: string ; suggestedName: string }) => string

Type declaration

▸ (params): string

Callback for generating the name of an operation.

Parameters
Name Type Description
params Object -
params.httpMethod string HTTP method of the operation. I.e. get.
params.operation OpenApiOperation OpenAPI Operation Object. See https://swagger.io/specification/#operation-object
params.path string Path of the operation. I.e. /orders/{orderId}.
params.pathItem OpenApiPathItem OpenAPI Path Item Object. See https://swagger.io/specification/#path-item-object
params.serviceName? string Name of the service.
params.suggestedName string Suggested name of the operation. Used by default if the callback is not specified.
Returns

string

Example

function generateOperationName({operation, httpMethod}) {
        return `${httpMethod}_${operation.operationId}`;
    }

GenerateOperationParameterArgumentName

Ƭ GenerateOperationParameterArgumentName: (params: { httpMethod: string ; operation: OpenApiOperation ; operationName: string ; parameter: OpenApiParameter ; path: string ; pathItem: OpenApiPathItem ; serviceName?: string ; suggestedName: string }) => string

Type declaration

▸ (params): string

Callback for generating the name of an operation parameter argument.

Parameters
Name Type Description
params Object -
params.httpMethod string HTTP method of the operation. I.e. get.
params.operation OpenApiOperation OpenAPI Operation Object. See https://swagger.io/specification/#operation-object
params.operationName string Generated class method name for the operation.
params.parameter OpenApiParameter OpenAPI Parameter Object. See https://swagger.io/specification/#parameter-object
params.path string Path of the operation. I.e. /orders/{orderId}.
params.pathItem OpenApiPathItem OpenAPI Path Item Object. See https://swagger.io/specification/#path-item-object
params.serviceName? string Name of the service.
params.suggestedName string Suggested name of the argument. Used by default if the callback is not specified.
Returns

string

Example

function generateOperationParameterArgumentName({parameter}) {
        return parameter.in + '_' + parameter.name;
    }

GenerateOperationParameterJsDoc

Ƭ GenerateOperationParameterJsDoc: (params: { httpMethod: string ; operation: OpenApiOperation ; operationName: string ; parameter: OpenApiParameter ; path: string ; pathItem: OpenApiPathItem ; serviceName?: string ; suggestedJsDoc: JsDocBlock }) => JsDocBlock

Type declaration

▸ (params): JsDocBlock

Callback for generating the JSDoc of an operation parameter argument.

Parameters
Name Type Description
params Object -
params.httpMethod string HTTP method of the operation. I.e. get.
params.operation OpenApiOperation OpenAPI Operation Object. See https://swagger.io/specification/#operation-object
params.operationName string Generated class method name for the operation.
params.parameter OpenApiParameter OpenAPI Parameter Object. See https://swagger.io/specification/#parameter-object
params.path string Path of the operation. I.e. /orders/{orderId}.
params.pathItem OpenApiPathItem OpenAPI Path Item Object. See https://swagger.io/specification/#path-item-object
params.serviceName? string Name of the service.
params.suggestedJsDoc JsDocBlock Suggested JSDoc block. Used by default if the callback is not specified.
Returns

JsDocBlock

Example

function generateOperationParameterJsDoc({suggestedJsDoc, parameter}) {
        return {
            ...suggestedJsDoc,
            tags: [
                ...suggestedJsDoc.tags,
                {name: 'name', value: parameter.name},
                {name: 'location', value: parameter.in}
            ]
        };
    }

GenerateOperationRequestBodyArgumentName

Ƭ GenerateOperationRequestBodyArgumentName: (params: { content: OpenApiMediaType ; httpMethod: string ; mediaType: string ; operation: OpenApiOperation ; operationName: string ; path: string ; pathItem: OpenApiPathItem ; requestBody: OpenApiRequestBody ; serviceName?: string ; suggestedName: string }) => string

Type declaration

▸ (params): string

Callback for generating the name of an operation request body argument.

Parameters
Name Type Description
params Object -
params.content OpenApiMediaType OpenAPI Media Type Object. See https://swagger.io/specification/#media-type-object
params.httpMethod string HTTP method of the operation. I.e. get.
params.mediaType string Media type of the request body. I.e. application/json.
params.operation OpenApiOperation OpenAPI Operation Object. See https://swagger.io/specification/#operation-object
params.operationName string Generated class method name for the operation.
params.path string Path of the operation. I.e. /orders/{orderId}.
params.pathItem OpenApiPathItem OpenAPI Path Item Object. See https://swagger.io/specification/#path-item-object
params.requestBody OpenApiRequestBody OpenAPI Request Body Object. See https://swagger.io/specification/#request-body-object
params.serviceName? string Name of the service.
params.suggestedName string Suggested name of the argument. Used by default if the callback is not specified.
Returns

string

Example

function generateOperationRequestBodyArgumentName({suggestedName}) {
        return suggestedName + 'RequestBody';
    }

GenerateOperationRequestBodyJsDoc

Ƭ GenerateOperationRequestBodyJsDoc: (params: { content: OpenApiMediaType ; httpMethod: string ; mediaType: string ; operation: OpenApiOperation ; operationName: string ; path: string ; pathItem: OpenApiPathItem ; requestBody: OpenApiRequestBody ; serviceName?: string ; suggestedJsDoc: JsDocBlock }) => JsDocBlock

Type declaration

▸ (params): JsDocBlock

Callback for generating the JSDoc of an operation request body argument.

Parameters
Name Type Description
params Object -
params.content OpenApiMediaType OpenAPI Media Type Object. See https://swagger.io/specification/#media-type-object
params.httpMethod string HTTP method of the operation. I.e. get.
params.mediaType string Media type of the request body. I.e. application/json.
params.operation OpenApiOperation OpenAPI Operation Object. See https://swagger.io/specification/#operation-object
params.operationName string Generated class method name for the operation.
params.path string Path of the operation. I.e. /orders/{orderId}.
params.pathItem OpenApiPathItem OpenAPI Path Item Object. See https://swagger.io/specification/#path-item-object
params.requestBody OpenApiRequestBody OpenAPI Request Body Object. See https://swagger.io/specification/#request-body-object
params.serviceName? string Name of the service.
params.suggestedJsDoc JsDocBlock Suggested JSDoc block. Used by default if the callback is not specified.
Returns

JsDocBlock

Example

function generateOperationRequestBodyJsDoc({suggestedJsDoc, mediaType}) {
        return {
            ...suggestedJsDoc,
            tags: [...suggestedJsDoc.tags, {name: 'mediaType', value: mediaType}]
        };
    }

GenerateOperationResultDescription

Ƭ GenerateOperationResultDescription: (params: { httpMethod: string ; operation: OpenApiOperation ; path: string ; pathItem: OpenApiPathItem ; serviceName?: string ; suggestedDescription: string }) => string

Type declaration

▸ (params): string

Callback for generating the description of an operation result.

Parameters
Name Type Description
params Object -
params.httpMethod string HTTP method of the operation. I.e. get.
params.operation OpenApiOperation OpenAPI Operation Object. See https://swagger.io/specification/#operation-object
params.path string Path of the operation. I.e. /orders/{orderId}.
params.pathItem OpenApiPathItem OpenAPI Path Item Object. See https://swagger.io/specification/#path-item-object
params.serviceName? string Name of the service.
params.suggestedDescription string Suggested description. Used by default if the callback is not specified.
Returns

string

Example

function generateOperationResultDescription({suggestedDescription, serviceName}) {
        return suggestedDescription + ' for ' + serviceName + ' service.';
    }

GenerateServiceJsDoc

Ƭ GenerateServiceJsDoc: (params: { paths: OpenApiPaths ; serviceName: string ; suggestedJsDoc: JsDocBlock ; tag: OpenApiTag }) => JsDocBlock

Type declaration

▸ (params): JsDocBlock

Callback for generating the JSDoc of a service.

Parameters
Name Type Description
params Object -
params.paths OpenApiPaths OpenAPI Paths Object. See https://swagger.io/specification/#paths-object
params.serviceName string Name of the service.
params.suggestedJsDoc JsDocBlock Suggested JSDoc block. Used by default if the callback is not specified.
params.tag OpenApiTag Tag of the service. The service contains all operations with the same tag. See https://swagger.io/specification/#tag-object
Returns

JsDocBlock

Example

function generateServiceJsDoc({suggestedJsDoc, tag}) {
        return {
            ...suggestedJsDoc,
            tags: [...suggestedJsDoc.tags, {name: 'tag', value: tag.name}]
        };
    }

GenerateServiceName

Ƭ GenerateServiceName: (params: { paths: OpenApiPaths ; suggestedName: string ; tag: OpenApiTag }) => string

Type declaration

▸ (params): string

Callback for generating the name of a service.

Parameters
Name Type Description
params Object -
params.paths OpenApiPaths OpenAPI Paths Object. See https://swagger.io/specification/#paths-object
params.suggestedName string Suggested name of the service. Used by default if the callback is not specified.
params.tag OpenApiTag Tag of the service. The service contains all operations with the same tag. See https://swagger.io/specification/#tag-object
Returns

string

Example

function generateServiceName({tag}) {
        return tag.name.replace(/[^a-zA-Z0-9]/g, '') + 'Service';
    }

OpenApiClientBuiltinBinaryType

Ƭ OpenApiClientBuiltinBinaryType: "blob" | "readableStream"

Built-in binary types for the OpenAPI client generation.


OpenApiClientCustomizableBinaryType

Ƭ OpenApiClientCustomizableBinaryType: OpenApiClientBuiltinBinaryType | OpenApiClientExternalType

Customizable binary type for the OpenAPI client generation.


OpenApiClientExternalValueSourceImportEntity

Ƭ OpenApiClientExternalValueSourceImportEntity: { name: string } | "default"

What needs to be imported from the external source.