0.1.0-snapshot.15 • Published 4 years ago

@zhaochy/egg-swagger-ts v0.1.0-snapshot.15

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

使用说明

这个项目通过注解的方式生成Swagger文档

支持以下注解:

APIGroup

这个是类注解,作用于Controller上

@APIGroup(options: object)

options包括prefix和tags

Get, Post, Put, Delete, Patch

@Get(path: string)

用于描述url

Summary

@Summary(summary: string)

Description

@Description(description: string)

Security

@Security(type: string)

默认所有API开启JWT认证 如果某个API不需要认证,那么参数type填'none'

Throws

@Throws(code: number)

支持如下错误类型:

  • 400
  • 401
  • 403
  • 404
  • 500

RequestBody

@RequestBody(schema: object | string)

支持复用项目内置的joi schema(参数为string)

也可以写标准的JSON schema

SuccessBody

@SuccessBody(schema: object)

输出的Response body

Parameter

@Parameter(param: object) 用于描述参数,如果有多个参数,可以写多个注解