@@ -338,6 +338,29 @@ data MediaTypeObject = MediaTypeObject
338 , _mediaTypeObjectEncoding :: InsOrdHashMap Text Encoding
338 , _mediaTypeObjectEncoding :: InsOrdHashMap Text Encoding
339 } deriving (Eq, Show, Generic, Data, Typeable)
339 } deriving (Eq, Show, Generic, Data, Typeable)
341+-- | In order to support common ways of serializing simple parameters, a set of style values are defined.
344+ -- ^ Path-style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.7).
346+ -- ^ Label style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.7).
348+ -- ^ Form style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.7).
349+ -- This option replaces @collectionFormat@ with a @csv@ (when @explode@ is false) or @multi@
350+ -- (when explode is true) value from OpenAPI 2.0.
352+ -- ^ Simple style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.7).
353+ -- This option replaces @collectionFormat@ with a @csv@ value from OpenAPI 2.0.
354+ | StyleSpaceDelimited
355+ -- ^ Space separated array values.
356+ -- This option replaces @collectionFormat@ equal to @ssv@ from OpenAPI 2.0.
357+ | StylePipeDelimited
358+ -- ^ Pipe separated array values.
359+ -- This option replaces @collectionFormat@ equal to @pipes@ from OpenAPI 2.0.
361+ -- ^ Provides a simple way of rendering nested objects using form parameters.
362+ deriving (Eq, Show, Generic, Data, Typeable)
341data Encoding = Encoding
364data Encoding = Encoding
342 { -- | The Content-Type for encoding a specific property.
365 { -- | The Content-Type for encoding a specific property.
343 -- Default value depends on the property type: for @string@
366 -- Default value depends on the property type: for @string@
@@ -355,11 +378,11 @@ data Encoding = Encoding
355 , _encodingHeaders :: InsOrdHashMap Text (Referenced Header)
378 , _encodingHeaders :: InsOrdHashMap Text (Referenced Header)
357 -- | Describes how a specific property value will be serialized depending on its type.
380 -- | Describes how a specific property value will be serialized depending on its type.
358− -- See Parameter Object for details on the style property.
381+ -- See 'Param' Object for details on the style property.
359 -- The behavior follows the same values as query parameters, including default values.
382 -- The behavior follows the same values as query parameters, including default values.
360 -- This property SHALL be ignored if the request body media type
383 -- This property SHALL be ignored if the request body media type
361 -- is not @application/x-www-form-urlencoded@.
384 -- is not @application/x-www-form-urlencoded@.
362− , _encodingStyle :: Maybe Text -- TODO enum
385+ , _encodingStyle :: Maybe Style
364 -- | When this is true, property values of type @array@ or @object@ generate
387 -- | When this is true, property values of type @array@ or @object@ generate
365 -- separate parameters for each value of the array,
388 -- separate parameters for each value of the array,
@@ -424,10 +447,38 @@ data Param = Param
424 -- | Sets the ability to pass empty-valued parameters.
447 -- | Sets the ability to pass empty-valued parameters.
425 -- This is valid only for 'ParamQuery' parameters and allows sending
448 -- This is valid only for 'ParamQuery' parameters and allows sending
426 -- a parameter with an empty value. Default value is @false@.
449 -- a parameter with an empty value. Default value is @false@.
427− , _paramOtherSchemaAllowEmptyValue :: Maybe Bool
450+ , _paramAllowEmptyValue :: Maybe Bool
429 -- | Parameter schema.
452 -- | Parameter schema.
430 , _paramSchema :: Maybe (Referenced Schema)
453 , _paramSchema :: Maybe (Referenced Schema)
455+ -- | Describes how the parameter value will be serialized depending
456+ -- on the type of the parameter value. Default values (based on value of '_paramIn'):
457+ -- for 'ParamQuery' - 'StyleForm'; for 'ParamPath' - 'StyleSimple'; for 'ParamHeader' - 'StyleSimple';
458+ -- for 'ParamCookie' - 'StyleForm'.
459+ , _paramStyle :: Maybe Style
461+ -- | When this is true, parameter values of type @array@ or @object@
462+ -- generate separate parameters for each value of the array or key-value pair of the map.
463+ -- For other types of parameters this property has no effect.
464+ -- When style is @form@, the default value is true. For all other styles, the default value is false.
465+ , _paramExplode :: Maybe Bool
467+ -- | Example of the parameter's potential value.
468+ -- The example SHOULD match the specified schema and encoding properties if present.
469+ -- The '_paramExample' field is mutually exclusive of the '_paramExamples' field.
470+ -- Furthermore, if referencing a schema that contains an example, the example value
471+ -- SHALL override the example provided by the schema. To represent examples of media types
472+ -- that cannot naturally be represented in JSON or YAML, a string value can contain
473+ -- the example with escaping where necessary.
474+ , _paramExample :: Maybe Value
476+ -- | Examples of the parameter's potential value.
477+ -- Each example SHOULD contain a value in the correct format as specified
478+ -- in the parameter encoding. The '_paramExamples' field is mutually exclusive of the '_paramExample' field.
479+ -- Furthermore, if referencing a schema that contains an example,
480+ -- the examples value SHALL override the example provided by the schema.
481+ , _paramExamples :: InsOrdHashMap Text (Referenced Example)
431 } deriving (Eq, Show, Generic, Data, Typeable)
482 } deriving (Eq, Show, Generic, Data, Typeable)
433data Example = Example
484data Example = Example
@@ -454,136 +505,26 @@ data Example = Example
455-- | Items for @'SwaggerArray'@ schemas.
506-- | Items for @'SwaggerArray'@ schemas.
457−-- @'SwaggerItemsPrimitive'@ should be used only for query params, headers and path pieces.
508+-- __Warning__: OpenAPI 3.0 does not support tuple arrays. However, OpenAPI 3.1 will, as
458−-- The @'CollectionFormat' t@ parameter specifies how elements of an array should be displayed.
509+-- it will incorporate Json Schema mostly verbatim.
459−-- Note that @fmt@ in @'SwaggerItemsPrimitive' fmt schema@ specifies format for elements of type @schema@.
460−-- This is different from the original Swagger's <http://swagger.io/specification/#itemsObject Items Object>.
462-- @'SwaggerItemsObject'@ should be used to specify homogenous array @'Schema'@s.
511-- @'SwaggerItemsObject'@ should be used to specify homogenous array @'Schema'@s.
464-- @'SwaggerItemsArray'@ should be used to specify tuple @'Schema'@s.
513-- @'SwaggerItemsArray'@ should be used to specify tuple @'Schema'@s.
465−data SwaggerItems t where
514+data SwaggerItems where
466− SwaggerItemsPrimitive :: Maybe (CollectionFormat k) -> ParamSchema k-> SwaggerItems k
467− SwaggerItemsObject :: Referenced Schema -> SwaggerItems 'SwaggerKindSchema
515+ SwaggerItemsObject :: Referenced Schema -> SwaggerItems
468− SwaggerItemsArray :: [Referenced Schema] -> SwaggerItems 'SwaggerKindSchema
516+ SwaggerItemsArray :: [Referenced Schema] -> SwaggerItems
469− deriving (Typeable)
517+ deriving (Eq, Show, Typeable, Data)
471−deriving instance Eq (SwaggerItems t)
519+data SwaggerType where
472−deriving instance Show (SwaggerItems t)
520+ SwaggerString :: SwaggerType
473−--deriving instance Typeable (SwaggerItems t)
521+ SwaggerNumber :: SwaggerType
474−
522+ SwaggerInteger :: SwaggerType
475−swaggerItemsPrimitiveConstr :: Constr
523+ SwaggerBoolean :: SwaggerType
476−swaggerItemsPrimitiveConstr = mkConstr swaggerItemsDataType "SwaggerItemsPrimitive" [] Prefix
524+ SwaggerArray :: SwaggerType
477−
525+ SwaggerNull :: SwaggerType
478−swaggerItemsObjectConstr :: Constr
526+ SwaggerObject :: SwaggerType
479−swaggerItemsObjectConstr = mkConstr swaggerItemsDataType "SwaggerItemsObject" [] Prefix
527+ deriving (Eq, Show, Typeable, Generic, Data)
481−swaggerItemsArrayConstr :: Constr
482−swaggerItemsArrayConstr = mkConstr swaggerItemsDataType "SwaggerItemsArray" [] Prefix
484−swaggerItemsDataType :: DataType
485−swaggerItemsDataType = mkDataType "Data.Swagger.SwaggerItems" [swaggerItemsPrimitiveConstr]
487−-- Note: unfortunately we have to write these Data instances by hand,
488−-- to get better contexts / avoid duplicate name when using standalone deriving
490−instance Data t => Data (SwaggerItems ('SwaggerKindNormal t)) where
491− -- TODO: define gfoldl
492− gunfold k z c = case constrIndex c of
493− 1 -> k (k (z SwaggerItemsPrimitive))
494− _ -> error $ "Data.Data.gunfold: Constructor " ++ show c ++ " is not of type (SwaggerItems t)."
495− toConstr _ = swaggerItemsPrimitiveConstr
496− dataTypeOf _ = swaggerItemsDataType
498−-- SwaggerItems SwaggerKindParamOtherSchema can be constructed using SwaggerItemsPrimitive only
499−instance Data (SwaggerItems 'SwaggerKindParamOtherSchema) where
500− -- TODO: define gfoldl
501− gunfold k z c = case constrIndex c of
502− 1 -> k (k (z SwaggerItemsPrimitive))
503− _ -> error $ "Data.Data.gunfold: Constructor " ++ show c ++ " is not of type (SwaggerItems SwaggerKindParamOtherSchema)."
504− toConstr _ = swaggerItemsPrimitiveConstr
505− dataTypeOf _ = swaggerItemsDataType
507−instance Data (SwaggerItems 'SwaggerKindSchema) where
508− gfoldl _ _ (SwaggerItemsPrimitive _ _) = error " Data.Data.gfoldl: Constructor SwaggerItemsPrimitive used to construct SwaggerItems SwaggerKindSchema"
509− gfoldl k z (SwaggerItemsObject ref) = z SwaggerItemsObject `k` ref
510− gfoldl k z (SwaggerItemsArray ref) = z SwaggerItemsArray `k` ref
512− gunfold k z c = case constrIndex c of
513− 2 -> k (z SwaggerItemsObject)
514− 3 -> k (z SwaggerItemsArray)
515− _ -> error $ "Data.Data.gunfold: Constructor " ++ show c ++ " is not of type (SwaggerItems SwaggerKindSchema)."
517− toConstr (SwaggerItemsPrimitive _ _) = error "Not supported"
518− toConstr (SwaggerItemsObject _) = swaggerItemsObjectConstr
519− toConstr (SwaggerItemsArray _) = swaggerItemsArrayConstr
521− dataTypeOf _ = swaggerItemsDataType
523−-- | Type used as a kind to avoid overlapping instances.
525− = SwaggerKindNormal t
526− | SwaggerKindParamOtherSchema
530−deriving instance Typeable 'SwaggerKindNormal
531−deriving instance Typeable 'SwaggerKindParamOtherSchema
532−deriving instance Typeable 'SwaggerKindSchema
535−type family SwaggerKindType (k :: SwaggerKind *) :: *
536−type instance SwaggerKindType ('SwaggerKindNormal t) = t
537−type instance SwaggerKindType 'SwaggerKindSchema = Schema
538−--type instance SwaggerKindType 'SwaggerKindParamOtherSchema = ParamOtherSchema
540−data SwaggerType t where
541− SwaggerString :: SwaggerType t
542− SwaggerNumber :: SwaggerType t
543− SwaggerInteger :: SwaggerType t
544− SwaggerBoolean :: SwaggerType t
545− SwaggerArray :: SwaggerType t
546− SwaggerFile :: SwaggerType 'SwaggerKindParamOtherSchema
547− SwaggerNull :: SwaggerType 'SwaggerKindSchema
548− SwaggerObject :: SwaggerType 'SwaggerKindSchema
551−deriving instance Eq (SwaggerType t)
552−deriving instance Show (SwaggerType t)
554−swaggerTypeConstr :: Data (SwaggerType t) => SwaggerType t -> Constr
555−swaggerTypeConstr t = mkConstr (dataTypeOf t) (show t) [] Prefix
557−swaggerTypeDataType :: {- Data (SwaggerType t) => -} SwaggerType t -> DataType
558−swaggerTypeDataType _ = mkDataType "Data.Swagger.SwaggerType" swaggerTypeConstrs
560−swaggerCommonTypes :: [SwaggerType k]
561−swaggerCommonTypes = [SwaggerString, SwaggerNumber, SwaggerInteger, SwaggerBoolean, SwaggerArray]
563−swaggerParamTypes :: [SwaggerType 'SwaggerKindParamOtherSchema]
564−swaggerParamTypes = swaggerCommonTypes ++ [SwaggerFile]
566−swaggerSchemaTypes :: [SwaggerType 'SwaggerKindSchema]
567−swaggerSchemaTypes = swaggerCommonTypes ++ [error "SwaggerFile is invalid SwaggerType Schema", SwaggerNull, SwaggerObject]
569−swaggerTypeConstrs :: [Constr]
570−swaggerTypeConstrs = map swaggerTypeConstr (swaggerCommonTypes :: [SwaggerType 'SwaggerKindSchema])
571− ++ [swaggerTypeConstr SwaggerFile, swaggerTypeConstr SwaggerNull, swaggerTypeConstr SwaggerObject]
573−instance Typeable t => Data (SwaggerType ('SwaggerKindNormal t)) where
574− gunfold = gunfoldEnum "SwaggerType" swaggerCommonTypes
575− toConstr = swaggerTypeConstr
576− dataTypeOf = swaggerTypeDataType
578−instance Data (SwaggerType 'SwaggerKindParamOtherSchema) where
579− gunfold = gunfoldEnum "SwaggerType ParamOtherSchema" swaggerParamTypes
580− toConstr = swaggerTypeConstr
581− dataTypeOf = swaggerTypeDataType
583−instance Data (SwaggerType 'SwaggerKindSchema) where
584− gunfold = gunfoldEnum "SwaggerType Schema" swaggerSchemaTypes
585− toConstr = swaggerTypeConstr
586− dataTypeOf = swaggerTypeDataType
588data ParamLocation
529data ParamLocation
589 = -- | Parameters that are appended to the URL.
530 = -- | Parameters that are appended to the URL.
@@ -601,42 +542,6 @@ data ParamLocation
602type Format = Text
543type Format = Text
604−-- | Determines the format of the array.
605−data CollectionFormat t where
606− -- Comma separated values: @foo,bar@.
607− CollectionCSV :: CollectionFormat t
608− -- Space separated values: @foo bar@.
609− CollectionSSV :: CollectionFormat t
610− -- Tab separated values: @foo\\tbar@.
611− CollectionTSV :: CollectionFormat t
612− -- Pipe separated values: @foo|bar@.
613− CollectionPipes :: CollectionFormat t
614− -- Corresponds to multiple parameter instances
615− -- instead of multiple values for a single instance @foo=bar&foo=baz@.
616− -- This is valid only for parameters in @'ParamQuery'@ or @'ParamFormData'@.
617− CollectionMulti :: CollectionFormat 'SwaggerKindParamOtherSchema
620−deriving instance Eq (CollectionFormat t)
621−deriving instance Show (CollectionFormat t)
623−collectionFormatConstr :: CollectionFormat t -> Constr
624−collectionFormatConstr cf = mkConstr collectionFormatDataType (show cf) [] Prefix
626−collectionFormatDataType :: DataType
627−collectionFormatDataType = mkDataType "Data.Swagger.CollectionFormat" $
628− map collectionFormatConstr collectionCommonFormats
630−collectionCommonFormats :: [CollectionFormat t]
631−collectionCommonFormats = [ CollectionCSV, CollectionSSV, CollectionTSV, CollectionPipes ]
633−instance Data t => Data (CollectionFormat ('SwaggerKindNormal t)) where
634− gunfold = gunfoldEnum "CollectionFormat" collectionCommonFormats
635− toConstr = collectionFormatConstr
636− dataTypeOf _ = collectionFormatDataType
638−deriving instance Data (CollectionFormat 'SwaggerKindParamOtherSchema)
640type ParamName = Text
545type ParamName = Text
642data Schema = Schema
547data Schema = Schema
@@ -663,7 +568,7 @@ data Schema = Schema
663 , _schemaMaxProperties :: Maybe Integer
568 , _schemaMaxProperties :: Maybe Integer
664 , _schemaMinProperties :: Maybe Integer
569 , _schemaMinProperties :: Maybe Integer
666− , _schemaParamSchema :: ParamSchema 'SwaggerKindSchema
571+ , _schemaParamSchema :: ParamSchema
667 } deriving (Eq, Show, Generic, Data, Typeable)
572 } deriving (Eq, Show, Generic, Data, Typeable)
669data Discriminator = Discriminator
574data Discriminator = Discriminator
@@ -684,7 +589,7 @@ data NamedSchema = NamedSchema
684-- | Regex pattern for @string@ type.
589-- | Regex pattern for @string@ type.
685type Pattern = Text
590type Pattern = Text
687−data ParamSchema (t :: SwaggerKind *) = ParamSchema
592+data ParamSchema = ParamSchema
688 { -- | Declares the value of the parameter that the server will use if none is provided,
593 { -- | Declares the value of the parameter that the server will use if none is provided,
689 -- for example a @"count"@ to control the number of results per page might default to @100@
594 -- for example a @"count"@ to control the number of results per page might default to @100@
690 -- if not supplied by the client in the request.
595 -- if not supplied by the client in the request.
@@ -692,9 +597,9 @@ data ParamSchema (t :: SwaggerKind *) = ParamSchema
692 -- Unlike JSON Schema this value MUST conform to the defined type for this parameter.
597 -- Unlike JSON Schema this value MUST conform to the defined type for this parameter.
693 _paramSchemaDefault :: Maybe Value
598 _paramSchemaDefault :: Maybe Value
695− , _paramSchemaType :: Maybe (SwaggerType t)
600+ , _paramSchemaType :: Maybe SwaggerType
696 , _paramSchemaFormat :: Maybe Format
601 , _paramSchemaFormat :: Maybe Format
697− , _paramSchemaItems :: Maybe (SwaggerItems t)
602+ , _paramSchemaItems :: Maybe SwaggerItems
698 , _paramSchemaMaximum :: Maybe Scientific
603 , _paramSchemaMaximum :: Maybe Scientific
699 , _paramSchemaExclusiveMaximum :: Maybe Bool
604 , _paramSchemaExclusiveMaximum :: Maybe Bool
700 , _paramSchemaMinimum :: Maybe Scientific
605 , _paramSchemaMinimum :: Maybe Scientific
@@ -707,9 +612,7 @@ data ParamSchema (t :: SwaggerKind *) = ParamSchema
707 , _paramSchemaUniqueItems :: Maybe Bool
612 , _paramSchemaUniqueItems :: Maybe Bool
708 , _paramSchemaEnum :: Maybe [Value]
613 , _paramSchemaEnum :: Maybe [Value]
709 , _paramSchemaMultipleOf :: Maybe Scientific
614 , _paramSchemaMultipleOf :: Maybe Scientific
710− } deriving (Eq, Show, Generic, Typeable)
615+ } deriving (Eq, Show, Generic, Typeable, Data)
712−deriving instance (Typeable k, Data (Maybe (SwaggerType k)), Data (SwaggerItems k)) => Data (ParamSchema k)
714data Xml = Xml
617data Xml = Xml
715 { -- | Replaces the name of the element/attribute used for the described schema property.
618 { -- | Replaces the name of the element/attribute used for the described schema property.
@@ -779,11 +682,13 @@ instance IsString Response where
780type HeaderName = Text
683type HeaderName = Text
686+-- TODO this is mostly a copy of 'Param'.
782data Header = Header
687data Header = Header
783 { -- | A short description of the header.
688 { -- | A short description of the header.
784 _headerDescription :: Maybe Text
689 _headerDescription :: Maybe Text
786− , _headerSchema :: ParamSchema ('SwaggerKindNormal Header)
691+ , _headerSchema :: Maybe (Referenced Schema)
787 } deriving (Eq, Show, Generic, Data, Typeable)
692 } deriving (Eq, Show, Generic, Data, Typeable)
789-- | The location of the API key.
694-- | The location of the API key.
@@ -993,9 +898,9 @@ instance Monoid Schema where
993 mempty = genericMempty
898 mempty = genericMempty
994 mappend = (<>)
899 mappend = (<>)
996−instance Semigroup (ParamSchema t) where
901+instance Semigroup ParamSchema where
997 (<>) = genericMappend
902 (<>) = genericMappend
998−instance Monoid (ParamSchema t) where
903+instance Monoid ParamSchema where
999 mempty = genericMempty
904 mempty = genericMempty
1000 mappend = (<>)
905 mappend = (<>)
@@ -1093,7 +998,7 @@ instance SwaggerMonoid Info
1093instance SwaggerMonoid Components
998instance SwaggerMonoid Components
1094instance SwaggerMonoid PathItem
999instance SwaggerMonoid PathItem
1095instance SwaggerMonoid Schema
1000instance SwaggerMonoid Schema
1096−instance SwaggerMonoid (ParamSchema t)
1001+instance SwaggerMonoid ParamSchema
1097instance SwaggerMonoid Param
1002instance SwaggerMonoid Param
1098instance SwaggerMonoid Responses
1003instance SwaggerMonoid Responses
1099instance SwaggerMonoid Response
1004instance SwaggerMonoid Response
@@ -1104,7 +1009,7 @@ instance (Eq a, Hashable a) => SwaggerMonoid (InsOrdHashSet a)
1104instance SwaggerMonoid MimeList
1009instance SwaggerMonoid MimeList
1105deriving instance SwaggerMonoid URL
1010deriving instance SwaggerMonoid URL
1107−instance SwaggerMonoid (SwaggerType t) where
1012+instance SwaggerMonoid SwaggerType where
1108 swaggerMempty = SwaggerString
1013 swaggerMempty = SwaggerString
1109 swaggerMappend _ y = y
1014 swaggerMappend _ y = y
@@ -1125,6 +1030,12 @@ instance Monoid a => SwaggerMonoid (Referenced a) where
1125-- Simple Generic-based ToJSON instances
1030-- Simple Generic-based ToJSON instances
1126-- =======================================================================
1031-- =======================================================================
1033+instance ToJSON Style where
1034+ toJSON = genericToJSON (jsonPrefix "Style")
1036+instance ToJSON SwaggerType where
1037+ toJSON = genericToJSON (jsonPrefix "Swagger")
1128instance ToJSON ParamLocation where
1039instance ToJSON ParamLocation where
1129 toJSON = genericToJSON (jsonPrefix "Param")
1040 toJSON = genericToJSON (jsonPrefix "Param")
@@ -1174,6 +1085,12 @@ instance ToJSON OAuth2AuthorizationCodeFlow where
1174-- Simple Generic-based FromJSON instances
1085-- Simple Generic-based FromJSON instances
1175-- =======================================================================
1086-- =======================================================================
1088+instance FromJSON Style where
1089+ parseJSON = genericParseJSON (jsonPrefix "Style")
1091+instance FromJSON SwaggerType where
1092+ parseJSON = genericParseJSON (jsonPrefix "Swagger")
1177instance FromJSON ParamLocation where
1094instance FromJSON ParamLocation where
1178 parseJSON = genericParseJSON (jsonPrefix "Param")
1095 parseJSON = genericParseJSON (jsonPrefix "Param")
@@ -1272,10 +1189,7 @@ instance ToJSON Header where
1272-- >>> encode (SwaggerItemsArray [])
1189-- >>> encode (SwaggerItemsArray [])
1273-- "{\"example\":[],\"items\":{},\"maxItems\":0}"
1190-- "{\"example\":[],\"items\":{},\"maxItems\":0}"
1275−instance ToJSON (ParamSchema t) => ToJSON (SwaggerItems t) where
1192+instance ToJSON SwaggerItems where
1276− toJSON (SwaggerItemsPrimitive fmt schema) = object
1277− [ "collectionFormat" .= fmt
1278− , "items" .= schema ]
1279 toJSON (SwaggerItemsObject x) = object [ "items" .= x ]
1193 toJSON (SwaggerItemsObject x) = object [ "items" .= x ]
1280 toJSON (SwaggerItemsArray []) = object
1194 toJSON (SwaggerItemsArray []) = object
1281 [ "items" .= object []
1195 [ "items" .= object []
@@ -1344,24 +1258,7 @@ instance ToJSON (Referenced RequestBody) where toJSON = referencedToJSON "#/comp
1344instance ToJSON (Referenced Example) where toJSON = referencedToJSON "#/components/examples/"
1258instance ToJSON (Referenced Example) where toJSON = referencedToJSON "#/components/examples/"
1345instance ToJSON (Referenced Header) where toJSON = referencedToJSON "#/components/headers/"
1259instance ToJSON (Referenced Header) where toJSON = referencedToJSON "#/components/headers/"
1347−instance ToJSON (SwaggerType t) where
1348− toJSON SwaggerArray = "array"
1349− toJSON SwaggerString = "string"
1350− toJSON SwaggerInteger = "integer"
1351− toJSON SwaggerNumber = "number"
1352− toJSON SwaggerBoolean = "boolean"
1353− toJSON SwaggerFile = "file"
1354− toJSON SwaggerNull = "null"
1355− toJSON SwaggerObject = "object"
1357−instance ToJSON (CollectionFormat t) where
1358− toJSON CollectionCSV = "csv"
1359− toJSON CollectionSSV = "ssv"
1360− toJSON CollectionTSV = "tsv"
1361− toJSON CollectionPipes = "pipes"
1362− toJSON CollectionMulti = "multi"
1364−instance ToJSON (ParamSchema k) where
1261+instance ToJSON ParamSchema where
1365 -- TODO: this is a bit fishy, why we need sub object only in `ToJSON`?
1262 -- TODO: this is a bit fishy, why we need sub object only in `ToJSON`?
1366 toJSON = sopSwaggerGenericToJSONWithOpts $
1263 toJSON = sopSwaggerGenericToJSONWithOpts $
1367 mkSwaggerAesonOptions "paramSchema" & saoSubObject ?~ "items"
1264 mkSwaggerAesonOptions "paramSchema" & saoSubObject ?~ "items"
@@ -1412,28 +1309,7 @@ instance FromJSON Schema where
1412instance FromJSON Header where
1309instance FromJSON Header where
1413 parseJSON = sopSwaggerGenericParseJSON
1310 parseJSON = sopSwaggerGenericParseJSON
1415−instance (FromJSON (CollectionFormat ('SwaggerKindNormal t)), FromJSON (ParamSchema ('SwaggerKindNormal t))) => FromJSON (SwaggerItems ('SwaggerKindNormal t)) where
1312+instance FromJSON SwaggerItems where
1416− parseJSON = withObject "SwaggerItemsPrimitive" $ \o -> SwaggerItemsPrimitive
1417− <$> o .:? "collectionFormat"
1418− <*> (o .: "items" >>= parseJSON)
1420−instance FromJSON (SwaggerItems 'SwaggerKindParamOtherSchema) where
1421− parseJSON = withObject "SwaggerItemsPrimitive" $ \o -> SwaggerItemsPrimitive
1422− <$> o .:? "collectionFormat"
1423− <*> ((o .: "items" >>= parseJSON) <|> fail ("foo" ++ show o))
1427−-- >>> decode "{}" :: Maybe (SwaggerItems 'SwaggerKindSchema)
1428−-- Just (SwaggerItemsArray [])
1430−-- >>> eitherDecode "{\"$ref\":\"#/components/schemas/example\"}" :: Either String (SwaggerItems 'SwaggerKindSchema)
1431−-- Right (SwaggerItemsObject (Ref (Reference {getReference = "example"})))
1433−-- >>> eitherDecode "[{\"$ref\":\"#/components/schemas/example\"}]" :: Either String (SwaggerItems 'SwaggerKindSchema)
1434−-- Right (SwaggerItemsArray [Ref (Reference {getReference = "example"})])
1436−instance FromJSON (SwaggerItems 'SwaggerKindSchema) where
1437 parseJSON js@(Object obj)
1313 parseJSON js@(Object obj)
1438 | null obj = pure $ SwaggerItemsArray [] -- Nullary schema.
1314 | null obj = pure $ SwaggerItemsArray [] -- Nullary schema.
1439 | otherwise = SwaggerItemsObject <$> parseJSON js
1315 | otherwise = SwaggerItemsObject <$> parseJSON js
@@ -1506,30 +1382,7 @@ instance FromJSON (Referenced Header) where parseJSON = referencedParseJSON "#
1506instance FromJSON Xml where
1382instance FromJSON Xml where
1507 parseJSON = genericParseJSON (jsonPrefix "xml")
1383 parseJSON = genericParseJSON (jsonPrefix "xml")
1509−instance FromJSON (SwaggerType 'SwaggerKindSchema) where
1385+instance FromJSON ParamSchema where
1510− parseJSON = parseOneOf [SwaggerString, SwaggerInteger, SwaggerNumber, SwaggerBoolean, SwaggerArray, SwaggerNull, SwaggerObject]
1512−instance FromJSON (SwaggerType 'SwaggerKindParamOtherSchema) where
1513− parseJSON = parseOneOf [SwaggerString, SwaggerInteger, SwaggerNumber, SwaggerBoolean, SwaggerArray, SwaggerFile]
1515−instance FromJSON (SwaggerType ('SwaggerKindNormal t)) where
1516− parseJSON = parseOneOf [SwaggerString, SwaggerInteger, SwaggerNumber, SwaggerBoolean, SwaggerArray]
1518−instance FromJSON (CollectionFormat ('SwaggerKindNormal t)) where
1519− parseJSON = parseOneOf [CollectionCSV, CollectionSSV, CollectionTSV, CollectionPipes]
1521−-- NOTE: There aren't collections of 'Schema'
1522−--instance FromJSON (CollectionFormat (SwaggerKindSchema)) where
1523−-- parseJSON = parseOneOf [CollectionCSV, CollectionSSV, CollectionTSV, CollectionPipes]
1525−instance FromJSON (CollectionFormat 'SwaggerKindParamOtherSchema) where
1526− parseJSON = parseOneOf [CollectionCSV, CollectionSSV, CollectionTSV, CollectionPipes, CollectionMulti]
1528−instance (FromJSON (SwaggerType ('SwaggerKindNormal t)), FromJSON (SwaggerItems ('SwaggerKindNormal t))) => FromJSON (ParamSchema ('SwaggerKindNormal t)) where
1529− parseJSON = sopSwaggerGenericParseJSON
1530−instance FromJSON (ParamSchema 'SwaggerKindParamOtherSchema) where
1531− parseJSON = sopSwaggerGenericParseJSON
1532−instance FromJSON (ParamSchema 'SwaggerKindSchema) where
1533 parseJSON = sopSwaggerGenericParseJSON
1386 parseJSON = sopSwaggerGenericParseJSON
1535instance FromJSON AdditionalProperties where
1388instance FromJSON AdditionalProperties where
@@ -1571,17 +1424,12 @@ instance HasSwaggerAesonOptions Example where
1571instance HasSwaggerAesonOptions Encoding where
1424instance HasSwaggerAesonOptions Encoding where
1572 swaggerAesonOptions _ = mkSwaggerAesonOptions "encoding"
1425 swaggerAesonOptions _ = mkSwaggerAesonOptions "encoding"
1574−instance HasSwaggerAesonOptions (ParamSchema ('SwaggerKindNormal t)) where
1427+instance HasSwaggerAesonOptions ParamSchema where
1575− swaggerAesonOptions _ = mkSwaggerAesonOptions "paramSchema" & saoSubObject ?~ "items"
1576−instance HasSwaggerAesonOptions (ParamSchema 'SwaggerKindParamOtherSchema) where
1577− swaggerAesonOptions _ = mkSwaggerAesonOptions "paramSchema" & saoSubObject ?~ "items"
1578−-- NOTE: Schema doesn't have 'items' sub object!
1579−instance HasSwaggerAesonOptions (ParamSchema 'SwaggerKindSchema) where
1580 swaggerAesonOptions _ = mkSwaggerAesonOptions "paramSchema"
1428 swaggerAesonOptions _ = mkSwaggerAesonOptions "paramSchema"
1582instance AesonDefaultValue Server
1430instance AesonDefaultValue Server
1583instance AesonDefaultValue Components
1431instance AesonDefaultValue Components
1584−instance AesonDefaultValue (ParamSchema s)
1432+instance AesonDefaultValue ParamSchema
1585instance AesonDefaultValue OAuth2ImplicitFlow
1433instance AesonDefaultValue OAuth2ImplicitFlow
1586instance AesonDefaultValue OAuth2PasswordFlow
1434instance AesonDefaultValue OAuth2PasswordFlow
1587instance AesonDefaultValue OAuth2ClientCredentialsFlow
1435instance AesonDefaultValue OAuth2ClientCredentialsFlow
@@ -1589,7 +1437,7 @@ instance AesonDefaultValue OAuth2AuthorizationCodeFlow
1589instance AesonDefaultValue p => AesonDefaultValue (OAuth2Flow p)
1437instance AesonDefaultValue p => AesonDefaultValue (OAuth2Flow p)
1590instance AesonDefaultValue Responses
1438instance AesonDefaultValue Responses
1591instance AesonDefaultValue SecuritySchemeType
1439instance AesonDefaultValue SecuritySchemeType
1592−instance AesonDefaultValue (SwaggerType a)
1440+instance AesonDefaultValue SwaggerType
1593instance AesonDefaultValue MimeList where defaultValue = Just mempty
1441instance AesonDefaultValue MimeList where defaultValue = Just mempty
1594instance AesonDefaultValue Info
1442instance AesonDefaultValue Info
1595instance AesonDefaultValue ParamLocation
1443instance AesonDefaultValue ParamLocation