mirror of
https://github.com/nsnail/IGeekFan.AspNetCore.Knife4jUI.git
synced 2025-08-04 13:27:57 +08:00
添加项目文件。
This commit is contained in:
44
test/Basic/Controllers/SwaggerAnnotationsController.cs
Normal file
44
test/Basic/Controllers/SwaggerAnnotationsController.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using Basic.Swagger;
|
||||
|
||||
namespace Basic.Controllers
|
||||
{
|
||||
[SwaggerTag("Manipulate Carts to your heart's content", "http://www.tempuri.org")]
|
||||
public class SwaggerAnnotationsController
|
||||
{
|
||||
[HttpPost("/carts")]
|
||||
[SwaggerOperation(OperationId = "CreateCart")]
|
||||
[SwaggerResponse(201, "The cart was created", typeof(Cart))]
|
||||
[SwaggerResponse(400, "The cart data is invalid")]
|
||||
public Cart Create([FromBody, SwaggerRequestBody(Description = "The cart request body")]Cart cart)
|
||||
{
|
||||
return new Cart { Id = 1 };
|
||||
}
|
||||
|
||||
[HttpGet("/carts/{id}")]
|
||||
[SwaggerOperation(OperationId = "GetCart")]
|
||||
[SwaggerOperationFilter(typeof(AddCartsByIdGetExternalDocs))]
|
||||
public Cart Get([SwaggerParameter("The cart identifier")]int id)
|
||||
{
|
||||
return new Cart { Id = id };
|
||||
}
|
||||
|
||||
[HttpDelete("/carts/{id}")]
|
||||
[SwaggerOperation(
|
||||
OperationId = "DeleteCart",
|
||||
Summary = "Deletes a specific cart",
|
||||
Description = "Requires admin privileges")]
|
||||
public Cart Delete([FromRoute(Name = "id"), SwaggerParameter("The cart identifier")]int cartId)
|
||||
{
|
||||
return new Cart { Id = cartId };
|
||||
}
|
||||
}
|
||||
|
||||
[SwaggerSchema(Required = new[] { "Id" })]
|
||||
public class Cart
|
||||
{
|
||||
[SwaggerSchema("The cart identifier", ReadOnly = true)]
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user