@@ -1,7 +1,12 @@
11module OpenAPI.Checker.Report where
22
3−import Data.Text (Text)
4−import GHC.Generics (Generic)
3+import Data.Map.Strict as M
4+import Data.Text (Text)
5+import GHC.Generics (Generic)
6+import OpenAPI.Checker.Validate.Monad
7+
8+printReport :: Report -> IO ()
9+printReport = error "FIXME: printReport not implemented"
510
611data Report = Report
712 { status :: Status
@@ -11,21 +16,29 @@ data Report = Report
1116data Status = Success | Fail Text
1217 deriving (Eq, Ord, Show, Generic)
1318
14−type Errorable = Either Text
15−
1619type Path = FilePath -- From the library
1720
1821data ReportTree = ReportTree
19− { paths :: [PathTree]
22+ { paths :: Map Path (Errorable PathItemTree)
2023 } deriving (Eq, Ord, Show, Generic)
2124
22−data PathTree = PathTree
23− { path :: Path
24− , pathItem :: Errorable PathItemTree
25− } deriving (Eq, Ord, Show, Generic)
25+newtype PathItemTree = PathItemTree
26+ { operations :: Map OperationName (Errorable OperationTree)
27+ } deriving (Eq, Ord, Show, Generic, Semigroup, Monoid)
2628
27−data PathItemTree = PathItemTree
29+instance Nested PathItemTree where
30+ type Parent PathItemTree = ReportTree
31+ type Key PathItemTree = Path
32+ nest key p = ReportTree $ M.singleton key p
33+
34+data OperationName
35+ = Get | Put | Post | Delete | Options | Head | Patch | Trace
2836 deriving (Eq, Ord, Show, Generic)
2937
30−printReport :: Report -> IO ()
31−printReport = error "FIXME: printReport not implemented"
38+data OperationTree = OperationTree
39+ deriving (Eq, Ord, Show, Generic)
40+
41+instance Nested OperationTree where
42+ type Parent OperationTree = PathItemTree
43+ type Key OperationTree = OperationName
44+ nest key p = PathItemTree $ M.singleton key p