From 8598e346f34d4e540ea0049233c92620d6efd02d Mon Sep 17 00:00:00 2001 From: Akshit Gupta <96991785+akkshitgupta@users.noreply.github.com> Date: Thu, 15 Feb 2024 14:38:25 +0530 Subject: [PATCH] fix: generate doc for getters (#1780) --- .../typescript/presets/DescriptionPreset.ts | 2 +- .../__snapshots__/DescriptionPreset.spec.ts.snap | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/generators/typescript/presets/DescriptionPreset.ts b/src/generators/typescript/presets/DescriptionPreset.ts index a11612c030..8c9cd86a69 100644 --- a/src/generators/typescript/presets/DescriptionPreset.ts +++ b/src/generators/typescript/presets/DescriptionPreset.ts @@ -37,7 +37,7 @@ export const TS_DESCRIPTION_PRESET: TypeScriptPreset = { self({ renderer, model, content }) { return renderDescription({ renderer, content, item: model }); }, - property({ renderer, property, content }) { + getter({ renderer, property, content }) { return renderDescription({ renderer, content, item: property.property }); } }, diff --git a/test/generators/typescript/preset/__snapshots__/DescriptionPreset.spec.ts.snap b/test/generators/typescript/preset/__snapshots__/DescriptionPreset.spec.ts.snap index 59f18c2017..6d1ad289d4 100644 --- a/test/generators/typescript/preset/__snapshots__/DescriptionPreset.spec.ts.snap +++ b/test/generators/typescript/preset/__snapshots__/DescriptionPreset.spec.ts.snap @@ -6,14 +6,7 @@ exports[`Description generation should render example function for model 1`] = ` */ class Test { private _stringProp: string; - /** - * Description - * @example Example - */ private _numberProp?: number; - /** - * @example Example 1, Example 2 - */ private _objectProp?: NestedTest; private _additionalProperties?: Map; @@ -32,9 +25,16 @@ class Test { get stringProp(): string { return this._stringProp; } set stringProp(stringProp: string) { this._stringProp = stringProp; } + /** + * Description + * @example Example + */ get numberProp(): number | undefined { return this._numberProp; } set numberProp(numberProp: number | undefined) { this._numberProp = numberProp; } + /** + * @example Example 1, Example 2 + */ get objectProp(): NestedTest | undefined { return this._objectProp; } set objectProp(objectProp: NestedTest | undefined) { this._objectProp = objectProp; }