git.iko.soy/typeable/compaREST
on cbfeeed help sign in
30 lines 1.0 kB history raw
1module OpenAPI.Checker.Run (runChecker) where
3import Data.Aeson
4import qualified Data.ByteString.Char8 as BSC
5import Data.HList
6import qualified Data.Yaml as Yaml
7import OpenAPI.Checker.Options
8import OpenAPI.Checker.Subtree
9import OpenAPI.Checker.Paths
10import OpenAPI.Checker.Validate.OpenApi ()
11import Prelude hiding (id, (.))
13runChecker :: IO ()
14runChecker = do
15 opts <- execParser optionsParserInfo
16 let parseSchema path =
17 eitherDecodeFileStrict path >>= \case
18 Left jsonErr -> do
19 Yaml.decodeFileEither path >>= \case
20 Left yamlErr -> do
21 putStrLn "Could not parse as json or yaml"
22 putStrLn $ show jsonErr
23 putStrLn $ show yamlErr
24 fail "Exiting"
25 Right s -> pure s
26 Right s -> pure s
27 a <- traced Root <$> parseSchema (clientFile opts)
28 b <- traced Root <$> parseSchema (serverFile opts)
29 let report = runCompatFormula $ checkCompatibility HNil Root (ProdCons a b)
30 BSC.putStrLn $ Yaml.encode report