nestjs-swagger-instance-creator
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

NestJs Swagger Default Instance Creator

This is a library that reads information from Swagger decorators and creates instances.

How to use

create instance

class Post {
    @ApiProperty({
        description: 'post title',
        default: 'hello',
        required: true,
    })
    title: string | undefined;

    @ApiProperty({
        description: 'post content',
        default: 'world',
        required: false,

    })
    content: string | undefined;
}

const instance = createSwaggerDefaultDto(User);

console.log(instance);
Post { title: 'hello', content: 'world' }

update instance

updateSwaggerDto(instance, { name: 'morgoth' });

const updatedName = instance.name;

console.log(updatedName);
morgoth

Readme

Keywords

none

Package Sidebar

Install

npm i nestjs-swagger-instance-creator

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

1.93 kB

Total Files

2

Last publish

Collaborators

  • hypemova