git.iko.soy/typeable/openapi3
on master help sign in
Move type and format to SchemaCommon
commitbadf3a18201535eecfdabf24471039c059d5806b authorNickolay Kudasov <nickolay.kudasov@gmail.com> dateTue 8 Dec 2015, 18:09 (11 years ago) parent8f92180
5 files changed+106−129
src/Data/Swagger/Internal.hs+12−35 src/Data/Swagger/Internal/Param.hs+15−15 src/Data/Swagger/Lens.hs+26−20 swagger2.cabal+1 test/Data/SwaggerSpec.hs+52−59
src/Data/Swagger/Internal.hs+12−35
@@ -283,17 +283,6 @@ data ParamOtherSchema = ParamOtherSchema
283283 { -- | The location of the parameter.
284284 _paramOtherSchemaIn :: ParamLocation
285285
286− -- | The type of the parameter.
287− -- Since the parameter is not located at the request body,
288− -- it is limited to simple types (that is, not an object).
289− -- If type is @'ParamFile'@, the @consumes@ MUST be either
290− -- "multipart/form-data" or " application/x-www-form-urlencoded"
291− -- and the parameter MUST be in @'ParamFormData'@.
292− , _paramOtherSchemaType :: ParamType
293−
294− -- | The extending format for the previously mentioned type.
295− , _paramOtherSchemaFormat :: Maybe Format
296−
297286 -- | Sets the ability to pass empty-valued parameters.
298287 -- This is valid only for either @'ParamQuery'@ or @'ParamFormData'@
299288 -- and allows you to send a parameter with a name only or an empty value.
@@ -308,7 +297,7 @@ data ParamOtherSchema = ParamOtherSchema
308297 -- Default value is csv.
309298 , _paramOtherSchemaCollectionFormat :: Maybe CollectionFormat
310299
311− , _paramOtherSchemaCommon :: SchemaCommon
300+ , _paramOtherSchemaCommon :: SchemaCommon ParamType
312301 } deriving (Eq, Show, Generic)
313302
314303data ParamType
@@ -382,9 +371,7 @@ data ItemsCollectionFormat
382371type ParamName = Text
383372
384373data Schema = Schema
385− { _schemaType :: SchemaType
386− , _schemaFormat :: Maybe Format
387− , _schemaTitle :: Maybe Text
374+ { _schemaTitle :: Maybe Text
388375 , _schemaDescription :: Maybe Text
389376 , _schemaRequired :: [ParamName]
390377
@@ -402,7 +389,7 @@ data Schema = Schema
402389 , _schemaMaxProperties :: Maybe Integer
403390 , _schemaMinProperties :: Maybe Integer
404391
405− , _schemaSchemaCommon :: SchemaCommon
392+ , _schemaSchemaCommon :: SchemaCommon SchemaType
406393 } deriving (Eq, Show, Generic)
407394
408395data SchemaItems
@@ -410,7 +397,7 @@ data SchemaItems
410397 | SchemaItemsArray [Referenced Schema]
411398 deriving (Eq, Show)
412399
413−data SchemaCommon = SchemaCommon
400+data SchemaCommon typeDomain = SchemaCommon
414401 { -- | Declares the value of the parameter that the server will use if none is provided,
415402 -- for example a @"count"@ to control the number of results per page might default to @100@
416403 -- if not supplied by the client in the request.
@@ -418,6 +405,8 @@ data SchemaCommon = SchemaCommon
418405 -- Unlike JSON Schema this value MUST conform to the defined type for this parameter.
419406 _schemaCommonDefault :: Maybe Value
420407
408+ , _schemaCommonType :: typeDomain
409+ , _schemaCommonFormat :: Maybe Format
421410 , _schemaCommonMaximum :: Maybe Scientific
422411 , _schemaCommonExclusiveMaximum :: Maybe Bool
423412 , _schemaCommonMinimum :: Maybe Scientific
@@ -461,21 +450,15 @@ data Xml = Xml
461450 } deriving (Eq, Show, Generic)
462451
463452data Items = Items
464− { -- | The internal type of the array.
465− _itemsType :: ItemsType
466−
467− -- | The extending format for the previously mentioned type.
468− , _itemsFormat :: Maybe Format
469−
470− -- | __Required if type is @'ItemsArray'@.__
453+ { -- | __Required if type is @'ItemsArray'@.__
471454 -- Describes the type of items in the array.
472− , _itemsItems :: Maybe Items
455+ _itemsItems :: Maybe Items
473456
474457 -- | Determines the format of the array if type array is used.
475458 -- Default value is @'ItemsCollectionCSV'@.
476459 , _itemsCollectionFormat :: Maybe ItemsCollectionFormat
477460
478− , _itemsCommon :: SchemaCommon
461+ , _itemsCommon :: SchemaCommon ItemsType
479462 } deriving (Eq, Show, Generic)
480463
481464-- | A container for the expected responses of an operation.
@@ -521,12 +504,6 @@ data Header = Header
521504 { -- | A short description of the header.
522505 _headerDescription :: Maybe Text
523506
524− -- | The type of the object.
525− , _headerType :: ItemsType
526−
527− -- | The extending format for the previously mentioned type. See Data Type Formats for further details.
528− , _headerFormat :: Maybe Format
529−
530507 -- | __Required if type is @'ItemsArray'@__.
531508 -- Describes the type of items in the array.
532509 , _headerItems :: Maybe Items
@@ -535,7 +512,7 @@ data Header = Header
535512 -- Default value is @'ItemsCollectionCSV'@.
536513 , _headerCollectionFormat :: Maybe ItemsCollectionFormat
537514
538− , _headerCommon :: SchemaCommon
515+ , _headerCommon :: SchemaCommon ItemsType
539516 } deriving (Eq, Show, Generic)
540517
541518data Example = Example { getExample :: Map MediaType Value }
@@ -657,7 +634,7 @@ instance Monoid Schema where
657634 mempty = genericMempty
658635 mappend = genericMappend
659636
660−instance Monoid SchemaCommon where
637+instance SwaggerMonoid t => Monoid (SchemaCommon t) where
661638 mempty = genericMempty
662639 mappend = genericMappend
663640
@@ -693,7 +670,7 @@ instance SwaggerMonoid Info
693670instance SwaggerMonoid Paths
694671instance SwaggerMonoid PathItem
695672instance SwaggerMonoid Schema
696−instance SwaggerMonoid SchemaCommon
673+instance SwaggerMonoid t => SwaggerMonoid (SchemaCommon t)
697674instance SwaggerMonoid Param
698675instance SwaggerMonoid ParamOtherSchema
699676instance SwaggerMonoid Responses
src/Data/Swagger/Internal/Param.hs+15−15
@@ -34,17 +34,17 @@ class ToParamSchema a where
3434instance {-# OVERLAPPING #-} ToParamSchema String where
3535 toParamSchema _ loc = mempty
3636 & paramOtherSchemaIn .~ loc
37− & paramOtherSchemaType .~ ParamString
37+ & schemaType .~ ParamString
3838
3939instance ToParamSchema Bool where
4040 toParamSchema _ loc = mempty
4141 & paramOtherSchemaIn .~ loc
42− & paramOtherSchemaType .~ ParamBoolean
42+ & schemaType .~ ParamBoolean
4343
4444instance ToParamSchema Integer where
4545 toParamSchema _ loc = mempty
4646 & paramOtherSchemaIn .~ loc
47− & paramOtherSchemaType .~ ParamInteger
47+ & schemaType .~ ParamInteger
4848
4949instance ToParamSchema Int where toParamSchema = toParamSchemaBoundedIntegral
5050instance ToParamSchema Int8 where toParamSchema = toParamSchemaBoundedIntegral
@@ -61,59 +61,59 @@ instance ToParamSchema Word64 where toParamSchema = toParamSchemaBoundedIntegral
6161toParamSchemaBoundedIntegral :: forall proxy a. (Bounded a, Integral a) => proxy a -> ParamLocation -> ParamOtherSchema
6262toParamSchemaBoundedIntegral _ loc = mempty
6363 & paramOtherSchemaIn .~ loc
64− & paramOtherSchemaType .~ ParamInteger
64+ & schemaType .~ ParamInteger
6565 & schemaMinimum ?~ fromInteger (toInteger (minBound :: a))
6666 & schemaMaximum ?~ fromInteger (toInteger (maxBound :: a))
6767
6868instance ToParamSchema Char where
6969 toParamSchema _ loc = mempty
7070 & paramOtherSchemaIn .~ loc
71− & paramOtherSchemaType .~ ParamString
71+ & schemaType .~ ParamString
7272 & schemaMaxLength ?~ 1
7373 & schemaMinLength ?~ 1
7474
7575instance ToParamSchema Scientific where
7676 toParamSchema _ loc = mempty
7777 & paramOtherSchemaIn .~ loc
78− & paramOtherSchemaType .~ ParamNumber
78+ & schemaType .~ ParamNumber
7979
8080instance ToParamSchema Double where
8181 toParamSchema _ loc = mempty
8282 & paramOtherSchemaIn .~ loc
83− & paramOtherSchemaType .~ ParamNumber
83+ & schemaType .~ ParamNumber
8484
8585instance ToParamSchema Float where
8686 toParamSchema _ loc = mempty
8787 & paramOtherSchemaIn .~ loc
88− & paramOtherSchemaType .~ ParamNumber
88+ & schemaType .~ ParamNumber
8989
9090timeParamSchema :: String -> ParamLocation -> ParamOtherSchema
9191timeParamSchema format loc = mempty
9292 & paramOtherSchemaIn .~ loc
93− & paramOtherSchemaType .~ ParamString
94− & paramOtherSchemaFormat ?~ T.pack format
93+ & schemaType .~ ParamString
94+ & schemaFormat ?~ T.pack format
9595 & schemaMinLength ?~ toInteger (length format)
9696
9797-- |
98−-- >>> toParamSchema (Proxy :: Proxy Day) ParamQuery ^. paramOtherSchemaFormat
98+-- >>> toParamSchema (Proxy :: Proxy Day) ParamQuery ^. schemaFormat
9999-- Just "yyyy-mm-dd"
100100instance ToParamSchema Day where
101101 toParamSchema _ = timeParamSchema "yyyy-mm-dd"
102102
103103-- |
104−-- >>> toParamSchema (Proxy :: Proxy LocalTime) ParamQuery ^. paramOtherSchemaFormat
104+-- >>> toParamSchema (Proxy :: Proxy LocalTime) ParamQuery ^. schemaFormat
105105-- Just "yyyy-mm-ddThh:MM:ss"
106106instance ToParamSchema LocalTime where
107107 toParamSchema _ = timeParamSchema "yyyy-mm-ddThh:MM:ss"
108108
109109-- |
110−-- >>> toParamSchema (Proxy :: Proxy ZonedTime) ParamQuery ^. paramOtherSchemaFormat
110+-- >>> toParamSchema (Proxy :: Proxy ZonedTime) ParamQuery ^. schemaFormat
111111-- Just "yyyy-mm-ddThh:MM:ss+hhMM"
112112instance ToParamSchema ZonedTime where
113113 toParamSchema _ = timeParamSchema "yyyy-mm-ddThh:MM:ss+hhMM"
114114
115115-- |
116−-- >>> toParamSchema (Proxy :: Proxy UTCTime) ParamQuery ^. paramOtherSchemaFormat
116+-- >>> toParamSchema (Proxy :: Proxy UTCTime) ParamQuery ^. schemaFormat
117117-- Just "yyyy-mm-ddThh:MM:ssZ"
118118instance ToParamSchema UTCTime where
119119 toParamSchema _ = timeParamSchema "yyyy-mm-ddThh:MM:ssZ"
@@ -162,7 +162,7 @@ instance (GEnumParamSchema f, GEnumParamSchema g) => GEnumParamSchema (f :+: g)
162162instance Constructor c => GEnumParamSchema (C1 c U1) where
163163 genumParamSchema opts _ loc s = s
164164 & paramOtherSchemaIn .~ loc
165− & paramOtherSchemaType .~ ParamString
165+ & schemaType .~ ParamString
166166 & schemaEnum %~ addEnumValue tag
167167 where
168168 tag = toJSON (constructorTagModifier opts (conName (Proxy3 :: Proxy3 c f p)))
src/Data/Swagger/Lens.hs+26−20
@@ -57,51 +57,57 @@ 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 where
61− schemaCommon :: Lens' s SchemaCommon
60+class HasSchemaCommon s t | s -> t where
61+ schemaCommon :: Lens' s (SchemaCommon t)
6262
63−instance HasSchemaCommon Schema where schemaCommon = schemaSchemaCommon
64−instance HasSchemaCommon ParamOtherSchema where schemaCommon = paramOtherSchemaCommon
65−instance HasSchemaCommon Items where schemaCommon = itemsCommon
66−instance HasSchemaCommon Header where schemaCommon = headerCommon
67−instance HasSchemaCommon SchemaCommon where schemaCommon = id
63+instance HasSchemaCommon Schema SchemaType where schemaCommon = schemaSchemaCommon
64+instance HasSchemaCommon ParamOtherSchema ParamType where schemaCommon = paramOtherSchemaCommon
65+instance HasSchemaCommon Items ItemsType where schemaCommon = itemsCommon
66+instance HasSchemaCommon Header ItemsType where schemaCommon = headerCommon
67+instance HasSchemaCommon (SchemaCommon t) t where schemaCommon = id
6868
69−schemaDefault :: HasSchemaCommon s => Lens' s (Maybe Value)
69+schemaType :: HasSchemaCommon s t => Lens' s t
70+schemaType = schemaCommon.schemaCommonType
71+
72+schemaFormat :: HasSchemaCommon s t => Lens' s (Maybe Format)
73+schemaFormat = schemaCommon.schemaCommonFormat
74+
75+schemaDefault :: HasSchemaCommon s t => Lens' s (Maybe Value)
7076schemaDefault = schemaCommon.schemaCommonDefault
7177
72−schemaMaximum :: HasSchemaCommon s => Lens' s (Maybe Scientific)
78+schemaMaximum :: HasSchemaCommon s t => Lens' s (Maybe Scientific)
7379schemaMaximum = schemaCommon.schemaCommonMaximum
7480
75−schemaExclusiveMaximum :: HasSchemaCommon s => Lens' s (Maybe Bool)
81+schemaExclusiveMaximum :: HasSchemaCommon s t => Lens' s (Maybe Bool)
7682schemaExclusiveMaximum = schemaCommon.schemaCommonExclusiveMaximum
7783
78−schemaMinimum :: HasSchemaCommon s => Lens' s (Maybe Scientific)
84+schemaMinimum :: HasSchemaCommon s t => Lens' s (Maybe Scientific)
7985schemaMinimum = schemaCommon.schemaCommonMinimum
8086
81−schemaExclusiveMinimum :: HasSchemaCommon s => Lens' s (Maybe Bool)
87+schemaExclusiveMinimum :: HasSchemaCommon s t => Lens' s (Maybe Bool)
8288schemaExclusiveMinimum = schemaCommon.schemaCommonExclusiveMinimum
8389
84−schemaMaxLength :: HasSchemaCommon s => Lens' s (Maybe Integer)
90+schemaMaxLength :: HasSchemaCommon s t => Lens' s (Maybe Integer)
8591schemaMaxLength = schemaCommon.schemaCommonMaxLength
8692
87−schemaMinLength :: HasSchemaCommon s => Lens' s (Maybe Integer)
93+schemaMinLength :: HasSchemaCommon s t => Lens' s (Maybe Integer)
8894schemaMinLength = schemaCommon.schemaCommonMinLength
8995
90−schemaPattern :: HasSchemaCommon s => Lens' s (Maybe Text)
96+schemaPattern :: HasSchemaCommon s t => Lens' s (Maybe Text)
9197schemaPattern = schemaCommon.schemaCommonPattern
9298
93−schemaMaxItems :: HasSchemaCommon s => Lens' s (Maybe Integer)
99+schemaMaxItems :: HasSchemaCommon s t => Lens' s (Maybe Integer)
94100schemaMaxItems = schemaCommon.schemaCommonMaxItems
95101
96−schemaMinItems :: HasSchemaCommon s => Lens' s (Maybe Integer)
102+schemaMinItems :: HasSchemaCommon s t => Lens' s (Maybe Integer)
97103schemaMinItems = schemaCommon.schemaCommonMinItems
98104
99−schemaUniqueItems :: HasSchemaCommon s => Lens' s (Maybe Bool)
105+schemaUniqueItems :: HasSchemaCommon s t => Lens' s (Maybe Bool)
100106schemaUniqueItems = schemaCommon.schemaCommonUniqueItems
101107
102−schemaEnum :: HasSchemaCommon s => Lens' s (Maybe [Value])
108+schemaEnum :: HasSchemaCommon s t => Lens' s (Maybe [Value])
103109schemaEnum = schemaCommon.schemaCommonEnum
104110
105−schemaMultipleOf :: HasSchemaCommon s => Lens' s (Maybe Scientific)
111+schemaMultipleOf :: HasSchemaCommon s t => Lens' s (Maybe Scientific)
106112schemaMultipleOf = schemaCommon.schemaCommonMultipleOf
107113
swagger2.cabal+1
@@ -57,6 +57,7 @@ test-suite spec
5757 , containers
5858 , unordered-containers
5959 , vector
60+ , lens
6061 other-modules:
6162 SpecCommon
6263 Data.SwaggerSpec
test/Data/SwaggerSpec.hs+52−59
@@ -4,12 +4,15 @@
44{-# LANGUAGE QuasiQuotes #-}
55module Data.SwaggerSpec where
66
7+import Control.Lens
8+
79import Data.Aeson
810import Data.Aeson.QQ
911import Data.HashMap.Strict (HashMap)
1012import Data.Text (Text)
1113
1214import Data.Swagger
15+import Data.Swagger.Lens
1316import SpecCommon
1417import Test.Hspec
1518
@@ -148,10 +151,10 @@ operationExample = mempty
148151 , _paramSchema = ParamOther (stringSchema ParamFormData) }
149152 ]
150153
154+ stringSchema :: ParamLocation -> ParamOtherSchema
151155 stringSchema i = mempty
152− { _paramOtherSchemaIn = i
153− , _paramOtherSchemaType = ParamString
154− }
156+ & paramOtherSchemaIn .~ i
157+ & schemaType .~ ParamString
155158
156159operationExampleJSON :: Value
157160operationExampleJSON = [aesonQQ|
@@ -217,9 +220,8 @@ operationExampleJSON = [aesonQQ|
217220
218221schemaPrimitiveExample :: Schema
219222schemaPrimitiveExample = mempty
220− { _schemaType = SchemaString
221− , _schemaFormat = Just "email"
222− }
223+ & schemaType .~ SchemaString
224+ & schemaFormat ?~ "email"
223225
224226schemaPrimitiveExampleJSON :: Value
225227schemaPrimitiveExampleJSON = [aesonQQ|
@@ -231,17 +233,15 @@ schemaPrimitiveExampleJSON = [aesonQQ|
231233
232234schemaSimpleModelExample :: Schema
233235schemaSimpleModelExample = mempty
234− { _schemaType = SchemaObject
235− , _schemaRequired = [ "name" ]
236− , _schemaProperties =
237− [ ("name", Inline mempty
238− { _schemaType = SchemaString } )
236+ & schemaType .~ SchemaObject
237+ & schemaRequired .~ [ "name" ]
238+ & schemaProperties .~
239+ [ ("name", Inline (mempty & schemaType .~ SchemaString))
239240 , ("address", Ref (Reference "#/definitions/Address"))
240− , ("age", Inline mempty
241− { _schemaType = SchemaInteger
242− , _schemaFormat = Just "int32"
243− , _schemaSchemaCommon = mempty
244− { _schemaCommonMinimum = Just 0 } } ) ] }
241+ , ("age", Inline $ mempty
242+ & schemaMinimum ?~ 0
243+ & schemaType .~ SchemaInteger
244+ & schemaFormat ?~ "int32" ) ]
245245
246246schemaSimpleModelExampleJSON :: Value
247247schemaSimpleModelExampleJSON = [aesonQQ|
@@ -268,9 +268,8 @@ schemaSimpleModelExampleJSON = [aesonQQ|
268268
269269schemaModelDictExample :: Schema
270270schemaModelDictExample = mempty
271− { _schemaType = SchemaObject
272− , _schemaAdditionalProperties = Just mempty
273− { _schemaType = SchemaString } }
271+ & schemaType .~ SchemaObject
272+ & schemaAdditionalProperties ?~ (mempty & schemaType .~ SchemaString)
274273
275274schemaModelDictExampleJSON :: Value
276275schemaModelDictExampleJSON = [aesonQQ|
@@ -283,14 +282,12 @@ schemaModelDictExampleJSON = [aesonQQ|
283282|]
284283
285284schemaWithExampleExample :: Schema
286−schemaWithExampleExample = mempty
287− { _schemaType = SchemaObject
288− , _schemaProperties =
289− [ ("id", Inline mempty
290− { _schemaType = SchemaInteger
291− , _schemaFormat = Just "int64" })
292− , ("name", Inline mempty
293− { _schemaType = SchemaString }) ]
285+schemaWithExampleExample = (mempty & schemaType .~ SchemaObject)
286+ { _schemaProperties =
287+ [ ("id", Inline $ mempty
288+ & schemaType .~ SchemaInteger
289+ & schemaFormat ?~ "int64" )
290+ , ("name", Inline (mempty & schemaType .~ SchemaString)) ]
294291 , _schemaRequired = [ "name" ]
295292 , _schemaExample = Just [aesonQQ|
296293 {
@@ -329,21 +326,19 @@ schemaWithExampleExampleJSON = [aesonQQ|
329326definitionsExample :: HashMap Text Schema
330327definitionsExample =
331328 [ ("Category", mempty
332− { _schemaType = SchemaObject
333− , _schemaProperties =
334− [ ("id", Inline mempty
335− { _schemaType = SchemaInteger
336− , _schemaFormat = Just "int64" })
337− , ("name", Inline mempty
338− { _schemaType = SchemaString }) ] })
329+ & schemaType .~ SchemaObject
330+ & schemaProperties .~
331+ [ ("id", Inline $ mempty
332+ & schemaType .~ SchemaInteger
333+ & schemaFormat ?~ "int64")
334+ , ("name", Inline (mempty & schemaType .~ SchemaString)) ] )
339335 , ("Tag", mempty
340− { _schemaType = SchemaObject
341− , _schemaProperties =
342− [ ("id", Inline mempty
343− { _schemaType = SchemaInteger
344− , _schemaFormat = Just "int64" })
345− , ("name", Inline mempty
346− { _schemaType = SchemaString }) ] }) ]
336+ & schemaType .~ SchemaObject
337+ & schemaProperties .~
338+ [ ("id", Inline $ mempty
339+ & schemaType .~ SchemaInteger
340+ & schemaFormat ?~ "int64")
341+ , ("name", Inline (mempty & schemaType .~ SchemaString)) ] ) ]
347342
348343definitionsExampleJSON :: Value
349344definitionsExampleJSON = [aesonQQ|
@@ -385,18 +380,18 @@ paramsDefinitionExample =
385380 { _paramName = "skip"
386381 , _paramDescription = Just "number of items to skip"
387382 , _paramRequired = Just True
388− , _paramSchema = ParamOther mempty
389− { _paramOtherSchemaIn = ParamQuery
390− , _paramOtherSchemaType = ParamInteger
391− , _paramOtherSchemaFormat = Just "int32" } })
383+ , _paramSchema = ParamOther $ mempty
384+ & paramOtherSchemaIn .~ ParamQuery
385+ & schemaType .~ ParamInteger
386+ & schemaFormat ?~ "int32" })
392387 , ("limitParam", mempty
393388 { _paramName = "limit"
394389 , _paramDescription = Just "max records to return"
395390 , _paramRequired = Just True
396− , _paramSchema = ParamOther mempty
397− { _paramOtherSchemaIn = ParamQuery
398− , _paramOtherSchemaType = ParamInteger
399− , _paramOtherSchemaFormat = Just "int32" } }) ]
391+ , _paramSchema = ParamOther $ mempty
392+ & paramOtherSchemaIn .~ ParamQuery
393+ & schemaType .~ ParamInteger
394+ & schemaFormat ?~ "int32" }) ]
400395
401396paramsDefinitionExampleJSON :: Value
402397paramsDefinitionExampleJSON = [aesonQQ|
@@ -500,20 +495,18 @@ swaggerExample = mempty
500495 { _operationResponses = mempty
501496 { _responsesResponses =
502497 [ (200, Inline mempty
503− { _responseSchema = Just $ Inline mempty
498+ { _responseSchema = Just $ Inline (mempty & schemaType .~ SchemaObject)
504499 { _schemaExample = Just [aesonQQ|
505500 {
506501 "created": 100,
507502 "description": "get milk"
508503 } |]
509− , _schemaType = SchemaObject
510504 , _schemaDescription = Just "This is some real Todo right here"
511505 , _schemaProperties =
512− [ ("created", Inline mempty
513− { _schemaType = SchemaInteger
514− , _schemaFormat = Just "int32" })
515− , ("description", Inline mempty
516− { _schemaType = SchemaString }) ] }
506+ [ ("created", Inline $ mempty
507+ & schemaType .~ SchemaInteger
508+ & schemaFormat ?~ "int32")
509+ , ("description", Inline (mempty & schemaType .~ SchemaString)) ] }
517510 , _responseDescription = "OK" }) ] }
518511 , _operationProduces = Just (MimeList [ "application/json" ])
519512 , _operationParameters =
@@ -521,9 +514,9 @@ swaggerExample = mempty
521514 { _paramRequired = Just True
522515 , _paramName = "id"
523516 , _paramDescription = Just "TodoId param"
524− , _paramSchema = ParamOther mempty
525− { _paramOtherSchemaIn = ParamPath
526− , _paramOtherSchemaType = ParamString } } ]
517+ , _paramSchema = ParamOther $ mempty
518+ & paramOtherSchemaIn .~ ParamPath
519+ & schemaType .~ ParamString } ]
527520 , _operationTags = [ "todo" ] } }) ] } }
528521
529522swaggerExampleJSON :: Value