Comments (3)
可以参考 swagger 的语法,没有做额外的处理
// 定义 swagger 的默认返回格式
export const defaultResponse = {
403: {
description: 'Forbidden'
},
500: {
description: 'Internal Server Error'
},
200: {
// response 这里还是遵循 swagger 的语法,没有做额外的封装,因为之前没有特殊的需求要严格定义返回的字段
// 如果有需求这边也可以做和请求入参一样的封装
description: 'success',
schema: {
// 通过 schema 定义返回的字段格式
type: 'object',
properties: {
status_code: { type: 'number' },
data: { type: 'object' },
message: { type: 'string' }
}
}
}
};
from koa-swagger-decorator.
+1
from koa-swagger-decorator.
可以参考 swagger 的语法,没有做额外的处理
// 定义 swagger 的默认返回格式 export const defaultResponse = { 403: { description: 'Forbidden' }, 500: { description: 'Internal Server Error' }, 200: { // response 这里还是遵循 swagger 的语法,没有做额外的封装,因为之前没有特殊的需求要严格定义返回的字段 // 如果有需求这边也可以做和请求入参一样的封装 description: 'success', schema: { // 通过 schema 定义返回的字段格式 type: 'object', properties: { status_code: { type: 'number' }, data: { type: 'object' }, message: { type: 'string' } } } } };
收到,谢谢。建议文档备注下这个,star一下
from koa-swagger-decorator.
Related Issues (20)
- No swagger doc shows when using export instead of export default HOT 1
- 参数校验失败,返回400和error, 是否可以自定义格式? HOT 2
- validator loses return value from next middleware
- 生产如何关闭swagger HOT 1
- Incorrect "main" file path in 1.8.1 HOT 1
- add response body example to responses HOT 1
- Check failure HOT 1
- date format should check 'yyyy-MM-dd' as stated in OpenAPI definition
- Add support for sorthing methods based on Request Type or alphabetically
- Add support for HEAD Request
- Controller resets on each request
- Can it support the array body?
- Can it support array body? HOT 1
- Could this support ESM when I set module 'ESNext' at tsconfig.json HOT 2
- SyntaxError: Invalid or unexpected token HOT 1
- tsconfig.json报错
- securityDefinitions 增加header属性不生效 HOT 1
- Swagger "spec" attribute is doing nothing. HOT 1
- too specific HOT 1
- 在最新的版本文档中未看到Authorize如何配置,请问这一块如何配置? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from koa-swagger-decorator.