@@ -39,8 +39,8 @@ import Data.Text.Encoding (encodeUtf8)
39import GHC.Generics (Generic)
39import GHC.Generics (Generic)
40import Network.HTTP.Media (MediaType, mainType, parameters, parseAccept, subType, (//),
40import Network.HTTP.Media (MediaType, mainType, parameters, parseAccept, subType, (//),
42−import Network.Socket (HostName, PortNumber)
43import Text.Read (readMaybe)
42import Text.Read (readMaybe)
43+import Test.QuickCheck.Arbitrary.Generic
45import Data.HashMap.Strict.InsOrd (InsOrdHashMap)
45import Data.HashMap.Strict.InsOrd (InsOrdHashMap)
46import qualified Data.HashMap.Strict.InsOrd as InsOrdHashMap
46import qualified Data.HashMap.Strict.InsOrd as InsOrdHashMap
@@ -774,6 +774,20 @@ data Header = Header
774 , _headerSchema :: Maybe (Referenced Schema)
774 , _headerSchema :: Maybe (Referenced Schema)
775 } deriving (Eq, Show, Generic, Data, Typeable)
775 } deriving (Eq, Show, Generic, Data, Typeable)
777+-- | According to RFC7235
789+ deriving (Eq, Show, Generic, Data, Typeable)
777-- | The location of the API key.
791-- | The location of the API key.
778data ApiKeyLocation
792data ApiKeyLocation
779 = ApiKeyQuery
793 = ApiKeyQuery
@@ -839,7 +853,7 @@ data OAuth2Flows = OAuth2Flows
839 } deriving (Eq, Show, Generic, Data, Typeable)
853 } deriving (Eq, Show, Generic, Data, Typeable)
841data SecuritySchemeType
855data SecuritySchemeType
842− = SecuritySchemeHttp
856+ = SecuritySchemeHttp HttpScheme
843 | SecuritySchemeApiKey ApiKeyParams
857 | SecuritySchemeApiKey ApiKeyParams
844 | SecuritySchemeOAuth2 OAuth2Flows
858 | SecuritySchemeOAuth2 OAuth2Flows
845 | SecuritySchemeOpenIdConnect URL
859 | SecuritySchemeOpenIdConnect URL
@@ -1127,6 +1141,13 @@ instance ToJSON License where
1127instance ToJSON ServerVariable where
1141instance ToJSON ServerVariable where
1128 toJSON = genericToJSON (jsonPrefix "ServerVariable")
1142 toJSON = genericToJSON (jsonPrefix "ServerVariable")
1144+instance ToJSON HttpScheme where
1145+ toJSON scheme = case scheme of
1146+ SCRAM_SHA_1 -> "SCRAM-SHA-1"
1147+ SCRAM_SHA_256 -> "SCRAM-SHA-256"
1149+ other -> genericToJSON defaultOptions other
1130instance ToJSON ApiKeyLocation where
1151instance ToJSON ApiKeyLocation where
1131 toJSON = genericToJSON (jsonPrefix "ApiKey")
1152 toJSON = genericToJSON (jsonPrefix "ApiKey")
@@ -1182,6 +1203,13 @@ instance FromJSON License where
1182instance FromJSON ServerVariable where
1203instance FromJSON ServerVariable where
1183 parseJSON = genericParseJSON (jsonPrefix "ServerVariable")
1204 parseJSON = genericParseJSON (jsonPrefix "ServerVariable")
1206+instance FromJSON HttpScheme where
1207+ parseJSON = withText "HttpScheme" $ \txt -> case txt of
1208+ "SCRAM-SHA-1" -> pure SCRAM_SHA_1
1209+ "SCRAM-SHA-256" -> pure SCRAM_SHA_256
1210+ "vapid" -> pure Vapid
1211+ _ -> genericParseJSON defaultOptions $ String txt
1185instance FromJSON ApiKeyLocation where
1213instance FromJSON ApiKeyLocation where
1186 parseJSON = genericParseJSON (jsonPrefix "ApiKey")
1214 parseJSON = genericParseJSON (jsonPrefix "ApiKey")
@@ -1229,8 +1257,8 @@ instance ToJSON OAuth2Flows where
1229 toEncoding = sopSwaggerGenericToEncoding
1257 toEncoding = sopSwaggerGenericToEncoding
1231instance ToJSON SecuritySchemeType where
1259instance ToJSON SecuritySchemeType where
1232− toJSON SecuritySchemeHttp
1260+ toJSON (SecuritySchemeHttp scheme)
1233− = object [ "type" .= ("http" :: Text) ]
1261+ = object [ "type" .= ("http" :: Text), "scheme" .= toJSON scheme ]
1234 toJSON (SecuritySchemeApiKey params)
1262 toJSON (SecuritySchemeApiKey params)
1235 = toJSON params
1263 = toJSON params
1236 <+> object [ "type" .= ("apiKey" :: Text) ]
1264 <+> object [ "type" .= ("apiKey" :: Text) ]
@@ -1379,7 +1407,7 @@ instance FromJSON SecuritySchemeType where
1379 parseJSON js@(Object o) = do
1407 parseJSON js@(Object o) = do
1380 (t :: Text) <- o .: "type"
1408 (t :: Text) <- o .: "type"
1381 case t of
1409 case t of
1382− "http" -> pure SecuritySchemeHttp
1410+ "http" -> SecuritySchemeHttp <$> o .: "scheme"
1383 "apiKey" -> SecuritySchemeApiKey <$> parseJSON js
1411 "apiKey" -> SecuritySchemeApiKey <$> parseJSON js
1384 "oauth2" -> SecuritySchemeOAuth2 <$> (o .: "flows")
1412 "oauth2" -> SecuritySchemeOAuth2 <$> (o .: "flows")
1385 "openIdConnect" -> SecuritySchemeOpenIdConnect <$> (o .: "openIdConnectUrl")
1413 "openIdConnect" -> SecuritySchemeOpenIdConnect <$> (o .: "openIdConnectUrl")
@@ -1550,3 +1578,6 @@ instance AesonDefaultValue MimeList where defaultValue = Just mempty
1550instance AesonDefaultValue Info
1578instance AesonDefaultValue Info
1551instance AesonDefaultValue ParamLocation
1579instance AesonDefaultValue ParamLocation
1552instance AesonDefaultValue Link
1580instance AesonDefaultValue Link
1582+instance Arbitrary HttpScheme where
1583+ arbitrary = genericArbitrary