# @fastify-plus/openapi

> modern fastify (@openapi)

Latest version **0.2.1-alpha.0** (published 2020-01-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @fastify-plus/openapi
pnpm add @fastify-plus/openapi
yarn add @fastify-plus/openapi
bun add @fastify-plus/openapi
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1-alpha.0 |
| Published | 2020-01-20 |
| First published | 2020-01-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 346.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | zhongyuanjia |
| Maintainers | metauro |

## Links

- npm: https://www.npmjs.com/package/@fastify-plus/openapi
- npm.io page: https://npm.io/package/@fastify-plus/openapi

## Dependencies (5)

- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [is-class](https://npm.io/package/is-class.md) ^0.0.9
- [url-join](https://npm.io/package/url-join.md) ^4.0.1
- [utility-types](https://npm.io/package/utility-types.md) ^3.10.0
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.13

## Recent versions

- 0.2.1-alpha.0 (latest) — 2020-01-20
- 0.2.0-alpha.0 — 2020-01-20

## README

### OpenApi Specification

this package define the api schema and export common decorators

### Define Api

```typescript
// 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;
}
```

---
_Source: https://npm.io/package/@fastify-plus/openapi · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
