Giter VIP home page Giter VIP logo

panda-api's Introduction

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:

  1. A better online read api docs.
  2. Use json or json5 to write the api docs,eazy to lean and write.
  3. Manage you api docs change as your code with git.
  4. You can use Panda api as a back end api service with out backend develop.
  5. Panda api takes test data helps developers auto test back end and front end
  6. Suport define test case data
  7. Mork data auto created
  8. Environment route support, you can change the back end on panda api to development, test, production
  9. Websocket support

Getting started

Install

A auth api docus

{
    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"}
            }
        ]
    }
]}

Field options

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:

name

the field name, default is the field

desc

the field description, defaulti is ""

type

default it string, the type can be: string, number, bool, object, array

default

the field default value

enum

enum value list , ex: enum:["a", "b", "c"]

required

If false, the field is optional. Default is true.

Examples

  1. Basics
  2. Inherit from models
  3. Global field settings

Panda Api 如何使用

panda-api's People

Contributors

arlicle avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.