简体   繁体   中英

ASP.Net WebAPI Swagger

How do I specify whether a property on a model is optional/required in order for that to carry through to the generated swagger documentation?

eg (simple example)

/api/Authenticate

Authenticate(AuthRequest request)
{ }

AuthRequest()
{
   public string Username { get; set; }
   public string Password { get; set; }
}

由Nkosi解答:尝试在要强制使用的属性上使用[Required]属性

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM