diff --git a/test/WireMock.Net.Tests/OpenApiParser/WireMockOpenApiParserTests.FromText_UsingJson_WithPlainTextExample_ShouldReturnMappings.verified.txt b/test/WireMock.Net.Tests/OpenApiParser/WireMockOpenApiParserTests.FromText_UsingJson_WithPlainTextExample_ShouldReturnMappings.verified.txt new file mode 100644 index 00000000..ecc3a435 --- /dev/null +++ b/test/WireMock.Net.Tests/OpenApiParser/WireMockOpenApiParserTests.FromText_UsingJson_WithPlainTextExample_ShouldReturnMappings.verified.txt @@ -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 + } + } + } +] \ No newline at end of file diff --git a/test/WireMock.Net.Tests/OpenApiParser/WireMockOpenApiParserTests.FromText_ShouldReturnMappings.verified.txt b/test/WireMock.Net.Tests/OpenApiParser/WireMockOpenApiParserTests.FromText_UsingYaml_ShouldReturnMappings.verified.txt similarity index 100% rename from test/WireMock.Net.Tests/OpenApiParser/WireMockOpenApiParserTests.FromText_ShouldReturnMappings.verified.txt rename to test/WireMock.Net.Tests/OpenApiParser/WireMockOpenApiParserTests.FromText_UsingYaml_ShouldReturnMappings.verified.txt diff --git a/test/WireMock.Net.Tests/OpenApiParser/WireMockOpenApiParserTests.cs b/test/WireMock.Net.Tests/OpenApiParser/WireMockOpenApiParserTests.cs index 2afddcaa..8a291897 100644 --- a/test/WireMock.Net.Tests/OpenApiParser/WireMockOpenApiParserTests.cs +++ b/test/WireMock.Net.Tests/OpenApiParser/WireMockOpenApiParserTests.cs @@ -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 \ No newline at end of file diff --git a/test/WireMock.Net.Tests/OpenApiParser/oas-content-example.json b/test/WireMock.Net.Tests/OpenApiParser/oas-content-example.json new file mode 100644 index 00000000..c6a726de --- /dev/null +++ b/test/WireMock.Net.Tests/OpenApiParser/oas-content-example.json @@ -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": { + } + } +} \ No newline at end of file