在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:AfterShip/swagger-ajv开源软件地址:https://github.com/AfterShip/swagger-ajv开源编程语言:JavaScript 91.8%开源软件介绍:swagger-ajv ·The middleware for validating and documenting express and koa applications.
Compatible with node >= 4 SpecificationNOTE: The middleware must be applied to the router not the application when using koa. The documentation should be written using OpenAPI 3.0 specification with the differences listed below. The differences with JSON schema can be noted here. When writing schema for your application please note that the keywords must be used in a way that can be supported by both Swagger and AJV.
Reference
MiddlewaresswaggerAjv.middlewares.express
swaggerAjv.middlewares.koa
pass the schema object as specified by openapi
pass an object should contain Utils
Test
Building
ExamplesDefine schemas for your application
schema for new component should be defined under {
"components": {
"schemas": {
"Component": {
"type": "object"
}
}
}
}
keys other than {
"openapi": "3.0.0"
}
schema for a path should be defined as under {
"paths": {
"/post": {
"post": {
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"body": {
"type": ["string", "null"]
}
}
}
}
}
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"properties": {
"data": {
"$ref": "#/components/schemas/Component"
}
}
}
}
}
}
}
}
}
}
} Write middleware in your favourite framework
CreditsLicense |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论