@@ -111,7 +111,7 @@ rename name (NamedSchema _ schema) = NamedSchema name schema
111-- declareNamedSchema _ = do
111-- declareNamedSchema _ = do
112-- doubleSchema <- declareSchemaRef (Proxy :: Proxy Double)
112-- doubleSchema <- declareSchemaRef (Proxy :: Proxy Double)
113-- return $ NamedSchema (Just \"Coord\") $ mempty
113-- return $ NamedSchema (Just \"Coord\") $ mempty
114−-- & type_ .~ SwaggerObject
114+-- & type_ ?~ SwaggerObject
115-- & properties .~
115-- & properties .~
116-- [ (\"x\", doubleSchema)
116-- [ (\"x\", doubleSchema)
117-- , (\"y\", doubleSchema)
117-- , (\"y\", doubleSchema)
@@ -294,20 +294,20 @@ inlineNonRecursiveSchemas defs = inlineSchemasWhen nonRecursive defs
294-- | Default schema for binary data (any sequence of octets).
294-- | Default schema for binary data (any sequence of octets).
295binarySchema :: Schema
295binarySchema :: Schema
296binarySchema = mempty
296binarySchema = mempty
297− & type_ .~ SwaggerString
297+ & type_ ?~ SwaggerString
298 & format ?~ "binary"
298 & format ?~ "binary"
300-- | Default schema for binary data (base64 encoded).
300-- | Default schema for binary data (base64 encoded).
301byteSchema :: Schema
301byteSchema :: Schema
302byteSchema = mempty
302byteSchema = mempty
303− & type_ .~ SwaggerString
303+ & type_ ?~ SwaggerString
304 & format ?~ "byte"
304 & format ?~ "byte"
306-- | Default schema for password string.
306-- | Default schema for password string.
307-- @"password"@ format is used to hint UIs the input needs to be obscured.
307-- @"password"@ format is used to hint UIs the input needs to be obscured.
308passwordSchema :: Schema
308passwordSchema :: Schema
309passwordSchema = mempty
309passwordSchema = mempty
310− & type_ .~ SwaggerString
310+ & type_ ?~ SwaggerString
311 & format ?~ "password"
311 & format ?~ "password"
313-- | Make an unrestrictive sketch of a @'Schema'@ based on a @'ToJSON'@ instance.
313-- | Make an unrestrictive sketch of a @'Schema'@ based on a @'ToJSON'@ instance.
@@ -333,12 +333,12 @@ sketchSchema = sketch . toJSON
333 sketch js@(Bool _) = go js
333 sketch js@(Bool _) = go js
334 sketch js = go js & example ?~ js
334 sketch js = go js & example ?~ js
336− go Null = mempty & type_ .~ SwaggerNull
336+ go Null = mempty & type_ ?~ SwaggerNull
337− go (Bool _) = mempty & type_ .~ SwaggerBoolean
337+ go (Bool _) = mempty & type_ ?~ SwaggerBoolean
338− go (String _) = mempty & type_ .~ SwaggerString
338+ go (String _) = mempty & type_ ?~ SwaggerString
339− go (Number _) = mempty & type_ .~ SwaggerNumber
339+ go (Number _) = mempty & type_ ?~ SwaggerNumber
340 go (Array xs) = mempty
340 go (Array xs) = mempty
341− & type_ .~ SwaggerArray
341+ & type_ ?~ SwaggerArray
342 & items ?~ case ischema of
342 & items ?~ case ischema of
343 Just s -> SwaggerItemsObject (Inline s)
343 Just s -> SwaggerItemsObject (Inline s)
344 _ -> SwaggerItemsArray (map Inline ys)
344 _ -> SwaggerItemsArray (map Inline ys)
@@ -350,7 +350,7 @@ sketchSchema = sketch . toJSON
350 (z:_) | allSame -> Just z
350 (z:_) | allSame -> Just z
351 _ -> Nothing
351 _ -> Nothing
352 go (Object o) = mempty
352 go (Object o) = mempty
353− & type_ .~ SwaggerObject
353+ & type_ ?~ SwaggerObject
354 & required .~ HashMap.keys o
354 & required .~ HashMap.keys o
355 & properties .~ fmap (Inline . go) (InsOrdHashMap.fromHashMap o)
355 & properties .~ fmap (Inline . go) (InsOrdHashMap.fromHashMap o)
@@ -373,24 +373,24 @@ sketchSchema = sketch . toJSON
373sketchStrictSchema :: ToJSON a => a -> Schema
373sketchStrictSchema :: ToJSON a => a -> Schema
374sketchStrictSchema = go . toJSON
374sketchStrictSchema = go . toJSON
376− go Null = mempty & type_ .~ SwaggerNull
376+ go Null = mempty & type_ ?~ SwaggerNull
377 go js@(Bool _) = mempty
377 go js@(Bool _) = mempty
378− & type_ .~ SwaggerBoolean
378+ & type_ ?~ SwaggerBoolean
379 & enum_ ?~ [js]
379 & enum_ ?~ [js]
380 go js@(String s) = mempty
380 go js@(String s) = mempty
381− & type_ .~ SwaggerString
381+ & type_ ?~ SwaggerString
382 & maxLength ?~ fromIntegral (T.length s)
382 & maxLength ?~ fromIntegral (T.length s)
383 & minLength ?~ fromIntegral (T.length s)
383 & minLength ?~ fromIntegral (T.length s)
384 & pattern ?~ s
384 & pattern ?~ s
385 & enum_ ?~ [js]
385 & enum_ ?~ [js]
386 go js@(Number n) = mempty
386 go js@(Number n) = mempty
387− & type_ .~ SwaggerNumber
387+ & type_ ?~ SwaggerNumber
388 & maximum_ ?~ n
388 & maximum_ ?~ n
389 & minimum_ ?~ n
389 & minimum_ ?~ n
390 & multipleOf ?~ n
390 & multipleOf ?~ n
391 & enum_ ?~ [js]
391 & enum_ ?~ [js]
392 go js@(Array xs) = mempty
392 go js@(Array xs) = mempty
393− & type_ .~ SwaggerArray
393+ & type_ ?~ SwaggerArray
394 & maxItems ?~ fromIntegral sz
394 & maxItems ?~ fromIntegral sz
395 & minItems ?~ fromIntegral sz
395 & minItems ?~ fromIntegral sz
396 & items ?~ SwaggerItemsArray (map (Inline . go) (V.toList xs))
396 & items ?~ SwaggerItemsArray (map (Inline . go) (V.toList xs))
@@ -400,7 +400,7 @@ sketchStrictSchema = go . toJSON
400 sz = length xs
400 sz = length xs
401 allUnique = sz == HashSet.size (HashSet.fromList (V.toList xs))
401 allUnique = sz == HashSet.size (HashSet.fromList (V.toList xs))
402 go js@(Object o) = mempty
402 go js@(Object o) = mempty
403− & type_ .~ SwaggerObject
403+ & type_ ?~ SwaggerObject
404 & required .~ names
404 & required .~ names
405 & properties .~ fmap (Inline . go) (InsOrdHashMap.fromHashMap o)
405 & properties .~ fmap (Inline . go) (InsOrdHashMap.fromHashMap o)
406 & maxProperties ?~ fromIntegral (length names)
406 & maxProperties ?~ fromIntegral (length names)
@@ -416,7 +416,7 @@ instance OVERLAPPABLE_ ToSchema a => ToSchema [a] where
416 declareNamedSchema _ = do
416 declareNamedSchema _ = do
417 ref <- declareSchemaRef (Proxy :: Proxy a)
417 ref <- declareSchemaRef (Proxy :: Proxy a)
418 return $ unnamed $ mempty
418 return $ unnamed $ mempty
419− & type_ .~ SwaggerArray
419+ & type_ ?~ SwaggerArray
420 & items ?~ SwaggerItemsObject ref
420 & items ?~ SwaggerItemsObject ref
422instance OVERLAPPING_ ToSchema String where declareNamedSchema = plain . paramSchemaToSchema
422instance OVERLAPPING_ ToSchema String where declareNamedSchema = plain . paramSchemaToSchema
@@ -466,7 +466,7 @@ instance (ToSchema a, ToSchema b, ToSchema c, ToSchema d, ToSchema e, ToSchema f
467timeSchema :: T.Text -> Schema
467timeSchema :: T.Text -> Schema
468timeSchema fmt = mempty
468timeSchema fmt = mempty
469− & type_ .~ SwaggerString
469+ & type_ ?~ SwaggerString
470 & format ?~ fmt
470 & format ?~ fmt
472-- | Format @"date"@ corresponds to @yyyy-mm-dd@ format.
472-- | Format @"date"@ corresponds to @yyyy-mm-dd@ format.
@@ -528,7 +528,7 @@ instance (ToJSONKey k, ToSchema k, ToSchema v) => ToSchema (Map k v) where
528 declareObjectMapSchema = do
528 declareObjectMapSchema = do
529 schema <- declareSchemaRef (Proxy :: Proxy v)
529 schema <- declareSchemaRef (Proxy :: Proxy v)
530 return $ unnamed $ mempty
530 return $ unnamed $ mempty
531− & type_ .~ SwaggerObject
531+ & type_ ?~ SwaggerObject
532 & additionalProperties ?~ AdditionalPropertiesSchema schema
532 & additionalProperties ?~ AdditionalPropertiesSchema schema
534instance (ToJSONKey k, ToSchema k, ToSchema v) => ToSchema (HashMap k v) where
534instance (ToJSONKey k, ToSchema k, ToSchema v) => ToSchema (HashMap k v) where
@@ -540,7 +540,7 @@ instance ToSchema a => ToSchema (Map String a) where
540 declareNamedSchema _ = do
540 declareNamedSchema _ = do
541 schema <- declareSchemaRef (Proxy :: Proxy a)
541 schema <- declareSchemaRef (Proxy :: Proxy a)
542 return $ unnamed $ mempty
542 return $ unnamed $ mempty
543− & type_ .~ SwaggerObject
543+ & type_ ?~ SwaggerObject
544 & additionalProperties ?~ schema
544 & additionalProperties ?~ schema
546instance ToSchema a => ToSchema (Map T.Text a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map String a))
546instance ToSchema a => ToSchema (Map T.Text a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map String a))
@@ -554,7 +554,7 @@ instance ToSchema a => ToSchema (HashMap TL.Text a) where declareNamedSchema _ =
555instance OVERLAPPING_ ToSchema Object where
555instance OVERLAPPING_ ToSchema Object where
556 declareNamedSchema _ = pure $ NamedSchema (Just "Object") $ mempty
556 declareNamedSchema _ = pure $ NamedSchema (Just "Object") $ mempty
557− & type_ .~ SwaggerObject
557+ & type_ ?~ SwaggerObject
558 & description ?~ "Arbitrary JSON object."
558 & description ?~ "Arbitrary JSON object."
559 & additionalProperties ?~ AdditionalPropertiesAllowed True
559 & additionalProperties ?~ AdditionalPropertiesAllowed True
@@ -595,7 +595,7 @@ instance ToSchema a => ToSchema (Identity a) where declareNamedSchema _ = declar
595-- "{\"maximum\":32767,\"minimum\":-32768,\"type\":\"integer\"}"
595-- "{\"maximum\":32767,\"minimum\":-32768,\"type\":\"integer\"}"
596toSchemaBoundedIntegral :: forall a. (Bounded a, Integral a) => Proxy a -> Schema
596toSchemaBoundedIntegral :: forall a. (Bounded a, Integral a) => Proxy a -> Schema
597toSchemaBoundedIntegral _ = mempty
597toSchemaBoundedIntegral _ = mempty
598− & type_ .~ SwaggerInteger
598+ & type_ ?~ SwaggerInteger
599 & minimum_ ?~ fromInteger (toInteger (minBound :: a))
599 & minimum_ ?~ fromInteger (toInteger (minBound :: a))
600 & maximum_ ?~ fromInteger (toInteger (maxBound :: a))
600 & maximum_ ?~ fromInteger (toInteger (maxBound :: a))
@@ -641,7 +641,7 @@ declareSchemaBoundedEnumKeyMapping _ = case toJSONKey :: ToJSONKeyFunction key o
641 let allKeys = [minBound..maxBound :: key]
641 let allKeys = [minBound..maxBound :: key]
642 mkPair k = (keyToText k, valueRef)
642 mkPair k = (keyToText k, valueRef)
643 return $ mempty
643 return $ mempty
644− & type_ .~ SwaggerObject
644+ & type_ ?~ SwaggerObject
645 & properties .~ InsOrdHashMap.fromList (map mkPair allKeys)
645 & properties .~ InsOrdHashMap.fromList (map mkPair allKeys)
647-- | A 'Schema' for a mapping with 'Bounded' 'Enum' keys.
647-- | A 'Schema' for a mapping with 'Bounded' 'Enum' keys.
@@ -715,7 +715,7 @@ paramSchemaToSchema proxy = mempty & paramSchema .~ toParamSchema proxy
716nullarySchema :: Schema
716nullarySchema :: Schema
717nullarySchema = mempty
717nullarySchema = mempty
718− & type_ .~ SwaggerArray
718+ & type_ ?~ SwaggerArray
719 & items ?~ SwaggerItemsArray []
719 & items ?~ SwaggerItemsArray []
721gtoNamedSchema :: GToSchema f => SchemaOptions -> Proxy f -> NamedSchema
721gtoNamedSchema :: GToSchema f => SchemaOptions -> Proxy f -> NamedSchema
@@ -786,12 +786,12 @@ withFieldSchema opts _ isRequiredField schema = do
787 if T.null fname
787 if T.null fname
788 then schema
788 then schema
789− & type_ .~ SwaggerArray
789+ & type_ ?~ SwaggerArray
790 & items %~ appendItem ref
790 & items %~ appendItem ref
791 & maxItems %~ Just . maybe 1 (+1) -- increment maxItems
791 & maxItems %~ Just . maybe 1 (+1) -- increment maxItems
792 & minItems %~ Just . maybe 1 (+1) -- increment minItems
792 & minItems %~ Just . maybe 1 (+1) -- increment minItems
793 else schema
793 else schema
794− & type_ .~ SwaggerObject
794+ & type_ ?~ SwaggerObject
795 & properties . at fname ?~ ref
795 & properties . at fname ?~ ref
796 & if isRequiredField
796 & if isRequiredField
797 then required %~ (++ [fname])
797 then required %~ (++ [fname])
@@ -828,7 +828,7 @@ gdeclareNamedSumSchema opts proxy s
828 (sumSchema, All allNullary) = undeclare (runWriterT declareSumSchema)
828 (sumSchema, All allNullary) = undeclare (runWriterT declareSumSchema)
830 toStringTag schema = mempty
830 toStringTag schema = mempty
831− & type_ .~ SwaggerString
831+ & type_ ?~ SwaggerString
832 & enum_ ?~ map toJSON (schema ^.. properties.ifolded.asIndex)
832 & enum_ ?~ map toJSON (schema ^.. properties.ifolded.asIndex)
834type AllNullary = All
834type AllNullary = All
@@ -842,7 +842,7 @@ instance (GSumToSchema f, GSumToSchema g) => GSumToSchema (f :+: g) where
842gsumConToSchemaWith :: forall c f. (GToSchema (C1 c f), Constructor c) =>
842gsumConToSchemaWith :: forall c f. (GToSchema (C1 c f), Constructor c) =>
843 Referenced Schema -> SchemaOptions -> Proxy (C1 c f) -> Schema -> Schema
843 Referenced Schema -> SchemaOptions -> Proxy (C1 c f) -> Schema -> Schema
844gsumConToSchemaWith ref opts _ schema = schema
844gsumConToSchemaWith ref opts _ schema = schema
845− & type_ .~ SwaggerObject
845+ & type_ ?~ SwaggerObject
846 & properties . at tag ?~ ref
846 & properties . at tag ?~ ref
847 & maxProperties ?~ 1
847 & maxProperties ?~ 1
848 & minProperties ?~ 1
848 & minProperties ?~ 1