git.iko.soy/typeable/compaREST
on master help sign in
Made warnings stricter (#76)

* Made warnings stricter * Fixed imports * Moved file * Don't upload artifacts * Fixed more warnings

commit28519f107b6dd573182e11e4f65086d32ca5afec authoriko <ilyakooo0@gmail.com> dateTue 8 Jun 2021, 19:12 (5 years ago) parent5fd5a1c
18 files changed+152−154
.github/workflows/haskell.yml+4−14 src/OpenAPI/Checker/Options.hs → app/OpenAPI/Checker/Options.hs openapi-diff.cabal+39−42 src/OpenAPI/Checker/Paths.hs+3−6 src/OpenAPI/Checker/PathsPrefixTree.hs+5−5 src/OpenAPI/Checker/Subtree.hs+4−4 src/OpenAPI/Checker/Validate/Link.hs+1−1 src/OpenAPI/Checker/Validate/MediaTypeObject.hs+7−7 src/OpenAPI/Checker/Validate/OAuth2Flows.hs+2−2 src/OpenAPI/Checker/Validate/OpenApi.hs+9−9 src/OpenAPI/Checker/Validate/Operation.hs+9−9 src/OpenAPI/Checker/Validate/Param.hs+38−30 src/OpenAPI/Checker/Validate/PathFragment.hs+18−13 src/OpenAPI/Checker/Validate/RequestBody.hs+2−2 src/OpenAPI/Checker/Validate/Schema.hs+7−6 src/OpenAPI/Checker/Validate/SecurityScheme.hs+2−2 src/OpenAPI/Checker/Validate/Server.hs+1−1 test/Spec/Golden/Extra.hs+1−1
.github/workflows/haskell.yml+4−14
@@ -29,23 +29,13 @@ jobs:
2929 run: stack build --ghc-options="-O3 -j" --local-bin-path out --copy-bins --flag openapi-diff:Static
3030 - name: Test
3131 run: stack test --test-arguments='--hide-successes --no-create'
32− - name: Upload artifact
33− uses: actions/upload-artifact@v2
34− with:
35− name: openapi-diff-linux
36− path: out/openapi-diff
37− release:
38− name: "Release"
39− if: github.ref == 'refs/heads/master'
40− runs-on: "ubuntu-latest"
41− needs: [linux-build]
42− steps:
43− - uses: actions/download-artifact@v2
32+
4433 - name: Zip
34+ if: github.ref == 'refs/heads/master'
4535 run: |
46− chmod +x openapi-diff-linux/openapi-diff
47− zip openapi-diff-linux openapi-diff-linux/openapi-diff
36+ zip openapi-diff-linux out/openapi-diff
4837 - uses: "marvinpinto/action-automatic-releases@latest"
38+ if: github.ref == 'refs/heads/master'
4939 with:
5040 repo_token: "${{ secrets.GITHUB_TOKEN }}"
5141 automatic_release_tag: "latest"
src/OpenAPI/Checker/Options.hs → app/OpenAPI/Checker/Options.hsrenamed

The content is the same.

openapi-diff.cabal+39−42
@@ -23,50 +23,21 @@ common common-options
2323 cc-options: -static
2424 ld-options: -static -pthread
2525 ghc-options: -static
26− ghc-options: -Wall
27− -Wcompat
28− -Widentities
29− -Wincomplete-uni-patterns
30− -Wincomplete-record-updates
31− if impl(ghc >= 8.0)
32− ghc-options: -Wredundant-constraints
33− if impl(ghc >= 8.2)
34− ghc-options: -fhide-source-paths
35− if impl(ghc >= 8.4)
36− ghc-options: -Wmissing-export-lists
37− -Wpartial-fields
38−
26+ ghc-options:
27+ -Weverything
28+ -Wno-implicit-prelude
29+ -Wno-missing-safe-haskell-mode
30+ -Wno-safe
31+ -Wno-prepositive-qualified-module
32+ -Wno-missing-import-lists
33+ -Wno-partial-fields
34+ -Wno-all-missed-specialisations
35+ -Wno-missing-local-signatures
36+ -Wno-unsafe
3937 default-language: Haskell2010
4038 build-depends: base >= 4.12.0.0 && < 4.15
41− , aeson
42− , attoparsec
4339 , bytestring
44− , containers
45− , comonad
46− , deriving-aeson
47− , generic-data
48− , generic-monoid
49− , http-media
50− , insert-ordered-containers
51− , lattices
52− , lens
53− , mtl
54− , openapi3
55− , optparse-applicative
56− , pcre2
57− , scientific
58− , tagged
5940 , text
60− , transformers
61− , typerep-map
62− , unordered-containers
63− , vector
64− , yaml
65− , hashable
66− , pandoc-types
67− , open-union
68− , type-fun
69− , free
7041
7142 default-extensions: ApplicativeDo
7243 , BangPatterns
@@ -111,12 +82,33 @@ common common-options
11182
11283library
11384 import: common-options
85+ build-depends:
86+ , pcre2
87+ , open-union
88+ , vector
89+ , unordered-containers
90+ , type-fun
91+ , typerep-map
92+ , tagged
93+ , scientific
94+ , pandoc-types
95+ , openapi3
96+ , lattices
97+ , insert-ordered-containers
98+ , http-media
99+ , hashable
100+ , free
101+ , containers
102+ , comonad
103+ , attoparsec
104+ , transformers
105+ , mtl
106+ , aeson
114107 hs-source-dirs: src
115108 exposed-modules: Data.HList
116109 , OpenAPI.Checker.Behavior
117110 , OpenAPI.Checker.Formula
118111 , OpenAPI.Checker.Memo
119− , OpenAPI.Checker.Options
120112 , OpenAPI.Checker.Orphans
121113 , OpenAPI.Checker.Paths
122114 , OpenAPI.Checker.PathsPrefixTree
@@ -153,11 +145,15 @@ executable openapi-diff
153145 , bytestring
154146 , yaml
155147 , filepath
148+ , optparse-applicative
149+ , mtl
150+ , aeson
156151 ghc-options: -threaded
157152 -rtsopts
158153 -with-rtsopts=-N
159154 other-modules:
160155 FormatHeuristic
156+ OpenAPI.Checker.Options
161157
162158test-suite openapi-diff-test
163159 import: common-options
@@ -172,12 +168,13 @@ test-suite openapi-diff-test
172168 , tasty-golden
173169 , tasty
174170 , bytestring
175− , aeson
176171 , yaml
177172 , directory
178173 , filepath
179174 , pandoc
180175 , data-default
176+ , lens
177+ , openapi3
181178 ghc-options: -threaded
182179 -rtsopts
183180 -with-rtsopts=-N
src/OpenAPI/Checker/Paths.hs+3−6
@@ -7,7 +7,6 @@ module OpenAPI.Checker.Paths
77 , Paths (..)
88 , DiffPaths (..)
99 , catDiffPaths
10− , _DiffPaths
1110 , AnItem (..)
1211 , step
1312
@@ -18,8 +17,6 @@ module OpenAPI.Checker.Paths
1817where
1918
2019import Control.Category
21−import Control.Comonad.Env
22−import Control.Lens
2320import Data.Kind
2421import Data.Type.Equality
2522import Type.Reflection
@@ -87,9 +84,9 @@ newtype DiffPaths (q :: k -> k -> Type) (a :: k) (b :: k)
8784catDiffPaths :: DiffPaths q a b -> DiffPaths q b c -> DiffPaths q a c
8885catDiffPaths (DiffPaths f) (DiffPaths g) = DiffPaths (g . f)
8986
90−_DiffPaths :: Iso (DiffPaths q a b) (DiffPaths q c d) (Paths q a b) (Paths q c d)
91−_DiffPaths = dimap (\(DiffPaths f) -> f Root) $
92− fmap $ \xs -> DiffPaths (>>> xs)
87+-- _DiffPaths :: Iso (DiffPaths q a b) (DiffPaths q c d) (Paths q a b) (Paths q c d)
88+-- _DiffPaths = dimap (\(DiffPaths f) -> f Root) $
89+-- fmap $ \xs -> DiffPaths (>>> xs)
9390
9491-- | An item related to some path relative to the root @r@.
9592data AnItem (q :: k -> k -> Type) (f :: k -> Type) (r :: k) where
src/OpenAPI/Checker/PathsPrefixTree.hs+5−5
@@ -51,7 +51,7 @@ instance (forall a. ToJSON (f a)) => ToJSON (PathsPrefixTree q f r) where
5151 Object . getMergableObject
5252 . foldWith (\t x -> MergableObject . traceObject t $ toJSON x)
5353
54−deriving instance Eq (PathsPrefixTree q f a)
54+deriving stock instance Eq (PathsPrefixTree q f a)
5555
5656-- Kind of orphan. Treat the map as an infinite tuple of @Maybe (f a)@'s, where
5757-- the components are ordered by the @SomeTypeRep@ of the @a@.
@@ -104,9 +104,9 @@ instance Semigroup (ASet a) where
104104 s <> AnEmptySet = s
105105 ASet s1 <> ASet s2 = ASet $ S.union s1 s2
106106
107−deriving instance Eq (ASet a)
107+deriving stock instance Eq (ASet a)
108108
109−deriving instance Ord (ASet a)
109+deriving stock instance Ord (ASet a)
110110
111111-- type traceprefixset = traceprefixtree proxy
112112
@@ -119,9 +119,9 @@ data AStep (q :: k -> k -> Type) (f :: k -> Type) (r :: k) (a :: k) where
119119 !(M.Map (q r a) (PathsPrefixTree q f a))
120120 -> AStep q f r a
121121
122−deriving instance Eq (AStep q f r a)
122+deriving stock instance Eq (AStep q f r a)
123123
124−deriving instance Ord (AStep q f r a)
124+deriving stock instance Ord (AStep q f r a)
125125
126126singleton :: AnItem q f r -> PathsPrefixTree q f r
127127singleton (AnItem ys v) = go ys $ PathsPrefixTree (ASet $ S.singleton v) TRM.empty
src/OpenAPI/Checker/Subtree.hs+4−4
@@ -80,7 +80,7 @@ instance Steppable TraceRoot OpenApi where
8080
8181type Trace = Paths Step TraceRoot
8282
83−type instance AdditionalQuiverConstraints Step a b = ()
83+type instance AdditionalQuiverConstraints Step _ _ = ()
8484
8585type Traced' a b = Env (Trace a) b
8686
@@ -104,7 +104,7 @@ data ProdCons a = ProdCons
104104 { producer :: a
105105 , consumer :: a
106106 }
107− deriving (Eq, Ord, Show, Functor, Foldable, Traversable)
107+ deriving stock (Eq, Ord, Show, Functor, Foldable, Traversable)
108108
109109swapProdCons :: ProdCons a -> ProdCons a
110110swapProdCons (ProdCons a b) = ProdCons b a
@@ -134,7 +134,7 @@ data VoidQuiver a b
134134
135135deriving stock instance Eq (VoidQuiver a b)
136136
137−type instance AdditionalQuiverConstraints VoidQuiver a b = ()
137+type instance AdditionalQuiverConstraints VoidQuiver _ _ = ()
138138
139139deriving stock instance Ord (VoidQuiver a b)
140140
@@ -219,7 +219,7 @@ iohmStructural e =
219219
220220instance (Typeable k, Typeable v, Ord k, Show k) => Steppable (IOHM.InsOrdHashMap k v) v where
221221 data Step (IOHM.InsOrdHashMap k v) v = InsOrdHashMapKeyStep k
222− deriving (Eq, Ord, Show)
222+ deriving stock (Eq, Ord, Show)
223223
224224iohmStructuralWith
225225 :: (Ord k, Hashable k, Typeable k, Typeable v, Show k)
src/OpenAPI/Checker/Validate/Link.hs+1−1
@@ -16,7 +16,7 @@ instance Subtree Link where
1616instance Issuable 'LinkLevel where
1717 data Issue 'LinkLevel
1818 = LinksUnsupported
19− deriving (Eq, Ord, Show)
19+ deriving stock (Eq, Ord, Show)
2020 issueIsUnsupported = \case
2121 LinksUnsupported -> True
2222 describeIssue LinksUnsupported = para "OpenApi Diff does not currently support Link Objects."
src/OpenAPI/Checker/Validate/MediaTypeObject.hs+7−7
@@ -6,8 +6,8 @@ module OpenAPI.Checker.Validate.MediaTypeObject
66 )
77where
88
9−import Control.Lens hiding (para)
109import Data.Foldable as F
10+import Data.Functor
1111import Data.HList
1212import Data.HashMap.Strict.InsOrd as IOHM
1313import Data.Map.Strict as M
@@ -37,7 +37,7 @@ instance Issuable 'PayloadLevel where
3737 = MediaTypeSchemaRequired
3838 | MediaEncodingMissing Text
3939 | EncodingNotSupported
40− deriving (Eq, Ord, Show)
40+ deriving stock (Eq, Ord, Show)
4141 issueIsUnsupported = \case
4242 EncodingNotSupported -> True
4343 _ -> False
@@ -49,7 +49,7 @@ instance Issuable 'PayloadLevel where
4949instance Behavable 'PayloadLevel 'SchemaLevel where
5050 data Behave 'PayloadLevel 'SchemaLevel
5151 = PayloadSchema
52− deriving (Eq, Ord, Show)
52+ deriving stock (Eq, Ord, Show)
5353 describeBehaviour PayloadSchema = "JSON Schema"
5454
5555instance Subtree MediaTypeObject where
@@ -124,19 +124,19 @@ instance Subtree Encoding where
124124
125125instance Steppable MediaTypeObject (Referenced Schema) where
126126 data Step MediaTypeObject (Referenced Schema) = MediaTypeSchema
127− deriving (Eq, Ord, Show)
127+ deriving stock (Eq, Ord, Show)
128128
129129instance Steppable MediaTypeObject (Definitions Encoding) where
130130 data Step MediaTypeObject (Definitions Encoding) = MediaTypeEncodingMapping
131− deriving (Eq, Ord, Show)
131+ deriving stock (Eq, Ord, Show)
132132
133133instance Steppable MediaTypeObject Encoding where
134134 data Step MediaTypeObject Encoding = MediaTypeParamEncoding Text
135− deriving (Eq, Ord, Show)
135+ deriving stock (Eq, Ord, Show)
136136
137137instance Steppable Encoding (Definitions (Referenced Header)) where
138138 data Step Encoding (Definitions (Referenced Header)) = EncodingHeaderStep
139− deriving (Eq, Ord, Show)
139+ deriving stock (Eq, Ord, Show)
140140
141141instance Behavable 'OperationLevel 'ResponseLevel where
142142 data Behave 'OperationLevel 'ResponseLevel
src/OpenAPI/Checker/Validate/OAuth2Flows.hs+2−2
@@ -52,7 +52,7 @@ instance Subtree OAuth2Flows where
5252
5353instance Typeable t => Steppable OAuth2Flows (OAuth2Flow t) where
5454 data Step OAuth2Flows (OAuth2Flow t) = OAuth2FlowsFlow (Proxy t)
55− deriving (Eq, Ord, Show)
55+ deriving stock (Eq, Ord, Show)
5656
5757instance (Typeable t, Subtree t, SubtreeLevel (OAuth2Flow t) ~ SubtreeLevel t) => Subtree (OAuth2Flow t) where
5858 type CheckEnv (OAuth2Flow t) = CheckEnv t
@@ -68,7 +68,7 @@ instance (Typeable t, Subtree t, SubtreeLevel (OAuth2Flow t) ~ SubtreeLevel t) =
6868
6969instance Typeable t => Steppable (OAuth2Flow t) t where
7070 data Step (OAuth2Flow t) t = OAuth2FlowParamsStep (Proxy t)
71− deriving (Eq, Ord, Show)
71+ deriving stock (Eq, Ord, Show)
7272
7373instance Subtree OAuth2ImplicitFlow where
7474 type SubtreeLevel OAuth2ImplicitFlow = 'SecuritySchemeLevel
src/OpenAPI/Checker/Validate/OpenApi.hs+9−9
@@ -92,36 +92,36 @@ instance Subtree OpenApi where
9292
9393instance Steppable OpenApi ProcessedPathItems where
9494 data Step OpenApi ProcessedPathItems = OpenApiPathsStep
95− deriving (Eq, Ord, Show)
95+ deriving stock (Eq, Ord, Show)
9696
9797instance Steppable OpenApi (Definitions RequestBody) where
9898 data Step OpenApi (Definitions RequestBody) = ComponentsRequestBody
99− deriving (Eq, Ord, Show)
99+ deriving stock (Eq, Ord, Show)
100100
101101instance Steppable OpenApi (Definitions Param) where
102102 data Step OpenApi (Definitions Param) = ComponentsParam
103− deriving (Eq, Ord, Show)
103+ deriving stock (Eq, Ord, Show)
104104
105105instance Steppable OpenApi (Definitions SecurityScheme) where
106106 data Step OpenApi (Definitions SecurityScheme) = ComponentsSecurityScheme
107− deriving (Eq, Ord, Show)
107+ deriving stock (Eq, Ord, Show)
108108
109109instance Steppable OpenApi (Definitions Response) where
110110 data Step OpenApi (Definitions Response) = ComponentsResponse
111− deriving (Eq, Ord, Show)
111+ deriving stock (Eq, Ord, Show)
112112
113113instance Steppable OpenApi (Definitions Header) where
114114 data Step OpenApi (Definitions Header) = ComponentsHeader
115− deriving (Eq, Ord, Show)
115+ deriving stock (Eq, Ord, Show)
116116
117117instance Steppable OpenApi (Definitions Schema) where
118118 data Step OpenApi (Definitions Schema) = ComponentsSchema
119− deriving (Eq, Ord, Show)
119+ deriving stock (Eq, Ord, Show)
120120
121121instance Steppable OpenApi (Definitions Link) where
122122 data Step OpenApi (Definitions Link) = ComponentsLink
123− deriving (Eq, Ord, Show)
123+ deriving stock (Eq, Ord, Show)
124124
125125instance Steppable OpenApi (Definitions Callback) where
126126 data Step OpenApi (Definitions Callback) = ComponentsCallbacks
127− deriving (Eq, Ord, Show)
127+ deriving stock (Eq, Ord, Show)
src/OpenAPI/Checker/Validate/Operation.hs+9−9
@@ -297,7 +297,7 @@ data OperationMethod
297297 | HeadMethod
298298 | PatchMethod
299299 | TraceMethod
300− deriving (Eq, Ord, Show)
300+ deriving stock (Eq, Ord, Show)
301301
302302pathItemMethod :: OperationMethod -> PathItem -> Maybe Operation
303303pathItemMethod = \case
@@ -334,7 +334,7 @@ instance Steppable MatchedOperation [Server] where
334334 data Step MatchedOperation [Server]
335335 = OperationServersStep
336336 | EnvServerStep
337− deriving (Eq, Ord, Show)
337+ deriving stock (Eq, Ord, Show)
338338
339339-- * ProcessedPathItems
340340
@@ -466,7 +466,7 @@ instance Issuable 'PathLevel where
466466instance Behavable 'PathLevel 'OperationLevel where
467467 data Behave 'PathLevel 'OperationLevel
468468 = InOperation OperationMethod
469− deriving (Eq, Ord, Show)
469+ deriving stock (Eq, Ord, Show)
470470
471471 describeBehaviour (InOperation method) = showMethod method
472472
@@ -538,19 +538,19 @@ instance Subtree MatchedPathItem where
538538
539539instance Steppable ProcessedPathItems MatchedPathItem where
540540 data Step ProcessedPathItems MatchedPathItem = MatchedPathStep FilePath
541− deriving (Eq, Ord, Show)
541+ deriving stock (Eq, Ord, Show)
542542
543543instance Steppable MatchedPathItem MatchedOperation where
544544 data Step MatchedPathItem MatchedOperation = OperationMethodStep OperationMethod
545− deriving (Eq, Ord, Show)
545+ deriving stock (Eq, Ord, Show)
546546
547547instance Steppable MatchedPathItem (Referenced Param) where
548548 data Step MatchedPathItem (Referenced Param) = PathItemParam Int
549− deriving (Eq, Ord, Show)
549+ deriving stock (Eq, Ord, Show)
550550
551551instance Steppable MatchedPathItem PathFragmentParam where
552552 data Step MatchedPathItem PathFragmentParam = PathFragmentStep Int
553− deriving (Eq, Ord, Show)
553+ deriving stock (Eq, Ord, Show)
554554
555555-- * Callbacks
556556
@@ -575,7 +575,7 @@ instance Subtree Callback where
575575instance Issuable 'CallbackLevel where
576576 data Issue 'CallbackLevel
577577 = CallbacksUnsupported
578− deriving (Eq, Ord, Show)
578+ deriving stock (Eq, Ord, Show)
579579 issueIsUnsupported = \case
580580 CallbacksUnsupported -> True
581581 describeIssue CallbacksUnsupported = para "OpenApi Diff does not currently support callbacks."
@@ -586,7 +586,7 @@ tracedCallbackPathItems (Traced t (Callback x)) =
586586
587587instance Steppable Callback ProcessedPathItems where
588588 data Step Callback ProcessedPathItems = CallbackPathsStep
589− deriving (Eq, Ord, Show)
589+ deriving stock (Eq, Ord, Show)
590590
591591instance Behavable 'OperationLevel 'CallbackLevel where
592592 data Behave 'OperationLevel 'CallbackLevel = OperationCallback Text
src/OpenAPI/Checker/Validate/Param.hs+38−30
@@ -4,10 +4,11 @@
44module OpenAPI.Checker.Validate.Param
55 ( Behave (..)
66 , Issue (..)
7− ) where
7+ )
8+where
89
9−import Control.Lens hiding (para)
1010import Control.Monad
11+import Data.Functor
1112import Data.Maybe
1213import Data.OpenApi
1314import Data.Text as T
@@ -22,13 +23,18 @@ import Text.Pandoc.Builder
2223data EncodingStyle = EncodingStyle
2324 { style :: Style
2425 , explode :: Bool
25− , allowReserved :: Maybe Bool
26− -- ^ Nothing when @in@ parameter is not @query@
27− } deriving (Eq, Ord, Show)
26+ , -- | Nothing when @in@ parameter is not @query@
27+ allowReserved :: Maybe Bool
28+ }
29+ deriving stock (Eq, Ord, Show)
2830
2931paramEncoding :: Param -> EncodingStyle
30−paramEncoding p = EncodingStyle
31− { style, explode, allowReserved }
32+paramEncoding p =
33+ EncodingStyle
34+ { style
35+ , explode
36+ , allowReserved
37+ }
3238 where
3339 style = fromMaybe defaultStyle $ _paramStyle p
3440 defaultStyle = case _paramIn p of
@@ -49,19 +55,19 @@ tracedSchema par = _paramSchema (extract par) <&> traced (ask par >>> step Param
4955
5056instance Issuable 'PathFragmentLevel where
5157 data Issue 'PathFragmentLevel
52− = ParamNameMismatch
53− -- ^ Params have different names
54− | ParamEmptinessIncompatible
55− -- ^ Consumer requires non-empty param, but producer gives emptyable
56− | ParamRequired
57− -- ^ Consumer requires mandatory parm, but producer optional
58+ = -- | Params have different names
59+ ParamNameMismatch
60+ | -- | Consumer requires non-empty param, but producer gives emptyable
61+ ParamEmptinessIncompatible
62+ | -- | Consumer requires mandatory parm, but producer optional
63+ ParamRequired
5864 | ParamPlaceIncompatible
59− | ParamStyleMismatch
60− -- ^ Params encoded in different styles
61− | ParamSchemaMismatch
62− -- ^ One of schemas not presented
65+ | -- | Params encoded in different styles
66+ ParamStyleMismatch
67+ | -- | One of schemas not presented
68+ ParamSchemaMismatch
6369 | PathFragmentsDontMatch Text Text
64− deriving (Eq, Ord, Show)
70+ deriving stock (Eq, Ord, Show)
6571 issueIsUnsupported _ = False
6672 describeIssue ParamNameMismatch = para "The path fragments don't match."
6773 describeIssue ParamEmptinessIncompatible = para "Expected that an empty parameter is allowed, but it isn't."
@@ -74,8 +80,8 @@ instance Issuable 'PathFragmentLevel where
7480instance Behavable 'PathFragmentLevel 'SchemaLevel where
7581 data Behave 'PathFragmentLevel 'SchemaLevel
7682 = InParamSchema
77− deriving (Eq, Ord, Show)
78−
83+ deriving stock (Eq, Ord, Show)
84+
7985 describeBehaviour InParamSchema = "JSON Schema"
8086
8187instance Subtree Param where
@@ -92,30 +98,32 @@ instance Subtree Param where
9298 structuralEq $ fmap _paramExplode <$> pc
9399 pure ()
94100 checkSemanticCompatibility env beh pc@(ProdCons p c) = do
95− when (_paramName (extract p) /= _paramName (extract c))
96− $ issueAt beh ParamNameMismatch
97− when ((fromMaybe False . _paramRequired . extract $ c) &&
98− not (fromMaybe False . _paramRequired . extract $ p))
101+ when (_paramName (extract p) /= _paramName (extract c)) $
102+ issueAt beh ParamNameMismatch
103+ when
104+ ((fromMaybe False . _paramRequired . extract $ c)
105+ && not (fromMaybe False . _paramRequired . extract $ p))
99106 $ issueAt beh ParamRequired
100107 case (_paramIn . extract $ p, _paramIn . extract $ c) of
101108 (ParamQuery, ParamQuery) -> do
102109 -- Emptiness is only for query params
103− when ((fromMaybe False . _paramAllowEmptyValue . extract $ p)
104− && not (fromMaybe False . _paramAllowEmptyValue . extract $ c))
110+ when
111+ ((fromMaybe False . _paramAllowEmptyValue . extract $ p)
112+ && not (fromMaybe False . _paramAllowEmptyValue . extract $ c))
105113 $ issueAt beh ParamEmptinessIncompatible
106114 (a, b) | a == b -> pure ()
107115 _ -> issueAt beh ParamPlaceIncompatible
108− unless (paramEncoding (extract p) == paramEncoding (extract c))
109− $ issueAt beh ParamStyleMismatch
116+ unless (paramEncoding (extract p) == paramEncoding (extract c)) $
117+ issueAt beh ParamStyleMismatch
110118 case tracedSchema <$> pc of
111119 ProdCons (Just prodSchema) (Just consSchema) -> do
112120 checkCompatibility env (beh >>> step InParamSchema) $ ProdCons prodSchema consSchema
113121 ProdCons Nothing Nothing -> pure ()
114122 ProdCons Nothing (Just _consSchema) -> issueAt beh ParamSchemaMismatch
115123 ProdCons (Just _prodSchema) Nothing -> pure ()
116− -- If consumer doesn't care then why we should?
124+ -- If consumer doesn't care then why we should?
117125 pure ()
118126
119127instance Steppable Param (Referenced Schema) where
120128 data Step Param (Referenced Schema) = ParamSchema
121− deriving (Eq, Ord, Show)
129+ deriving stock (Eq, Ord, Show)
src/OpenAPI/Checker/Validate/PathFragment.hs+18−13
@@ -38,17 +38,19 @@ type PathFragmentParam = PathFragment (Traced Param)
3838
3939instance (Typeable param) => Steppable (PathFragment param) Param where
4040 data Step (PathFragment param) Param = StaticPathParam Text
41− deriving (Eq, Ord, Show)
41+ deriving stock (Eq, Ord, Show)
4242
4343tracedPathFragmentParam :: Traced PathFragmentParam -> Traced Param
4444tracedPathFragmentParam pfp = case extract pfp of
45− StaticPath s -> traced (ask pfp >>> step (StaticPathParam s))
46− $ mempty
47− { _paramRequired = Just True
48− , _paramIn = ParamPath
49− , _paramAllowEmptyValue = Just False
50− , _paramAllowReserved = Just False
51− , _paramSchema = Just $ Inline $ staticStringSchema s }
45+ StaticPath s ->
46+ traced (ask pfp >>> step (StaticPathParam s)) $
47+ mempty
48+ { _paramRequired = Just True
49+ , _paramIn = ParamPath
50+ , _paramAllowEmptyValue = Just False
51+ , _paramAllowReserved = Just False
52+ , _paramSchema = Just $ Inline $ staticStringSchema s
53+ }
5254 DynamicPath p -> p
5355
5456staticStringSchema :: Text -> Schema
@@ -61,13 +63,16 @@ staticStringSchema t =
6163
6264instance Subtree PathFragmentParam where
6365 type SubtreeLevel PathFragmentParam = 'PathFragmentLevel
64− type CheckEnv PathFragmentParam =
65− '[ ProdCons (Traced (Definitions Schema)) ]
66+ type
67+ CheckEnv PathFragmentParam =
68+ '[ProdCons (Traced (Definitions Schema))]
69+
6670 -- Not much to compare at this level
67− checkStructuralCompatibility _ _ = structuralIssue
71+ checkStructuralCompatibility _ _ = structuralIssue
72+
6873 -- This case isn't strictly needed. It is here for optimization.
69− checkSemanticCompatibility _ beh (ProdCons (extract -> StaticPath x) (extract -> StaticPath y))
70− = if x == y
74+ checkSemanticCompatibility _ beh (ProdCons (extract -> StaticPath x) (extract -> StaticPath y)) =
75+ if x == y
7176 then pure ()
7277 else issueAt beh (PathFragmentsDontMatch x y)
7378 checkSemanticCompatibility env beh prodCons = do
src/OpenAPI/Checker/Validate/RequestBody.hs+2−2
@@ -67,8 +67,8 @@ instance Subtree RequestBody where
6767
6868instance Steppable RequestBody MediaTypeObject where
6969 data Step RequestBody MediaTypeObject = RequestMediaTypeObject MediaType
70− deriving (Eq, Ord, Show)
70+ deriving stock (Eq, Ord, Show)
7171
7272instance Steppable RequestBody (IOHM.InsOrdHashMap MediaType MediaTypeObject) where
7373 data Step RequestBody (IOHM.InsOrdHashMap MediaType MediaTypeObject) = RequestMediaTypeObjectMapping
74− deriving (Eq, Ord, Show)
74+ deriving stock (Eq, Ord, Show)
src/OpenAPI/Checker/Validate/Schema.hs+7−6
@@ -19,7 +19,6 @@ import Algebra.Lattice
1919import Control.Applicative
2020import Control.Arrow
2121import Control.Comonad.Env hiding (env)
22−import Control.Lens hiding (cons, para)
2322import Control.Monad.Reader hiding (ask)
2423import qualified Control.Monad.Reader as R
2524import Control.Monad.State
@@ -28,6 +27,8 @@ import qualified Data.Aeson as A
2827import qualified Data.ByteString.Lazy as BSL
2928import Data.Coerce
3029import qualified Data.Foldable as F
30+import Data.Functor
31+import Data.Functor.Identity
3132import Data.HList
3233import qualified Data.HashMap.Strict as HM
3334import qualified Data.HashMap.Strict.InsOrd as IOHM
@@ -90,7 +91,7 @@ untypeValue (TArray a) = A.Array a
9091untypeValue (TObject o) = A.Object o
9192
9293data Bound a = Exclusive !a | Inclusive !a
93− deriving (Eq, Show, Functor)
94+ deriving stock (Eq, Show, Functor)
9495
9596-- | The order is lexicographical on @a * Bool@.
9697instance Ord a => Ord (Bound a) where
@@ -417,19 +418,19 @@ instance Steppable Schema (Referenced Schema) where
417418 | ItemsArrayStep Int
418419 | AdditionalPropertiesStep
419420 | NotStep
420− deriving (Eq, Ord, Show)
421+ deriving stock (Eq, Ord, Show)
421422
422423instance Steppable Schema (Definitions (Referenced Schema)) where
423424 data Step Schema (Definitions (Referenced Schema)) = PropertiesStep
424− deriving (Eq, Ord, Show)
425+ deriving stock (Eq, Ord, Show)
425426
426427instance Steppable Schema Discriminator where
427428 data Step Schema Discriminator = DiscriminatorStep
428− deriving (Eq, Ord, Show)
429+ deriving stock (Eq, Ord, Show)
429430
430431instance Steppable Discriminator (Definitions (Referenced Schema)) where
431432 data Step Discriminator (Definitions (Referenced Schema)) = DiscriminatorMapping
432− deriving (Eq, Ord, Show)
433+ deriving stock (Eq, Ord, Show)
433434
434435parseDiscriminatorValue :: Text -> Referenced Schema
435436parseDiscriminatorValue v = case A.fromJSON @(Referenced Schema) $ A.object ["$ref" A..= v] of
src/OpenAPI/Checker/Validate/SecurityScheme.hs+2−2
@@ -36,8 +36,8 @@ tracedSecuritySchemaTypes (Traced t x) = Traced (t >>> step SecuritySchemeTypeSt
3636
3737instance Steppable SecurityScheme SecuritySchemeType where
3838 data Step SecurityScheme SecuritySchemeType = SecuritySchemeTypeStep
39− deriving (Eq, Ord, Show)
39+ deriving stock (Eq, Ord, Show)
4040
4141instance Steppable SecuritySchemeType OAuth2Flows where
4242 data Step SecuritySchemeType OAuth2Flows = SecurityOAuthFlowsStep
43− deriving (Eq, Ord, Show)
43+ deriving stock (Eq, Ord, Show)
src/OpenAPI/Checker/Validate/Server.hs+1−1
@@ -124,7 +124,7 @@ parseServerUrl = fromRight undefined . parseOnly (serverUrlParser <* endOfInput)
124124
125125instance Steppable [Server] ProcessedServer where
126126 data Step [Server] ProcessedServer = ServerStep Text
127− deriving (Eq, Ord, Show)
127+ deriving stock (Eq, Ord, Show)
128128
129129instance Issuable 'ServerLevel where
130130 data Issue 'ServerLevel
test/Spec/Golden/Extra.hs+1−1
@@ -17,7 +17,7 @@ import Test.Tasty.Golden
1717data TestInput t
1818 = TestInputNode TestName [TestInput t]
1919 | TestInputLeaf TestName t FilePath
20− deriving (Functor)
20+ deriving stock (Functor)
2121
2222getGoldenInputs
2323 :: (Each s t (FilePath, FilePath -> IO a) a)