@fastify-plus/openapi
TypeScript icon, indicating that this package has built-in type declarations

0.2.1-alpha.0 • Public • Published

OpenApi Specification

this package define the api schema and export common decorators

Define Api

// optional tag, default is class name
@ApiTag('User')
@Controller('users')
class UserController {
  @Post({ description: 'create a new user' })
  @ApiOkResponse({ type: Number, description: 'return created user id' })
  async createUser(
    @ApiRequestBody({ description: 'user schema' }) userSchema: UserSchema,
  ): Promise<number> {
    return 1;
  }

  @Get()
  @ApiOkResponse({ type: UserSchema })
  async getUser(@ApiRequestQuery() id: number) {
    return new UserSchema();
  }
}

@ApiSchema({ description: 'user' })
class UserSchema {
  @ApiSchema({
    description: 'user id',
    required: false,
  })
  id?: number;

  @ApiSchema()
  username: string;

  @ApiSchema()
  password: string;
}

/@fastify-plus/openapi/

    Package Sidebar

    Install

    npm i @fastify-plus/openapi

    Weekly Downloads

    0

    Version

    0.2.1-alpha.0

    License

    MIT

    Unpacked Size

    355 kB

    Total Files

    175

    Last publish

    Collaborators

    • metauro