panda-api | 中文文档
Panda api makes it easier to build better api docs more quickly and easy for front end and back end.
Panda api encourages test driven development. it takes care of much of the hassle of web development between front end and back end, when you write done your api docs, you can focus on writing front end without needing to finish the backend. It’s free and open source.
Why Panda Api:
- A better online read api docs.
- Use json or json5 to write the api docs,eazy to lean and write.
- Manage you api docs change as your code with git.
- You can use Panda api as a back end api service with out backend develop.
- Panda api takes test data helps developers auto test back end and front end
- Suport define test case data
- Mork data auto created
- Environment route support, you can change the back end on panda api to development, test, production
- Websocket support
{
name:"Auth",
desc:"user login and logout",
order:1,
api:
[{
name:"user login",
desc:"if user login success, will get a token",
method: "POST",
url:"/login/",
body_mode:"json", // form-data, text, json, html, xml, javascript, binary
body:{
username:{name: "username"},
password:{name: "password"}
},
response:{
code:{name:"response result code", type:"int", desc:"success is 1"},
msg:{name:"response result message", type:"string", desc:""},
token:{name:"login success, get a user token; login failed, no token", type:"string", required:false}
},
test_data:[
{
body:{username:"edison", password:"123"},
response:{code:-1, msg:"password incorrect"}
},
{
body:{username:"lily", password:"123"},
response:{code:-2, msg:"username not exist"}
},
{
body:{username:"root", password:"123"},
response:{code:1, msg:"login success", token:"fjdlkfjlafjdlaj3jk2l4j"}
},
{
body:{username:"lily"},
response:{code:-1, msg:"password is required"}
},
{
body:{password:"123"},
response:{code:-1, msg:"username is required"}
}
]
},
{
name:"user logout",
method:"GET",
url:"/logout/",
query:{
id:{name:"user id"},
username:{}
},
response:{
code:{name:"response result code", type:"int", desc:"success is 1"},
msg:{name:"response result message", type:"string", desc:""}
},
test_data:[
{
query:{id:1, username:"root"},
response:{code:1, msg:"logout success"}
},
{
response:{code:-1, msg:"error"}
},
{
query:{id:3, username:"lily"},
response:{code:-1, msg:"username and id not match"}
}
]
}
]}
Each field takes a set of field-specific arguments (documented in the body、query、response field reference).
There’s also a set of common arguments available to all field types. All are optional. Here’s a quick summary of the most often-used ones:
the field name, default is the field
the field description, defaulti is ""
default it string, the type can be: string, number, bool, object, array
the field default value
enum value list , ex: enum:["a", "b", "c"]
If false, the field is optional. Default is true.