@@ -292,7 +292,7 @@ data ParamOtherSchema = ParamOtherSchema
293 -- | Determines the format of the array if @'ParamArray'@ is used.
293 -- | Determines the format of the array if @'ParamArray'@ is used.
294 -- Default value is csv.
294 -- Default value is csv.
295− , _paramOtherSchemaCollectionFormat :: Maybe CollectionFormat
295+ , _paramOtherSchemaCollectionFormat :: Maybe (CollectionFormat Param)
297 , _paramOtherSchemaCommon :: SchemaCommon (SwaggerType Param) Items
297 , _paramOtherSchemaCommon :: SchemaCommon (SwaggerType Param) Items
298 } deriving (Eq, Show, Generic)
298 } deriving (Eq, Show, Generic)
@@ -333,23 +333,22 @@ data ParamLocation
333type Format = Text
333type Format = Text
335-- | Determines the format of the array.
335-- | Determines the format of the array.
336−data CollectionFormat
336+data CollectionFormat t where
337+ -- Comma separated values: @foo,bar@.
338+ CollectionCSV :: CollectionFormat t
337− = CollectionCSV -- ^ Comma separated values: @foo,bar@.
339+ -- Space separated values: @foo bar@.
340+ CollectionSSV :: CollectionFormat t
338− | CollectionSSV -- ^ Space separated values: @foo bar@.
341+ -- Tab separated values: @foo\\tbar@.
342+ CollectionTSV :: CollectionFormat t
339− | CollectionTSV -- ^ Tab separated values: @foo\\tbar@.
343+ -- Pipe separated values: @foo|bar@.
340− | CollectionPipes -- ^ Pipe separated values: @foo|bar@.
344+ CollectionPipes :: CollectionFormat t
341− | CollectionMulti -- ^ Corresponds to multiple parameter instances
345+ -- Corresponds to multiple parameter instances
342− -- instead of multiple values for a single instance @foo=bar&foo=baz@.
346+ -- instead of multiple values for a single instance @foo=bar&foo=baz@.
343− -- This is valid only for parameters in @'ParamQuery'@ or @'ParamFormData'@.
347+ -- This is valid only for parameters in @'ParamQuery'@ or @'ParamFormData'@.
344− deriving (Eq, Show)
348+ CollectionMulti :: CollectionFormat Param
346−-- | Determines the format of the nested array.
350+deriving instance Eq (CollectionFormat t)
347−data ItemsCollectionFormat
351+deriving instance Show (CollectionFormat t)
348− = ItemsCollectionCSV -- ^ Comma separated values: @foo,bar@.
349− | ItemsCollectionSSV -- ^ Space separated values: @foo bar@.
350− | ItemsCollectionTSV -- ^ Tab separated values: @foo\\tbar@.
351− | ItemsCollectionPipes -- ^ Pipe separated values: @foo|bar@.
354type ParamName = Text
353type ParamName = Text
@@ -435,7 +434,7 @@ data Xml = Xml
435data Items = Items
434data Items = Items
436 { -- | Determines the format of the array if type array is used.
435 { -- | Determines the format of the array if type array is used.
437 -- Default value is @'ItemsCollectionCSV'@.
436 -- Default value is @'ItemsCollectionCSV'@.
438− _itemsCollectionFormat :: Maybe ItemsCollectionFormat
437+ _itemsCollectionFormat :: Maybe (CollectionFormat Items)
440 , _itemsCommon :: SchemaCommon (SwaggerType Items) Items
439 , _itemsCommon :: SchemaCommon (SwaggerType Items) Items
441 } deriving (Eq, Show, Generic)
440 } deriving (Eq, Show, Generic)
@@ -485,7 +484,7 @@ data Header = Header
486 -- | Determines the format of the array if type array is used.
485 -- | Determines the format of the array if type array is used.
487 -- Default value is @'ItemsCollectionCSV'@.
486 -- Default value is @'ItemsCollectionCSV'@.
488− , _headerCollectionFormat :: Maybe ItemsCollectionFormat
487+ , _headerCollectionFormat :: Maybe (CollectionFormat Items)
490 , _headerCommon :: SchemaCommon (SwaggerType Items) Items
489 , _headerCommon :: SchemaCommon (SwaggerType Items) Items
491 } deriving (Eq, Show, Generic)
490 } deriving (Eq, Show, Generic)
@@ -715,8 +714,6 @@ deriveJSON (jsonPrefix "Param") ''ParamLocation
715deriveJSON' ''Info
714deriveJSON' ''Info
716deriveJSON' ''Contact
715deriveJSON' ''Contact
717deriveJSON' ''License
716deriveJSON' ''License
718−deriveJSON (jsonPrefix "ItemsCollection") ''ItemsCollectionFormat
719−deriveJSON (jsonPrefix "Collection") ''CollectionFormat
720deriveJSON (jsonPrefix "ApiKey") ''ApiKeyLocation
717deriveJSON (jsonPrefix "ApiKey") ''ApiKeyLocation
721deriveJSON (jsonPrefix "apiKey") ''ApiKeyParams
718deriveJSON (jsonPrefix "apiKey") ''ApiKeyParams
722deriveJSON' ''SchemaCommon
719deriveJSON' ''SchemaCommon
@@ -828,6 +825,13 @@ instance ToJSON (SwaggerType t) where
828 toJSON SwaggerNull = "null"
825 toJSON SwaggerNull = "null"
829 toJSON SwaggerObject = "object"
826 toJSON SwaggerObject = "object"
828+instance ToJSON (CollectionFormat t) where
829+ toJSON CollectionCSV = "csv"
830+ toJSON CollectionSSV = "ssv"
831+ toJSON CollectionTSV = "tsv"
832+ toJSON CollectionPipes = "pipes"
833+ toJSON CollectionMulti = "multi"
831-- =======================================================================
835-- =======================================================================
832-- Manual FromJSON instances
836-- Manual FromJSON instances
833-- =======================================================================
837-- =======================================================================
@@ -969,3 +973,9 @@ instance FromJSON (SwaggerType Param) where
969instance FromJSON (SwaggerType Items) where
973instance FromJSON (SwaggerType Items) where
970 parseJSON = parseOneOf [SwaggerString, SwaggerInteger, SwaggerNumber, SwaggerBoolean, SwaggerArray]
974 parseJSON = parseOneOf [SwaggerString, SwaggerInteger, SwaggerNumber, SwaggerBoolean, SwaggerArray]
976+instance FromJSON (CollectionFormat Param) where
977+ parseJSON = parseOneOf [CollectionCSV, CollectionSSV, CollectionTSV, CollectionPipes, CollectionMulti]
979+instance FromJSON (CollectionFormat Items) where
980+ parseJSON = parseOneOf [CollectionCSV, CollectionSSV, CollectionTSV, CollectionPipes]