强大骆驼盒在摇摇欲坠的gen中进行参数
问题:< / strong>
我的休息端点带有路由参数,看起来像这样的路线
[HttpDelete("{id}")]
public async Task<IActionResult> DeleteDocument([FromRoute] DeleteDocumentRequest request)
,“ deletedocumentRequest”具有一个gettor / settor,
public Guid Id {get; set;}
但是,当Swagger Gen将其序列序列化为OpenAPI 3.0时,它会产生错误,因为它的情况是类中的属性“ ID”与路由中的属性“ ID”不匹配。
问题:
如何覆盖序列化器将其所有属性更改为骆驼以确保合规性?
使用.NET 6中的Newtonsoft JSON,我尝试使用CamelCasePropertyNamesContractresolver以及覆盖propertyname和createProperties的覆盖,但是控制器端点中的参数不是“属性”的“属性”。
Problem:
I have Rest Endpoint with route params that look something like this
[HttpDelete("{id}")]
public async Task<IActionResult> DeleteDocument([FromRoute] DeleteDocumentRequest request)
Where the "DeleteDocumentRequest" has a gettor / settor
public Guid Id {get; set;}
However, when swagger gen serializes this into OpenApi 3.0, it generates an error because the case of the property "Id" in the class does not match the property "id" in the route.
Question:
How can I override the serializer for it to change all of my properties to camelCase to ensure conformity?
Using Newtonsoft Json in .NET 6, I have tried to use CamelCasePropertyNamesContractResolver as well as overrides for ResolvePropertyName and CreateProperties, but the parameters in the controller endpoint are not "properties" that get hit.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够通过在Swagger Gen设置中添加以下内容来解决它。感谢@JSPCAL提供了一个相关问题的链接。
I was able to solve it by adding the following to the Swagger Gen setup. Thanks to @jspcal for the link to a related question.