【发布时间】:2020-03-14 13:38:08
【问题描述】:
应用背景
- Spring Boot 1.5.12 版
- 通过 swagger-codegen-maven-plugin 生成的 Java bean
问题
使用开放 API 3.0 创建的 swagger 模板使用 swagger-codegen-maven-plugin 转换为 pojos..
这里是生成pojo
public class TestPojo {
@JsonProperty("isNameValid")
private Boolean isNameValid = null;
@Schema(
required = true,
description = "Checks if name is Valid "
)
public Boolean isIsNameValid() {
return this.isNameValid;
}
}
这里是使用的招摇模板
openapi: 3.0.1
info:
title: XM MNOLine Domain Definitions
description: |
version: "V0.0.1"
components:
schemas:
TestPojo:
required:
- isNameValid
properties:
isNameValid:
type: boolean
description: |
Checks if name is Valid
在控制器中,@Valid 注释似乎没有任何影响..字段“isNameValid”的空值或无值仍在处理..
processRequest(@Valid @RequestBody TestPojo request)
我错过了什么..
【问题讨论】:
标签: java spring spring-boot openapi