git.iko.soy/typeable/openapi3
on master help sign in
Monoid instance for merging OAuth2 scopes
2437f8dTao Yang
.gitignore+1−1
@@ -16,4 +16,4 @@ cabal.sandbox.config
16*.prof
16*.prof
17*.aux
17*.aux
18*.hp
18*.hp
19−.stack-work/
19+.stack-work/
src/Data/Swagger/Internal.hs+12
@@ -935,6 +935,18 @@ instance OVERLAPPING_ SwaggerMonoid (InsOrdHashMap FilePath PathItem) where
935 swaggerMempty = InsOrdHashMap.empty
935 swaggerMempty = InsOrdHashMap.empty
936 swaggerMappend = InsOrdHashMap.unionWith mappend
936 swaggerMappend = InsOrdHashMap.unionWith mappend
937
937
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+
938instance Monoid a => SwaggerMonoid (Referenced a) where
950instance Monoid a => SwaggerMonoid (Referenced a) where
939 swaggerMempty = Inline mempty
951 swaggerMempty = Inline mempty
940 swaggerMappend (Inline x) (Inline y) = Inline (mappend x y)
952 swaggerMappend (Inline x) (Inline y) = Inline (mappend x y)