A C# test automation solution for validating APIs against their Swagger/OpenAPI contracts. Ensures that APIs send expected request structures and response payloads, improving reliability, reducing errors, and supporting scalable automation.
- Swagger/OpenAPI validation: Ensures APIs match their defined contracts.
- Request format checks: Verifies all outgoing requests adhere to the expected schema.
- Response validation: Confirms API responses match expected structures, data types, and status codes.
- Automated testing: Integrates seamlessly with CI/CD pipelines.
- Scalable architecture: Easily extendable to cover new APIs and endpoints.
- Early detection of issues – Catch mismatches or missing fields before production.
- Improved API quality – Maintain consistent and reliable endpoints.
- Reduced manual effort – Automated tests save time and reduce human error.
- Safe refactoring – Confidently modify APIs knowing contract tests will catch breaking changes.
- CI/CD integration – Continuous validation ensures contracts are always respected.
- .NET 9 SDK
- Access to API Swagger/OpenAPI specification (JSON)
git clone https://github.com/m4rri4nne/SwaggerIntegration.git
cd SwaggerIntegration
dotnet restore
dotnet builddotnet test [Test]
public async Task CheckSwaggerGetMethod()
{
var response = await _requests.GetAsync<string>("api/v1/Activities");
Assert.That(response.StatusCode, Is.EqualTo(System.Net.HttpStatusCode.OK));
await _validator.ContractValidation(
_swaggerUrl,
"/api/v1/Activities",
"get",
200,
response.Content);
}- Dynamic test generation from Swagger definitions.
- Data-driven testing for multiple scenarios.
- Support for GraphQL or other API specifications.
- Reporting dashboards to visualize contract violations.
