Skip to content

Commit

Permalink
Add Swagger annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanpotts committed Feb 6, 2024
1 parent 9469308 commit a861cc7
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Recipe Catalog is a [.NET](https://dotnet.microsoft.com/) 8 project showcasing a
- [Migrations](https://learn.microsoft.com/ef/core/managing-schemas/migrations/)
- [SQLite](https://www.sqlite.org/)
- [FluentValidation](https://github.com/FluentValidation/FluentValidation)
- [Swagger / OpenAPI](https://swagger.io/) ([Swashbuckle](https://github.com/domaindrivendev/Swashbuckle.AspNetCore))
- Markdown ([Markdig](https://github.com/xoofx/markdig))
- Snowflake IDs ([IdGen](https://github.com/RobThree/IdGen))

Expand Down
2 changes: 2 additions & 0 deletions src/WebApi/Apis/RecipesApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using SharpGrip.FluentValidation.AutoValidation.Endpoints.Extensions;
using Swashbuckle.AspNetCore.Annotations;

namespace JonathanPotts.RecipeCatalog.WebApi.Apis;

Expand Down Expand Up @@ -144,6 +145,7 @@ public static async Task<Results<Ok<RecipeWithCuisineDto>, NotFound>> GetAsync(
});
}

[SwaggerResponse(200, contentTypes: "image/webp")]
public static async Task<Results<PhysicalFileHttpResult, NotFound>> GetCoverImageAsync(
[AsParameters] Services services,
long id)
Expand Down
2 changes: 2 additions & 0 deletions src/WebApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(c =>
{
c.EnableAnnotations();

c.AddSecurityDefinition("Identity", new OpenApiSecurityScheme
{
In = ParameterLocation.Header,
Expand Down
1 change: 1 addition & 0 deletions src/WebApi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ WebApi is a REST Web API that provides CRUD operations for managing recipes. Tec
- [Migrations](https://learn.microsoft.com/ef/core/managing-schemas/migrations/)
- [SQLite](https://www.sqlite.org/)
- [FluentValidation](https://github.com/FluentValidation/FluentValidation)
- [Swagger / OpenAPI](https://swagger.io/) ([Swashbuckle](https://github.com/domaindrivendev/Swashbuckle.AspNetCore))
- Markdown ([Markdig](https://github.com/xoofx/markdig))
- Snowflake IDs ([IdGen](https://github.com/RobThree/IdGen))

Expand Down
1 change: 1 addition & 0 deletions src/WebApi/WebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
</PackageReference>
<PackageReference Include="SharpGrip.FluentValidation.AutoValidation.Endpoints" Version="1.4.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="8.0.0" />
</ItemGroup>

Expand Down

0 comments on commit a861cc7

Please sign in to comment.