The HttpClientDemo project demonstrates how to automatically generate a REST API client during the build process using NSwag and MSBuild. This approach streamlines the development workflow by ensuring that the API client is always up-to-date with the latest API changes.
To get started with the HttpClientDemo project, clone this repository to your local machine using the following command:
git clone https://github.com/AnderCelsius/HttpClientDemo.gitNavigate to the src directory where the project files are located:
cd HttpClientDemo/srcMake sure you have the following installed:
- .NET 8.0 SDK or later
- NSwag (version 13.20.0 or later)
To build the project and generate the API client, use the following command:
dotnet buildThis command will invoke MSBuild, which is configured to run NSwag to generate the API client based on the Swagger specification.
The NSwag generation is configured in the .csproj file of the project. For more details, refer to the csharpClient.nswag configuration file in the repository.
After building the project, the generated API client will be available for use within your application. You can instantiate the client and begin making API calls to the corresponding REST endpoints.
Contributions to the HttpClientDemo project are welcome. Please feel free to submit issues, pull requests, or suggest improvements via the GitHub repository.
This project is licensed under the MIT License. Feel free to use it, contribute, or share it as per the license terms.
A special thanks to the NSwag toolchain for making API client generation seamless and to all the contributors of the HttpClientDemo project.
For any additional information or questions, you can reach out through the repository's issue tracker.