git.iko.soy/typeable/swagger2
on master help sign in
Rename SchemaCommon -> ParamSchema -> ParamAnySchema
commit1377bff1445babe05d64e4f4cbdf23bc188ee706 authorNickolay Kudasov <nickolay.kudasov@gmail.com> dateWed 9 Dec 2015, 14:24 (11 years ago) parent7a5df24
3 files changed+84−84
src/Data/Swagger.hs+3−3 src/Data/Swagger/Internal.hs+40−40 src/Data/Swagger/Lens.hs+41−41
src/Data/Swagger.hs+3−3
@@ -33,7 +33,7 @@ module Data.Swagger (
3333
3434 -- * Parameters
3535 Param(..),
36− ParamSchema(..),
36+ ParamAnySchema(..),
3737 ParamOtherSchema(..),
3838 ParamLocation(..),
3939 ParamName,
@@ -41,10 +41,10 @@ module Data.Swagger (
4141 Header(..),
4242 Example(..),
4343
44− -- * Schema
44+ -- * Schemas
45+ ParamSchema(..),
4546 Schema(..),
4647 SchemaItems(..),
47− SchemaCommon(..),
4848 Xml(..),
4949
5050 -- * Responses
src/Data/Swagger/Internal.hs+40−40
@@ -273,10 +273,10 @@ data Param = Param
273273 , _paramRequired :: Maybe Bool
274274
275275 -- | Parameter schema.
276− , _paramSchema :: ParamSchema
276+ , _paramSchema :: ParamAnySchema
277277 } deriving (Eq, Show, Generic)
278278
279−data ParamSchema
279+data ParamAnySchema
280280 = ParamBody (Referenced Schema)
281281 | ParamOther ParamOtherSchema
282282 deriving (Eq, Show)
@@ -295,7 +295,7 @@ data ParamOtherSchema = ParamOtherSchema
295295 -- Default value is csv.
296296 , _paramOtherSchemaCollectionFormat :: Maybe (CollectionFormat Param)
297297
298− , _paramOtherSchemaCommon :: SchemaCommon ParamOtherSchema Items
298+ , _paramOtherSchemaParamSchema :: ParamSchema ParamOtherSchema Items
299299 } deriving (Eq, Show, Generic)
300300
301301data SwaggerType t where
@@ -371,7 +371,7 @@ data Schema = Schema
371371 , _schemaMaxProperties :: Maybe Integer
372372 , _schemaMinProperties :: Maybe Integer
373373
374− , _schemaSchemaCommon :: SchemaCommon Schema SchemaItems
374+ , _schemaParamSchema :: ParamSchema Schema SchemaItems
375375 } deriving (Eq, Show, Generic)
376376
377377data SchemaItems
@@ -379,29 +379,29 @@ data SchemaItems
379379 | SchemaItemsArray [Referenced Schema]
380380 deriving (Eq, Show)
381381
382−data SchemaCommon t items = SchemaCommon
382+data ParamSchema t items = ParamSchema
383383 { -- | Declares the value of the parameter that the server will use if none is provided,
384384 -- for example a @"count"@ to control the number of results per page might default to @100@
385385 -- if not supplied by the client in the request.
386386 -- (Note: "default" has no meaning for required parameters.)
387387 -- Unlike JSON Schema this value MUST conform to the defined type for this parameter.
388− _schemaCommonDefault :: Maybe Value
389−
390− , _schemaCommonType :: SwaggerType t
391− , _schemaCommonFormat :: Maybe Format
392− , _schemaCommonItems :: Maybe items
393− , _schemaCommonMaximum :: Maybe Scientific
394− , _schemaCommonExclusiveMaximum :: Maybe Bool
395− , _schemaCommonMinimum :: Maybe Scientific
396− , _schemaCommonExclusiveMinimum :: Maybe Bool
397− , _schemaCommonMaxLength :: Maybe Integer
398− , _schemaCommonMinLength :: Maybe Integer
399− , _schemaCommonPattern :: Maybe Text
400− , _schemaCommonMaxItems :: Maybe Integer
401− , _schemaCommonMinItems :: Maybe Integer
402− , _schemaCommonUniqueItems :: Maybe Bool
403− , _schemaCommonEnum :: Maybe [Value]
404− , _schemaCommonMultipleOf :: Maybe Scientific
388+ _paramSchemaDefault :: Maybe Value
389+
390+ , _paramSchemaType :: SwaggerType t
391+ , _paramSchemaFormat :: Maybe Format
392+ , _paramSchemaItems :: Maybe items
393+ , _paramSchemaMaximum :: Maybe Scientific
394+ , _paramSchemaExclusiveMaximum :: Maybe Bool
395+ , _paramSchemaMinimum :: Maybe Scientific
396+ , _paramSchemaExclusiveMinimum :: Maybe Bool
397+ , _paramSchemaMaxLength :: Maybe Integer
398+ , _paramSchemaMinLength :: Maybe Integer
399+ , _paramSchemaPattern :: Maybe Text
400+ , _paramSchemaMaxItems :: Maybe Integer
401+ , _paramSchemaMinItems :: Maybe Integer
402+ , _paramSchemaUniqueItems :: Maybe Bool
403+ , _paramSchemaEnum :: Maybe [Value]
404+ , _paramSchemaMultipleOf :: Maybe Scientific
405405 } deriving (Eq, Show, Generic)
406406
407407data Xml = Xml
@@ -437,7 +437,7 @@ data Items = Items
437437 -- Default value is @'ItemsCollectionCSV'@.
438438 _itemsCollectionFormat :: Maybe (CollectionFormat Items)
439439
440− , _itemsCommon :: SchemaCommon Items Items
440+ , _itemsParamSchema :: ParamSchema Items Items
441441 } deriving (Eq, Show, Generic)
442442
443443-- | A container for the expected responses of an operation.
@@ -487,7 +487,7 @@ data Header = Header
487487 -- Default value is @'ItemsCollectionCSV'@.
488488 , _headerCollectionFormat :: Maybe (CollectionFormat Items)
489489
490− , _headerCommon :: SchemaCommon Header Items
490+ , _headerParamSchema :: ParamSchema Header Items
491491 } deriving (Eq, Show, Generic)
492492
493493data Example = Example { getExample :: Map MediaType Value }
@@ -609,7 +609,7 @@ instance Monoid Schema where
609609 mempty = genericMempty
610610 mappend = genericMappend
611611
612−instance Monoid (SchemaCommon t i) where
612+instance Monoid (ParamSchema t i) where
613613 mempty = genericMempty
614614 mappend = genericMappend
615615
@@ -645,7 +645,7 @@ instance SwaggerMonoid Info
645645instance SwaggerMonoid Paths
646646instance SwaggerMonoid PathItem
647647instance SwaggerMonoid Schema
648−instance SwaggerMonoid (SchemaCommon t i)
648+instance SwaggerMonoid (ParamSchema t i)
649649instance SwaggerMonoid Param
650650instance SwaggerMonoid ParamOtherSchema
651651instance SwaggerMonoid Responses
@@ -701,7 +701,7 @@ instance SwaggerMonoid (HashMap HttpStatusCode (Referenced Response)) where
701701 swaggerMempty = HashMap.empty
702702 swaggerMappend = flip HashMap.union
703703
704−instance SwaggerMonoid ParamSchema where
704+instance SwaggerMonoid ParamAnySchema where
705705 swaggerMempty = ParamOther swaggerMempty
706706 swaggerMappend (ParamBody x) (ParamBody y) = ParamBody (swaggerMappend x y)
707707 swaggerMappend (ParamOther x) (ParamOther y) = ParamOther (swaggerMappend x y)
@@ -721,7 +721,7 @@ deriveJSONDefault ''Scheme
721721deriveJSON' ''Tag
722722deriveJSON' ''ExternalDocs
723723
724−deriveToJSON' ''SchemaCommon
724+deriveToJSON' ''ParamSchema
725725deriveToJSON' ''Operation
726726deriveToJSON' ''Response
727727deriveToJSON' ''PathItem
@@ -769,13 +769,13 @@ instance ToJSON SecurityScheme where
769769 toJSON = genericToJSONWithSub "type" (jsonPrefix "securityScheme")
770770
771771instance ToJSON Schema where
772− toJSON = genericToJSONWithSub "schemaCommon" (jsonPrefix "schema")
772+ toJSON = genericToJSONWithSub "paramSchema" (jsonPrefix "schema")
773773
774774instance ToJSON Header where
775− toJSON = genericToJSONWithSub "common" (jsonPrefix "header")
775+ toJSON = genericToJSONWithSub "paramSchema" (jsonPrefix "header")
776776
777777instance ToJSON Items where
778− toJSON = genericToJSONWithSub "common" (jsonPrefix "items")
778+ toJSON = genericToJSONWithSub "paramSchema" (jsonPrefix "items")
779779
780780instance ToJSON Host where
781781 toJSON (Host host mport) = toJSON $
@@ -792,12 +792,12 @@ instance ToJSON MimeList where
792792instance ToJSON Param where
793793 toJSON = genericToJSONWithSub "schema" (jsonPrefix "param")
794794
795−instance ToJSON ParamSchema where
795+instance ToJSON ParamAnySchema where
796796 toJSON (ParamBody s) = object [ "in" .= ("body" :: Text), "schema" .= s ]
797797 toJSON (ParamOther s) = toJSON s
798798
799799instance ToJSON ParamOtherSchema where
800− toJSON = genericToJSONWithSub "common" (jsonPrefix "paramOtherSchema")
800+ toJSON = genericToJSONWithSub "paramSchema" (jsonPrefix "paramOtherSchema")
801801
802802instance ToJSON SchemaItems where
803803 toJSON (SchemaItemsObject x) = toJSON x
@@ -883,15 +883,15 @@ instance FromJSON SecurityScheme where
883883 parseJSON = genericParseJSONWithSub "type" (jsonPrefix "securityScheme")
884884
885885instance FromJSON Schema where
886− parseJSON = genericParseJSONWithSub "schemaCommon" (jsonPrefix "schema")
886+ parseJSON = genericParseJSONWithSub "paramSchema" (jsonPrefix "schema")
887887 `withDefaults` [ "properties" .= (mempty :: HashMap Text Schema)
888888 , "required" .= ([] :: [ParamName]) ]
889889
890890instance FromJSON Header where
891− parseJSON = genericParseJSONWithSub "common" (jsonPrefix "header")
891+ parseJSON = genericParseJSONWithSub "paramSchema" (jsonPrefix "header")
892892
893893instance FromJSON Items where
894− parseJSON = genericParseJSONWithSub "common" (jsonPrefix "items")
894+ parseJSON = genericParseJSONWithSub "paramSchema" (jsonPrefix "items")
895895
896896instance FromJSON Host where
897897 parseJSON (String s) =
@@ -912,7 +912,7 @@ instance FromJSON MimeList where
912912instance FromJSON Param where
913913 parseJSON = genericParseJSONWithSub "schema" (jsonPrefix "param")
914914
915−instance FromJSON ParamSchema where
915+instance FromJSON ParamAnySchema where
916916 parseJSON js@(Object o) = do
917917 (i :: Text) <- o .: "in"
918918 case i of
@@ -923,7 +923,7 @@ instance FromJSON ParamSchema where
923923 parseJSON _ = empty
924924
925925instance FromJSON ParamOtherSchema where
926− parseJSON = genericParseJSONWithSub "common" (jsonPrefix "paramOtherSchema")
926+ parseJSON = genericParseJSONWithSub "paramSchema" (jsonPrefix "paramOtherSchema")
927927
928928instance FromJSON SchemaItems where
929929 parseJSON js@(Object _) = SchemaItemsObject <$> parseJSON js
@@ -983,5 +983,5 @@ instance FromJSON (CollectionFormat Items) where
983983-- NOTE: The constraint @FromJSON (SwaggerType t)@ is necessary here!
984984-- Without the constraint the general instance will be used
985985-- that only accepts common types (i.e. NOT object, null or file).
986−instance (FromJSON (SwaggerType t), FromJSON i) => FromJSON (SchemaCommon t i) where
987− parseJSON = genericParseJSON (jsonPrefix "SchemaCommon")
986+instance (FromJSON (SwaggerType t), FromJSON i) => FromJSON (ParamSchema t i) where
987+ parseJSON = genericParseJSON (jsonPrefix "ParamSchema")
src/Data/Swagger/Lens.hs+41−41
@@ -24,13 +24,13 @@ makeLenses ''PathItem
2424makeLenses ''Tag
2525makeLenses ''Operation
2626makeLenses ''Param
27−makePrisms ''ParamSchema
27+makePrisms ''ParamAnySchema
2828makeLenses ''ParamOtherSchema
2929makeLenses ''Items
3030makeLenses ''Header
3131makeLenses ''Schema
3232makePrisms ''SchemaItems
33−makeLenses ''SchemaCommon
33+makeLenses ''ParamSchema
3434makeLenses ''Xml
3535makeLenses ''Responses
3636makeLenses ''Response
@@ -57,60 +57,60 @@ instance HasDescription Schema (Maybe Text) where description = schemaDe
5757instance HasDescription SecurityScheme (Maybe Text) where description = securitySchemeDescription
5858instance HasDescription ExternalDocs (Maybe Text) where description = externalDocsDescription
5959
60−class HasSchemaCommon s t i | s -> t i where
61− schemaCommon :: Lens' s (SchemaCommon t i)
60+class HasParamSchema s t i | s -> t i where
61+ parameterSchema :: Lens' s (ParamSchema t i)
6262
63−instance HasSchemaCommon Schema Schema SchemaItems where schemaCommon = schemaSchemaCommon
64−instance HasSchemaCommon ParamOtherSchema ParamOtherSchema Items where schemaCommon = paramOtherSchemaCommon
65−instance HasSchemaCommon Items Items Items where schemaCommon = itemsCommon
66−instance HasSchemaCommon Header Header Items where schemaCommon = headerCommon
67−instance HasSchemaCommon (SchemaCommon t i) t i where schemaCommon = id
63+instance HasParamSchema Schema Schema SchemaItems where parameterSchema = schemaParamSchema
64+instance HasParamSchema ParamOtherSchema ParamOtherSchema Items where parameterSchema = paramOtherSchemaParamSchema
65+instance HasParamSchema Items Items Items where parameterSchema = itemsParamSchema
66+instance HasParamSchema Header Header Items where parameterSchema = headerParamSchema
67+instance HasParamSchema (ParamSchema t i) t i where parameterSchema = id
6868
69−schemaType :: HasSchemaCommon s t i => Lens' s (SwaggerType t)
70−schemaType = schemaCommon.schemaCommonType
69+schemaType :: HasParamSchema s t i => Lens' s (SwaggerType t)
70+schemaType = parameterSchema.paramSchemaType
7171
72−schemaFormat :: HasSchemaCommon s t i => Lens' s (Maybe Format)
73−schemaFormat = schemaCommon.schemaCommonFormat
72+schemaFormat :: HasParamSchema s t i => Lens' s (Maybe Format)
73+schemaFormat = parameterSchema.paramSchemaFormat
7474
75−schemaItems :: HasSchemaCommon s t i => Lens' s (Maybe i)
76−schemaItems = schemaCommon.schemaCommonItems
75+schemaItems :: HasParamSchema s t i => Lens' s (Maybe i)
76+schemaItems = parameterSchema.paramSchemaItems
7777
78−schemaDefault :: HasSchemaCommon s t i => Lens' s (Maybe Value)
79−schemaDefault = schemaCommon.schemaCommonDefault
78+schemaDefault :: HasParamSchema s t i => Lens' s (Maybe Value)
79+schemaDefault = parameterSchema.paramSchemaDefault
8080
81−schemaMaximum :: HasSchemaCommon s t i => Lens' s (Maybe Scientific)
82−schemaMaximum = schemaCommon.schemaCommonMaximum
81+schemaMaximum :: HasParamSchema s t i => Lens' s (Maybe Scientific)
82+schemaMaximum = parameterSchema.paramSchemaMaximum
8383
84−schemaExclusiveMaximum :: HasSchemaCommon s t i => Lens' s (Maybe Bool)
85−schemaExclusiveMaximum = schemaCommon.schemaCommonExclusiveMaximum
84+schemaExclusiveMaximum :: HasParamSchema s t i => Lens' s (Maybe Bool)
85+schemaExclusiveMaximum = parameterSchema.paramSchemaExclusiveMaximum
8686
87−schemaMinimum :: HasSchemaCommon s t i => Lens' s (Maybe Scientific)
88−schemaMinimum = schemaCommon.schemaCommonMinimum
87+schemaMinimum :: HasParamSchema s t i => Lens' s (Maybe Scientific)
88+schemaMinimum = parameterSchema.paramSchemaMinimum
8989
90−schemaExclusiveMinimum :: HasSchemaCommon s t i => Lens' s (Maybe Bool)
91−schemaExclusiveMinimum = schemaCommon.schemaCommonExclusiveMinimum
90+schemaExclusiveMinimum :: HasParamSchema s t i => Lens' s (Maybe Bool)
91+schemaExclusiveMinimum = parameterSchema.paramSchemaExclusiveMinimum
9292
93−schemaMaxLength :: HasSchemaCommon s t i => Lens' s (Maybe Integer)
94−schemaMaxLength = schemaCommon.schemaCommonMaxLength
93+schemaMaxLength :: HasParamSchema s t i => Lens' s (Maybe Integer)
94+schemaMaxLength = parameterSchema.paramSchemaMaxLength
9595
96−schemaMinLength :: HasSchemaCommon s t i => Lens' s (Maybe Integer)
97−schemaMinLength = schemaCommon.schemaCommonMinLength
96+schemaMinLength :: HasParamSchema s t i => Lens' s (Maybe Integer)
97+schemaMinLength = parameterSchema.paramSchemaMinLength
9898
99−schemaPattern :: HasSchemaCommon s t i => Lens' s (Maybe Text)
100−schemaPattern = schemaCommon.schemaCommonPattern
99+schemaPattern :: HasParamSchema s t i => Lens' s (Maybe Text)
100+schemaPattern = parameterSchema.paramSchemaPattern
101101
102−schemaMaxItems :: HasSchemaCommon s t i => Lens' s (Maybe Integer)
103−schemaMaxItems = schemaCommon.schemaCommonMaxItems
102+schemaMaxItems :: HasParamSchema s t i => Lens' s (Maybe Integer)
103+schemaMaxItems = parameterSchema.paramSchemaMaxItems
104104
105−schemaMinItems :: HasSchemaCommon s t i => Lens' s (Maybe Integer)
106−schemaMinItems = schemaCommon.schemaCommonMinItems
105+schemaMinItems :: HasParamSchema s t i => Lens' s (Maybe Integer)
106+schemaMinItems = parameterSchema.paramSchemaMinItems
107107
108−schemaUniqueItems :: HasSchemaCommon s t i => Lens' s (Maybe Bool)
109−schemaUniqueItems = schemaCommon.schemaCommonUniqueItems
108+schemaUniqueItems :: HasParamSchema s t i => Lens' s (Maybe Bool)
109+schemaUniqueItems = parameterSchema.paramSchemaUniqueItems
110110
111−schemaEnum :: HasSchemaCommon s t i => Lens' s (Maybe [Value])
112−schemaEnum = schemaCommon.schemaCommonEnum
111+schemaEnum :: HasParamSchema s t i => Lens' s (Maybe [Value])
112+schemaEnum = parameterSchema.paramSchemaEnum
113113
114−schemaMultipleOf :: HasSchemaCommon s t i => Lens' s (Maybe Scientific)
115−schemaMultipleOf = schemaCommon.schemaCommonMultipleOf
114+schemaMultipleOf :: HasParamSchema s t i => Lens' s (Maybe Scientific)
115+schemaMultipleOf = parameterSchema.paramSchemaMultipleOf
116116