api-typescript-generator / Modules / openapi-client
- CommonHttpClientFetchRequest
- CommonHttpClientFetchRequestHeaders
- CommonHttpClientFetchResponse
- CommonHttpClientOptions
- CommonHttpClientRequestHeaders
- CommonHttpClientRequestParameterSerializeInfo
- CommonHttpClientResponse
- OpenApiClientExternalType
- OpenApiClientExternalValue
- OpenApiClientExternalValueSource
- OpenApiClientGeneratorConfig
- OpenApiClientGeneratorConfigClient
- OpenApiClientGeneratorConfigComments
- OpenApiClientGeneratorConfigCore
- OpenApiClientGeneratorConfigJsDoc
- OpenApiClientGeneratorConfigJsDocWordWrap
- OpenApiClientGeneratorConfigModels
- OpenApiClientGeneratorConfigOperations
- OpenApiClientGeneratorConfigServices
- OpenApiClientGeneratorConfigValidation
- OpenApiClientGeneratorConfigValidationSchemaStorage
- CommonHttpClientFetchResponseBody
- CommonHttpClientRequest
- CommonHttpClientRequestParameterLocation
- CommonHttpClientRequestParameterSerializeStyle
- CommonHttpClientRequestParameters
- CommonHttpClientResponseHeaders
- GenerateClientErrorJsDoc
- GenerateClientJsDoc
- GenerateCoreJsDoc
- GenerateModelJsDoc
- GenerateModelNameCallback
- GenerateOperationJsDoc
- GenerateOperationName
- GenerateOperationParameterArgumentName
- GenerateOperationParameterJsDoc
- GenerateOperationRequestBodyArgumentName
- GenerateOperationRequestBodyJsDoc
- GenerateOperationResultDescription
- GenerateServiceJsDoc
- GenerateServiceName
- OpenApiClientBuiltinBinaryType
- OpenApiClientCustomizableBinaryType
- OpenApiClientExternalValueSourceImportEntity
Ƭ CommonHttpClientFetchResponseBody: { data: unknown ; type: "json" } | { data: Blob ; type: "blob" } | { data: ReadableStream<Uint8Array> ; type: "readableStream" }
Ƭ 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: "path" | "query" | "header" | "cookie"
Request parameter location.
Ƭ CommonHttpClientRequestParameterSerializeStyle: "simple" | "label" | "matrix" | "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"
Parameter serialization style.
Ƭ CommonHttpClientRequestParameters: { [K in CommonHttpClientRequestParameterLocation]?: Record<string, CommonHttpClientRequestParameterSerializeInfo> }
Request parameters.
Ƭ CommonHttpClientResponseHeaders: Record<string, string> & { set-cookie?: string[] }
Ƭ GenerateClientErrorJsDoc: (params: { info: OpenApiInfo ; suggestedJsDoc: JsDocBlock }) => JsDocBlock
▸ (params): JsDocBlock
Callback for generating the JSDoc of a client.
| 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. |
Example
function generateClientErrorJsDoc({suggestedJsDoc, info}) {
return {
...suggestedJsDoc,
title: 'Error Class for ' + info.summary
};
}Ƭ GenerateClientJsDoc: (params: { info: OpenApiInfo ; suggestedJsDoc: JsDocBlock }) => JsDocBlock
▸ (params): JsDocBlock
Callback for generating the JSDoc of a client.
| 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. |
Example
function generateClientJsDoc({suggestedJsDoc, info}) {
return {
title: info.summary,
description: info.description,
tags: [{name: 'version', value: info.version}]
};
}Ƭ GenerateCoreJsDoc: (params: { memberName?: string ; suggestedJsDoc: JsDocBlock ; typeName: string }) => JsDocBlock
▸ (params): JsDocBlock
Callback for generating the JSDoc for core classes.
| 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. |
Example
function GenerateCoreJsDoc({suggestedJsDoc}) {
return {
...suggestedJsDoc,
tags: [...suggestedJsDoc.tags, {name: 'internal'}]
};
}Ƭ GenerateModelJsDoc: (params: { fieldPath: OpenApiSchemaFieldPathItem[] ; schema: OpenApiSchema ; schemaName: string ; suggestedJsDoc: JsDocBlock }) => JsDocBlock
▸ (params): JsDocBlock
Callback for generating the JSDoc of a model.
| 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. |
Example
function generateModelJsDoc({suggestedJsDoc, schemaName, fieldPath}) {
if (fieldPath.length === 0) {
return {
title: schemaName,
...suggestedJsDoc
};
} else {
return suggestedJsDoc;
}
}Ƭ GenerateModelNameCallback: (context: { schemaName: string ; suggestedName: string }) => string
▸ (context): string
Callback for generating the name of a model.
| 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. |
string
Example
function generateModelName({suggestedName, schemaName, fieldPath}) {
if (fieldPath.length === 0) {
return schemaName + 'Model';
} else {
return suggestedName;
}
}Ƭ GenerateOperationJsDoc: (params: { httpMethod: string ; operation: OpenApiOperation ; path: string ; pathItem: OpenApiPathItem ; serviceName?: string ; suggestedJsDoc: JsDocBlock }) => JsDocBlock
▸ (params): JsDocBlock
Callback for generating the JSDoc of an operation.
| 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. |
Example
function generateOperationJsDoc({suggestedJsDoc, path, httpMethod}) {
return {
...suggestedJsDoc,
tags: [...suggestedJsDoc.tags, {name: 'path', value: `{${httpMethod}} ${path}`}]
};
}Ƭ GenerateOperationName: (params: { httpMethod: string ; operation: OpenApiOperation ; path: string ; pathItem: OpenApiPathItem ; serviceName?: string ; suggestedName: string }) => string
▸ (params): string
Callback for generating the name of an operation.
| 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. |
string
Example
function generateOperationName({operation, httpMethod}) {
return `${httpMethod}_${operation.operationId}`;
}Ƭ GenerateOperationParameterArgumentName: (params: { httpMethod: string ; operation: OpenApiOperation ; operationName: string ; parameter: OpenApiParameter ; path: string ; pathItem: OpenApiPathItem ; serviceName?: string ; suggestedName: string }) => string
▸ (params): string
Callback for generating the name of an operation parameter argument.
| 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. |
string
Example
function generateOperationParameterArgumentName({parameter}) {
return parameter.in + '_' + parameter.name;
}Ƭ GenerateOperationParameterJsDoc: (params: { httpMethod: string ; operation: OpenApiOperation ; operationName: string ; parameter: OpenApiParameter ; path: string ; pathItem: OpenApiPathItem ; serviceName?: string ; suggestedJsDoc: JsDocBlock }) => JsDocBlock
▸ (params): JsDocBlock
Callback for generating the JSDoc of an operation parameter argument.
| 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. |
Example
function generateOperationParameterJsDoc({suggestedJsDoc, parameter}) {
return {
...suggestedJsDoc,
tags: [
...suggestedJsDoc.tags,
{name: 'name', value: parameter.name},
{name: 'location', value: parameter.in}
]
};
}Ƭ GenerateOperationRequestBodyArgumentName: (params: { content: OpenApiMediaType ; httpMethod: string ; mediaType: string ; operation: OpenApiOperation ; operationName: string ; path: string ; pathItem: OpenApiPathItem ; requestBody: OpenApiRequestBody ; serviceName?: string ; suggestedName: string }) => string
▸ (params): string
Callback for generating the name of an operation request body argument.
| 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. |
string
Example
function generateOperationRequestBodyArgumentName({suggestedName}) {
return suggestedName + 'RequestBody';
}Ƭ GenerateOperationRequestBodyJsDoc: (params: { content: OpenApiMediaType ; httpMethod: string ; mediaType: string ; operation: OpenApiOperation ; operationName: string ; path: string ; pathItem: OpenApiPathItem ; requestBody: OpenApiRequestBody ; serviceName?: string ; suggestedJsDoc: JsDocBlock }) => JsDocBlock
▸ (params): JsDocBlock
Callback for generating the JSDoc of an operation request body argument.
| 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. |
Example
function generateOperationRequestBodyJsDoc({suggestedJsDoc, mediaType}) {
return {
...suggestedJsDoc,
tags: [...suggestedJsDoc.tags, {name: 'mediaType', value: mediaType}]
};
}Ƭ GenerateOperationResultDescription: (params: { httpMethod: string ; operation: OpenApiOperation ; path: string ; pathItem: OpenApiPathItem ; serviceName?: string ; suggestedDescription: string }) => string
▸ (params): string
Callback for generating the description of an operation result.
| 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. |
string
Example
function generateOperationResultDescription({suggestedDescription, serviceName}) {
return suggestedDescription + ' for ' + serviceName + ' service.';
}Ƭ GenerateServiceJsDoc: (params: { paths: OpenApiPaths ; serviceName: string ; suggestedJsDoc: JsDocBlock ; tag: OpenApiTag }) => JsDocBlock
▸ (params): JsDocBlock
Callback for generating the JSDoc of a service.
| 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 |
Example
function generateServiceJsDoc({suggestedJsDoc, tag}) {
return {
...suggestedJsDoc,
tags: [...suggestedJsDoc.tags, {name: 'tag', value: tag.name}]
};
}Ƭ GenerateServiceName: (params: { paths: OpenApiPaths ; suggestedName: string ; tag: OpenApiTag }) => string
▸ (params): string
Callback for generating the name of a service.
| 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 |
string
Example
function generateServiceName({tag}) {
return tag.name.replace(/[^a-zA-Z0-9]/g, '') + 'Service';
}Ƭ OpenApiClientBuiltinBinaryType: "blob" | "readableStream"
Built-in binary types for the OpenAPI client generation.
Ƭ OpenApiClientCustomizableBinaryType: OpenApiClientBuiltinBinaryType | OpenApiClientExternalType
Customizable binary type for the OpenAPI client generation.
Ƭ OpenApiClientExternalValueSourceImportEntity: { name: string } | "default"
What needs to be imported from the external source.