繁体   English   中英

Springdoc Openapi - 添加响应示例值

[英]Springdoc Openapi - Add Response Example Value

我正在尝试将示例响应值添加到我的 springdoc-openapi swagger 文档中。

比如用“Mark Twain”等替换“string”。

在此处输入图像描述

我尝试使用此解决方案 - springdoc-openapi: How to add example of POST request?

我已经在我的 class 中使用org.springframework.web.bind.annotation.RequestBody

如果我用这个 -
@io.swagger.v3.oas.annotations.parameters.RequestBody(content = @Content(examples = { @ExampleObject( name = "Person sample", summary = "person example", value = "{"email": test@ gmail.Com," + ""firstName": "josh"," + ""lastName": "spring..."" + "}") }))

我得到低于 excptiontion -

no viable alternative at input ',@io.swagger.v3.oas.annotations.parameters.RequestBody(content=@Content(examples={@ExampleObject(name="Person sample",summary="person example",value="{\"email\": test@gmail.Com,"+"\"firstName\": \"josh\","+"\"lastName\": \"spring...\""+"}")})))': NoViableAltException

谁能给我一个解决方案?

这对我有用

@Schema( type = "string", example = "Clark Kent")
private String name;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM