0

My WebApi has methods that look like the method below. Is there a way to provide input examples using Swashbuckler?

public UserModel Login([FromBody] JObject data)
{
            dynamic json = data;
            string sdkversion = (string) json.sdkversion;
            string loginid = json.loginid;
            string password = json.password;
            string ipaddress;
            string jsonipaddress = (string)json.ipaddress;
            string hostname = HttpContext.Current.Request.UserHostName;
            string useragent;

            useragent = (string)json.useragent;

        Do stuff...
}
Webjedi
  • 4,677
  • 7
  • 42
  • 59

1 Answers1

0

The best way SwashBuckle would handle this is to have one method per object type, which would then help you to have one method entry in your Swagger descriptor (easier for consumers).

Still, having a REST API endpoint that accepts "anything" is not really much REST oriented; how would people using your Swagger endpoint would guess what they should send?

Benjamin Soulier
  • 2,223
  • 1
  • 18
  • 30
  • I know it's not really very RESTy. But to answer your question, this is why I want to manually populate the "Example" data part of the Swashbuckler doc. – Webjedi Jul 28 '16 at 14:41
  • Your only solution then is to modify the output documentation from Swashbuckle, creating a custom `IDocumentFilter` to duplicate generated schema entries, and to use it with `c.DocumentFilter` – Benjamin Soulier Jul 28 '16 at 14:49