@@ -179,6 +179,9 @@ data ServerVariable = ServerVariable
179179 , _serverVariableDescription :: Maybe Text
180180 } deriving (Eq, Show, Generic, Data, Typeable)
181181
182+instance IsString Server where
183+ fromString s = Server (fromString s) Nothing mempty
184+
182185-- | Holds a set of reusable objects for different aspects of the OAS.
183186-- All objects defined within the components object will have no effect on the API
184187-- unless they are explicitly referenced from properties outside the components object.
@@ -194,36 +197,6 @@ data Components = Components
194197-- , _componentsCallbacks
195198 } deriving (Eq, Show, Generic, Data, Typeable)
196199
197−-- | The host (name or ip) serving the API. It MAY include a port.
198−data Host = Host
199− { _hostName :: HostName -- ^ Host name.
200− , _hostPort :: Maybe PortNumber -- ^ Optional port.
201− } deriving (Eq, Show, Generic, Typeable)
202−
203−instance IsString Host where
204− fromString s = Host s Nothing
205−
206−hostConstr :: Constr
207−hostConstr = mkConstr hostDataType "Host" [] Prefix
208−
209−hostDataType :: DataType
210−hostDataType = mkDataType "Data.Swagger.Host" [hostConstr]
211−
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
218−
219−-- | The transfer protocol of the API.
220−data Scheme
221− = Http
222− | Https
223− | Ws
224− | Wss
225− deriving (Eq, Show, Generic, Data, Typeable)
226−
227200-- | Describes the operations available on a single path.
228201-- A @'PathItem'@ may be empty, due to ACL constraints.
229202-- The path itself is still exposed to the documentation viewer
@@ -421,6 +394,9 @@ instance Data MimeList where
421394 toConstr (MimeList _) = mimeListConstr
422395 dataTypeOf _ = mimeListDataType
423396
397+-- TODO style
398+-- TODO example
399+
424400-- | Describes a single operation parameter.
425401-- A unique parameter is defined by a combination of a name and location.
426402data Param = Param
@@ -438,27 +414,21 @@ data Param = Param
438414 -- Otherwise, the property MAY be included and its default value is @False@.
439415 , _paramRequired :: Maybe Bool
440416
441− -- | Parameter schema.
442− , _paramSchema :: ParamAnySchema
443− } deriving (Eq, Show, Generic, Data, Typeable)
444−
445−data ParamAnySchema
446− = ParamBody (Referenced Schema)
447− | ParamOther ParamOtherSchema
448− deriving (Eq, Show, Generic, Data, Typeable)
417+ -- | Specifies that a parameter is deprecated and SHOULD be transitioned out of usage.
418+ -- Default value is @false@.
419+ , _paramDeprecated :: Maybe Bool
449420
450−data ParamOtherSchema = ParamOtherSchema
451− { -- | The location of the parameter.
452− _paramOtherSchemaIn :: ParamLocation
421+ -- | The location of the parameter.
422+ , _paramIn :: ParamLocation
453423
454424 -- | Sets the ability to pass empty-valued parameters.
455− -- This is valid only for either @'ParamQuery'@ or @'ParamFormData'@
456− -- and allows you to send a parameter with a name only or an empty value.
457− -- Default value is @False@.
425+ -- This is valid only for 'ParamQuery' parameters and allows sending
426+ -- a parameter with an empty value. Default value is @false@.
458427 , _paramOtherSchemaAllowEmptyValue :: Maybe Bool
459428
460− , _paramOtherSchemaParamSchema :: ParamSchema 'SwaggerKindParamOtherSchema
461− } deriving (Eq, Show, Generic, Typeable, Data)
429+ -- | Parameter schema.
430+ , _paramSchema :: Maybe (Referenced Schema)
431+ } deriving (Eq, Show, Generic, Data, Typeable)
462432
463433data Example = Example
464434 { -- | Short description for the example.
@@ -561,10 +531,11 @@ deriving instance Typeable 'SwaggerKindNormal
561531deriving instance Typeable 'SwaggerKindParamOtherSchema
562532deriving instance Typeable 'SwaggerKindSchema
563533
534+-- TODO remove
564535type family SwaggerKindType (k :: SwaggerKind *) :: *
565536type instance SwaggerKindType ('SwaggerKindNormal t) = t
566537type instance SwaggerKindType 'SwaggerKindSchema = Schema
567−type instance SwaggerKindType 'SwaggerKindParamOtherSchema = ParamOtherSchema
538+--type instance SwaggerKindType 'SwaggerKindParamOtherSchema = ParamOtherSchema
568539
569540data SwaggerType t where
570541 SwaggerString :: SwaggerType t
@@ -967,7 +938,6 @@ deriveGeneric ''OAuth2Flow
967938deriveGeneric ''OAuth2Flows
968939deriveGeneric ''Operation
969940deriveGeneric ''Param
970−deriveGeneric ''ParamOtherSchema
971941deriveGeneric ''PathItem
972942deriveGeneric ''Response
973943deriveGeneric ''RequestBody
@@ -1032,12 +1002,6 @@ instance Monoid Param where
10321002 mempty = genericMempty
10331003 mappend = (<>)
10341004
1035−instance Semigroup ParamOtherSchema where
1036− (<>) = genericMappend
1037−instance Monoid ParamOtherSchema where
1038− mempty = genericMempty
1039− mappend = (<>)
1040−
10411005instance Semigroup Header where
10421006 (<>) = genericMappend
10431007instance Monoid Header where
@@ -1086,6 +1050,12 @@ instance Monoid OAuth2Flows where
10861050 mempty = genericMempty
10871051 mappend = (<>)
10881052
1053+instance Semigroup RequestBody where
1054+ (<>) = genericMappend
1055+instance Monoid RequestBody where
1056+ mempty = genericMempty
1057+ mappend = (<>)
1058+
10891059-- =======================================================================
10901060-- SwaggerMonoid helper instances
10911061-- =======================================================================
@@ -1096,7 +1066,6 @@ instance SwaggerMonoid PathItem
10961066instance SwaggerMonoid Schema
10971067instance SwaggerMonoid (ParamSchema t)
10981068instance SwaggerMonoid Param
1099−instance SwaggerMonoid ParamOtherSchema
11001069instance SwaggerMonoid Responses
11011070instance SwaggerMonoid Response
11021071instance SwaggerMonoid ExternalDocs
@@ -1123,12 +1092,6 @@ instance Monoid a => SwaggerMonoid (Referenced a) where
11231092 swaggerMappend (Inline x) (Inline y) = Inline (mappend x y)
11241093 swaggerMappend _ y = y
11251094
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
1131−
11321095-- =======================================================================
11331096-- Simple Generic-based ToJSON instances
11341097-- =======================================================================
@@ -1157,9 +1120,6 @@ instance ToJSON ApiKeyLocation where
11571120instance ToJSON ApiKeyParams where
11581121 toJSON = genericToJSON (jsonPrefix "apiKey")
11591122
1160−instance ToJSON Scheme where
1161− toJSON = genericToJSON (jsonPrefix "")
1162−
11631123instance ToJSON Tag where
11641124 toJSON = genericToJSON (jsonPrefix "Tag")
11651125
@@ -1212,9 +1172,6 @@ instance FromJSON ApiKeyLocation where
12121172instance FromJSON ApiKeyParams where
12131173 parseJSON = genericParseJSON (jsonPrefix "apiKey")
12141174
1215−instance FromJSON Scheme where
1216− parseJSON = genericParseJSON (jsonPrefix "")
1217−
12181175instance FromJSON Tag where
12191176 parseJSON = genericParseJSON (jsonPrefix "Tag")
12201177
@@ -1303,12 +1260,6 @@ instance ToJSON Components where
13031260 toJSON = sopSwaggerGenericToJSON
13041261 toEncoding = sopSwaggerGenericToEncoding
13051262
1306−instance ToJSON Host where
1307− toJSON (Host host mport) = toJSON $
1308− case mport of
1309− Nothing -> host
1310− Just port -> host ++ ":" ++ show port
1311−
13121263instance ToJSON MimeList where
13131264 toJSON (MimeList xs) = toJSON (map show xs)
13141265
@@ -1316,14 +1267,6 @@ instance ToJSON Param where
13161267 toJSON = sopSwaggerGenericToJSON
13171268 toEncoding = sopSwaggerGenericToEncoding
13181269
1319−instance ToJSON ParamAnySchema where
1320− toJSON (ParamBody s) = object [ "in" .= ("body" :: Text), "schema" .= s ]
1321− toJSON (ParamOther s) = toJSON s
1322−
1323−instance ToJSON ParamOtherSchema where
1324− toJSON = sopSwaggerGenericToJSON
1325− toEncoding = sopSwaggerGenericToEncoding
1326−
13271270instance ToJSON Responses where
13281271 toJSON = sopSwaggerGenericToJSON
13291272 toEncoding = sopSwaggerGenericToEncoding
@@ -1466,34 +1409,12 @@ instance FromJSON (SwaggerItems 'SwaggerKindSchema) where
14661409instance FromJSON Components where
14671410 parseJSON = sopSwaggerGenericParseJSON
14681411
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
1477−
14781412instance FromJSON MimeList where
14791413 parseJSON js = (MimeList . map fromString) <$> parseJSON js
14801414
14811415instance FromJSON Param where
14821416 parseJSON = sopSwaggerGenericParseJSON
14831417
1484−instance FromJSON ParamAnySchema where
1485− parseJSON js@(Object o) = do
1486− (i :: Text) <- o .: "in"
1487− case i of
1488− "body" -> do
1489− schema <- o .: "schema"
1490− ParamBody <$> parseJSON schema
1491− _ -> ParamOther <$> parseJSON js
1492− parseJSON _ = empty
1493−
1494−instance FromJSON ParamOtherSchema where
1495− parseJSON = sopSwaggerGenericParseJSON
1496−
14971418instance FromJSON Responses where
14981419 parseJSON (Object o) = Responses
14991420 <$> o .:? "default"
@@ -1589,9 +1510,7 @@ instance HasSwaggerAesonOptions OAuth2Flows where
15891510instance HasSwaggerAesonOptions Operation where
15901511 swaggerAesonOptions _ = mkSwaggerAesonOptions "operation"
15911512instance HasSwaggerAesonOptions Param where
1592− swaggerAesonOptions _ = mkSwaggerAesonOptions "param" & saoSubObject ?~ "schema"
1593−instance HasSwaggerAesonOptions ParamOtherSchema where
1594− swaggerAesonOptions _ = mkSwaggerAesonOptions "paramOtherSchema" & saoSubObject ?~ "paramSchema"
1513+ swaggerAesonOptions _ = mkSwaggerAesonOptions "param"
15951514instance HasSwaggerAesonOptions PathItem where
15961515 swaggerAesonOptions _ = mkSwaggerAesonOptions "pathItem"
15971516instance HasSwaggerAesonOptions Response where
@@ -1629,7 +1548,6 @@ instance AesonDefaultValue OAuth2ClientCredentialsFlow
16291548instance AesonDefaultValue OAuth2AuthorizationCodeFlow
16301549instance AesonDefaultValue p => AesonDefaultValue (OAuth2Flow p)
16311550instance AesonDefaultValue Responses
1632−instance AesonDefaultValue ParamAnySchema
16331551instance AesonDefaultValue SecuritySchemeType
16341552instance AesonDefaultValue (SwaggerType a)
16351553instance AesonDefaultValue MimeList where defaultValue = Just mempty