swaggerswashbuckleswashbuckle.examples

Swagger-net (or swashbuckle) : how to set the namespace in the xml requests?


is there a way to generate example requests with xml namespaces using Swagger-net? Or in swashbuckle?

I was thinking of something like:

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

Solution

  • In Swagger-Net you have SwaggerResponse you can call it like these:

    [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();
        }
    

    But I never had a need for xmlnamespace so there is no such an option:

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

    but if you can provide precise details of how is that xmlnamespace used I can add it.