【问题标题】:Swagger-net (or swashbuckle) : how to set the namespace in the xml requests?Swagger-net(或 swashbuckle):如何在 xml 请求中设置命名空间?
【发布时间】:2019-02-27 13:12:21
【问题描述】:

有没有办法使用 Swagger-net 生成带有 xml 命名空间的示例请求?还是花花公子?

我在想这样的事情:

 [SwaggerResponseExample(HttpStatusCode.OK,
 typeof(ResponseExample), xmlnamespace="wanted xml namespace goes here...")]

【问题讨论】:

  • 有趣!我以前从未使用过 xmlnamespace……你为什么需要这个?

标签: swagger swashbuckle swashbuckle.examples


【解决方案1】:

在 Swagger-Net 中,您有 SwaggerResponse,您可以这样称呼它:

[SwaggerResponse(400, "Bad request")]
public class SwaggerAnnotatedController : ApiController
{
    [SwaggerResponseRemoveDefaults]
    [SwaggerResponse(HttpStatusCode.Created, Type = typeof(int), MediaType = "text", Examples = 123)]
    [SwaggerResponse(HttpStatusCode.BadRequest, "Invalid message", typeof(HttpError))]
    public int Create(Message message)
    {
        throw new NotImplementedException();
    }

    [SwaggerResponse( 200, Type = typeof( IEnumerable<Message> ), TypeName = "Messages" )]
    public IEnumerable<Message> GetAll()
    {
        throw new NotImplementedException();
    }

但我从来不需要 xmlnamespace,所以没有这样的选择:

https://github.com/heldersepu/Swagger-Net/blob/master/Swagger.Net/Swagger/Annotations/SwaggerResponseAttribute.cs

但如果您能提供有关如何使用 xmlnamespace 的准确详细信息,我可以添加它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-13
    • 1970-01-01
    相关资源
    最近更新 更多