@@ -6,12 +6,11 @@ import Data.Array as Array
6import Data.Maybe (Maybe(..))
6import Data.Maybe (Maybe(..))
7import Effect (Effect)
7import Effect (Effect)
8import Type.Function (type (#))
8import Type.Function (type (#))
9−import Type.Proxy (Proxy(..))
10−import Yoga.HTTP.API.Path (Path, Lit, Capture, type (:), type (/), type (:?))
9+import Yoga.HTTP.API.Path (type (:), type (/), type (:?))
11import Yoga.HTTP.API.Route (GET, POST, PUT, DELETE, Route, Request, buildOpenAPISpec)
10import Yoga.HTTP.API.Route (GET, POST, PUT, DELETE, Route, Request, buildOpenAPISpec)
12import Yoga.HTTP.API.Route.Auth (BearerToken, ApiKeyHeader, BasicAuth)
11import Yoga.HTTP.API.Route.Auth (BearerToken, ApiKeyHeader, BasicAuth)
13import Yoga.HTTP.API.Route.Encoding (JSON, PlainText, XML)
12import Yoga.HTTP.API.Route.Encoding (JSON, PlainText, XML)
14−import Yoga.HTTP.API.Route.OpenAPIMetadata (Description, Example, Examples, ExampleValue, ExampleWithSummary, Schema, Minimum, Maximum, Pattern, MinLength, MaxLength)
13+import Yoga.HTTP.API.Route.OpenAPIMetadata (Description, Example, ExampleValue, Examples, Schema)
15import Yoga.JSON (writeJSON)
14import Yoga.JSON (writeJSON)
16import Test.OpenAPIValidation (validate)
15import Test.OpenAPIValidation (validate)
17import ViTest (ViTest, describe, test)
16import ViTest (ViTest, describe, test)
@@ -55,31 +54,31 @@ type ComprehensiveAPI =
56 , -- Multiple content types - XML
55 , -- Multiple content types - XML
57 exportUser ::
56 exportUser ::
58− Route GET ("users" / "id" : Int / Lit "export")
57+ Route GET ("users" / "id" : Int / "export")
59 (Request {})
58 (Request {})
60 (ok :: { body :: XML User })
59 (ok :: { body :: XML User })
62 , -- Plain text response
61 , -- Plain text response
63 healthCheck ::
62 healthCheck ::
64− Route GET (Path (Lit "health"))
63+ Route GET "health"
65 (Request {})
64 (Request {})
66 (ok :: { body :: PlainText String })
65 (ok :: { body :: PlainText String })
68 , -- API Key authentication
67 , -- API Key authentication
69 getStats ::
68 getStats ::
70− Route GET (Path (Lit "stats"))
69+ Route GET "stats"
71 (Request { headers :: { xApiKey :: ApiKeyHeader } })
70 (Request { headers :: { xApiKey :: ApiKeyHeader } })
72 (ok :: { body :: Stats })
71 (ok :: { body :: Stats })
74 , -- Basic auth
73 , -- Basic auth
76− Route POST (Path (Lit "login"))
75+ Route POST "login"
77 (Request { headers :: { authorization :: BasicAuth } })
76 (Request { headers :: { authorization :: BasicAuth } })
78 (ok :: { body :: { token :: String # Description "JWT access token" } })
77 (ok :: { body :: { token :: String # Description "JWT access token" } })
80 , -- Path with examples
79 , -- Path with examples
81 getUserPosts ::
80 getUserPosts ::
82− Route GET ("users" / "userId" : (Int # Examples (alice :: ExampleValue "1", bob :: ExampleValue "2")) / Lit "posts")
81+ Route GET ("users" / "userId" : (Int # Examples (alice :: ExampleValue "1", bob :: ExampleValue "2")) / "posts")
83 (Request {})
82 (Request {})
84 (ok :: { body :: Array Post })
83 (ok :: { body :: Array Post })