首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Springdoc Openapi -添加响应示例值

Springdoc Openapi -添加响应示例值
EN

Stack Overflow用户
提问于 2022-03-29 11:30:25
回答 1查看 2.3K关注 0票数 4

我试图在我的springdoc swagger文档中添加示例响应值。

比如用“马克吐温”代替“字符串”等等。

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

我已经在课堂上使用org.springframework.web.bind.annotation.RequestBody了。

如果我用这个-

@io.swagger.v3.oas.annotations.parameters.RequestBody(content =@Content(示例={ @ExampleObject( name = "Person sample",汇总= "person示例“,value =”test@gmail.Com“,”+ ""firstName":"josh",“+ ""lastName":”spring……“+ "}") })

我没那么过分-

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

有人能给我一个解决办法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-03-31 12:33:21

这对我来说很管用

代码语言:javascript
运行
复制
@Schema( type = "string", example = "Clark Kent")
private String name;
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71661223

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档