@@ -105,7 +105,7 @@ rename name (NamedSchema _ schema) = NamedSchema name schema
105-- declareNamedSchema _ = do
105-- declareNamedSchema _ = do
106-- doubleSchema <- declareSchemaRef (Proxy :: Proxy Double)
106-- doubleSchema <- declareSchemaRef (Proxy :: Proxy Double)
107-- return $ NamedSchema (Just \"Coord\") $ mempty
107-- return $ NamedSchema (Just \"Coord\") $ mempty
108−-- & type_ ?~ SwaggerObject
108+-- & type_ ?~ OpenApiObject
109-- & properties .~
109-- & properties .~
110-- [ (\"x\", doubleSchema)
110-- [ (\"x\", doubleSchema)
111-- , (\"y\", doubleSchema)
111-- , (\"y\", doubleSchema)
@@ -312,12 +312,12 @@ sketchSchema = sketch . toJSON
312 sketch js@(Bool _) = go js
312 sketch js@(Bool _) = go js
313 sketch js = go js & example ?~ js
313 sketch js = go js & example ?~ js
315− go Null = mempty & type_ ?~ SwaggerNull
315+ go Null = mempty & type_ ?~ OpenApiNull
316− go (Bool _) = mempty & type_ ?~ SwaggerBoolean
316+ go (Bool _) = mempty & type_ ?~ OpenApiBoolean
317− go (String _) = mempty & type_ ?~ SwaggerString
317+ go (String _) = mempty & type_ ?~ OpenApiString
318− go (Number _) = mempty & type_ ?~ SwaggerNumber
318+ go (Number _) = mempty & type_ ?~ OpenApiNumber
319 go (Array xs) = mempty
319 go (Array xs) = mempty
320− & type_ ?~ SwaggerArray
320+ & type_ ?~ OpenApiArray
321 & items ?~ case ischema of
321 & items ?~ case ischema of
322 Just s -> SwaggerItemsObject (Inline s)
322 Just s -> SwaggerItemsObject (Inline s)
323 _ -> SwaggerItemsArray (map Inline ys)
323 _ -> SwaggerItemsArray (map Inline ys)
@@ -329,7 +329,7 @@ sketchSchema = sketch . toJSON
329 (z:_) | allSame -> Just z
329 (z:_) | allSame -> Just z
330 _ -> Nothing
330 _ -> Nothing
331 go (Object o) = mempty
331 go (Object o) = mempty
332− & type_ ?~ SwaggerObject
332+ & type_ ?~ OpenApiObject
333 & required .~ HashMap.keys o
333 & required .~ HashMap.keys o
334 & properties .~ fmap (Inline . go) (InsOrdHashMap.fromHashMap o)
334 & properties .~ fmap (Inline . go) (InsOrdHashMap.fromHashMap o)
@@ -352,24 +352,24 @@ sketchSchema = sketch . toJSON
352sketchStrictSchema :: ToJSON a => a -> Schema
352sketchStrictSchema :: ToJSON a => a -> Schema
353sketchStrictSchema = go . toJSON
353sketchStrictSchema = go . toJSON
355− go Null = mempty & type_ ?~ SwaggerNull
355+ go Null = mempty & type_ ?~ OpenApiNull
356 go js@(Bool _) = mempty
356 go js@(Bool _) = mempty
357− & type_ ?~ SwaggerBoolean
357+ & type_ ?~ OpenApiBoolean
358 & enum_ ?~ [js]
358 & enum_ ?~ [js]
359 go js@(String s) = mempty
359 go js@(String s) = mempty
360− & type_ ?~ SwaggerString
360+ & type_ ?~ OpenApiString
361 & maxLength ?~ fromIntegral (T.length s)
361 & maxLength ?~ fromIntegral (T.length s)
362 & minLength ?~ fromIntegral (T.length s)
362 & minLength ?~ fromIntegral (T.length s)
363 & pattern ?~ s
363 & pattern ?~ s
364 & enum_ ?~ [js]
364 & enum_ ?~ [js]
365 go js@(Number n) = mempty
365 go js@(Number n) = mempty
366− & type_ ?~ SwaggerNumber
366+ & type_ ?~ OpenApiNumber
367 & maximum_ ?~ n
367 & maximum_ ?~ n
368 & minimum_ ?~ n
368 & minimum_ ?~ n
369 & multipleOf ?~ n
369 & multipleOf ?~ n
370 & enum_ ?~ [js]
370 & enum_ ?~ [js]
371 go js@(Array xs) = mempty
371 go js@(Array xs) = mempty
372− & type_ ?~ SwaggerArray
372+ & type_ ?~ OpenApiArray
373 & maxItems ?~ fromIntegral sz
373 & maxItems ?~ fromIntegral sz
374 & minItems ?~ fromIntegral sz
374 & minItems ?~ fromIntegral sz
375 & items ?~ SwaggerItemsArray (map (Inline . go) (V.toList xs))
375 & items ?~ SwaggerItemsArray (map (Inline . go) (V.toList xs))
@@ -379,7 +379,7 @@ sketchStrictSchema = go . toJSON
379 sz = length xs
379 sz = length xs
380 allUnique = sz == HashSet.size (HashSet.fromList (V.toList xs))
380 allUnique = sz == HashSet.size (HashSet.fromList (V.toList xs))
381 go js@(Object o) = mempty
381 go js@(Object o) = mempty
382− & type_ ?~ SwaggerObject
382+ & type_ ?~ OpenApiObject
383 & required .~ names
383 & required .~ names
384 & properties .~ fmap (Inline . go) (InsOrdHashMap.fromHashMap o)
384 & properties .~ fmap (Inline . go) (InsOrdHashMap.fromHashMap o)
385 & maxProperties ?~ fromIntegral (length names)
385 & maxProperties ?~ fromIntegral (length names)
@@ -395,7 +395,7 @@ instance {-# OVERLAPPABLE #-} ToSchema a => ToSchema [a] where
395 declareNamedSchema _ = do
395 declareNamedSchema _ = do
396 ref <- declareSchemaRef (Proxy :: Proxy a)
396 ref <- declareSchemaRef (Proxy :: Proxy a)
397 return $ unnamed $ mempty
397 return $ unnamed $ mempty
398− & type_ ?~ SwaggerArray
398+ & type_ ?~ OpenApiArray
399 & items ?~ SwaggerItemsObject ref
399 & items ?~ SwaggerItemsObject ref
401instance {-# OVERLAPPING #-} ToSchema String where declareNamedSchema = plain . paramSchemaToSchema
401instance {-# OVERLAPPING #-} ToSchema String where declareNamedSchema = plain . paramSchemaToSchema
@@ -447,7 +447,7 @@ instance (ToSchema a, ToSchema b, ToSchema c, ToSchema d, ToSchema e, ToSchema f
448timeSchema :: T.Text -> Schema
448timeSchema :: T.Text -> Schema
449timeSchema fmt = mempty
449timeSchema fmt = mempty
450− & type_ ?~ SwaggerString
450+ & type_ ?~ OpenApiString
451 & format ?~ fmt
451 & format ?~ fmt
453-- | Format @"date"@ corresponds to @yyyy-mm-dd@ format.
453-- | Format @"date"@ corresponds to @yyyy-mm-dd@ format.
@@ -505,7 +505,7 @@ instance (ToJSONKey k, ToSchema k, ToSchema v) => ToSchema (Map k v) where
505 declareObjectMapSchema = do
505 declareObjectMapSchema = do
506 schema <- declareSchemaRef (Proxy :: Proxy v)
506 schema <- declareSchemaRef (Proxy :: Proxy v)
507 return $ unnamed $ mempty
507 return $ unnamed $ mempty
508− & type_ ?~ SwaggerObject
508+ & type_ ?~ OpenApiObject
509 & additionalProperties ?~ AdditionalPropertiesSchema schema
509 & additionalProperties ?~ AdditionalPropertiesSchema schema
511instance (ToJSONKey k, ToSchema k, ToSchema v) => ToSchema (HashMap k v) where
511instance (ToJSONKey k, ToSchema k, ToSchema v) => ToSchema (HashMap k v) where
@@ -513,7 +513,7 @@ instance (ToJSONKey k, ToSchema k, ToSchema v) => ToSchema (HashMap k v) where
514instance {-# OVERLAPPING #-} ToSchema Object where
514instance {-# OVERLAPPING #-} ToSchema Object where
515 declareNamedSchema _ = pure $ NamedSchema (Just "Object") $ mempty
515 declareNamedSchema _ = pure $ NamedSchema (Just "Object") $ mempty
516− & type_ ?~ SwaggerObject
516+ & type_ ?~ OpenApiObject
517 & description ?~ "Arbitrary JSON object."
517 & description ?~ "Arbitrary JSON object."
518 & additionalProperties ?~ AdditionalPropertiesAllowed True
518 & additionalProperties ?~ AdditionalPropertiesAllowed True
@@ -554,7 +554,7 @@ instance ToSchema a => ToSchema (Identity a) where declareNamedSchema _ = declar
554-- {"maximum":32767,"minimum":-32768,"type":"integer"}
554-- {"maximum":32767,"minimum":-32768,"type":"integer"}
555toSchemaBoundedIntegral :: forall a. (Bounded a, Integral a) => Proxy a -> Schema
555toSchemaBoundedIntegral :: forall a. (Bounded a, Integral a) => Proxy a -> Schema
556toSchemaBoundedIntegral _ = mempty
556toSchemaBoundedIntegral _ = mempty
557− & type_ ?~ SwaggerInteger
557+ & type_ ?~ OpenApiInteger
558 & minimum_ ?~ fromInteger (toInteger (minBound :: a))
558 & minimum_ ?~ fromInteger (toInteger (minBound :: a))
559 & maximum_ ?~ fromInteger (toInteger (maxBound :: a))
559 & maximum_ ?~ fromInteger (toInteger (maxBound :: a))
@@ -600,7 +600,7 @@ declareSchemaBoundedEnumKeyMapping _ = case toJSONKey :: ToJSONKeyFunction key o
600 let allKeys = [minBound..maxBound :: key]
600 let allKeys = [minBound..maxBound :: key]
601 mkPair k = (keyToText k, valueRef)
601 mkPair k = (keyToText k, valueRef)
602 return $ mempty
602 return $ mempty
603− & type_ ?~ SwaggerObject
603+ & type_ ?~ OpenApiObject
604 & properties .~ InsOrdHashMap.fromList (map mkPair allKeys)
604 & properties .~ InsOrdHashMap.fromList (map mkPair allKeys)
606-- | A 'Schema' for a mapping with 'Bounded' 'Enum' keys.
606-- | A 'Schema' for a mapping with 'Bounded' 'Enum' keys.
@@ -659,7 +659,7 @@ paramSchemaToSchema = toParamSchema
660nullarySchema :: Schema
660nullarySchema :: Schema
661nullarySchema = mempty
661nullarySchema = mempty
662− & type_ ?~ SwaggerArray
662+ & type_ ?~ OpenApiArray
663 & items ?~ SwaggerItemsArray []
663 & items ?~ SwaggerItemsArray []
665gtoNamedSchema :: GToSchema f => SchemaOptions -> Proxy f -> NamedSchema
665gtoNamedSchema :: GToSchema f => SchemaOptions -> Proxy f -> NamedSchema
@@ -730,12 +730,12 @@ withFieldSchema opts _ isRequiredField schema = do
731 if T.null fname
731 if T.null fname
732 then schema
732 then schema
733− & type_ ?~ SwaggerArray
733+ & type_ ?~ OpenApiArray
734 & items %~ appendItem ref
734 & items %~ appendItem ref
735 & maxItems %~ Just . maybe 1 (+1) -- increment maxItems
735 & maxItems %~ Just . maybe 1 (+1) -- increment maxItems
736 & minItems %~ Just . maybe 1 (+1) -- increment minItems
736 & minItems %~ Just . maybe 1 (+1) -- increment minItems
737 else schema
737 else schema
738− & type_ ?~ SwaggerObject
738+ & type_ ?~ OpenApiObject
739 & properties . at fname ?~ ref
739 & properties . at fname ?~ ref
740 & if isRequiredField
740 & if isRequiredField
741 then required %~ (++ [fname])
741 then required %~ (++ [fname])
@@ -770,14 +770,14 @@ gdeclareNamedSumSchema opts proxy _
770 | otherwise = do
770 | otherwise = do
771 (schemas, _) <- runWriterT declareSumSchema
771 (schemas, _) <- runWriterT declareSumSchema
772 return $ unnamed $ mempty
772 return $ unnamed $ mempty
773− & type_ ?~ SwaggerObject
773+ & type_ ?~ OpenApiObject
774 & oneOf ?~ (snd <$> schemas)
774 & oneOf ?~ (snd <$> schemas)
776 declareSumSchema = gsumToSchema opts proxy
776 declareSumSchema = gsumToSchema opts proxy
777 (sumSchemas, All allNullary) = undeclare (runWriterT declareSumSchema)
777 (sumSchemas, All allNullary) = undeclare (runWriterT declareSumSchema)
779 toStringTag schemas = mempty
779 toStringTag schemas = mempty
780− & type_ ?~ SwaggerString
780+ & type_ ?~ OpenApiString
781 & enum_ ?~ map (String . fst) sumSchemas
781 & enum_ ?~ map (String . fst) sumSchemas
783type AllNullary = All
783type AllNullary = All
@@ -799,15 +799,15 @@ gsumConToSchemaWith ref opts _ = (tag, schema)
799 case ref of
799 case ref of
800 -- If subschema is an object and constructor is a record, we add tag directly
800 -- If subschema is an object and constructor is a record, we add tag directly
801 -- to the record, as Aeson does it.
801 -- to the record, as Aeson does it.
802− Just (Inline sub) | sub ^. type_ == Just SwaggerObject && isRecord -> Inline $ sub
802+ Just (Inline sub) | sub ^. type_ == Just OpenApiObject && isRecord -> Inline $ sub
803 & required <>~ [T.pack tagField]
803 & required <>~ [T.pack tagField]
804− & properties . at (T.pack tagField) ?~ (Inline $ mempty & type_ ?~ SwaggerString & enum_ ?~ [String tag])
804+ & properties . at (T.pack tagField) ?~ (Inline $ mempty & type_ ?~ OpenApiString & enum_ ?~ [String tag])
806 -- If it is not a record, we need to put subschema into "contents" field.
806 -- If it is not a record, we need to put subschema into "contents" field.
807 _ | not isRecord -> Inline $ mempty
807 _ | not isRecord -> Inline $ mempty
808− & type_ ?~ SwaggerObject
808+ & type_ ?~ OpenApiObject
809 & required .~ [T.pack tagField]
809 & required .~ [T.pack tagField]
810− & properties . at (T.pack tagField) ?~ (Inline $ mempty & type_ ?~ SwaggerString & enum_ ?~ [String tag])
810+ & properties . at (T.pack tagField) ?~ (Inline $ mempty & type_ ?~ OpenApiString & enum_ ?~ [String tag])
811 -- If constructor is nullary, there is no content.
811 -- If constructor is nullary, there is no content.
812 & case ref of
812 & case ref of
813 Just r -> (properties . at (T.pack contentsField) ?~ r) . (required <>~ [T.pack contentsField])
813 Just r -> (properties . at (T.pack contentsField) ?~ r) . (required <>~ [T.pack contentsField])
@@ -815,17 +815,17 @@ gsumConToSchemaWith ref opts _ = (tag, schema)
816 -- In the remaining cases we combine "tag" object and "contents" object using allOf.
816 -- In the remaining cases we combine "tag" object and "contents" object using allOf.
817 _ -> Inline $ mempty
817 _ -> Inline $ mempty
818− & type_ ?~ SwaggerObject
818+ & type_ ?~ OpenApiObject
819 & allOf ?~ [Inline $ mempty
819 & allOf ?~ [Inline $ mempty
820− & type_ ?~ SwaggerObject
820+ & type_ ?~ OpenApiObject
821 & required .~ (T.pack tagField : if isRecord then [] else [T.pack contentsField])
821 & required .~ (T.pack tagField : if isRecord then [] else [T.pack contentsField])
822− & properties . at (T.pack tagField) ?~ (Inline $ mempty & type_ ?~ SwaggerString & enum_ ?~ [String tag])]
822+ & properties . at (T.pack tagField) ?~ (Inline $ mempty & type_ ?~ OpenApiString & enum_ ?~ [String tag])]
823 & if isRecord
823 & if isRecord
824 then allOf . _Just <>~ [refOrNullary]
824 then allOf . _Just <>~ [refOrNullary]
825− else allOf . _Just <>~ [Inline $ mempty & type_ ?~ SwaggerObject & properties . at (T.pack contentsField) ?~ refOrNullary]
825+ else allOf . _Just <>~ [Inline $ mempty & type_ ?~ OpenApiObject & properties . at (T.pack contentsField) ?~ refOrNullary]
826 UntaggedValue -> refOrEnum -- Aeson encodes nullary constructors as strings in this case.
826 UntaggedValue -> refOrEnum -- Aeson encodes nullary constructors as strings in this case.
827 ObjectWithSingleField -> Inline $ mempty
827 ObjectWithSingleField -> Inline $ mempty
828− & type_ ?~ SwaggerObject
828+ & type_ ?~ OpenApiObject
829 & required .~ [tag]
829 & required .~ [tag]
830 & properties . at tag ?~ refOrNullary
830 & properties . at tag ?~ refOrNullary
831 TwoElemArray -> error "unrepresentable in OpenAPI 3"
831 TwoElemArray -> error "unrepresentable in OpenAPI 3"
@@ -833,7 +833,7 @@ gsumConToSchemaWith ref opts _ = (tag, schema)
833 tag = T.pack (constructorTagModifier opts (conName (Proxy3 :: Proxy3 c f p)))
833 tag = T.pack (constructorTagModifier opts (conName (Proxy3 :: Proxy3 c f p)))
834 isRecord = conIsRecord (Proxy3 :: Proxy3 c f p)
834 isRecord = conIsRecord (Proxy3 :: Proxy3 c f p)
835 refOrNullary = fromMaybe (Inline nullarySchema) ref
835 refOrNullary = fromMaybe (Inline nullarySchema) ref
836− refOrEnum = fromMaybe (Inline $ mempty & type_ ?~ SwaggerString & enum_ ?~ [String tag]) ref
836+ refOrEnum = fromMaybe (Inline $ mempty & type_ ?~ OpenApiString & enum_ ?~ [String tag]) ref
838gsumConToSchema :: (GToSchema (C1 c f), Constructor c) =>
838gsumConToSchema :: (GToSchema (C1 c f), Constructor c) =>
839 SchemaOptions -> Proxy (C1 c f) -> Declare (Definitions Schema) [(T.Text, Referenced Schema)]
839 SchemaOptions -> Proxy (C1 c f) -> Declare (Definitions Schema) [(T.Text, Referenced Schema)]