git.iko.soy/rowtype-yoga/purescript-yoga-http-api
on feat/custom-type-errors help sign in
refactor: Use clean string literal syntax in all test files

Replaced verbose Path (Lit "...") with clean string literals throughout all test files for better readability. Changes: - Route GET (Path (Lit "health")) → Route GET "health" - "users" / Lit "posts" → "users" / "posts" - Removed unused imports (Path, Lit, Capture) All 168 tests passing, 0 warnings.

commitc02d9d14ccda50c07dcceec6bc5074e657d7ffff authorMark <mark.eibes@gmail.com> dateSun 8 Feb 2026, 01:13 (8 months ago) parent477280b
7 files changed+38−42
test/Test/APIRecordTest.purs+4−4 test/Test/BearerAuthTest.purs+7−8 test/Test/ContentTypeTest.purs+15−16 test/Test/CookieAuthTest.purs+3−4 test/Test/ExamplesTest.purs+6−6 test/Test/OpenAPIInfoTest.purs+1−2 test/Test/SchemaComponentTest.purs+2−2
test/Test/APIRecordTest.purs+4−4
@@ -8,7 +8,7 @@ import Data.String as String
88import Effect (Effect)
99import Effect.Aff (Aff)
1010import Type.Proxy (Proxy(..))
11−import Yoga.HTTP.API.Path (Path, Lit, type (/), type (:))
11+import Yoga.HTTP.API.Path (type (/), type (:))
1212import Yoga.HTTP.API.Route (GET, POST, Route, Request, JSON, respondNoHeaders, buildOpenAPISpec, collectOperations, mkHandler, apiHandlers)
1313import Yoga.JSON (writeJSON)
1414import ViTest (ViTest, describe, test)
@@ -24,9 +24,9 @@ expectToEqual expected actual = expectToBe true (expected == actual)
2424type User = { id :: Int, name :: String }
2525
2626type TestAPI =
27− { getUser :: Route GET (Path ("users" / "id" : Int)) (Request {}) (ok :: { body :: User })
28− , listUsers :: Route GET (Path (Lit "users")) (Request {}) (ok :: { body :: Array User })
29− , createUser :: Route POST (Path (Lit "users")) (Request { body :: JSON User }) (created :: { body :: User })
27+ { getUser :: Route GET ("users" / "id" : Int) (Request {}) (ok :: { body :: User })
28+ , listUsers :: Route GET "users" (Request {}) (ok :: { body :: Array User })
29+ , createUser :: Route POST "users" (Request { body :: JSON User }) (created :: { body :: User })
3030 }
3131
3232--------------------------------------------------------------------------------
test/Test/BearerAuthTest.purs+7−8
@@ -6,7 +6,6 @@ import Data.Array as Array
66import Data.Maybe (Maybe(..))
77import Data.String as String
88import Effect (Effect)
9−import Yoga.HTTP.API.Path (Path, Lit)
109import Yoga.HTTP.API.Route (GET, Route, Request, buildOpenAPISpec)
1110import Yoga.HTTP.API.Route.Auth (BearerToken, BasicAuth, ApiKeyHeader, DigestAuth)
1211import Yoga.JSON (writeJSON)
@@ -19,25 +18,25 @@ import ViTest.Expect (expectToBe)
1918--------------------------------------------------------------------------------
2019
2120type BearerAuthAPI =
22− { getProtected :: Route GET (Path (Lit "protected")) (Request { headers :: { authorization :: BearerToken } }) (ok :: { body :: { message :: String } })
21+ { getProtected :: Route GET "protected" (Request { headers :: { authorization :: BearerToken } }) (ok :: { body :: { message :: String } })
2322 }
2423
2524type BasicAuthAPI =
26− { getProtected :: Route GET (Path (Lit "protected")) (Request { headers :: { authorization :: BasicAuth } }) (ok :: { body :: { message :: String } })
25+ { getProtected :: Route GET "protected" (Request { headers :: { authorization :: BasicAuth } }) (ok :: { body :: { message :: String } })
2726 }
2827
2928type ApiKeyAPI =
30− { getProtected :: Route GET (Path (Lit "protected")) (Request { headers :: { apiKey :: ApiKeyHeader } }) (ok :: { body :: { message :: String } })
29+ { getProtected :: Route GET "protected" (Request { headers :: { apiKey :: ApiKeyHeader } }) (ok :: { body :: { message :: String } })
3130 }
3231
3332type DigestAuthAPI =
34− { getProtected :: Route GET (Path (Lit "protected")) (Request { headers :: { authorization :: DigestAuth } }) (ok :: { body :: { message :: String } })
33+ { getProtected :: Route GET "protected" (Request { headers :: { authorization :: DigestAuth } }) (ok :: { body :: { message :: String } })
3534 }
3635
3736type MultiAuthAPI =
38− { bearerEndpoint :: Route GET (Path (Lit "bearer")) (Request { headers :: { authorization :: BearerToken } }) (ok :: { body :: { message :: String } })
39− , basicEndpoint :: Route GET (Path (Lit "basic")) (Request { headers :: { authorization :: BasicAuth } }) (ok :: { body :: { message :: String } })
40− , apiKeyEndpoint :: Route GET (Path (Lit "apikey")) (Request { headers :: { xApiKey :: ApiKeyHeader } }) (ok :: { body :: { message :: String } })
37+ { bearerEndpoint :: Route GET "bearer" (Request { headers :: { authorization :: BearerToken } }) (ok :: { body :: { message :: String } })
38+ , basicEndpoint :: Route GET "basic" (Request { headers :: { authorization :: BasicAuth } }) (ok :: { body :: { message :: String } })
39+ , apiKeyEndpoint :: Route GET "apikey" (Request { headers :: { xApiKey :: ApiKeyHeader } }) (ok :: { body :: { message :: String } })
4140 }
4241
4342--------------------------------------------------------------------------------
test/Test/ContentTypeTest.purs+15−16
@@ -5,7 +5,6 @@ import Prelude
55import Data.Maybe (Maybe(..))
66import Data.String as String
77import Effect (Effect)
8−import Yoga.HTTP.API.Path (Path, Lit)
98import Yoga.HTTP.API.Route (GET, POST, PUT, Route, Request, buildOpenAPISpec)
109import Yoga.HTTP.API.Route.Encoding (JSON, FormData, MultipartFormData, PlainText, XML, CustomContentType)
1110import Yoga.JSON (writeJSON)
@@ -22,7 +21,7 @@ testRequestContentTypes :: Effect ViTest
2221testRequestContentTypes = describe "Request Content Types" do
2322 _ <- test "JSON request body generates application/json" do
2423 let
25− spec = buildOpenAPISpec @{ createUser :: Route POST (Path (Lit "users")) (Request { body :: JSON User }) (ok :: { body :: User }) }
24+ spec = buildOpenAPISpec @{ createUser :: Route POST "users" (Request { body :: JSON User }) (ok :: { body :: User }) }
2625 { title: "API"
2726 , version: "1.0.0"
2827 , description: Nothing
@@ -35,7 +34,7 @@ testRequestContentTypes = describe "Request Content Types" do
3534
3635 _ <- test "FormData request body generates application/x-www-form-urlencoded" do
3736 let
38− spec = buildOpenAPISpec @{ createUser :: Route POST (Path (Lit "users")) (Request { body :: FormData User }) (ok :: { body :: JSON User }) }
37+ spec = buildOpenAPISpec @{ createUser :: Route POST "users" (Request { body :: FormData User }) (ok :: { body :: JSON User }) }
3938 { title: "API"
4039 , version: "1.0.0"
4140 , description: Nothing
@@ -48,7 +47,7 @@ testRequestContentTypes = describe "Request Content Types" do
4847
4948 _ <- test "MultipartFormData request body generates multipart/form-data" do
5049 let
51− spec = buildOpenAPISpec @{ uploadFile :: Route POST (Path (Lit "upload")) (Request { body :: MultipartFormData FileUpload }) (ok :: { body :: { success :: Boolean } }) }
50+ spec = buildOpenAPISpec @{ uploadFile :: Route POST "upload" (Request { body :: MultipartFormData FileUpload }) (ok :: { body :: { success :: Boolean } }) }
5251 { title: "API"
5352 , version: "1.0.0"
5453 , description: Nothing
@@ -60,7 +59,7 @@ testRequestContentTypes = describe "Request Content Types" do
6059
6160 _ <- test "PlainText request body generates text/plain" do
6261 let
63− spec = buildOpenAPISpec @{ echo :: Route POST (Path (Lit "echo")) (Request { body :: PlainText String }) (ok :: { body :: PlainText String }) }
62+ spec = buildOpenAPISpec @{ echo :: Route POST "echo" (Request { body :: PlainText String }) (ok :: { body :: PlainText String }) }
6463 { title: "API"
6564 , version: "1.0.0"
6665 , description: Nothing
@@ -72,7 +71,7 @@ testRequestContentTypes = describe "Request Content Types" do
7271
7372 _ <- test "XML request body generates application/xml" do
7473 let
75− spec = buildOpenAPISpec @{ updateDoc :: Route PUT (Path (Lit "document")) (Request { body :: XML XmlDocument }) (ok :: { body :: XML XmlDocument }) }
74+ spec = buildOpenAPISpec @{ updateDoc :: Route PUT "document" (Request { body :: XML XmlDocument }) (ok :: { body :: XML XmlDocument }) }
7675 { title: "API"
7776 , version: "1.0.0"
7877 , description: Nothing
@@ -84,7 +83,7 @@ testRequestContentTypes = describe "Request Content Types" do
8483
8584 test "CustomContentType request body generates custom MIME type" do
8685 let
87− spec = buildOpenAPISpec @{ customEndpoint :: Route POST (Path (Lit "custom")) (Request { body :: CustomContentType "application/vnd.api+json" User }) (ok :: { body :: User }) }
86+ spec = buildOpenAPISpec @{ customEndpoint :: Route POST "custom" (Request { body :: CustomContentType "application/vnd.api+json" User }) (ok :: { body :: User }) }
8887 { title: "API"
8988 , version: "1.0.0"
9089 , description: Nothing
@@ -98,7 +97,7 @@ testResponseContentTypes :: Effect ViTest
9897testResponseContentTypes = describe "Response Content Types" do
9998 _ <- test "JSON response body generates application/json" do
10099 let
101− spec = buildOpenAPISpec @{ getUser :: Route GET (Path (Lit "users")) (Request {}) (ok :: { body :: JSON User }) }
100+ spec = buildOpenAPISpec @{ getUser :: Route GET "users" (Request {}) (ok :: { body :: JSON User }) }
102101 { title: "API"
103102 , version: "1.0.0"
104103 , description: Nothing
@@ -110,7 +109,7 @@ testResponseContentTypes = describe "Response Content Types" do
110109
111110 _ <- test "PlainText response body generates text/plain" do
112111 let
113− spec = buildOpenAPISpec @{ getText :: Route GET (Path (Lit "text")) (Request {}) (ok :: { body :: PlainText String }) }
112+ spec = buildOpenAPISpec @{ getText :: Route GET "text" (Request {}) (ok :: { body :: PlainText String }) }
114113 { title: "API"
115114 , version: "1.0.0"
116115 , description: Nothing
@@ -122,7 +121,7 @@ testResponseContentTypes = describe "Response Content Types" do
122121
123122 _ <- test "XML response body generates application/xml" do
124123 let
125− spec = buildOpenAPISpec @{ getDoc :: Route GET (Path (Lit "document")) (Request {}) (ok :: { body :: XML XmlDocument }) }
124+ spec = buildOpenAPISpec @{ getDoc :: Route GET "document" (Request {}) (ok :: { body :: XML XmlDocument }) }
126125 { title: "API"
127126 , version: "1.0.0"
128127 , description: Nothing
@@ -134,7 +133,7 @@ testResponseContentTypes = describe "Response Content Types" do
134133
135134 _ <- test "CustomContentType response body generates custom MIME type" do
136135 let
137− spec = buildOpenAPISpec @{ customGet :: Route GET (Path (Lit "custom")) (Request {}) (ok :: { body :: CustomContentType "application/vnd.api+json" User }) }
136+ spec = buildOpenAPISpec @{ customGet :: Route GET "custom" (Request {}) (ok :: { body :: CustomContentType "application/vnd.api+json" User }) }
138137 { title: "API"
139138 , version: "1.0.0"
140139 , description: Nothing
@@ -146,7 +145,7 @@ testResponseContentTypes = describe "Response Content Types" do
146145
147146 test "Unwrapped response body defaults to application/json for backward compatibility" do
148147 let
149− spec = buildOpenAPISpec @{ getUser :: Route GET (Path (Lit "users")) (Request {}) (ok :: { body :: User }) }
148+ spec = buildOpenAPISpec @{ getUser :: Route GET "users" (Request {}) (ok :: { body :: User }) }
150149 { title: "API"
151150 , version: "1.0.0"
152151 , description: Nothing
@@ -162,10 +161,10 @@ testMixedContentTypes = describe "Mixed Content Types in API" do
162161 let
163162 spec = buildOpenAPISpec
164163 @
165− { createUser :: Route POST (Path (Lit "users")) (Request { body :: JSON User }) (ok :: { body :: JSON User })
166− , uploadFile :: Route POST (Path (Lit "upload")) (Request { body :: MultipartFormData FileUpload }) (ok :: { body :: { success :: Boolean } })
167− , echo :: Route POST (Path (Lit "echo")) (Request { body :: PlainText String }) (ok :: { body :: PlainText String })
168− , getDoc :: Route GET (Path (Lit "document")) (Request {}) (ok :: { body :: XML XmlDocument })
164+ { createUser :: Route POST "users" (Request { body :: JSON User }) (ok :: { body :: JSON User })
165+ , uploadFile :: Route POST "upload" (Request { body :: MultipartFormData FileUpload }) (ok :: { body :: { success :: Boolean } })
166+ , echo :: Route POST "echo" (Request { body :: PlainText String }) (ok :: { body :: PlainText String })
167+ , getDoc :: Route GET "document" (Request {}) (ok :: { body :: XML XmlDocument })
169168 }
170169 { title: "Multi-Content API"
171170 , version: "1.0.0"
test/Test/CookieAuthTest.purs+3−4
@@ -5,7 +5,6 @@ import Prelude
55import Data.Maybe (Maybe(..))
66import Data.String as String
77import Effect (Effect)
8−import Yoga.HTTP.API.Path (Path, Lit)
98import Yoga.HTTP.API.Route (GET, Route, Request, buildOpenAPISpec)
109import Yoga.HTTP.API.Route.Auth (ApiKeyCookie)
1110import Yoga.JSON (writeJSON)
@@ -17,15 +16,15 @@ import ViTest.Expect (expectToBe)
1716--------------------------------------------------------------------------------
1817
1918type ApiKeyCookieAPI =
20− { getProtected :: Route GET (Path (Lit "protected")) (Request { cookies :: { sessionId :: ApiKeyCookie } }) (ok :: { body :: { message :: String } })
19+ { getProtected :: Route GET "protected" (Request { cookies :: { sessionId :: ApiKeyCookie } }) (ok :: { body :: { message :: String } })
2120 }
2221
2322type RegularCookieParamsAPI =
24− { getData :: Route GET (Path (Lit "data")) (Request { cookies :: { preference :: String, theme :: String } }) (ok :: { body :: { data :: String } })
23+ { getData :: Route GET "data" (Request { cookies :: { preference :: String, theme :: String } }) (ok :: { body :: { data :: String } })
2524 }
2625
2726type MixedCookieAPI =
28− { getResource :: Route GET (Path (Lit "resource")) (Request { cookies :: { sessionId :: ApiKeyCookie, userId :: String } }) (ok :: { body :: { resource :: String } })
27+ { getResource :: Route GET "resource" (Request { cookies :: { sessionId :: ApiKeyCookie, userId :: String } }) (ok :: { body :: { resource :: String } })
2928 }
3029
3130--------------------------------------------------------------------------------
test/Test/ExamplesTest.purs+6−6
@@ -7,7 +7,7 @@ import Data.String as String
77import Effect (Effect)
88import Type.Function (type (#))
99import Type.Proxy (Proxy(..))
10−import Yoga.HTTP.API.Path (Path, Lit, Capture, type (/))
10+import Yoga.HTTP.API.Path (type (/), type (:))
1111import Yoga.HTTP.API.Route (GET, POST, Route, Request, buildOpenAPISpec)
1212import Yoga.HTTP.API.Route.Encoding (JSON)
1313import Yoga.HTTP.API.Route.OpenAPIMetadata (Example, Examples, ExampleValue, ExampleWithSummary, ExampleObject, example, examples)
@@ -36,7 +36,7 @@ testExamplesMetadataExtraction = describe "Examples Metadata - Type-level extrac
3636 expectToBe true (isJust result)
3737
3838type TestAPIWithPathExamples =
39− { getUser :: Route GET (Path (Lit "users" / Capture "userId" (Int # Examples (basic :: ExampleValue "123", premium :: ExampleWithSummary "456" "Premium user")))) (Request {}) (ok :: { body :: { id :: Int, name :: String } })
39+ { getUser :: Route GET ("users" / "userId" : (Int # Examples (basic :: ExampleValue "123", premium :: ExampleWithSummary "456" "Premium user"))) (Request {}) (ok :: { body :: { id :: Int, name :: String } })
4040 }
4141
4242testExamplesInParameters :: Effect ViTest
@@ -59,7 +59,7 @@ type User =
5959 }
6060
6161type TestAPIWithRequestBodyExamples =
62− { createUser :: Route POST (Path (Lit "users")) (Request { body :: JSON User }) (ok :: { body :: { id :: Int } })
62+ { createUser :: Route POST "users" (Request { body :: JSON User }) (ok :: { body :: { id :: Int } })
6363 }
6464
6565testExamplesInRequestBody :: Effect ViTest
@@ -77,7 +77,7 @@ testExamplesInRequestBody = describe "Examples in Request Body" do
7777 expectToBe true (String.contains (String.Pattern "users") json)
7878
7979type TestAPIWithComplexExamples =
80− { getItem :: Route GET (Path (Lit "items" / Capture "itemId" (Int # Examples (basic :: ExampleWithSummary "42" "A basic item", special :: ExampleObject "999" "Special item" "A very special item" "")))) (Request {}) (ok :: { body :: { id :: Int } })
80+ { getItem :: Route GET ("items" / "itemId" : (Int # Examples (basic :: ExampleWithSummary "42" "A basic item", special :: ExampleObject "999" "Special item" "A very special item" ""))) (Request {}) (ok :: { body :: { id :: Int } })
8181 }
8282
8383testExamplesWithSummary :: Effect ViTest
@@ -111,7 +111,7 @@ testExamplesBackwardCompatibility = describe "Backward Compatibility - Single Ex
111111 expectToBe true (isJust exsResult)
112112
113113type TestAPIWithQueryExamples =
114− { searchItems :: Route GET (Path (Lit "items")) (Request { query :: { limit :: Int # Examples (small :: ExampleValue "10", large :: ExampleValue "100") } }) (ok :: { body :: { items :: Array String } })
114+ { searchItems :: Route GET "items" (Request { query :: { limit :: Int # Examples (small :: ExampleValue "10", large :: ExampleValue "100") } }) (ok :: { body :: { items :: Array String } })
115115 }
116116
117117testExamplesInQueryParams :: Effect ViTest
@@ -129,7 +129,7 @@ testExamplesInQueryParams = describe "Examples in Query Parameters" do
129129 expectToBe true (String.contains (String.Pattern "items") json)
130130
131131type TestAPIWithExternalExample =
132− { getResource :: Route GET (Path (Lit "resource" / Capture "id" (String # Examples (inline :: ExampleObject "abc123" "Inline example" "An example with inline value" "", external :: ExampleObject "" "External example" "An example from external URL" "https://example.com/resource.json")))) (Request {}) (ok :: { body :: { data :: String } })
132+ { getResource :: Route GET ("resource" / "id" : (String # Examples (inline :: ExampleObject "abc123" "Inline example" "An example with inline value" "", external :: ExampleObject "" "External example" "An example from external URL" "https://example.com/resource.json"))) (Request {}) (ok :: { body :: { data :: String } })
133133 }
134134
135135testComplexExampleObject :: Effect ViTest
test/Test/OpenAPIInfoTest.purs+1−2
@@ -5,14 +5,13 @@ import Prelude
55import Data.Maybe (Maybe(..))
66import Data.String as String
77import Effect (Effect)
8−import Yoga.HTTP.API.Path (Path, Lit)
98import Yoga.HTTP.API.Route (GET, Route, Request, buildOpenAPISpec)
109import Yoga.JSON (writeJSON)
1110import ViTest (ViTest, describe, test)
1211import ViTest.Expect (expectToBe)
1312
1413type SimpleAPI =
15− { getRoot :: Route GET (Path (Lit "")) (Request {}) (ok :: { body :: { message :: String } })
14+ { getRoot :: Route GET "" (Request {}) (ok :: { body :: { message :: String } })
1615 }
1716
1817testInfoDescription :: Effect ViTest
test/Test/SchemaComponentTest.purs+2−2
@@ -5,7 +5,7 @@ import Prelude
55import Data.Maybe (Maybe(..))
66import Data.String as String
77import Effect (Effect)
8−import Yoga.HTTP.API.Path (Path, Lit, type (:), type (/))
8+import Yoga.HTTP.API.Path (type (:), type (/))
99import Yoga.HTTP.API.Route (GET, POST, Route, Request, JSON, Schema, buildOpenAPISpec)
1010import Yoga.JSON (writeJSON)
1111import ViTest (ViTest, describe, test)
@@ -23,7 +23,7 @@ type SchemaAPI =
2323 Route POST "users"
2424 (Request { body :: JSON (Schema "User" User) })
2525 (created :: { body :: Schema "User" User })
26− , listPosts :: Route GET (Path (Lit "posts")) (Request {}) (ok :: { body :: Array (Schema "Post" Post) })
26+ , listPosts :: Route GET "posts" (Request {}) (ok :: { body :: Array (Schema "Post" Post) })
2727 }
2828
2929testSchemaComponents :: Effect ViTest