0

I need to document all different request models for the endpoint:

public Task<SomeResponse> Post(JObject request) 
{
    ...
}

What options do I have besides just writing detailed comments about expected request models or creating endpoints per model?

Andrei
  • 42,814
  • 35
  • 154
  • 218
  • 2
    Please, show some exmaples of what you need to do. For example, can the JObject be absolutely anything or there are several cocnrete cases, or does it have a minimum common structure for all the cases? – JotaBe May 09 '19 at 14:40
  • IMO, you would benefit from splitting this `Post` method into multiple endpoints, each accepting a different strongly-typed model. That said, I don't know if you can document the different possible expected models as-is. –  May 09 '19 at 15:02
  • @JotaBe JObject can be absolutely anything. – Andrei May 09 '19 at 20:19
  • @Amy too many to split... – Andrei May 09 '19 at 20:20
  • 1
    If it can be absolutely anything, I don't see how it can be documented other than "The payload can be absolutely anything." –  May 09 '19 at 20:51

1 Answers1

0

I don't think you can. Since the payload is dynamic, how can NSwag know?

Ricardo Peres
  • 13,724
  • 5
  • 57
  • 74
  • By providing `[SwaggerRequest(typeof(MyRequestModel))]` attribute or some similar option. – Andrei May 09 '19 at 20:21
  • The correct (tool independent) attribute is `ProducesResponseTypeAttribute` https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.producesresponsetypeattribute?view=aspnetcore-2.2 – Rico Suter May 10 '19 at 22:01
  • 2
    No, it’s not. This is for the response type, what he wants is for the payload (the parameter). – Ricardo Peres May 10 '19 at 22:02