@@ -117,7 +117,7 @@ data Swagger = Swagger
117 , _swaggerResponses :: Definitions Response
117 , _swaggerResponses :: Definitions Response
119 -- | Security scheme definitions that can be used across the specification.
119 -- | Security scheme definitions that can be used across the specification.
120− , _swaggerSecurityDefinitions :: SecurityDefinitions
120+ , _swaggerSecurityDefinitions :: Definitions SecurityScheme
122 -- | A declaration of which security schemes are applied for the API as a whole.
122 -- | A declaration of which security schemes are applied for the API as a whole.
123 -- The list of values describes alternative security schemes that can be used
123 -- The list of values describes alternative security schemes that can be used
@@ -755,22 +755,6 @@ data SecurityScheme = SecurityScheme
755 , _securitySchemeDescription :: Maybe Text
755 , _securitySchemeDescription :: Maybe Text
756 } deriving (Eq, Show, Generic, Data, Typeable)
756 } deriving (Eq, Show, Generic, Data, Typeable)
759−-- | merge scopes of two OAuth2 security schemes when their flows are identical.
760−-- In other case returns first security scheme
761−mergeSecurityScheme :: SecurityScheme -> SecurityScheme -> SecurityScheme
762−mergeSecurityScheme s1@(SecurityScheme (SecuritySchemeOAuth2 (OAuth2Params flow1 scopes1)) desc)
763− s2@(SecurityScheme (SecuritySchemeOAuth2 (OAuth2Params flow2 scopes2)) _)
764− = if flow1 == flow2 then
765− SecurityScheme (SecuritySchemeOAuth2 (OAuth2Params flow1 (scopes1 <> scopes2))) desc
768−mergeSecurityScheme s1 _ = s1
770−newtype SecurityDefinitions
771− = SecurityDefinitions (Definitions SecurityScheme)
772− deriving (Eq, Show, Generic, Data, Typeable)
774-- | Lists the required security schemes to execute this operation.
758-- | Lists the required security schemes to execute this operation.
775-- The object can have multiple security schemes declared in it which are all required
759-- The object can have multiple security schemes declared in it which are all required
776-- (that is, there is a logical AND between the schemes).
760-- (that is, there is a logical AND between the schemes).
@@ -920,17 +904,6 @@ instance Monoid Example where
920 mempty = genericMempty
904 mempty = genericMempty
921 mappend = (<>)
905 mappend = (<>)
923−instance Semigroup SecurityScheme where
924− (<>) = mergeSecurityScheme
926−instance Semigroup SecurityDefinitions where
927− (SecurityDefinitions sd1) <> (SecurityDefinitions sd2) =
928− SecurityDefinitions $ InsOrdHashMap.unionWith (<>) sd1 sd2
930−instance Monoid SecurityDefinitions where
931− mempty = SecurityDefinitions $ InsOrdHashMap.empty
934-- =======================================================================
907-- =======================================================================
935-- SwaggerMonoid helper instances
908-- SwaggerMonoid helper instances
936-- =======================================================================
909-- =======================================================================
@@ -945,7 +918,6 @@ instance SwaggerMonoid Responses
945instance SwaggerMonoid Response
918instance SwaggerMonoid Response
946instance SwaggerMonoid ExternalDocs
919instance SwaggerMonoid ExternalDocs
947instance SwaggerMonoid Operation
920instance SwaggerMonoid Operation
948−instance SwaggerMonoid SecurityDefinitions
949instance (Eq a, Hashable a) => SwaggerMonoid (InsOrdHashSet a)
921instance (Eq a, Hashable a) => SwaggerMonoid (InsOrdHashSet a)
951instance SwaggerMonoid MimeList
923instance SwaggerMonoid MimeList
@@ -1146,9 +1118,6 @@ instance ToJSON PathItem where
1146instance ToJSON Example where
1118instance ToJSON Example where
1147 toJSON = toJSON . Map.mapKeys show . getExample
1119 toJSON = toJSON . Map.mapKeys show . getExample
1149−instance ToJSON SecurityDefinitions where
1150− toJSON (SecurityDefinitions sd) = toJSON sd
1152instance ToJSON Reference where
1121instance ToJSON Reference where
1153 toJSON (Reference ref) = object [ "$ref" .= ref ]
1122 toJSON (Reference ref) = object [ "$ref" .= ref ]
@@ -1310,9 +1279,6 @@ instance FromJSON Operation where
1310instance FromJSON PathItem where
1279instance FromJSON PathItem where
1311 parseJSON = sopSwaggerGenericParseJSON
1280 parseJSON = sopSwaggerGenericParseJSON
1313−instance FromJSON SecurityDefinitions where
1314− parseJSON js = SecurityDefinitions <$> parseJSON js
1316instance FromJSON Reference where
1282instance FromJSON Reference where
1317 parseJSON (Object o) = Reference <$> o .: "$ref"
1283 parseJSON (Object o) = Reference <$> o .: "$ref"
1318 parseJSON _ = empty
1284 parseJSON _ = empty
@@ -1424,4 +1390,3 @@ instance AesonDefaultValue (SwaggerType a)
1424instance AesonDefaultValue MimeList where defaultValue = Just mempty
1390instance AesonDefaultValue MimeList where defaultValue = Just mempty
1425instance AesonDefaultValue Info
1391instance AesonDefaultValue Info
1426instance AesonDefaultValue ParamLocation
1392instance AesonDefaultValue ParamLocation
1427−instance AesonDefaultValue SecurityDefinitions where defaultValue = Just $ SecurityDefinitions mempty