代码拉取完成,页面将自动刷新
This is a demo to show users how to construct OpenAPI specification to allow certain field to be null. If only one data type is defined and a null value is passed in, the built-in JSON schema validator will report an error.
In this demo we have a post endpoint with start date in the body. In order to allow startDate to be null, we have to define this field in yaml as
startDate:
type:
- "string"
- "null"
format: "date"
And corresponding JSON field is
"startDate": {
"type": [
"string",
"null"
],
"format": "date"
},
Run with
mvn package exec:exec
``
## Test
As this is just a simple demo, no security definitions in the spec. The post
endpoint url is
localhost:8080/v1/data
Header Content-Type must be set as application/json
Content-Type=application/json
And you can use this JSON object as request body.
{ "id": 123, "name": "king", "weight": 76.22, "startDate": null }
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。