api-typescript-generator
Advanced tools
Comparing version 2.4.14 to 2.4.15
@@ -126,3 +126,3 @@ [api-typescript-generator](../../README.md) / [Modules](../modules.md) / [openapi-client](../modules/openapi_client.md) / OpenApiClientGeneratorConfigClient | ||
• `Optional` **generateErrorJsDoc**: `GenerateClientErrorJsDoc` | ||
• `Optional` **generateErrorJsDoc**: [`GenerateClientErrorJsDoc`](../modules/openapi_client.md#generateclienterrorjsdoc) | ||
@@ -129,0 +129,0 @@ Client error class JSDoc generation callback. |
@@ -39,2 +39,3 @@ [api-typescript-generator](../../README.md) / [Modules](../modules.md) / openapi-client | ||
- [CommonHttpClientResponseHeaders](openapi_client.md#commonhttpclientresponseheaders) | ||
- [GenerateClientErrorJsDoc](openapi_client.md#generateclienterrorjsdoc) | ||
- [GenerateClientJsDoc](openapi_client.md#generateclientjsdoc) | ||
@@ -78,2 +79,37 @@ - [GenerateModelJsDoc](openapi_client.md#generatemodeljsdoc) | ||
### GenerateClientErrorJsDoc | ||
Ƭ **GenerateClientErrorJsDoc**: (`params`: \{ `info`: [`OpenApiInfo`](../interfaces/openapi.OpenApiInfo.md) ; `suggestedJsDoc`: [`JsDocBlock`](../interfaces/index.JsDocBlock.md) }) => [`JsDocBlock`](../interfaces/index.JsDocBlock.md) | ||
#### Type declaration | ||
▸ (`params`): [`JsDocBlock`](../interfaces/index.JsDocBlock.md) | ||
Callback for generating the JSDoc of a client. | ||
##### Parameters | ||
| Name | Type | Description | | ||
| :------ | :------ | :------ | | ||
| `params` | `Object` | - | | ||
| `params.info` | [`OpenApiInfo`](../interfaces/openapi.OpenApiInfo.md) | OpenAPI Info Object. | | ||
| `params.suggestedJsDoc` | [`JsDocBlock`](../interfaces/index.JsDocBlock.md) | Suggested JSDoc block. Used by default if the callback is not specified. | | ||
##### Returns | ||
[`JsDocBlock`](../interfaces/index.JsDocBlock.md) | ||
**`Example`** | ||
```ts | ||
function generateClientErrorJsDoc({suggestedJsDoc, info}) { | ||
return { | ||
...suggestedJsDoc, | ||
title: 'Error Class for ' + info.summary | ||
}; | ||
} | ||
``` | ||
___ | ||
### GenerateClientJsDoc | ||
@@ -80,0 +116,0 @@ |
@@ -1,2 +0,2 @@ | ||
export type { OpenApiClientGeneratorConfig, GenerateModelJsDoc, GenerateModelNameCallback, GenerateOperationJsDoc, GenerateOperationName, GenerateOperationParameterArgumentName, GenerateOperationParameterJsDoc, GenerateOperationRequestBodyJsDoc, GenerateServiceName, GenerateOperationRequestBodyArgumentName, GenerateOperationResultDescription, GenerateServiceJsDoc, GenerateClientJsDoc, OpenApiClientBuiltinBinaryType, OpenApiClientCustomizableBinaryType, OpenApiClientExternalType, OpenApiClientExternalValue, OpenApiClientExternalValueSource, OpenApiClientGeneratorConfigOperations, OpenApiClientGeneratorConfigClient, OpenApiClientGeneratorConfigModels, OpenApiClientGeneratorConfigServices, OpenApiClientGeneratorConfigCore, OpenApiClientGeneratorConfigValidation, OpenApiClientGeneratorConfigComments, OpenApiClientGeneratorConfigJsDoc, OpenApiClientGeneratorConfigJsDocWordWrap, OpenApiClientGeneratorConfigValidationSchemaStorage, OpenApiClientExternalValueSourceImportEntity } from './schema-to-typescript/openapi-to-typescript-client'; | ||
export type { OpenApiClientGeneratorConfig, GenerateModelJsDoc, GenerateModelNameCallback, GenerateOperationJsDoc, GenerateOperationName, GenerateOperationParameterArgumentName, GenerateOperationParameterJsDoc, GenerateOperationRequestBodyJsDoc, GenerateServiceName, GenerateOperationRequestBodyArgumentName, GenerateOperationResultDescription, GenerateServiceJsDoc, GenerateClientJsDoc, GenerateClientErrorJsDoc, OpenApiClientBuiltinBinaryType, OpenApiClientCustomizableBinaryType, OpenApiClientExternalType, OpenApiClientExternalValue, OpenApiClientExternalValueSource, OpenApiClientGeneratorConfigOperations, OpenApiClientGeneratorConfigClient, OpenApiClientGeneratorConfigModels, OpenApiClientGeneratorConfigServices, OpenApiClientGeneratorConfigCore, OpenApiClientGeneratorConfigValidation, OpenApiClientGeneratorConfigComments, OpenApiClientGeneratorConfigJsDoc, OpenApiClientGeneratorConfigJsDocWordWrap, OpenApiClientGeneratorConfigValidationSchemaStorage, OpenApiClientExternalValueSourceImportEntity } from './schema-to-typescript/openapi-to-typescript-client'; | ||
export type { CommonHttpClientFetchRequest, CommonHttpClientFetchResponse, CommonHttpClientError, CommonHttpClientRequest, CommonHttpClientResponse, CommonHttpClientFetchResponseBody, CommonHttpClientFetchRequestHeaders, CommonHttpClientResponseHeaders, CommonHttpClientOptions, CommonHttpClientRequestHeaders } from './schema-to-typescript/common/core/common-http-client'; |
@@ -60,2 +60,23 @@ "use strict"; | ||
exports.renderJsDocList = renderJsDocList; | ||
function renderJsDocTagAsPlainText(tag) { | ||
let result = `${tag.name}`; | ||
if (tag.value) { | ||
if (tag.name === 'example') { | ||
if (tag.value.match(/^[\n\r \t]/)) { | ||
result += `:${tag.value}`; | ||
} | ||
else { | ||
result += `:${tag.value.replace(/^([^\n]+)\n/, ' "$1":\n```')}\`\`\``; | ||
} | ||
} | ||
else { | ||
result += ':'; | ||
if (!tag.value.match(/^[\n\r \t]/)) { | ||
result += ' '; | ||
} | ||
result += tag.value; | ||
} | ||
} | ||
return result; | ||
} | ||
function renderJsDocAsPlainText(jsdoc) { | ||
@@ -72,3 +93,3 @@ const bits = []; | ||
if (jsdoc.tags.length > 0) { | ||
bits.push(jsdoc.tags.map(({ name, value }) => `${name}${value ? `: ${value.trim()}` : ''}`).join('\n')); | ||
bits.push(jsdoc.tags.map(renderJsDocTagAsPlainText).join('\n')); | ||
} | ||
@@ -75,0 +96,0 @@ if (bits.length === 0) { |
{ | ||
"name": "api-typescript-generator", | ||
"version": "2.4.14", | ||
"version": "2.4.15", | ||
"description": "Generates OpenAPI TypeScript client. Extremely fast and flexible.", | ||
@@ -42,3 +42,3 @@ "license": "MIT", | ||
"build": "rimraf lib && tsc -p tsconfig.build.json && cp -R src/schema-to-typescript/common/core/* lib/schema-to-typescript/common/core && cp -R src/schema-to-typescript/common/validation-providers/zod-validation-provider/*-*.ts lib/schema-to-typescript/common/validation-providers/zod-validation-provider", | ||
"build:docs": "rm -Rf docs && typedoc --exclude test --excludeInternal --excludeExternals --disableSources --plugin typedoc-plugin-markdown --entryDocument ../README.md --out docs src/index.ts src/openapi.ts src/openapi-client.ts && ts-node tools/cleanup-docs.ts", | ||
"build:docs": "rm -Rf docs && typedoc && ts-node tools/cleanup-docs.ts", | ||
"prepublishOnly": "npm run build", | ||
@@ -45,0 +45,0 @@ "lint": "eslint {src,test,tools}/**/*.ts", |
431258
5912