与JsonNode结合使用

时间:2019-08-21 13:53:33

标签: java spring-boot swagger swagger-ui

我有一个PATCH方法,该方法将输入的JSON作为JsonNode通过JSON Schema对其进行验证并执行一些逻辑。

方法:

@PatchMapping(UPDATE_OR_ADD_LINE, produces = [APPLICATION_JSON_VALUE])
fun updateOrAddLines(@PathVariable id: String, @RequestBody request: JsonNode): Response {
    validationService.validatePatchLines(request = request)
    return lineService.updateOrAddLines(id = id, request = request)
}

JSON模式:

{
  "definitions": {},
  "type": "object",
  "required": [
    "updateBy",
    "lines"
  ],
  "properties": {
    "updateBy": {
      "type": "string",
      "minLength": 1,
      "pattern": "^(.*)$"
    },
    "lines": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "lineId"
        ],
        "properties": {
          "lineId": {
            "type": "string",
            "pattern": "^(.*)$"
          },
          "itemReference": {
            "type": "string",
            "pattern": "^(.*)$"
          },
          "price": {
            "type": "number",
            "minimum": 0.0
          },
          "quantity": {
            "type": "number",
            "minimum": 0.0
          }
        }
      }
    }
  }
}

问题:生成的Swagger没有将输入显示为显示所有JSON属性的JSON模型。

期望:我想通过JSON模式生成Swagger

0 个答案:

没有答案