From 9b003cc1f189953b6266bf89cd37d8146e183774 Mon Sep 17 00:00:00 2001 From: Honza Dvorsky Date: Thu, 7 Sep 2023 17:24:20 +0200 Subject: [PATCH] Add an escaped path component test case (#49) ### Motivation While investigating https://github.com/apple/swift-openapi-generator/issues/251 I noticed we don't have a test case for an escaped path component. ### Modifications Added an extra test case. ### Result Unescaping path params has better test coverage. ### Test Plan This whole PR is about improving the tests. --- .../Conversion/Test_Converter+Server.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Tests/OpenAPIRuntimeTests/Conversion/Test_Converter+Server.swift b/Tests/OpenAPIRuntimeTests/Conversion/Test_Converter+Server.swift index 4151df26..ab8dc21f 100644 --- a/Tests/OpenAPIRuntimeTests/Conversion/Test_Converter+Server.swift +++ b/Tests/OpenAPIRuntimeTests/Conversion/Test_Converter+Server.swift @@ -125,6 +125,7 @@ final class Test_ServerConverterExtensions: Test_Runtime { "foo": "bar", "number": "1", "habitats": "land,air", + "withEscaping": "Hello%20world%21", ] do { let value = try converter.getPathParameterAsURI( @@ -150,6 +151,14 @@ final class Test_ServerConverterExtensions: Test_Runtime { ) XCTAssertEqual(value, [.land, .air]) } + do { + let value = try converter.getPathParameterAsURI( + in: path, + name: "withEscaping", + as: String.self + ) + XCTAssertEqual(value, "Hello world!") + } } // | server | get | request query | URI | optional | getOptionalQueryItemAsURI |