Git Product home page Git Product logo

panda-api's Introduction

Hello World

Statistics

Lang

panda-api's People

Contributors

arlicle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

panda-api's Issues

rustfmt?

There are parts of code that do not appear to be properly formatted. Maybe run rustfmt across the repository for potential improvements in readability? 🙏

README 里补充源码安装方法以及一些其他使用建议

  1. 使用下载的Linux安装包,直接在解压的目录里运行./panda, 无法加载网页内容。(使用安装命令以后可以)。希望能添加无需安装的运行方式以及源码编译运行的命令。

  2. -h--help 留给使用说明。

源码无法构建

你好,我执行cargo run无法正确构建项目

我的环境如下:
rustc 1.41.1 (f3e1a954d 2020-02-24)
rustup 1.21.1 (7832b2ebe 2019-12-20)
cargo 1.41.0 (626f0f40e 2019-12-03)

rustup show
Default host: x86_64-apple-darwin

我执行cargo run 出现以下错误:
Compiling failure_derive v0.1.6
Compiling serde_json v1.0.48
Compiling serde_urlencoded v0.6.1
Compiling actix-router v0.2.4
error[E0433]: failed to resolve: could not find __rt in quote
--> /Users/xuexi/.cargo/registry/src/github.com-1ecc6299db9ec823/failure_derive-0.1.6/src/lib.rs:107:70
|
107 | fn display_body(s: &synstructure::Structure) -> Result<Optionquote::__rt::TokenStream, Error> {
| ^^^^ could not find __rt in quote

error: aborting due to previous error

For more information about this error, try rustc --explain E0433.
error: could not compile failure_derive.
warning: build failed, waiting for other jobs to finish...
error: build failed

是我的环境问题吗?我对rust了解不是很多,希望能得到帮助,谢谢。

执行cargo run发生错误

INFO actix_server::builder > Starting 32 workers
thread '' panicked at 'called Result::unwrap() on an Err value: Io(Os { code: 28, kind: Other, message: "No space left on device" })', src/libcore/result.rs:1188:5
stack backtrace:
INFO actix_server::builder > Starting "actix-web-service-0.0.0.0:8081" service on 0.0.0.0:8081
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print_fmt
at src/libstd/sys_common/backtrace.rs:84
3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
at src/libstd/sys_common/backtrace.rs:61
4: core::fmt::write
at src/libcore/fmt/mod.rs:1025
5: std::io::Write::write_fmt
at src/libstd/io/mod.rs:1426
6: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:65
7: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:50
8: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:193
9: std::panicking::default_hook
at src/libstd/panicking.rs:210
10: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:471
11: rust_begin_unwind
at src/libstd/panicking.rs:375
12: core::panicking::panic_fmt
at src/libcore/panicking.rs:84
13: core::result::unwrap_failed
at src/libcore/result.rs:1188
14: core::result::Result<T,E>::unwrap
at /rustc/5e1a799842ba6ed4a57e91f7ab9435947482f7d8/src/libcore/result.rs:956
15: panda_api::utils::watch_api_docs_change::{{closure}}
at src/utils.rs:22
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.

能否支持多个项目

像这样用
docs/projectA/XXX.json5
docs/projectB/YYY.json5
docs/projectC/ZZZ.json5

cd docs && panda

在mock 的时候, 想调用projectA 中的API 则需要带上 projectA 前缀 e.g. /projectA/login

json5 文件中的 method 为数组,包含两个非GET的字段,在线浏览时,method 显示为 GET

例如:article.json5 文件内容如下:
method 为 ["POST", "PUT"],在 test_case 中每个 api 明确具体的 method.

{
    name:"Article",
    apis:[
        {
            name:"Article add or edit",
            url:"/post/add/",
            method:["POST", "PUT"],
            body_mode:"json",
            body:{
                id:{name:"article id", desc:"has id field is edit, no id field is add", type:"number", required:false},
                title:{},
            },
            response:{
                code:{name:"response result code", type:"int", desc:"success is 1"},
                msg:{name:"response result message", type:"string", desc:""},
                id: {name:"article id"}
            },
            test_data:[
                {
                    // add a article
                    method:"POST",
                    body:{
                        title:"Hello World",
                    },
                    response:{
                        code: 1,
                        msg:"post done",
                        id: 1,
                    }
                },
                {
                    // edit a article
                    method:"PUT",
                    body:{
                        title:"Hello World",
                    },
                    response:{
                        code: 1,
                        msg:"post done",
                        id: 1,
                    }
                }
            ]
        },

在线浏览时,此接口的 method 默认显示为 GET,但点击下拉框时会出现"POST" 和 "PUT" 两个可选择项。这里为什么不是默认显示数据中的第一个字段,如 "POST",点击下拉框时显示出 "PUT" 呢。
image

若 json5 文件中 method 为数据,但是数据中只有一个字段,如 ["POST"],在线浏览时查看这个接口的数据返回则是正常的。
article.json5 文件内容如下:

{
    name:"Article",
    apis:[
        {
            name:"Article add or edit",
            url:"/post/add/",
            method:["POST"],
            body_mode:"json",
            body:{
                id:{name:"article id", desc:"has id field is edit, no id field is add", type:"number", required:false},
                title:{},
            },
            response:{
                code:{name:"response result code", type:"int", desc:"success is 1"},
                msg:{name:"response result message", type:"string", desc:""},
                id: {name:"article id"}
            },
            test_data:[
                {
                    // add a article
                    method:"POST",
                    body:{
                        title:"Hello World",
                    },
                    response:{
                        code: 1,
                        msg:"post done",
                        id: 1,
                    }
                }
            ]
        },

在线浏览这个接口时显示为
image

json5文件中接口字段名为 type,报错panicked at 'called `Option::unwrap()` on a `None` value'

接口中字段参数名为type,启动服务后报错

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/5e1a799842ba6ed4a57e91f7ab9435947482f7d8/src/libcore/macros/mod.rs:15:40
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
Panic in Arbiter thread.

使用 panda-api 源代码在本地运行,内容显示正常
接口文档例子:

{
  name: "name",
  desc: "desc",
  order: 1,
  apis: [
    {
      name: "name",
      desc: "desc",
      method: "POST",
      url: "my_api_url",
      body_mode: "json",
      body: {
        type: { name: "查询时间类型,[Day|Week|Month]" }, // 这里的 type 字段被认为是数据类型了导致服务报错
        beginDate: { name: "查询开始时间" },
        endDate: { name: "查询截至时间" },
      },
      response: {
        code: {
          name: "返回结果的代码",
          type: "int",
          desc: "登录成功返回1, 登录失败返回-1",
          enum: [-1, 1]
        },
        msg: {
          name: "登录成功返回消息",
          type: "csentence",
          desc: "通常返回都是空"
        }
      },
      test_data: [
.....
      ]
    }
  ]
}

desc配置了不显示

你好 我在auth.json5上配置了如下信息
{
name:"用户",
desc:"用户登录系统、退出登录系统",
}
但在页面上对于desc不会生效
image

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.