.config | ||
src | ||
tests/SampleApp | ||
.editorconfig | ||
.gitignore | ||
Directory.Build.props | ||
openapi.yaml | ||
README.md | ||
WebApiBootstrap.sln |
WebApiBootstrap
Demonstrates a setup for automatically generating a client library for an ASP.NET Core Web Api using OpenAPI ( Swashbuckle) and Refitter.
How it Works
The setup consists of 3 projects:
- WebApiBootstrap.Api - An ASP.NET Core Web API project.
- WebApiBootstrap.Contracts - A
netstandard2.0
class library containing data transfer objects (DTOs). - WebApiBootstrap.Client - A class library containing a client for the API project.
The Api and Client projects have a common dependency on the Contracts project, allowing them to share identical definitions for the DTOs and any associated serialization or validation logic.
The Api project is configured to generate an OpenApi document with Swashbuckle after it is built (see the "GenerateOpenApiDoc" target in its .csproj file).
The Client project uses this file to generate a file containing one or more Refit interface(s). The model generation is skipped so that the client can use the DTOs defined manually in the Contracts project. This interface generation occurs automatically before the Client project is built (see the "GenerateRefitInterface" target in its .csproj file).