mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
Add more tests for WireMockOpenApiParser (#1294)
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -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
|
||||
@@ -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": {
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user