Nswag: Required string query parameters are displayed as Nullable

Created on 29 Oct 2019  路  7Comments  路  Source: RicoSuter/NSwag

I am using latest version of Nswag (V13.xx) along with OpenApiDocument.

The string query parameters are displayed as Nullable on Swagger document when using both [Required] [FromQuery] attributes or only the [Required] attribute. Below is the code sample:

public ActionResult<List<Dictionary<string, string>>> Get([Required] [FromQuery] string format) { .... }

Is there another way to make Nswag to no display the string query parameter as Nullable?

Thanks

Most helpful comment

Use [BindRequired] and not [Required]

All 7 comments

Same for reference type route parameters

Use [BindRequired] and not [Required]

Where should we document this?

Thanks RicoSuter for your help.

I think a good place to document this will be https://github.com/RicoSuter/NSwag/wiki/WebApiOpenApiDocumentGenerator

RicoSuter ,
Ok. Thanks. I think the link you provided is a good place to document this.

Thanks

Updated wiki - please also improve the wiki if you have time and it makes sense, etc.

Was this page helpful?
0 / 5 - 0 ratings