@@ -32,7 +32,7 @@ import Data.Data.Lens (template)
3232
3333import Control.Monad
3434import Control.Monad.Writer
35−import Data.Aeson (ToJSON (..), ToJSONKey (..), ToJSONKeyFunction (..), Value (..), Object(..))
35+import Data.Aeson (ToJSON (..), ToJSONKey (..), ToJSONKeyFunction (..), Value (..))
3636import Data.Char
3737import Data.Data (Data)
3838import Data.Foldable (traverse_)
@@ -44,7 +44,6 @@ import qualified Data.HashMap.Strict.InsOrd as InsOrdHashMap
4444import Data.Int
4545import Data.IntSet (IntSet)
4646import Data.IntMap (IntMap)
47−import Data.List.NonEmpty.Compat (NonEmpty)
4847import Data.Map (Map)
4948import Data.Proxy
5049import Data.Scientific (Scientific)
@@ -57,8 +56,7 @@ import qualified Data.Vector as V
5756import qualified Data.Vector.Primitive as VP
5857import qualified Data.Vector.Storable as VS
5958import qualified Data.Vector.Unboxed as VU
60−import Data.Version (Version)
61−import Numeric.Natural.Compat (Natural)
59+import Numeric.Natural
6260import Data.Word
6361import GHC.Generics
6462import qualified Data.UUID.Types as UUID
@@ -111,7 +109,7 @@ rename name (NamedSchema _ schema) = NamedSchema name schema
111109-- declareNamedSchema _ = do
112110-- doubleSchema <- declareSchemaRef (Proxy :: Proxy Double)
113111-- return $ NamedSchema (Just \"Coord\") $ mempty
114−-- & type_ ?~ SwaggerObject
112+-- & type_ .~ SwaggerObject
115113-- & properties .~
116114-- [ (\"x\", doubleSchema)
117115-- , (\"y\", doubleSchema)
@@ -142,17 +140,13 @@ class ToSchema a where
142140 -- together with all used definitions.
143141 -- Note that the schema itself is included in definitions
144142 -- only if it is recursive (and thus needs its definition in scope).
145− declareNamedSchema :: Proxy a -> Declare (Definitions Schema) NamedSchema
143+ declareNamedSchema :: proxy a -> Declare (Definitions Schema) NamedSchema
146144 default declareNamedSchema :: (Generic a, GToSchema (Rep a), TypeHasSimpleShape a "genericDeclareNamedSchemaUnrestricted") =>
147− Proxy a -> Declare (Definitions Schema) NamedSchema
145+ proxy a -> Declare (Definitions Schema) NamedSchema
148146 declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
149147
150−instance ToSchema TimeOfDay where
151− declareNamedSchema _ = pure $ named "TimeOfDay" $ timeSchema "hh:MM:ss"
152− & example ?~ toJSON (TimeOfDay 12 33 15)
153−
154148-- | Convert a type into a schema and declare all used schema definitions.
155−declareSchema :: ToSchema a => Proxy a -> Declare (Definitions Schema) Schema
149+declareSchema :: ToSchema a => proxy a -> Declare (Definitions Schema) Schema
156150declareSchema = fmap _namedSchemaSchema . declareNamedSchema
157151
158152-- | Convert a type into an optionally named schema.
@@ -166,7 +160,7 @@ declareSchema = fmap _namedSchemaSchema . declareNamedSchema
166160-- Just "Day"
167161-- >>> encode (toNamedSchema (Proxy :: Proxy Day) ^. schema)
168162-- "{\"example\":\"2016-07-22\",\"format\":\"date\",\"type\":\"string\"}"
169−toNamedSchema :: ToSchema a => Proxy a -> NamedSchema
163+toNamedSchema :: ToSchema a => proxy a -> NamedSchema
170164toNamedSchema = undeclare . declareNamedSchema
171165
172166-- | Get type's schema name according to its @'ToSchema'@ instance.
@@ -176,7 +170,7 @@ toNamedSchema = undeclare . declareNamedSchema
176170--
177171-- >>> schemaName (Proxy :: Proxy UTCTime)
178172-- Just "UTCTime"
179−schemaName :: ToSchema a => Proxy a -> Maybe T.Text
173+schemaName :: ToSchema a => proxy a -> Maybe T.Text
180174schemaName = _namedSchemaName . toNamedSchema
181175
182176-- | Convert a type into a schema.
@@ -186,7 +180,7 @@ schemaName = _namedSchemaName . toNamedSchema
186180--
187181-- >>> encode $ toSchema (Proxy :: Proxy [Day])
188182-- "{\"items\":{\"$ref\":\"#/definitions/Day\"},\"type\":\"array\"}"
189−toSchema :: ToSchema a => Proxy a -> Schema
183+toSchema :: ToSchema a => proxy a -> Schema
190184toSchema = _namedSchemaSchema . toNamedSchema
191185
192186-- | Convert a type into a referenced schema if possible.
@@ -197,7 +191,7 @@ toSchema = _namedSchemaSchema . toNamedSchema
197191--
198192-- >>> encode $ toSchemaRef (Proxy :: Proxy Day)
199193-- "{\"$ref\":\"#/definitions/Day\"}"
200−toSchemaRef :: ToSchema a => Proxy a -> Referenced Schema
194+toSchemaRef :: ToSchema a => proxy a -> Referenced Schema
201195toSchemaRef = undeclare . declareSchemaRef
202196
203197-- | Convert a type into a referenced schema if possible
@@ -207,7 +201,7 @@ toSchemaRef = undeclare . declareSchemaRef
207201-- Schema definitions are typically declared for every referenced schema.
208202-- If @'declareSchemaRef'@ returns a reference, a corresponding schema
209203-- will be declared (regardless of whether it is recusive or not).
210−declareSchemaRef :: ToSchema a => Proxy a -> Declare (Definitions Schema) (Referenced Schema)
204+declareSchemaRef :: ToSchema a => proxy a -> Declare (Definitions Schema) (Referenced Schema)
211205declareSchemaRef proxy = do
212206 case toNamedSchema proxy of
213207 NamedSchema (Just name) schema -> do
@@ -269,7 +263,7 @@ inlineAllSchemas = inlineSchemasWhen (const True)
269263--
270264-- __WARNING:__ @'toInlinedSchema'@ will produce infinite schema
271265-- when inlining recursive schemas.
272−toInlinedSchema :: ToSchema a => Proxy a -> Schema
266+toInlinedSchema :: ToSchema a => proxy a -> Schema
273267toInlinedSchema proxy = inlineAllSchemas defs schema
274268 where
275269 (defs, schema) = runDeclare (declareSchema proxy) mempty
@@ -298,20 +292,20 @@ inlineNonRecursiveSchemas defs = inlineSchemasWhen nonRecursive defs
298292-- | Default schema for binary data (any sequence of octets).
299293binarySchema :: Schema
300294binarySchema = mempty
301− & type_ ?~ SwaggerString
295+ & type_ .~ SwaggerString
302296 & format ?~ "binary"
303297
304298-- | Default schema for binary data (base64 encoded).
305299byteSchema :: Schema
306300byteSchema = mempty
307− & type_ ?~ SwaggerString
301+ & type_ .~ SwaggerString
308302 & format ?~ "byte"
309303
310304-- | Default schema for password string.
311305-- @"password"@ format is used to hint UIs the input needs to be obscured.
312306passwordSchema :: Schema
313307passwordSchema = mempty
314− & type_ ?~ SwaggerString
308+ & type_ .~ SwaggerString
315309 & format ?~ "password"
316310
317311-- | Make an unrestrictive sketch of a @'Schema'@ based on a @'ToJSON'@ instance.
@@ -337,12 +331,12 @@ sketchSchema = sketch . toJSON
337331 sketch js@(Bool _) = go js
338332 sketch js = go js & example ?~ js
339333
340− go Null = mempty & type_ ?~ SwaggerNull
341− go (Bool _) = mempty & type_ ?~ SwaggerBoolean
342− go (String _) = mempty & type_ ?~ SwaggerString
343− go (Number _) = mempty & type_ ?~ SwaggerNumber
334+ go Null = mempty & type_ .~ SwaggerNull
335+ go (Bool _) = mempty & type_ .~ SwaggerBoolean
336+ go (String _) = mempty & type_ .~ SwaggerString
337+ go (Number _) = mempty & type_ .~ SwaggerNumber
344338 go (Array xs) = mempty
345− & type_ ?~ SwaggerArray
339+ & type_ .~ SwaggerArray
346340 & items ?~ case ischema of
347341 Just s -> SwaggerItemsObject (Inline s)
348342 _ -> SwaggerItemsArray (map Inline ys)
@@ -354,7 +348,7 @@ sketchSchema = sketch . toJSON
354348 (z:_) | allSame -> Just z
355349 _ -> Nothing
356350 go (Object o) = mempty
357− & type_ ?~ SwaggerObject
351+ & type_ .~ SwaggerObject
358352 & required .~ HashMap.keys o
359353 & properties .~ fmap (Inline . go) (InsOrdHashMap.fromHashMap o)
360354
@@ -377,24 +371,24 @@ sketchSchema = sketch . toJSON
377371sketchStrictSchema :: ToJSON a => a -> Schema
378372sketchStrictSchema = go . toJSON
379373 where
380− go Null = mempty & type_ ?~ SwaggerNull
374+ go Null = mempty & type_ .~ SwaggerNull
381375 go js@(Bool _) = mempty
382− & type_ ?~ SwaggerBoolean
376+ & type_ .~ SwaggerBoolean
383377 & enum_ ?~ [js]
384378 go js@(String s) = mempty
385− & type_ ?~ SwaggerString
379+ & type_ .~ SwaggerString
386380 & maxLength ?~ fromIntegral (T.length s)
387381 & minLength ?~ fromIntegral (T.length s)
388382 & pattern ?~ s
389383 & enum_ ?~ [js]
390384 go js@(Number n) = mempty
391− & type_ ?~ SwaggerNumber
385+ & type_ .~ SwaggerNumber
392386 & maximum_ ?~ n
393387 & minimum_ ?~ n
394388 & multipleOf ?~ n
395389 & enum_ ?~ [js]
396390 go js@(Array xs) = mempty
397− & type_ ?~ SwaggerArray
391+ & type_ .~ SwaggerArray
398392 & maxItems ?~ fromIntegral sz
399393 & minItems ?~ fromIntegral sz
400394 & items ?~ SwaggerItemsArray (map (Inline . go) (V.toList xs))
@@ -404,7 +398,7 @@ sketchStrictSchema = go . toJSON
404398 sz = length xs
405399 allUnique = sz == HashSet.size (HashSet.fromList (V.toList xs))
406400 go js@(Object o) = mempty
407− & type_ ?~ SwaggerObject
401+ & type_ .~ SwaggerObject
408402 & required .~ names
409403 & properties .~ fmap (Inline . go) (InsOrdHashMap.fromHashMap o)
410404 & maxProperties ?~ fromIntegral (length names)
@@ -414,13 +408,13 @@ sketchStrictSchema = go . toJSON
414408 names = HashMap.keys o
415409
416410class GToSchema (f :: * -> *) where
417− gdeclareNamedSchema :: SchemaOptions -> Proxy f -> Schema -> Declare (Definitions Schema) NamedSchema
411+ gdeclareNamedSchema :: SchemaOptions -> proxy f -> Schema -> Declare (Definitions Schema) NamedSchema
418412
419413instance OVERLAPPABLE_ ToSchema a => ToSchema [a] where
420414 declareNamedSchema _ = do
421415 ref <- declareSchemaRef (Proxy :: Proxy a)
422416 return $ unnamed $ mempty
423− & type_ ?~ SwaggerArray
417+ & type_ .~ SwaggerArray
424418 & items ?~ SwaggerItemsObject ref
425419
426420instance OVERLAPPING_ ToSchema String where declareNamedSchema = plain . paramSchemaToSchema
@@ -470,7 +464,7 @@ instance (ToSchema a, ToSchema b, ToSchema c, ToSchema d, ToSchema e, ToSchema f
470464
471465timeSchema :: T.Text -> Schema
472466timeSchema fmt = mempty
473− & type_ ?~ SwaggerString
467+ & type_ .~ SwaggerString
474468 & format ?~ fmt
475469
476470-- | Format @"date"@ corresponds to @yyyy-mm-dd@ format.
@@ -503,8 +497,6 @@ instance ToSchema UTCTime where
503497instance ToSchema T.Text where declareNamedSchema = plain . paramSchemaToSchema
504498instance ToSchema TL.Text where declareNamedSchema = plain . paramSchemaToSchema
505499
506−instance ToSchema Version where declareNamedSchema = plain . paramSchemaToSchema
507−
508500#if __GLASGOW_HASKELL__ < 800
509501#else
510502type family ToSchemaByteStringError bs where
@@ -532,8 +524,8 @@ instance (ToJSONKey k, ToSchema k, ToSchema v) => ToSchema (Map k v) where
532524 declareObjectMapSchema = do
533525 schema <- declareSchemaRef (Proxy :: Proxy v)
534526 return $ unnamed $ mempty
535− & type_ ?~ SwaggerObject
536− & additionalProperties ?~ AdditionalPropertiesSchema schema
527+ & type_ .~ SwaggerObject
528+ & additionalProperties ?~ schema
537529
538530instance (ToJSONKey k, ToSchema k, ToSchema v) => ToSchema (HashMap k v) where
539531 declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map k v))
@@ -544,7 +536,7 @@ instance ToSchema a => ToSchema (Map String a) where
544536 declareNamedSchema _ = do
545537 schema <- declareSchemaRef (Proxy :: Proxy a)
546538 return $ unnamed $ mempty
547− & type_ ?~ SwaggerObject
539+ & type_ .~ SwaggerObject
548540 & additionalProperties ?~ schema
549541
550542instance ToSchema a => ToSchema (Map T.Text a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map String a))
@@ -556,12 +548,6 @@ instance ToSchema a => ToSchema (HashMap TL.Text a) where declareNamedSchema _ =
556548
557549#endif
558550
559−instance OVERLAPPING_ ToSchema Object where
560− declareNamedSchema _ = pure $ NamedSchema (Just "Object") $ mempty
561− & type_ ?~ SwaggerObject
562− & description ?~ "Arbitrary JSON object."
563− & additionalProperties ?~ AdditionalPropertiesAllowed True
564−
565551instance ToSchema a => ToSchema (V.Vector a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy [a])
566552instance ToSchema a => ToSchema (VU.Vector a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy [a])
567553instance ToSchema a => ToSchema (VS.Vector a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy [a])
@@ -575,13 +561,6 @@ instance ToSchema a => ToSchema (Set a) where
575561
576562instance ToSchema a => ToSchema (HashSet a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Set a))
577563
578−-- | @since 2.2.1
579−instance ToSchema a => ToSchema (NonEmpty a) where
580− declareNamedSchema _ = do
581− schema <- declareSchema (Proxy :: Proxy [a])
582− return $ unnamed $ schema
583− & minItems .~ Just 1
584−
585564instance ToSchema All where declareNamedSchema = plain . paramSchemaToSchema
586565instance ToSchema Any where declareNamedSchema = plain . paramSchemaToSchema
587566
@@ -597,26 +576,26 @@ instance ToSchema a => ToSchema (Identity a) where declareNamedSchema _ = declar
597576--
598577-- >>> encode $ toSchemaBoundedIntegral (Proxy :: Proxy Int16)
599578-- "{\"maximum\":32767,\"minimum\":-32768,\"type\":\"integer\"}"
600−toSchemaBoundedIntegral :: forall a. (Bounded a, Integral a) => Proxy a -> Schema
579+toSchemaBoundedIntegral :: forall a proxy. (Bounded a, Integral a) => proxy a -> Schema
601580toSchemaBoundedIntegral _ = mempty
602− & type_ ?~ SwaggerInteger
581+ & type_ .~ SwaggerInteger
603582 & minimum_ ?~ fromInteger (toInteger (minBound :: a))
604583 & maximum_ ?~ fromInteger (toInteger (maxBound :: a))
605584
606585-- | Default generic named schema for @'Bounded'@, @'Integral'@ types.
607−genericToNamedSchemaBoundedIntegral :: forall a d f.
586+genericToNamedSchemaBoundedIntegral :: forall a d f proxy.
608587 ( Bounded a, Integral a
609588 , Generic a, Rep a ~ D1 d f, Datatype d)
610− => SchemaOptions -> Proxy a -> NamedSchema
589+ => SchemaOptions -> proxy a -> NamedSchema
611590genericToNamedSchemaBoundedIntegral opts proxy
612591 = genericNameSchema opts proxy (toSchemaBoundedIntegral proxy)
613592
614593-- | Declare a named schema for a @newtype@ wrapper.
615−genericDeclareNamedSchemaNewtype :: forall a d c s i inner.
594+genericDeclareNamedSchemaNewtype :: forall proxy a d c s i inner.
616595 (Generic a, Datatype d, Rep a ~ D1 d (C1 c (S1 s (K1 i inner))))
617596 => SchemaOptions -- ^ How to derive the name.
618597 -> (Proxy inner -> Declare (Definitions Schema) Schema) -- ^ How to create a schema for the wrapped type.
619− -> Proxy a
598+ -> proxy a
620599 -> Declare (Definitions Schema) NamedSchema
621600genericDeclareNamedSchemaNewtype opts f proxy = genericNameSchema opts proxy <$> f (Proxy :: Proxy inner)
622601
@@ -633,9 +612,9 @@ genericDeclareNamedSchemaNewtype opts f proxy = genericNameSchema opts proxy <$>
633612--
634613-- Note: this is only useful when @key@ is encoded with 'ToJSONKeyText'.
635614-- If it is encoded with 'ToJSONKeyValue' then a regular schema for @[(key, value)]@ is used.
636−declareSchemaBoundedEnumKeyMapping :: forall map key value.
615+declareSchemaBoundedEnumKeyMapping :: forall map key value proxy.
637616 (Bounded key, Enum key, ToJSONKey key, ToSchema key, ToSchema value)
638− => Proxy (map key value) -> Declare (Definitions Schema) Schema
617+ => proxy (map key value) -> Declare (Definitions Schema) Schema
639618declareSchemaBoundedEnumKeyMapping _ = case toJSONKey :: ToJSONKeyFunction key of
640619 ToJSONKeyText keyToText _ -> objectSchema keyToText
641620 ToJSONKeyValue _ _ -> declareSchema (Proxy :: Proxy [(key, value)])
@@ -645,7 +624,7 @@ declareSchemaBoundedEnumKeyMapping _ = case toJSONKey :: ToJSONKeyFunction key o
645624 let allKeys = [minBound..maxBound :: key]
646625 mkPair k = (keyToText k, valueRef)
647626 return $ mempty
648− & type_ ?~ SwaggerObject
627+ & type_ .~ SwaggerObject
649628 & properties .~ InsOrdHashMap.fromList (map mkPair allKeys)
650629
651630-- | A 'Schema' for a mapping with 'Bounded' 'Enum' keys.
@@ -661,71 +640,71 @@ declareSchemaBoundedEnumKeyMapping _ = case toJSONKey :: ToJSONKeyFunction key o
661640--
662641-- Note: this is only useful when @key@ is encoded with 'ToJSONKeyText'.
663642-- If it is encoded with 'ToJSONKeyValue' then a regular schema for @[(key, value)]@ is used.
664−toSchemaBoundedEnumKeyMapping :: forall map key value.
643+toSchemaBoundedEnumKeyMapping :: forall map key value proxy.
665644 (Bounded key, Enum key, ToJSONKey key, ToSchema key, ToSchema value)
666− => Proxy (map key value) -> Schema
645+ => proxy (map key value) -> Schema
667646toSchemaBoundedEnumKeyMapping = flip evalDeclare mempty . declareSchemaBoundedEnumKeyMapping
668647
669648-- | A configurable generic @'Schema'@ creator.
670649genericDeclareSchema :: (Generic a, GToSchema (Rep a), TypeHasSimpleShape a "genericDeclareSchemaUnrestricted") =>
671− SchemaOptions -> Proxy a -> Declare (Definitions Schema) Schema
650+ SchemaOptions -> proxy a -> Declare (Definitions Schema) Schema
672651genericDeclareSchema = genericDeclareSchemaUnrestricted
673652
674653-- | A configurable generic @'NamedSchema'@ creator.
675654-- This function applied to @'defaultSchemaOptions'@
676655-- is used as the default for @'declareNamedSchema'@
677656-- when the type is an instance of @'Generic'@.
678−genericDeclareNamedSchema :: (Generic a, GToSchema (Rep a), TypeHasSimpleShape a "genericDeclareNamedSchemaUnrestricted") =>
679− SchemaOptions -> Proxy a -> Declare (Definitions Schema) NamedSchema
657+genericDeclareNamedSchema :: forall a proxy. (Generic a, GToSchema (Rep a), TypeHasSimpleShape a "genericDeclareNamedSchemaUnrestricted") =>
658+ SchemaOptions -> proxy a -> Declare (Definitions Schema) NamedSchema
680659genericDeclareNamedSchema = genericDeclareNamedSchemaUnrestricted
681660
682661-- | A configurable generic @'Schema'@ creator.
683662--
684663-- Unlike 'genericDeclareSchema' also works for mixed sum types.
685664-- Use with care since some Swagger tools do not support well schemas for mixed sum types.
686−genericDeclareSchemaUnrestricted :: (Generic a, GToSchema (Rep a)) => SchemaOptions -> Proxy a -> Declare (Definitions Schema) Schema
665+genericDeclareSchemaUnrestricted :: (Generic a, GToSchema (Rep a)) => SchemaOptions -> proxy a -> Declare (Definitions Schema) Schema
687666genericDeclareSchemaUnrestricted opts proxy = _namedSchemaSchema <$> genericDeclareNamedSchemaUnrestricted opts proxy
688667
689668-- | A configurable generic @'NamedSchema'@ creator.
690669--
691670-- Unlike 'genericDeclareNamedSchema' also works for mixed sum types.
692671-- Use with care since some Swagger tools do not support well schemas for mixed sum types.
693−genericDeclareNamedSchemaUnrestricted :: forall a. (Generic a, GToSchema (Rep a)) =>
694− SchemaOptions -> Proxy a -> Declare (Definitions Schema) NamedSchema
672+genericDeclareNamedSchemaUnrestricted :: forall a proxy. (Generic a, GToSchema (Rep a)) =>
673+ SchemaOptions -> proxy a -> Declare (Definitions Schema) NamedSchema
695674genericDeclareNamedSchemaUnrestricted opts _ = gdeclareNamedSchema opts (Proxy :: Proxy (Rep a)) mempty
696675
697676-- | Derive a 'Generic'-based name for a datatype and assign it to a given 'Schema'.
698−genericNameSchema :: forall a d f.
677+genericNameSchema :: forall a d f proxy.
699678 (Generic a, Rep a ~ D1 d f, Datatype d)
700− => SchemaOptions -> Proxy a -> Schema -> NamedSchema
679+ => SchemaOptions -> proxy a -> Schema -> NamedSchema
701680genericNameSchema opts _ = NamedSchema (gdatatypeSchemaName opts (Proxy :: Proxy d))
702681
703−gdatatypeSchemaName :: forall d. Datatype d => SchemaOptions -> Proxy d -> Maybe T.Text
704−gdatatypeSchemaName opts _ = case orig of
682+gdatatypeSchemaName :: forall proxy d. Datatype d => SchemaOptions -> proxy d -> Maybe T.Text
683+gdatatypeSchemaName opts _ = case name of
705684 (c:_) | isAlpha c && isUpper c -> Just (T.pack name)
706685 _ -> Nothing
707686 where
708− orig = datatypeName (Proxy3 :: Proxy3 d f a)
709− name = datatypeNameModifier opts orig
687+ name = datatypeNameModifier opts (datatypeName (Proxy3 :: Proxy3 d f a))
710688
711689-- | Lift a plain @'ParamSchema'@ into a model @'NamedSchema'@.
712−paramSchemaToNamedSchema :: (ToParamSchema a, Generic a, Rep a ~ D1 d f, Datatype d) =>
713− SchemaOptions -> Proxy a -> NamedSchema
690+paramSchemaToNamedSchema :: forall a d f proxy.
691+ (ToParamSchema a, Generic a, Rep a ~ D1 d f, Datatype d)
692+ => SchemaOptions -> proxy a -> NamedSchema
714693paramSchemaToNamedSchema opts proxy = genericNameSchema opts proxy (paramSchemaToSchema proxy)
715694
716695-- | Lift a plain @'ParamSchema'@ into a model @'Schema'@.
717−paramSchemaToSchema :: ToParamSchema a => Proxy a -> Schema
718−paramSchemaToSchema proxy = mempty & paramSchema .~ toParamSchema proxy
696+paramSchemaToSchema :: forall a proxy. ToParamSchema a => proxy a -> Schema
697+paramSchemaToSchema _ = mempty & paramSchema .~ toParamSchema (Proxy :: Proxy a)
719698
720699nullarySchema :: Schema
721700nullarySchema = mempty
722− & type_ ?~ SwaggerArray
701+ & type_ .~ SwaggerArray
723702 & items ?~ SwaggerItemsArray []
724703
725−gtoNamedSchema :: GToSchema f => SchemaOptions -> Proxy f -> NamedSchema
704+gtoNamedSchema :: GToSchema f => SchemaOptions -> proxy f -> NamedSchema
726705gtoNamedSchema opts proxy = undeclare $ gdeclareNamedSchema opts proxy mempty
727706
728−gdeclareSchema :: GToSchema f => SchemaOptions -> Proxy f -> Declare (Definitions Schema) Schema
707+gdeclareSchema :: GToSchema f => SchemaOptions -> proxy f -> Declare (Definitions Schema) Schema
729708gdeclareSchema opts proxy = _namedSchemaSchema <$> gdeclareNamedSchema opts proxy mempty
730709
731710instance (GToSchema f, GToSchema g) => GToSchema (f :*: g) where
@@ -745,7 +724,7 @@ instance OVERLAPPING_ Constructor c => GToSchema (C1 c U1) where
745724 gdeclareNamedSchema = gdeclareNamedSumSchema
746725
747726-- | Single field constructor.
748−instance (Selector s, GToSchema f, GToSchema (S1 s f)) => GToSchema (C1 c (S1 s f)) where
727+instance (Selector s, GToSchema f) => GToSchema (C1 c (S1 s f)) where
749728 gdeclareNamedSchema opts _ s
750729 | unwrapUnaryRecords opts = fieldSchema
751730 | otherwise =
@@ -759,7 +738,7 @@ instance (Selector s, GToSchema f, GToSchema (S1 s f)) => GToSchema (C1 c (S1 s
759738 recordSchema = gdeclareNamedSchema opts (Proxy :: Proxy (S1 s f)) s
760739 fieldSchema = gdeclareNamedSchema opts (Proxy :: Proxy f) s
761740
762−gdeclareSchemaRef :: GToSchema a => SchemaOptions -> Proxy a -> Declare (Definitions Schema) (Referenced Schema)
741+gdeclareSchemaRef :: GToSchema a => SchemaOptions -> proxy a -> Declare (Definitions Schema) (Referenced Schema)
763742gdeclareSchemaRef opts proxy = do
764743 case gtoNamedSchema opts proxy of
765744 NamedSchema (Just name) schema -> do
@@ -790,12 +769,12 @@ withFieldSchema opts _ isRequiredField schema = do
790769 return $
791770 if T.null fname
792771 then schema
793− & type_ ?~ SwaggerArray
772+ & type_ .~ SwaggerArray
794773 & items %~ appendItem ref
795774 & maxItems %~ Just . maybe 1 (+1) -- increment maxItems
796775 & minItems %~ Just . maybe 1 (+1) -- increment minItems
797776 else schema
798− & type_ ?~ SwaggerObject
777+ & type_ .~ SwaggerObject
799778 & properties . at fname ?~ ref
800779 & if isRequiredField
801780 then required %~ (++ [fname])
@@ -823,7 +802,7 @@ instance ( GSumToSchema f
823802 where
824803 gdeclareNamedSchema = gdeclareNamedSumSchema
825804
826−gdeclareNamedSumSchema :: GSumToSchema f => SchemaOptions -> Proxy f -> Schema -> Declare (Definitions Schema) NamedSchema
805+gdeclareNamedSumSchema :: GSumToSchema f => SchemaOptions -> proxy f -> Schema -> Declare (Definitions Schema) NamedSchema
827806gdeclareNamedSumSchema opts proxy s
828807 | allNullaryToStringTag opts && allNullary = pure $ unnamed (toStringTag sumSchema)
829808 | otherwise = (unnamed . fst) <$> runWriterT declareSumSchema
@@ -832,29 +811,29 @@ gdeclareNamedSumSchema opts proxy s
832811 (sumSchema, All allNullary) = undeclare (runWriterT declareSumSchema)
833812
834813 toStringTag schema = mempty
835− & type_ ?~ SwaggerString
814+ & type_ .~ SwaggerString
836815 & enum_ ?~ map toJSON (schema ^.. properties.ifolded.asIndex)
837816
838817type AllNullary = All
839818
840819class GSumToSchema (f :: * -> *) where
841− gsumToSchema :: SchemaOptions -> Proxy f -> Schema -> WriterT AllNullary (Declare (Definitions Schema)) Schema
820+ gsumToSchema :: SchemaOptions -> proxy f -> Schema -> WriterT AllNullary (Declare (Definitions Schema)) Schema
842821
843822instance (GSumToSchema f, GSumToSchema g) => GSumToSchema (f :+: g) where
844823 gsumToSchema opts _ = gsumToSchema opts (Proxy :: Proxy f) >=> gsumToSchema opts (Proxy :: Proxy g)
845824
846−gsumConToSchemaWith :: forall c f. (GToSchema (C1 c f), Constructor c) =>
847− Referenced Schema -> SchemaOptions -> Proxy (C1 c f) -> Schema -> Schema
825+gsumConToSchemaWith :: forall c f proxy. (GToSchema (C1 c f), Constructor c) =>
826+ Referenced Schema -> SchemaOptions -> proxy (C1 c f) -> Schema -> Schema
848827gsumConToSchemaWith ref opts _ schema = schema
849− & type_ ?~ SwaggerObject
828+ & type_ .~ SwaggerObject
850829 & properties . at tag ?~ ref
851830 & maxProperties ?~ 1
852831 & minProperties ?~ 1
853832 where
854833 tag = T.pack (constructorTagModifier opts (conName (Proxy3 :: Proxy3 c f p)))
855834
856−gsumConToSchema :: (GToSchema (C1 c f), Constructor c) =>
857− SchemaOptions -> Proxy (C1 c f) -> Schema -> Declare (Definitions Schema) Schema
835+gsumConToSchema :: forall c f proxy. (GToSchema (C1 c f), Constructor c) =>
836+ SchemaOptions -> proxy (C1 c f) -> Schema -> Declare (Definitions Schema) Schema
858837gsumConToSchema opts proxy schema = do
859838 ref <- gdeclareSchemaRef opts proxy
860839 return $ gsumConToSchemaWith ref opts proxy schema