【问题标题】:Change parameter type in SwaggerWcf在 SwaggerWcf 中更改参数类型
【发布时间】:2017-10-07 22:09:48
【问题描述】:

Swagger 允许设置 parameter type,但使用 SwaggerWcf 我无法编辑此文件,它已生成。它默认设置为body,但我需要它是路径。

有人可能会认为SwaggerWcfParameterAttribute 允许设置此项。但它只允许DescriptionRequired

具体怎么设置?

【问题讨论】:

  • 看起来不支持路径和查询参数。已经在作者的github上提了一个问题Lgithub.com/abelsilva/swaggerwcf/issues/74
  • @tomredfern 谢谢,但是使用带有 {} 中的变量名的 UriTemplate 它确实将其识别为路径参数。
  • 酷 - 我已经关闭了这个问题。

标签: wcf configuration swagger swagger-wcf


【解决方案1】:

您是否尝试使用示例服务中的格式?

https://github.com/abelsilva/swaggerwcf/blob/master/src/SwaggerWcf.Test.Service/IStore.cs#L48

    [SwaggerWcfPath("Get book author", "Retrieve the author of a book using the book id")]
    [WebGet(UriTemplate = "/books/{id}/author", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
    [OperationContract]
    Author ReadBookAuthor(string id);

路径中的参数id将传递给函数

【讨论】:

  • 这是否意味着生成的 swagger 将参数定义为路径?谢谢
  • 谢谢,我已经测试过了,它可以工作。该参数不被视为路径类型。
猜你喜欢
  • 2023-04-03
  • 2017-05-02
  • 2016-10-23
  • 1970-01-01
  • 1970-01-01
  • 2019-03-20
  • 2016-11-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多