@@ -179,6 +179,9 @@ data ServerVariable = ServerVariable
179 , _serverVariableDescription :: Maybe Text
179 , _serverVariableDescription :: Maybe Text
180 } deriving (Eq, Show, Generic, Data, Typeable)
180 } deriving (Eq, Show, Generic, Data, Typeable)
182+instance IsString Server where
183+ fromString s = Server (fromString s) Nothing mempty
182-- | Holds a set of reusable objects for different aspects of the OAS.
185-- | Holds a set of reusable objects for different aspects of the OAS.
183-- All objects defined within the components object will have no effect on the API
186-- All objects defined within the components object will have no effect on the API
184-- unless they are explicitly referenced from properties outside the components object.
187-- unless they are explicitly referenced from properties outside the components object.
@@ -194,36 +197,6 @@ data Components = Components
194-- , _componentsCallbacks
197-- , _componentsCallbacks
195 } deriving (Eq, Show, Generic, Data, Typeable)
198 } deriving (Eq, Show, Generic, Data, Typeable)
197−-- | The host (name or ip) serving the API. It MAY include a port.
199− { _hostName :: HostName -- ^ Host name.
200− , _hostPort :: Maybe PortNumber -- ^ Optional port.
201− } deriving (Eq, Show, Generic, Typeable)
203−instance IsString Host where
204− fromString s = Host s Nothing
207−hostConstr = mkConstr hostDataType "Host" [] Prefix
209−hostDataType :: DataType
210−hostDataType = mkDataType "Data.Swagger.Host" [hostConstr]
212−instance Data Host where
213− gunfold k z c = case constrIndex c of
214− 1 -> k (k (z (\name mport -> Host name (fromInteger <$> mport))))
215− _ -> error $ "Data.Data.gunfold: Constructor " ++ show c ++ " is not of type Host."
216− toConstr (Host _ _) = hostConstr
217− dataTypeOf _ = hostDataType
219−-- | The transfer protocol of the API.
225− deriving (Eq, Show, Generic, Data, Typeable)
227-- | Describes the operations available on a single path.
200-- | Describes the operations available on a single path.
228-- A @'PathItem'@ may be empty, due to ACL constraints.
201-- A @'PathItem'@ may be empty, due to ACL constraints.
229-- The path itself is still exposed to the documentation viewer
202-- The path itself is still exposed to the documentation viewer
@@ -421,6 +394,9 @@ instance Data MimeList where
421 toConstr (MimeList _) = mimeListConstr
394 toConstr (MimeList _) = mimeListConstr
422 dataTypeOf _ = mimeListDataType
395 dataTypeOf _ = mimeListDataType
424-- | Describes a single operation parameter.
400-- | Describes a single operation parameter.
425-- A unique parameter is defined by a combination of a name and location.
401-- A unique parameter is defined by a combination of a name and location.
426data Param = Param
402data Param = Param
@@ -438,27 +414,21 @@ data Param = Param
438 -- Otherwise, the property MAY be included and its default value is @False@.
414 -- Otherwise, the property MAY be included and its default value is @False@.
439 , _paramRequired :: Maybe Bool
415 , _paramRequired :: Maybe Bool
441− -- | Parameter schema.
417+ -- | Specifies that a parameter is deprecated and SHOULD be transitioned out of usage.
442− , _paramSchema :: ParamAnySchema
418+ -- Default value is @false@.
443− } deriving (Eq, Show, Generic, Data, Typeable)
419+ , _paramDeprecated :: Maybe Bool
446− = ParamBody (Referenced Schema)
447− | ParamOther ParamOtherSchema
448− deriving (Eq, Show, Generic, Data, Typeable)
450−data ParamOtherSchema = ParamOtherSchema
451− { -- | The location of the parameter.
421+ -- | The location of the parameter.
452− _paramOtherSchemaIn :: ParamLocation
422+ , _paramIn :: ParamLocation
454 -- | Sets the ability to pass empty-valued parameters.
424 -- | Sets the ability to pass empty-valued parameters.
455− -- This is valid only for either @'ParamQuery'@ or @'ParamFormData'@
425+ -- This is valid only for 'ParamQuery' parameters and allows sending
456− -- and allows you to send a parameter with a name only or an empty value.
426+ -- a parameter with an empty value. Default value is @false@.
457− -- Default value is @False@.
458 , _paramOtherSchemaAllowEmptyValue :: Maybe Bool
427 , _paramOtherSchemaAllowEmptyValue :: Maybe Bool
460− , _paramOtherSchemaParamSchema :: ParamSchema 'SwaggerKindParamOtherSchema
429+ -- | Parameter schema.
430+ , _paramSchema :: Maybe (Referenced Schema)
461− } deriving (Eq, Show, Generic, Typeable, Data)
431+ } deriving (Eq, Show, Generic, Data, Typeable)
463data Example = Example
433data Example = Example
464 { -- | Short description for the example.
434 { -- | Short description for the example.
@@ -561,10 +531,11 @@ deriving instance Typeable 'SwaggerKindNormal
561deriving instance Typeable 'SwaggerKindParamOtherSchema
531deriving instance Typeable 'SwaggerKindParamOtherSchema
562deriving instance Typeable 'SwaggerKindSchema
532deriving instance Typeable 'SwaggerKindSchema
564type family SwaggerKindType (k :: SwaggerKind *) :: *
535type family SwaggerKindType (k :: SwaggerKind *) :: *
565type instance SwaggerKindType ('SwaggerKindNormal t) = t
536type instance SwaggerKindType ('SwaggerKindNormal t) = t
566type instance SwaggerKindType 'SwaggerKindSchema = Schema
537type instance SwaggerKindType 'SwaggerKindSchema = Schema
567−type instance SwaggerKindType 'SwaggerKindParamOtherSchema = ParamOtherSchema
538+--type instance SwaggerKindType 'SwaggerKindParamOtherSchema = ParamOtherSchema
569data SwaggerType t where
540data SwaggerType t where
570 SwaggerString :: SwaggerType t
541 SwaggerString :: SwaggerType t
@@ -967,7 +938,6 @@ deriveGeneric ''OAuth2Flow
967deriveGeneric ''OAuth2Flows
938deriveGeneric ''OAuth2Flows
968deriveGeneric ''Operation
939deriveGeneric ''Operation
969deriveGeneric ''Param
940deriveGeneric ''Param
970−deriveGeneric ''ParamOtherSchema
971deriveGeneric ''PathItem
941deriveGeneric ''PathItem
972deriveGeneric ''Response
942deriveGeneric ''Response
973deriveGeneric ''RequestBody
943deriveGeneric ''RequestBody
@@ -1032,12 +1002,6 @@ instance Monoid Param where
1032 mempty = genericMempty
1002 mempty = genericMempty
1033 mappend = (<>)
1003 mappend = (<>)
1035−instance Semigroup ParamOtherSchema where
1036− (<>) = genericMappend
1037−instance Monoid ParamOtherSchema where
1038− mempty = genericMempty
1041instance Semigroup Header where
1005instance Semigroup Header where
1042 (<>) = genericMappend
1006 (<>) = genericMappend
1043instance Monoid Header where
1007instance Monoid Header where
@@ -1086,6 +1050,12 @@ instance Monoid OAuth2Flows where
1086 mempty = genericMempty
1050 mempty = genericMempty
1087 mappend = (<>)
1051 mappend = (<>)
1053+instance Semigroup RequestBody where
1054+ (<>) = genericMappend
1055+instance Monoid RequestBody where
1056+ mempty = genericMempty
1089-- =======================================================================
1059-- =======================================================================
1090-- SwaggerMonoid helper instances
1060-- SwaggerMonoid helper instances
1091-- =======================================================================
1061-- =======================================================================
@@ -1096,7 +1066,6 @@ instance SwaggerMonoid PathItem
1096instance SwaggerMonoid Schema
1066instance SwaggerMonoid Schema
1097instance SwaggerMonoid (ParamSchema t)
1067instance SwaggerMonoid (ParamSchema t)
1098instance SwaggerMonoid Param
1068instance SwaggerMonoid Param
1099−instance SwaggerMonoid ParamOtherSchema
1100instance SwaggerMonoid Responses
1069instance SwaggerMonoid Responses
1101instance SwaggerMonoid Response
1070instance SwaggerMonoid Response
1102instance SwaggerMonoid ExternalDocs
1071instance SwaggerMonoid ExternalDocs
@@ -1123,12 +1092,6 @@ instance Monoid a => SwaggerMonoid (Referenced a) where
1123 swaggerMappend (Inline x) (Inline y) = Inline (mappend x y)
1092 swaggerMappend (Inline x) (Inline y) = Inline (mappend x y)
1124 swaggerMappend _ y = y
1093 swaggerMappend _ y = y
1126−instance SwaggerMonoid ParamAnySchema where
1127− swaggerMempty = ParamOther swaggerMempty
1128− swaggerMappend (ParamBody x) (ParamBody y) = ParamBody (swaggerMappend x y)
1129− swaggerMappend (ParamOther x) (ParamOther y) = ParamOther (swaggerMappend x y)
1130− swaggerMappend _ y = y
1132-- =======================================================================
1095-- =======================================================================
1133-- Simple Generic-based ToJSON instances
1096-- Simple Generic-based ToJSON instances
1134-- =======================================================================
1097-- =======================================================================
@@ -1157,9 +1120,6 @@ instance ToJSON ApiKeyLocation where
1157instance ToJSON ApiKeyParams where
1120instance ToJSON ApiKeyParams where
1158 toJSON = genericToJSON (jsonPrefix "apiKey")
1121 toJSON = genericToJSON (jsonPrefix "apiKey")
1160−instance ToJSON Scheme where
1161− toJSON = genericToJSON (jsonPrefix "")
1163instance ToJSON Tag where
1123instance ToJSON Tag where
1164 toJSON = genericToJSON (jsonPrefix "Tag")
1124 toJSON = genericToJSON (jsonPrefix "Tag")
@@ -1212,9 +1172,6 @@ instance FromJSON ApiKeyLocation where
1212instance FromJSON ApiKeyParams where
1172instance FromJSON ApiKeyParams where
1213 parseJSON = genericParseJSON (jsonPrefix "apiKey")
1173 parseJSON = genericParseJSON (jsonPrefix "apiKey")
1215−instance FromJSON Scheme where
1216− parseJSON = genericParseJSON (jsonPrefix "")
1218instance FromJSON Tag where
1175instance FromJSON Tag where
1219 parseJSON = genericParseJSON (jsonPrefix "Tag")
1176 parseJSON = genericParseJSON (jsonPrefix "Tag")
@@ -1303,12 +1260,6 @@ instance ToJSON Components where
1303 toJSON = sopSwaggerGenericToJSON
1260 toJSON = sopSwaggerGenericToJSON
1304 toEncoding = sopSwaggerGenericToEncoding
1261 toEncoding = sopSwaggerGenericToEncoding
1306−instance ToJSON Host where
1307− toJSON (Host host mport) = toJSON $
1310− Just port -> host ++ ":" ++ show port
1312instance ToJSON MimeList where
1263instance ToJSON MimeList where
1313 toJSON (MimeList xs) = toJSON (map show xs)
1264 toJSON (MimeList xs) = toJSON (map show xs)
@@ -1316,14 +1267,6 @@ instance ToJSON Param where
1316 toJSON = sopSwaggerGenericToJSON
1267 toJSON = sopSwaggerGenericToJSON
1317 toEncoding = sopSwaggerGenericToEncoding
1268 toEncoding = sopSwaggerGenericToEncoding
1319−instance ToJSON ParamAnySchema where
1320− toJSON (ParamBody s) = object [ "in" .= ("body" :: Text), "schema" .= s ]
1321− toJSON (ParamOther s) = toJSON s
1323−instance ToJSON ParamOtherSchema where
1324− toJSON = sopSwaggerGenericToJSON
1325− toEncoding = sopSwaggerGenericToEncoding
1327instance ToJSON Responses where
1270instance ToJSON Responses where
1328 toJSON = sopSwaggerGenericToJSON
1271 toJSON = sopSwaggerGenericToJSON
1329 toEncoding = sopSwaggerGenericToEncoding
1272 toEncoding = sopSwaggerGenericToEncoding
@@ -1466,34 +1409,12 @@ instance FromJSON (SwaggerItems 'SwaggerKindSchema) where
1466instance FromJSON Components where
1409instance FromJSON Components where
1467 parseJSON = sopSwaggerGenericParseJSON
1410 parseJSON = sopSwaggerGenericParseJSON
1469−instance FromJSON Host where
1470− parseJSON (String s) = case map Text.unpack $ Text.split (== ':') s of
1471− [host] -> return $ Host host Nothing
1472− [host, port] -> case readMaybe port of
1473− Nothing -> fail $ "Invalid port `" ++ port ++ "'"
1474− Just p -> return $ Host host (Just (fromInteger p))
1475− _ -> fail $ "Invalid host `" ++ Text.unpack s ++ "'"
1476− parseJSON _ = empty
1478instance FromJSON MimeList where
1412instance FromJSON MimeList where
1479 parseJSON js = (MimeList . map fromString) <$> parseJSON js
1413 parseJSON js = (MimeList . map fromString) <$> parseJSON js
1481instance FromJSON Param where
1415instance FromJSON Param where
1482 parseJSON = sopSwaggerGenericParseJSON
1416 parseJSON = sopSwaggerGenericParseJSON
1484−instance FromJSON ParamAnySchema where
1485− parseJSON js@(Object o) = do
1486− (i :: Text) <- o .: "in"
1489− schema <- o .: "schema"
1490− ParamBody <$> parseJSON schema
1491− _ -> ParamOther <$> parseJSON js
1492− parseJSON _ = empty
1494−instance FromJSON ParamOtherSchema where
1495− parseJSON = sopSwaggerGenericParseJSON
1497instance FromJSON Responses where
1418instance FromJSON Responses where
1498 parseJSON (Object o) = Responses
1419 parseJSON (Object o) = Responses
1499 <$> o .:? "default"
1420 <$> o .:? "default"
@@ -1589,9 +1510,7 @@ instance HasSwaggerAesonOptions OAuth2Flows where
1589instance HasSwaggerAesonOptions Operation where
1510instance HasSwaggerAesonOptions Operation where
1590 swaggerAesonOptions _ = mkSwaggerAesonOptions "operation"
1511 swaggerAesonOptions _ = mkSwaggerAesonOptions "operation"
1591instance HasSwaggerAesonOptions Param where
1512instance HasSwaggerAesonOptions Param where
1592− swaggerAesonOptions _ = mkSwaggerAesonOptions "param" & saoSubObject ?~ "schema"
1513+ swaggerAesonOptions _ = mkSwaggerAesonOptions "param"
1593−instance HasSwaggerAesonOptions ParamOtherSchema where
1594− swaggerAesonOptions _ = mkSwaggerAesonOptions "paramOtherSchema" & saoSubObject ?~ "paramSchema"
1595instance HasSwaggerAesonOptions PathItem where
1514instance HasSwaggerAesonOptions PathItem where
1596 swaggerAesonOptions _ = mkSwaggerAesonOptions "pathItem"
1515 swaggerAesonOptions _ = mkSwaggerAesonOptions "pathItem"
1597instance HasSwaggerAesonOptions Response where
1516instance HasSwaggerAesonOptions Response where
@@ -1629,7 +1548,6 @@ instance AesonDefaultValue OAuth2ClientCredentialsFlow
1629instance AesonDefaultValue OAuth2AuthorizationCodeFlow
1548instance AesonDefaultValue OAuth2AuthorizationCodeFlow
1630instance AesonDefaultValue p => AesonDefaultValue (OAuth2Flow p)
1549instance AesonDefaultValue p => AesonDefaultValue (OAuth2Flow p)
1631instance AesonDefaultValue Responses
1550instance AesonDefaultValue Responses
1632−instance AesonDefaultValue ParamAnySchema
1633instance AesonDefaultValue SecuritySchemeType
1551instance AesonDefaultValue SecuritySchemeType
1634instance AesonDefaultValue (SwaggerType a)
1552instance AesonDefaultValue (SwaggerType a)
1635instance AesonDefaultValue MimeList where defaultValue = Just mempty
1553instance AesonDefaultValue MimeList where defaultValue = Just mempty