How to configure Swashbuckle to ignore property on model

后端 未结 15 1786
旧巷少年郎
旧巷少年郎 2020-12-02 15:10

I\'m using Swashbuckle to generate swagger documentation\\UI for a webapi2 project. Our models are shared with some legacy interfaces so there are a couple of properties I

15条回答
  •  囚心锁ツ
    2020-12-02 15:48

    For people like me who are using .Net Core and are using the build in app.UseSwaggerUi3WithApiExplorer()

    Use [JsonIgnore] tag using Newtonsoft.Json;

    public class Project
    {
        [Required]
        public string ProjectName { get; set; }
    
        [JsonIgnore]
        public string SomeValueYouWantToIgnore { get; set; }
    }
    

    It will be excluded from your documentation.

提交回复
热议问题