git.iko.soy/typeable/openapi3
on master help sign in
Rename SchemaCommon -> ParamSchema -> ParamAnySchema
1377bffNickolay Kudasov
src/Data/Swagger.hs+3−3
@@ -33,7 +33,7 @@ module Data.Swagger (
33
33
34 -- * Parameters
34 -- * Parameters
35 Param(..),
35 Param(..),
36− ParamSchema(..),
36+ ParamAnySchema(..),
37 ParamOtherSchema(..),
37 ParamOtherSchema(..),
38 ParamLocation(..),
38 ParamLocation(..),
39 ParamName,
39 ParamName,
@@ -41,10 +41,10 @@ module Data.Swagger (
41 Header(..),
41 Header(..),
42 Example(..),
42 Example(..),
43
43
44− -- * Schema
44+ -- * Schemas
45+ ParamSchema(..),
45 Schema(..),
46 Schema(..),
46 SchemaItems(..),
47 SchemaItems(..),
47− SchemaCommon(..),
48 Xml(..),
48 Xml(..),
49
49
50 -- * Responses
50 -- * Responses
src/Data/Swagger/Internal.hs+40−40
@@ -273,10 +273,10 @@ data Param = Param
273 , _paramRequired :: Maybe Bool
273 , _paramRequired :: Maybe Bool
274
274
275 -- | Parameter schema.
275 -- | Parameter schema.
276− , _paramSchema :: ParamSchema
276+ , _paramSchema :: ParamAnySchema
277 } deriving (Eq, Show, Generic)
277 } deriving (Eq, Show, Generic)
278
278
279−data ParamSchema
279+data ParamAnySchema
280 = ParamBody (Referenced Schema)
280 = ParamBody (Referenced Schema)
281 | ParamOther ParamOtherSchema
281 | ParamOther ParamOtherSchema
282 deriving (Eq, Show)
282 deriving (Eq, Show)
@@ -295,7 +295,7 @@ data ParamOtherSchema = ParamOtherSchema
295 -- Default value is csv.
295 -- Default value is csv.
296 , _paramOtherSchemaCollectionFormat :: Maybe (CollectionFormat Param)
296 , _paramOtherSchemaCollectionFormat :: Maybe (CollectionFormat Param)
297
297
298− , _paramOtherSchemaCommon :: SchemaCommon ParamOtherSchema Items
298+ , _paramOtherSchemaParamSchema :: ParamSchema ParamOtherSchema Items
299 } deriving (Eq, Show, Generic)
299 } deriving (Eq, Show, Generic)
300
300
301data SwaggerType t where
301data SwaggerType t where
@@ -371,7 +371,7 @@ data Schema = Schema
371 , _schemaMaxProperties :: Maybe Integer
371 , _schemaMaxProperties :: Maybe Integer
372 , _schemaMinProperties :: Maybe Integer
372 , _schemaMinProperties :: Maybe Integer
373
373
374− , _schemaSchemaCommon :: SchemaCommon Schema SchemaItems
374+ , _schemaParamSchema :: ParamSchema Schema SchemaItems
375 } deriving (Eq, Show, Generic)
375 } deriving (Eq, Show, Generic)
376
376
377data SchemaItems
377data SchemaItems
@@ -379,29 +379,29 @@ data SchemaItems
379 | SchemaItemsArray [Referenced Schema]
379 | SchemaItemsArray [Referenced Schema]
380 deriving (Eq, Show)
380 deriving (Eq, Show)
381
381
382−data SchemaCommon t items = SchemaCommon
382+data ParamSchema t items = ParamSchema
383 { -- | Declares the value of the parameter that the server will use if none is provided,
383 { -- | Declares the value of the parameter that the server will use if none is provided,
384 -- for example a @"count"@ to control the number of results per page might default to @100@
384 -- for example a @"count"@ to control the number of results per page might default to @100@
385 -- if not supplied by the client in the request.
385 -- if not supplied by the client in the request.
386 -- (Note: "default" has no meaning for required parameters.)
386 -- (Note: "default" has no meaning for required parameters.)
387 -- Unlike JSON Schema this value MUST conform to the defined type for this parameter.
387 -- Unlike JSON Schema this value MUST conform to the defined type for this parameter.
388− _schemaCommonDefault :: Maybe Value
388+ _paramSchemaDefault :: Maybe Value
389−
389+
390− , _schemaCommonType :: SwaggerType t
390+ , _paramSchemaType :: SwaggerType t
391− , _schemaCommonFormat :: Maybe Format
391+ , _paramSchemaFormat :: Maybe Format
392− , _schemaCommonItems :: Maybe items
392+ , _paramSchemaItems :: Maybe items
393− , _schemaCommonMaximum :: Maybe Scientific
393+ , _paramSchemaMaximum :: Maybe Scientific
394− , _schemaCommonExclusiveMaximum :: Maybe Bool
394+ , _paramSchemaExclusiveMaximum :: Maybe Bool
395− , _schemaCommonMinimum :: Maybe Scientific
395+ , _paramSchemaMinimum :: Maybe Scientific
396− , _schemaCommonExclusiveMinimum :: Maybe Bool
396+ , _paramSchemaExclusiveMinimum :: Maybe Bool
397− , _schemaCommonMaxLength :: Maybe Integer
397+ , _paramSchemaMaxLength :: Maybe Integer
398− , _schemaCommonMinLength :: Maybe Integer
398+ , _paramSchemaMinLength :: Maybe Integer
399− , _schemaCommonPattern :: Maybe Text
399+ , _paramSchemaPattern :: Maybe Text
400− , _schemaCommonMaxItems :: Maybe Integer
400+ , _paramSchemaMaxItems :: Maybe Integer
401− , _schemaCommonMinItems :: Maybe Integer
401+ , _paramSchemaMinItems :: Maybe Integer
402− , _schemaCommonUniqueItems :: Maybe Bool
402+ , _paramSchemaUniqueItems :: Maybe Bool
403− , _schemaCommonEnum :: Maybe [Value]
403+ , _paramSchemaEnum :: Maybe [Value]
404− , _schemaCommonMultipleOf :: Maybe Scientific
404+ , _paramSchemaMultipleOf :: Maybe Scientific
405 } deriving (Eq, Show, Generic)
405 } deriving (Eq, Show, Generic)
406
406
407data Xml = Xml
407data Xml = Xml
@@ -437,7 +437,7 @@ data Items = Items
437 -- Default value is @'ItemsCollectionCSV'@.
437 -- Default value is @'ItemsCollectionCSV'@.
438 _itemsCollectionFormat :: Maybe (CollectionFormat Items)
438 _itemsCollectionFormat :: Maybe (CollectionFormat Items)
439
439
440− , _itemsCommon :: SchemaCommon Items Items
440+ , _itemsParamSchema :: ParamSchema Items Items
441 } deriving (Eq, Show, Generic)
441 } deriving (Eq, Show, Generic)
442
442
443-- | A container for the expected responses of an operation.
443-- | A container for the expected responses of an operation.
@@ -487,7 +487,7 @@ data Header = Header
487 -- Default value is @'ItemsCollectionCSV'@.
487 -- Default value is @'ItemsCollectionCSV'@.
488 , _headerCollectionFormat :: Maybe (CollectionFormat Items)
488 , _headerCollectionFormat :: Maybe (CollectionFormat Items)
489
489
490− , _headerCommon :: SchemaCommon Header Items
490+ , _headerParamSchema :: ParamSchema Header Items
491 } deriving (Eq, Show, Generic)
491 } deriving (Eq, Show, Generic)
492
492
493data Example = Example { getExample :: Map MediaType Value }
493data Example = Example { getExample :: Map MediaType Value }
@@ -609,7 +609,7 @@ instance Monoid Schema where
609 mempty = genericMempty
609 mempty = genericMempty
610 mappend = genericMappend
610 mappend = genericMappend
611
611
612−instance Monoid (SchemaCommon t i) where
612+instance Monoid (ParamSchema t i) where
613 mempty = genericMempty
613 mempty = genericMempty
614 mappend = genericMappend
614 mappend = genericMappend
615
615
@@ -645,7 +645,7 @@ instance SwaggerMonoid Info
645instance SwaggerMonoid Paths
645instance SwaggerMonoid Paths
646instance SwaggerMonoid PathItem
646instance SwaggerMonoid PathItem
647instance SwaggerMonoid Schema
647instance SwaggerMonoid Schema
648−instance SwaggerMonoid (SchemaCommon t i)
648+instance SwaggerMonoid (ParamSchema t i)
649instance SwaggerMonoid Param
649instance SwaggerMonoid Param
650instance SwaggerMonoid ParamOtherSchema
650instance SwaggerMonoid ParamOtherSchema
651instance SwaggerMonoid Responses
651instance SwaggerMonoid Responses
@@ -701,7 +701,7 @@ instance SwaggerMonoid (HashMap HttpStatusCode (Referenced Response)) where
701 swaggerMempty = HashMap.empty
701 swaggerMempty = HashMap.empty
702 swaggerMappend = flip HashMap.union
702 swaggerMappend = flip HashMap.union
703
703
704−instance SwaggerMonoid ParamSchema where
704+instance SwaggerMonoid ParamAnySchema where
705 swaggerMempty = ParamOther swaggerMempty
705 swaggerMempty = ParamOther swaggerMempty
706 swaggerMappend (ParamBody x) (ParamBody y) = ParamBody (swaggerMappend x y)
706 swaggerMappend (ParamBody x) (ParamBody y) = ParamBody (swaggerMappend x y)
707 swaggerMappend (ParamOther x) (ParamOther y) = ParamOther (swaggerMappend x y)
707 swaggerMappend (ParamOther x) (ParamOther y) = ParamOther (swaggerMappend x y)
@@ -721,7 +721,7 @@ deriveJSONDefault ''Scheme
721deriveJSON' ''Tag
721deriveJSON' ''Tag
722deriveJSON' ''ExternalDocs
722deriveJSON' ''ExternalDocs
723
723
724−deriveToJSON' ''SchemaCommon
724+deriveToJSON' ''ParamSchema
725deriveToJSON' ''Operation
725deriveToJSON' ''Operation
726deriveToJSON' ''Response
726deriveToJSON' ''Response
727deriveToJSON' ''PathItem
727deriveToJSON' ''PathItem
@@ -769,13 +769,13 @@ instance ToJSON SecurityScheme where
769 toJSON = genericToJSONWithSub "type" (jsonPrefix "securityScheme")
769 toJSON = genericToJSONWithSub "type" (jsonPrefix "securityScheme")
770
770
771instance ToJSON Schema where
771instance ToJSON Schema where
772− toJSON = genericToJSONWithSub "schemaCommon" (jsonPrefix "schema")
772+ toJSON = genericToJSONWithSub "paramSchema" (jsonPrefix "schema")
773
773
774instance ToJSON Header where
774instance ToJSON Header where
775− toJSON = genericToJSONWithSub "common" (jsonPrefix "header")
775+ toJSON = genericToJSONWithSub "paramSchema" (jsonPrefix "header")
776
776
777instance ToJSON Items where
777instance ToJSON Items where
778− toJSON = genericToJSONWithSub "common" (jsonPrefix "items")
778+ toJSON = genericToJSONWithSub "paramSchema" (jsonPrefix "items")
779
779
780instance ToJSON Host where
780instance ToJSON Host where
781 toJSON (Host host mport) = toJSON $
781 toJSON (Host host mport) = toJSON $
@@ -792,12 +792,12 @@ instance ToJSON MimeList where
792instance ToJSON Param where
792instance ToJSON Param where
793 toJSON = genericToJSONWithSub "schema" (jsonPrefix "param")
793 toJSON = genericToJSONWithSub "schema" (jsonPrefix "param")
794
794
795−instance ToJSON ParamSchema where
795+instance ToJSON ParamAnySchema where
796 toJSON (ParamBody s) = object [ "in" .= ("body" :: Text), "schema" .= s ]
796 toJSON (ParamBody s) = object [ "in" .= ("body" :: Text), "schema" .= s ]
797 toJSON (ParamOther s) = toJSON s
797 toJSON (ParamOther s) = toJSON s
798
798
799instance ToJSON ParamOtherSchema where
799instance ToJSON ParamOtherSchema where
800− toJSON = genericToJSONWithSub "common" (jsonPrefix "paramOtherSchema")
800+ toJSON = genericToJSONWithSub "paramSchema" (jsonPrefix "paramOtherSchema")
801
801
802instance ToJSON SchemaItems where
802instance ToJSON SchemaItems where
803 toJSON (SchemaItemsObject x) = toJSON x
803 toJSON (SchemaItemsObject x) = toJSON x
@@ -883,15 +883,15 @@ instance FromJSON SecurityScheme where
883 parseJSON = genericParseJSONWithSub "type" (jsonPrefix "securityScheme")
883 parseJSON = genericParseJSONWithSub "type" (jsonPrefix "securityScheme")
884
884
885instance FromJSON Schema where
885instance FromJSON Schema where
886− parseJSON = genericParseJSONWithSub "schemaCommon" (jsonPrefix "schema")
886+ parseJSON = genericParseJSONWithSub "paramSchema" (jsonPrefix "schema")
887 `withDefaults` [ "properties" .= (mempty :: HashMap Text Schema)
887 `withDefaults` [ "properties" .= (mempty :: HashMap Text Schema)
888 , "required" .= ([] :: [ParamName]) ]
888 , "required" .= ([] :: [ParamName]) ]
889
889
890instance FromJSON Header where
890instance FromJSON Header where
891− parseJSON = genericParseJSONWithSub "common" (jsonPrefix "header")
891+ parseJSON = genericParseJSONWithSub "paramSchema" (jsonPrefix "header")
892
892
893instance FromJSON Items where
893instance FromJSON Items where
894− parseJSON = genericParseJSONWithSub "common" (jsonPrefix "items")
894+ parseJSON = genericParseJSONWithSub "paramSchema" (jsonPrefix "items")
895
895
896instance FromJSON Host where
896instance FromJSON Host where
897 parseJSON (String s) =
897 parseJSON (String s) =
@@ -912,7 +912,7 @@ instance FromJSON MimeList where
912instance FromJSON Param where
912instance FromJSON Param where
913 parseJSON = genericParseJSONWithSub "schema" (jsonPrefix "param")
913 parseJSON = genericParseJSONWithSub "schema" (jsonPrefix "param")
914
914
915−instance FromJSON ParamSchema where
915+instance FromJSON ParamAnySchema where
916 parseJSON js@(Object o) = do
916 parseJSON js@(Object o) = do
917 (i :: Text) <- o .: "in"
917 (i :: Text) <- o .: "in"
918 case i of
918 case i of
@@ -923,7 +923,7 @@ instance FromJSON ParamSchema where
923 parseJSON _ = empty
923 parseJSON _ = empty
924
924
925instance FromJSON ParamOtherSchema where
925instance FromJSON ParamOtherSchema where
926− parseJSON = genericParseJSONWithSub "common" (jsonPrefix "paramOtherSchema")
926+ parseJSON = genericParseJSONWithSub "paramSchema" (jsonPrefix "paramOtherSchema")
927
927
928instance FromJSON SchemaItems where
928instance FromJSON SchemaItems where
929 parseJSON js@(Object _) = SchemaItemsObject <$> parseJSON js
929 parseJSON js@(Object _) = SchemaItemsObject <$> parseJSON js
@@ -983,5 +983,5 @@ instance FromJSON (CollectionFormat Items) where
983-- NOTE: The constraint @FromJSON (SwaggerType t)@ is necessary here!
983-- NOTE: The constraint @FromJSON (SwaggerType t)@ is necessary here!
984-- Without the constraint the general instance will be used
984-- Without the constraint the general instance will be used
985-- that only accepts common types (i.e. NOT object, null or file).
985-- that only accepts common types (i.e. NOT object, null or file).
986−instance (FromJSON (SwaggerType t), FromJSON i) => FromJSON (SchemaCommon t i) where
986+instance (FromJSON (SwaggerType t), FromJSON i) => FromJSON (ParamSchema t i) where
987− parseJSON = genericParseJSON (jsonPrefix "SchemaCommon")
987+ parseJSON = genericParseJSON (jsonPrefix "ParamSchema")
src/Data/Swagger/Lens.hs+41−41
@@ -24,13 +24,13 @@ makeLenses ''PathItem
24makeLenses ''Tag
24makeLenses ''Tag
25makeLenses ''Operation
25makeLenses ''Operation
26makeLenses ''Param
26makeLenses ''Param
27−makePrisms ''ParamSchema
27+makePrisms ''ParamAnySchema
28makeLenses ''ParamOtherSchema
28makeLenses ''ParamOtherSchema
29makeLenses ''Items
29makeLenses ''Items
30makeLenses ''Header
30makeLenses ''Header
31makeLenses ''Schema
31makeLenses ''Schema
32makePrisms ''SchemaItems
32makePrisms ''SchemaItems
33−makeLenses ''SchemaCommon
33+makeLenses ''ParamSchema
34makeLenses ''Xml
34makeLenses ''Xml
35makeLenses ''Responses
35makeLenses ''Responses
36makeLenses ''Response
36makeLenses ''Response
@@ -57,60 +57,60 @@ instance HasDescription Schema (Maybe Text) where description = schemaDe
57instance HasDescription SecurityScheme (Maybe Text) where description = securitySchemeDescription
57instance HasDescription SecurityScheme (Maybe Text) where description = securitySchemeDescription
58instance HasDescription ExternalDocs (Maybe Text) where description = externalDocsDescription
58instance HasDescription ExternalDocs (Maybe Text) where description = externalDocsDescription
59
59
60−class HasSchemaCommon s t i | s -> t i where
60+class HasParamSchema s t i | s -> t i where
61− schemaCommon :: Lens' s (SchemaCommon t i)
61+ parameterSchema :: Lens' s (ParamSchema t i)
62
62
63−instance HasSchemaCommon Schema Schema SchemaItems where schemaCommon = schemaSchemaCommon
63+instance HasParamSchema Schema Schema SchemaItems where parameterSchema = schemaParamSchema
64−instance HasSchemaCommon ParamOtherSchema ParamOtherSchema Items where schemaCommon = paramOtherSchemaCommon
64+instance HasParamSchema ParamOtherSchema ParamOtherSchema Items where parameterSchema = paramOtherSchemaParamSchema
65−instance HasSchemaCommon Items Items Items where schemaCommon = itemsCommon
65+instance HasParamSchema Items Items Items where parameterSchema = itemsParamSchema
66−instance HasSchemaCommon Header Header Items where schemaCommon = headerCommon
66+instance HasParamSchema Header Header Items where parameterSchema = headerParamSchema
67−instance HasSchemaCommon (SchemaCommon t i) t i where schemaCommon = id
67+instance HasParamSchema (ParamSchema t i) t i where parameterSchema = id
68
68
69−schemaType :: HasSchemaCommon s t i => Lens' s (SwaggerType t)
69+schemaType :: HasParamSchema s t i => Lens' s (SwaggerType t)
70−schemaType = schemaCommon.schemaCommonType
70+schemaType = parameterSchema.paramSchemaType
71
71
72−schemaFormat :: HasSchemaCommon s t i => Lens' s (Maybe Format)
72+schemaFormat :: HasParamSchema s t i => Lens' s (Maybe Format)
73−schemaFormat = schemaCommon.schemaCommonFormat
73+schemaFormat = parameterSchema.paramSchemaFormat
74
74
75−schemaItems :: HasSchemaCommon s t i => Lens' s (Maybe i)
75+schemaItems :: HasParamSchema s t i => Lens' s (Maybe i)
76−schemaItems = schemaCommon.schemaCommonItems
76+schemaItems = parameterSchema.paramSchemaItems
77
77
78−schemaDefault :: HasSchemaCommon s t i => Lens' s (Maybe Value)
78+schemaDefault :: HasParamSchema s t i => Lens' s (Maybe Value)
79−schemaDefault = schemaCommon.schemaCommonDefault
79+schemaDefault = parameterSchema.paramSchemaDefault
80
80
81−schemaMaximum :: HasSchemaCommon s t i => Lens' s (Maybe Scientific)
81+schemaMaximum :: HasParamSchema s t i => Lens' s (Maybe Scientific)
82−schemaMaximum = schemaCommon.schemaCommonMaximum
82+schemaMaximum = parameterSchema.paramSchemaMaximum
83
83
84−schemaExclusiveMaximum :: HasSchemaCommon s t i => Lens' s (Maybe Bool)
84+schemaExclusiveMaximum :: HasParamSchema s t i => Lens' s (Maybe Bool)
85−schemaExclusiveMaximum = schemaCommon.schemaCommonExclusiveMaximum
85+schemaExclusiveMaximum = parameterSchema.paramSchemaExclusiveMaximum
86
86
87−schemaMinimum :: HasSchemaCommon s t i => Lens' s (Maybe Scientific)
87+schemaMinimum :: HasParamSchema s t i => Lens' s (Maybe Scientific)
88−schemaMinimum = schemaCommon.schemaCommonMinimum
88+schemaMinimum = parameterSchema.paramSchemaMinimum
89
89
90−schemaExclusiveMinimum :: HasSchemaCommon s t i => Lens' s (Maybe Bool)
90+schemaExclusiveMinimum :: HasParamSchema s t i => Lens' s (Maybe Bool)
91−schemaExclusiveMinimum = schemaCommon.schemaCommonExclusiveMinimum
91+schemaExclusiveMinimum = parameterSchema.paramSchemaExclusiveMinimum
92
92
93−schemaMaxLength :: HasSchemaCommon s t i => Lens' s (Maybe Integer)
93+schemaMaxLength :: HasParamSchema s t i => Lens' s (Maybe Integer)
94−schemaMaxLength = schemaCommon.schemaCommonMaxLength
94+schemaMaxLength = parameterSchema.paramSchemaMaxLength
95
95
96−schemaMinLength :: HasSchemaCommon s t i => Lens' s (Maybe Integer)
96+schemaMinLength :: HasParamSchema s t i => Lens' s (Maybe Integer)
97−schemaMinLength = schemaCommon.schemaCommonMinLength
97+schemaMinLength = parameterSchema.paramSchemaMinLength
98
98
99−schemaPattern :: HasSchemaCommon s t i => Lens' s (Maybe Text)
99+schemaPattern :: HasParamSchema s t i => Lens' s (Maybe Text)
100−schemaPattern = schemaCommon.schemaCommonPattern
100+schemaPattern = parameterSchema.paramSchemaPattern
101
101
102−schemaMaxItems :: HasSchemaCommon s t i => Lens' s (Maybe Integer)
102+schemaMaxItems :: HasParamSchema s t i => Lens' s (Maybe Integer)
103−schemaMaxItems = schemaCommon.schemaCommonMaxItems
103+schemaMaxItems = parameterSchema.paramSchemaMaxItems
104
104
105−schemaMinItems :: HasSchemaCommon s t i => Lens' s (Maybe Integer)
105+schemaMinItems :: HasParamSchema s t i => Lens' s (Maybe Integer)
106−schemaMinItems = schemaCommon.schemaCommonMinItems
106+schemaMinItems = parameterSchema.paramSchemaMinItems
107
107
108−schemaUniqueItems :: HasSchemaCommon s t i => Lens' s (Maybe Bool)
108+schemaUniqueItems :: HasParamSchema s t i => Lens' s (Maybe Bool)
109−schemaUniqueItems = schemaCommon.schemaCommonUniqueItems
109+schemaUniqueItems = parameterSchema.paramSchemaUniqueItems
110
110
111−schemaEnum :: HasSchemaCommon s t i => Lens' s (Maybe [Value])
111+schemaEnum :: HasParamSchema s t i => Lens' s (Maybe [Value])
112−schemaEnum = schemaCommon.schemaCommonEnum
112+schemaEnum = parameterSchema.paramSchemaEnum
113
113
114−schemaMultipleOf :: HasSchemaCommon s t i => Lens' s (Maybe Scientific)
114+schemaMultipleOf :: HasParamSchema s t i => Lens' s (Maybe Scientific)
115−schemaMultipleOf = schemaCommon.schemaCommonMultipleOf
115+schemaMultipleOf = parameterSchema.paramSchemaMultipleOf
116
116