Skip to content

Commit

Permalink
feat: add support for deprecated api property
Browse files Browse the repository at this point in the history
  • Loading branch information
glebbash committed Dec 20, 2021
1 parent dbd7bd8 commit c1ceaf7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/core.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,32 @@ describe('core options', () => {
});
});

describe('description and depreacted properties', () => {
class Test {
@DtoDecorator({
description: 'Deprecated. Just a normal boolean field',
deprecated: true,
})
booleanField!: boolean;
}

it('generates correct schema', async () => {
expect(await generateSchemas([Test])).toStrictEqual({
Test: {
type: 'object',
properties: {
booleanField: {
type: 'boolean',
description: 'Deprecated. Just a normal boolean field',
deprecated: true,
},
},
required: ['booleanField'],
},
});
});
});

describe('optional', () => {
class Test {
@DtoDecorator({ optional: true, meta: 'hello' })
Expand Down
3 changes: 3 additions & 0 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type BasePropertyOptions = {
name?: string;
optional?: true;
description?: string;
deprecated?: true;
nullable?: true;
};

Expand All @@ -35,6 +36,7 @@ export const compose = <T, CustomOptions>(
example,
optional,
description,
deprecated,
default: def,
name,
}: PropertyOptions<T, CustomOptions>,
Expand Down Expand Up @@ -62,6 +64,7 @@ export const compose = <T, CustomOptions>(
isArray: !!isArray,
name,
description,
deprecated,
example,
default: def,
required: !optional,
Expand Down

0 comments on commit c1ceaf7

Please sign in to comment.