@@ -39,8 +39,8 @@ import Data.Text.Encoding (encodeUtf8)
3939import GHC.Generics (Generic)
4040import Network.HTTP.Media (MediaType, mainType, parameters, parseAccept, subType, (//),
4141 (/:))
42−import Network.Socket (HostName, PortNumber)
4342import Text.Read (readMaybe)
43+import Test.QuickCheck.Arbitrary.Generic
4444
4545import Data.HashMap.Strict.InsOrd (InsOrdHashMap)
4646import qualified Data.HashMap.Strict.InsOrd as InsOrdHashMap
@@ -774,6 +774,20 @@ data Header = Header
774774 , _headerSchema :: Maybe (Referenced Schema)
775775 } deriving (Eq, Show, Generic, Data, Typeable)
776776
777+-- | According to RFC7235
778+data HttpScheme
779+ = Basic
780+ | Bearer
781+ | Digest
782+ | HOBA
783+ | Mutual
784+ | Negotiate
785+ | OAuth
786+ | SCRAM_SHA_1
787+ | SCRAM_SHA_256
788+ | Vapid
789+ deriving (Eq, Show, Generic, Data, Typeable)
790+
777791-- | The location of the API key.
778792data ApiKeyLocation
779793 = ApiKeyQuery
@@ -839,7 +853,7 @@ data OAuth2Flows = OAuth2Flows
839853 } deriving (Eq, Show, Generic, Data, Typeable)
840854
841855data SecuritySchemeType
842− = SecuritySchemeHttp
856+ = SecuritySchemeHttp HttpScheme
843857 | SecuritySchemeApiKey ApiKeyParams
844858 | SecuritySchemeOAuth2 OAuth2Flows
845859 | SecuritySchemeOpenIdConnect URL
@@ -1127,6 +1141,13 @@ instance ToJSON License where
11271141instance ToJSON ServerVariable where
11281142 toJSON = genericToJSON (jsonPrefix "ServerVariable")
11291143
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"
1148+ Vapid -> "vapid"
1149+ other -> genericToJSON defaultOptions other
1150+
11301151instance ToJSON ApiKeyLocation where
11311152 toJSON = genericToJSON (jsonPrefix "ApiKey")
11321153
@@ -1182,6 +1203,13 @@ instance FromJSON License where
11821203instance FromJSON ServerVariable where
11831204 parseJSON = genericParseJSON (jsonPrefix "ServerVariable")
11841205
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
1212+
11851213instance FromJSON ApiKeyLocation where
11861214 parseJSON = genericParseJSON (jsonPrefix "ApiKey")
11871215
@@ -1229,8 +1257,8 @@ instance ToJSON OAuth2Flows where
12291257 toEncoding = sopSwaggerGenericToEncoding
12301258
12311259instance ToJSON SecuritySchemeType where
1232− toJSON SecuritySchemeHttp
1233− = object [ "type" .= ("http" :: Text) ]
1260+ toJSON (SecuritySchemeHttp scheme)
1261+ = object [ "type" .= ("http" :: Text), "scheme" .= toJSON scheme ]
12341262 toJSON (SecuritySchemeApiKey params)
12351263 = toJSON params
12361264 <+> object [ "type" .= ("apiKey" :: Text) ]
@@ -1379,7 +1407,7 @@ instance FromJSON SecuritySchemeType where
13791407 parseJSON js@(Object o) = do
13801408 (t :: Text) <- o .: "type"
13811409 case t of
1382− "http" -> pure SecuritySchemeHttp
1410+ "http" -> SecuritySchemeHttp <$> o .: "scheme"
13831411 "apiKey" -> SecuritySchemeApiKey <$> parseJSON js
13841412 "oauth2" -> SecuritySchemeOAuth2 <$> (o .: "flows")
13851413 "openIdConnect" -> SecuritySchemeOpenIdConnect <$> (o .: "openIdConnectUrl")
@@ -1550,3 +1578,6 @@ instance AesonDefaultValue MimeList where defaultValue = Just mempty
15501578instance AesonDefaultValue Info
15511579instance AesonDefaultValue ParamLocation
15521580instance AesonDefaultValue Link
1581+
1582+instance Arbitrary HttpScheme where
1583+ arbitrary = genericArbitrary