///<summary> /// The create product parameter example class ///</summary> ///<seealso cref="IExamplesProvider{CreateProductParameter}"/> publicclassCreateProductParameterExample : IExamplesProvider<CreateProductParameter> { ///<summary> /// Gets the examples ///</summary> ///<returns>The create product parameter</returns> public CreateProductParameter GetExamples() { var createProductParameter = new CreateProductParameter { Name = "Blue Striped Shirt", Description = "A blue and white striped shirt, great for a casual day out.", Price = 29.99M, Brand = "H&M", Category = "Clothing", Color = "Blue", Size = "M", Material = "Cotton", };
return createProductParameter; } }
可以在 Action 方法上添加 [SwaggerRequestExample],以提供請求範例資料,方便 Swagger 文檔中的使用者了解 API 的使用方式。