Add more tests for WireMockOpenApiParser (#1294)

This commit is contained in:
Stef Heyenrath
2025-05-13 22:11:25 +02:00
committed by GitHub
parent 7596967fcc
commit 492f01ade1
4 changed files with 82 additions and 1 deletions

View File

@@ -0,0 +1,19 @@
[
{
Guid: Guid_1,
Request: {
Path: /api/code-example/csharp/v2/health-checks,
Methods: [
GET
],
Body: {}
},
Response: {
StatusCode: 200,
BodyAsJson: This is an example for 200,
Headers: {
Content-Type: text/plain; charset=utf-8
}
}
}
]

View File

@@ -32,7 +32,7 @@ public class WireMockOpenApiParserTests
}
[Fact]
public async Task FromText_ShouldReturnMappings()
public async Task FromText_UsingYaml_ShouldReturnMappings()
{
// Arrange
var settings = new WireMockOpenApiParserSettings
@@ -48,5 +48,23 @@ public class WireMockOpenApiParserTests
// Verify
await Verifier.Verify(mappings);
}
[Fact]
public async Task FromText_UsingJson_WithPlainTextExample_ShouldReturnMappings()
{
// Arrange
var settings = new WireMockOpenApiParserSettings
{
ExampleValues = _exampleValuesMock.Object
};
var openApiDocument = await File.ReadAllTextAsync(Path.Combine("OpenApiParser", "oas-content-example.json"));
// Act
var mappings = _sut.FromText(openApiDocument, settings, out _);
// Verify
await Verifier.Verify(mappings);
}
}
#endif

View File

@@ -0,0 +1,44 @@
{
"openapi": "3.0.1",
"info": {
"title": "codeExample-api",
"description": "This is API which is exposing low level system information of the domain in a domain convenient manner.",
"contact": {
"name": "API"
},
"version": "2.0.0"
},
"servers": [
{
"url": "/api/code-example/csharp/v2",
"description": "Example programming language API V2"
}
],
"paths": {
"/health-checks": {
"get": {
"tags": [ "Health checks" ],
"description": "Retrieves the health of API and all services included in the monitoring.",
"summary": "Retrieves the health of API and all services included in the monitoring.",
"responses": {
"200": {
"description": "Ok: The request has succeeded",
"content": {
"text/plain; charset=utf-8": {
"schema": {
"type": "string",
"example": "This is an example for 200"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
}
}
}