git.iko.soy/typeable/swagger2
on master help sign in
Monoid instance for merging OAuth2 scopes

Only merge scopes when OAuth2Flow are same

commit2437f8dd44cefda16b7645a21907de80059483f7 authorTao Yang <tao.yang@zalando.de> dateThu 22 Mar 2018, 11:35 (9 years ago) parent7879efa
2 files changed+13−1
.gitignore+1−1 src/Data/Swagger/Internal.hs+12
.gitignore+1−1
@@ -16,4 +16,4 @@ cabal.sandbox.config
1616*.prof
1717*.aux
1818*.hp
19−.stack-work/
19+.stack-work/
src/Data/Swagger/Internal.hs+12
@@ -935,6 +935,18 @@ instance OVERLAPPING_ SwaggerMonoid (InsOrdHashMap FilePath PathItem) where
935935 swaggerMempty = InsOrdHashMap.empty
936936 swaggerMappend = InsOrdHashMap.unionWith mappend
937937
938+instance OVERLAPPING_ SwaggerMonoid (InsOrdHashMap Text SecurityScheme) where
939+ swaggerMempty = InsOrdHashMap.empty
940+ swaggerMappend = InsOrdHashMap.unionWith mergeFun
941+ where
942+ mergeFun s1@(SecurityScheme (SecuritySchemeOAuth2 (OAuth2Params flow1 scopes1)) desc)
943+ s2@(SecurityScheme (SecuritySchemeOAuth2 (OAuth2Params flow2 scopes2)) _)
944+ = if flow1 == flow2 then
945+ SecurityScheme (SecuritySchemeOAuth2 (OAuth2Params flow1 (scopes1 <> scopes2))) desc
946+ else
947+ s2
948+ mergeFun _ ss = ss
949+
938950instance Monoid a => SwaggerMonoid (Referenced a) where
939951 swaggerMempty = Inline mempty
940952 swaggerMappend (Inline x) (Inline y) = Inline (mappend x y)