Git Product home page Git Product logo

Comments (3)

xiaoymin avatar xiaoymin commented on May 22, 2024

好的,感谢反馈

from knife4j.

xiaoymin avatar xiaoymin commented on May 22, 2024

第三个,paramsType="query"的显示这个应该是swagger给出的application/json

ui这边应该没有处理的

from knife4j.

xiaoymin avatar xiaoymin commented on May 22, 2024

https的应该是构建curl的功能吧?文档中只有该处我是写死的,发送时没有使用绝对地址

关于第二点,dataTypeClass = BigDecimal.class ,生成文档变成了 string;我测试了下:

代码:

@ApiOperation(value = "BigDecimal类型->String类型",position = 2)
@PostMapping("/dataBigDeciaml1")
@ApiImplicitParam(name = "bigDecimal",dataTypeClass = BigDecimal.class,value = "工资",required = true)
public Rest<BigDecimal> dataBigDeciaml1(BigDecimal bigDecimal){
      Rest<BigDecimal> r=new Rest<>();
      r.setData(bigDecimal);
      return r;
}

最终查看swagger生成的json文件结构如下:

{
    "post": {
        "tags": [
            "1.8.5版本-20180925"
        ],
        "summary": "BigDecimal类型->String类型",
        "operationId": "dataBigDeciaml1UsingPOST",
        "consumes": [
            "application/json"
        ],
        "produces": [
            "*/*"
        ],
        "parameters": [
            {
                "name": "bigDecimal",
                "in": "query",
                "description": "工资",
                "required": true,
                "type": "string"
            }
        ],
        "responses": {
            "200": {
                "description": "OK",
                "schema": {
                    "$ref": "#/definitions/Rest«bigdecimal»"
                }
            },
            "201": {
                "description": "Created"
            },
            "401": {
                "description": "Unauthorized"
            },
            "403": {
                "description": "Forbidden"
            },
            "404": {
                "description": "Not Found"
            }
        },
        "security": [
            {
                "BearerToken": [
                    "global"
                ]
            },
            {
                "BearerToken1": [
                    "global"
                ]
            }
        ],
        "deprecated": false
    }
}

从结构中,swagger给出的BigDecimal类型是string,还有consumes ["application/json"],所以UI显示的也是如此

如果用下面Java方法类测试:

@ApiOperation(value = "BigDecimal类型解析为String类型",position = 1)
@GetMapping("/dataBigDeciaml")
public Rest<Model1851> dataBigDeciaml(@RequestBody Model1851 model1851){
        Rest<Model1851> r=new Rest<>();
        r.setData(model1851);
        return r;
}

Model1851 类包含BigDecimal类型

public class Model1851 {

    private BigDecimal total;

    private String name;
    //getter and setter....
}

生成的BigDecimal是Number类型.

Swagger的json结构如下:

{
    "get": {
        "tags": [
            "1.8.5版本-20180925"
        ],
        "summary": "BigDecimal类型解析为String类型",
        "operationId": "dataBigDeciamlUsingGET",
        "produces": [
            "*/*"
        ],
        "parameters": [
            {
                "in": "body",
                "name": "model1851",
                "description": "model1851",
                "required": true,
                "schema": {
                    "$ref": "#/definitions/Model1851"
                }
            }
        ],
        "responses": {
            "200": {
                "description": "OK",
                "schema": {
                    "$ref": "#/definitions/Rest«Model1851»"
                }
            },
            "401": {
                "description": "Unauthorized"
            },
            "403": {
                "description": "Forbidden"
            },
            "404": {
                "description": "Not Found"
            }
        },
        "security": [
            {
                "BearerToken": [
                    "global"
                ]
            },
            {
                "BearerToken1": [
                    "global"
                ]
            }
        ],
        "deprecated": false
    }
}

from knife4j.

Related Issues (20)

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.