git.iko.soy/typeable/openapi3
on master help sign in
Merge pull request #4 from paweln1986/rename-swagger-to-openApi
bd9df53Maxim Koltsov
examples/hackage.hs+7−7
@@ -27,7 +27,7 @@ instance ToSchema UserSummary where
27 usernameSchema <- declareSchemaRef (Proxy :: Proxy Username)
27 usernameSchema <- declareSchemaRef (Proxy :: Proxy Username)
28 useridSchema <- declareSchemaRef (Proxy :: Proxy Int)
28 useridSchema <- declareSchemaRef (Proxy :: Proxy Int)
29 return $ NamedSchema (Just "UserSummary") $ mempty
29 return $ NamedSchema (Just "UserSummary") $ mempty
30− & type_ ?~ SwaggerObject
30+ & type_ ?~ OpenApiObject
31 & properties .~
31 & properties .~
32 [ ("summaryUsername", usernameSchema )
32 [ ("summaryUsername", usernameSchema )
33 , ("summaryUserid" , useridSchema )
33 , ("summaryUserid" , useridSchema )
@@ -47,13 +47,13 @@ data UserDetailed = UserDetailed
47newtype Package = Package { packageName :: Text }
47newtype Package = Package { packageName :: Text }
48 deriving (Generic, ToSchema)
48 deriving (Generic, ToSchema)
49
49
50−hackageSwagger :: Swagger
50+hackageOpenApi :: OpenApi
51−hackageSwagger = spec & components.schemas .~ defs
51+hackageOpenApi = spec & components.schemas .~ defs
52 where
52 where
53− (defs, spec) = runDeclare declareHackageSwagger mempty
53+ (defs, spec) = runDeclare declareHackageOpenApi mempty
54
54
55−declareHackageSwagger :: Declare (Definitions Schema) Swagger
55+declareHackageOpenApi :: Declare (Definitions Schema) OpenApi
56−declareHackageSwagger = do
56+declareHackageOpenApi = do
57 -- param schemas
57 -- param schemas
58 let usernameParamSchema = toParamSchema (Proxy :: Proxy Username)
58 let usernameParamSchema = toParamSchema (Proxy :: Proxy Username)
59
59
@@ -78,5 +78,5 @@ declareHackageSwagger = do
78 ]
78 ]
79
79
80main :: IO ()
80main :: IO ()
81−main = putStrLn . read . show . encode $ hackageSwagger
81+main = putStrLn . read . show . encode $ hackageOpenApi
82
82
src/Data/OpenApi.hs+11−11
@@ -37,7 +37,7 @@ module Data.OpenApi (
37 module Data.OpenApi.Schema.Validation,
37 module Data.OpenApi.Schema.Validation,
38
38
39 -- * Swagger specification
39 -- * Swagger specification
40− Swagger(..),
40+ OpenApi(..),
41 Server(..),
41 Server(..),
42 ServerVariable(..),
42 ServerVariable(..),
43 Components(..),
43 Components(..),
@@ -56,7 +56,7 @@ module Data.OpenApi (
56 TagName,
56 TagName,
57
57
58 -- ** Types and formats
58 -- ** Types and formats
59− SwaggerType(..),
59+ OpenApiType(..),
60 Format,
60 Format,
61 Definitions,
61 Definitions,
62 Style(..),
62 Style(..),
@@ -75,7 +75,7 @@ module Data.OpenApi (
75 -- ** Schemas
75 -- ** Schemas
76 Schema(..),
76 Schema(..),
77 NamedSchema(..),
77 NamedSchema(..),
78− SwaggerItems(..),
78+ OpenApiItems(..),
79 Xml(..),
79 Xml(..),
80 Pattern,
80 Pattern,
81 AdditionalProperties(..),
81 AdditionalProperties(..),
@@ -152,7 +152,7 @@ import Data.OpenApi.Internal
152--
152--
153-- In this library you can use @'mempty'@ for a default/empty value. For instance:
153-- In this library you can use @'mempty'@ for a default/empty value. For instance:
154--
154--
155−-- >>> BSL.putStrLn $ encode (mempty :: Swagger)
155+-- >>> BSL.putStrLn $ encode (mempty :: OpenApi)
156-- {"openapi":"3.0.0","info":{"version":"","title":""},"components":{}}
156-- {"openapi":"3.0.0","info":{"version":"","title":""},"components":{}}
157--
157--
158-- As you can see some spec properties (e.g. @"version"@) are there even when the spec is empty.
158-- As you can see some spec properties (e.g. @"version"@) are there even when the spec is empty.
@@ -173,14 +173,14 @@ import Data.OpenApi.Internal
173--
173--
174-- @
174-- @
175-- \-\- /account subAPI specification
175-- \-\- /account subAPI specification
176−-- accountAPI :: Swagger
176+-- accountAPI :: OpenApi
177--
177--
178-- \-\- /task subAPI specification
178-- \-\- /task subAPI specification
179−-- taskAPI :: Swagger
179+-- taskAPI :: OpenApi
180--
180--
181-- \-\- while API specification is just a combination
181-- \-\- while API specification is just a combination
182-- \-\- of subAPIs' specifications
182-- \-\- of subAPIs' specifications
183−-- api :: Swagger
183+-- api :: OpenApi
184-- api = accountAPI <> taskAPI
184-- api = accountAPI <> taskAPI
185-- @
185-- @
186
186
@@ -193,8 +193,8 @@ import Data.OpenApi.Internal
193-- make it fairly simple to construct/modify any part of the specification:
193-- make it fairly simple to construct/modify any part of the specification:
194--
194--
195-- >>> :{
195-- >>> :{
196−-- BSL.putStrLn $ encode $ (mempty :: Swagger)
196+-- BSL.putStrLn $ encode $ (mempty :: OpenApi)
197−-- & components . schemas .~ [ ("User", mempty & type_ ?~ SwaggerString) ]
197+-- & components . schemas .~ [ ("User", mempty & type_ ?~ OpenApiString) ]
198-- & paths .~
198-- & paths .~
199-- [ ("/user", mempty & get ?~ (mempty
199-- [ ("/user", mempty & get ?~ (mempty
200-- & at 200 ?~ ("OK" & _Inline.content.at "application/json" ?~ (mempty & schema ?~ Ref (Reference "User")))
200-- & at 200 ?~ ("OK" & _Inline.content.at "application/json" ?~ (mempty & schema ?~ Ref (Reference "User")))
@@ -216,7 +216,7 @@ import Data.OpenApi.Internal
216-- {"description":"No content"}
216-- {"description":"No content"}
217-- >>> :{
217-- >>> :{
218-- BSL.putStrLn $ encode $ (mempty :: Schema)
218-- BSL.putStrLn $ encode $ (mempty :: Schema)
219−-- & type_ ?~ SwaggerBoolean
219+-- & type_ ?~ OpenApiBoolean
220-- & description ?~ "To be or not to be"
220-- & description ?~ "To be or not to be"
221-- :}
221-- :}
222-- {"type":"boolean","description":"To be or not to be"}
222-- {"type":"boolean","description":"To be or not to be"}
@@ -244,7 +244,7 @@ import Data.OpenApi.Internal
244-- @'ParamSchema'@ and @'Schema'@ are the two core types for data model specification.
244-- @'ParamSchema'@ and @'Schema'@ are the two core types for data model specification.
245--
245--
246-- @'ParamSchema' t@ specifies all the common properties, available for every data schema.
246-- @'ParamSchema' t@ specifies all the common properties, available for every data schema.
247−-- The @t@ parameter imposes some restrictions on @type@ and @items@ properties (see @'SwaggerType'@ and @'SwaggerItems'@).
247+-- The @t@ parameter imposes some restrictions on @type@ and @items@ properties (see @'OpenApiType'@ and @'OpenApiItems'@).
248--
248--
249-- @'Schema'@ is used for request and response bodies and allows specifying objects
249-- @'Schema'@ is used for request and response bodies and allows specifying objects
250-- with properties in addition to what @'ParamSchema'@ provides.
250-- with properties in addition to what @'ParamSchema'@ provides.
src/Data/OpenApi/Internal.hs+47−47
@@ -65,38 +65,38 @@ import Data.OpenApi.Internal.AesonUtils (sopSwaggerGenericToEncoding)
65type Definitions = InsOrdHashMap Text
65type Definitions = InsOrdHashMap Text
66
66
67-- | This is the root document object for the API specification.
67-- | This is the root document object for the API specification.
68−data Swagger = Swagger
68+data OpenApi = OpenApi
69 { -- | Provides metadata about the API.
69 { -- | Provides metadata about the API.
70 -- The metadata can be used by the clients if needed.
70 -- The metadata can be used by the clients if needed.
71− _swaggerInfo :: Info
71+ _openApiInfo :: Info
72
72
73 -- | An array of Server Objects, which provide connectivity information
73 -- | An array of Server Objects, which provide connectivity information
74 -- to a target server. If the servers property is not provided, or is an empty array,
74 -- to a target server. If the servers property is not provided, or is an empty array,
75 -- the default value would be a 'Server' object with a url value of @/@.
75 -- the default value would be a 'Server' object with a url value of @/@.
76− , _swaggerServers :: [Server]
76+ , _openApiServers :: [Server]
77
77
78 -- | The available paths and operations for the API.
78 -- | The available paths and operations for the API.
79− , _swaggerPaths :: InsOrdHashMap FilePath PathItem
79+ , _openApiPaths :: InsOrdHashMap FilePath PathItem
80
80
81 -- | An element to hold various schemas for the specification.
81 -- | An element to hold various schemas for the specification.
82− , _swaggerComponents :: Components
82+ , _openApiComponents :: Components
83
83
84 -- | A declaration of which security mechanisms can be used across the API.
84 -- | A declaration of which security mechanisms can be used across the API.
85 -- The list of values includes alternative security requirement objects that can be used.
85 -- The list of values includes alternative security requirement objects that can be used.
86 -- Only one of the security requirement objects need to be satisfied to authorize a request.
86 -- Only one of the security requirement objects need to be satisfied to authorize a request.
87 -- Individual operations can override this definition.
87 -- Individual operations can override this definition.
88 -- To make security optional, an empty security requirement can be included in the array.
88 -- To make security optional, an empty security requirement can be included in the array.
89− , _swaggerSecurity :: [SecurityRequirement]
89+ , _openApiSecurity :: [SecurityRequirement]
90
90
91 -- | A list of tags used by the specification with additional metadata.
91 -- | A list of tags used by the specification with additional metadata.
92 -- The order of the tags can be used to reflect on their order by the parsing tools.
92 -- The order of the tags can be used to reflect on their order by the parsing tools.
93 -- Not all tags that are used by the 'Operation' Object must be declared.
93 -- Not all tags that are used by the 'Operation' Object must be declared.
94 -- The tags that are not declared MAY be organized randomly or based on the tools' logic.
94 -- The tags that are not declared MAY be organized randomly or based on the tools' logic.
95 -- Each tag name in the list MUST be unique.
95 -- Each tag name in the list MUST be unique.
96− , _swaggerTags :: InsOrdHashSet Tag
96+ , _openApiTags :: InsOrdHashSet Tag
97
97
98 -- | Additional external documentation.
98 -- | Additional external documentation.
99− , _swaggerExternalDocs :: Maybe ExternalDocs
99+ , _openApiExternalDocs :: Maybe ExternalDocs
100 } deriving (Eq, Show, Generic, Data, Typeable)
100 } deriving (Eq, Show, Generic, Data, Typeable)
101
101
102-- | The object provides metadata about the API.
102-- | The object provides metadata about the API.
@@ -571,27 +571,27 @@ data Link = Link
571 , _linkServer :: Maybe Server
571 , _linkServer :: Maybe Server
572 } deriving (Eq, Show, Generic, Typeable, Data)
572 } deriving (Eq, Show, Generic, Typeable, Data)
573
573
574−-- | Items for @'SwaggerArray'@ schemas.
574+-- | Items for @'OpenApiArray'@ schemas.
575--
575--
576-- __Warning__: OpenAPI 3.0 does not support tuple arrays. However, OpenAPI 3.1 will, as
576-- __Warning__: OpenAPI 3.0 does not support tuple arrays. However, OpenAPI 3.1 will, as
577-- it will incorporate Json Schema mostly verbatim.
577-- it will incorporate Json Schema mostly verbatim.
578--
578--
579−-- @'SwaggerItemsObject'@ should be used to specify homogenous array @'Schema'@s.
579+-- @'OpenApiItemsObject'@ should be used to specify homogenous array @'Schema'@s.
580--
580--
581−-- @'SwaggerItemsArray'@ should be used to specify tuple @'Schema'@s.
581+-- @'OpenApiItemsArray'@ should be used to specify tuple @'Schema'@s.
582−data SwaggerItems where
582+data OpenApiItems where
583− SwaggerItemsObject :: Referenced Schema -> SwaggerItems
583+ OpenApiItemsObject :: Referenced Schema -> OpenApiItems
584− SwaggerItemsArray :: [Referenced Schema] -> SwaggerItems
584+ OpenApiItemsArray :: [Referenced Schema] -> OpenApiItems
585 deriving (Eq, Show, Typeable, Data)
585 deriving (Eq, Show, Typeable, Data)
586
586
587−data SwaggerType where
587+data OpenApiType where
588− SwaggerString :: SwaggerType
588+ OpenApiString :: OpenApiType
589− SwaggerNumber :: SwaggerType
589+ OpenApiNumber :: OpenApiType
590− SwaggerInteger :: SwaggerType
590+ OpenApiInteger :: OpenApiType
591− SwaggerBoolean :: SwaggerType
591+ OpenApiBoolean :: OpenApiType
592− SwaggerArray :: SwaggerType
592+ OpenApiArray :: OpenApiType
593− SwaggerNull :: SwaggerType
593+ OpenApiNull :: OpenApiType
594− SwaggerObject :: SwaggerType
594+ OpenApiObject :: OpenApiType
595 deriving (Eq, Show, Typeable, Generic, Data)
595 deriving (Eq, Show, Typeable, Generic, Data)
596
596
597data ParamLocation
597data ParamLocation
@@ -643,9 +643,9 @@ data Schema = Schema
643 -- Unlike JSON Schema this value MUST conform to the defined type for this parameter.
643 -- Unlike JSON Schema this value MUST conform to the defined type for this parameter.
644 _schemaDefault :: Maybe Value
644 _schemaDefault :: Maybe Value
645
645
646− , _schemaType :: Maybe SwaggerType
646+ , _schemaType :: Maybe OpenApiType
647 , _schemaFormat :: Maybe Format
647 , _schemaFormat :: Maybe Format
648− , _schemaItems :: Maybe SwaggerItems
648+ , _schemaItems :: Maybe OpenApiItems
649 , _schemaMaximum :: Maybe Scientific
649 , _schemaMaximum :: Maybe Scientific
650 , _schemaExclusiveMaximum :: Maybe Bool
650 , _schemaExclusiveMaximum :: Maybe Bool
651 , _schemaMinimum :: Maybe Scientific
651 , _schemaMinimum :: Maybe Scientific
@@ -680,7 +680,7 @@ data NamedSchema = NamedSchema
680
680
681data Xml = Xml
681data Xml = Xml
682 { -- | Replaces the name of the element/attribute used for the described schema property.
682 { -- | Replaces the name of the element/attribute used for the described schema property.
683− -- When defined within the @'SwaggerItems'@ (items), it will affect the name of the individual XML elements within the list.
683+ -- When defined within the @'OpenApiItems'@ (items), it will affect the name of the individual XML elements within the list.
684 -- When defined alongside type being array (outside the items),
684 -- When defined alongside type being array (outside the items),
685 -- it will affect the wrapping element and only if wrapped is true.
685 -- it will affect the wrapping element and only if wrapped is true.
686 -- If wrapped is false, it will be ignored.
686 -- If wrapped is false, it will be ignored.
@@ -936,7 +936,7 @@ deriveGeneric ''MediaTypeObject
936deriveGeneric ''Responses
936deriveGeneric ''Responses
937deriveGeneric ''SecurityScheme
937deriveGeneric ''SecurityScheme
938deriveGeneric ''Schema
938deriveGeneric ''Schema
939−deriveGeneric ''Swagger
939+deriveGeneric ''OpenApi
940deriveGeneric ''Example
940deriveGeneric ''Example
941deriveGeneric ''Encoding
941deriveGeneric ''Encoding
942deriveGeneric ''Link
942deriveGeneric ''Link
@@ -945,9 +945,9 @@ deriveGeneric ''Link
945-- Monoid instances
945-- Monoid instances
946-- =======================================================================
946-- =======================================================================
947
947
948−instance Semigroup Swagger where
948+instance Semigroup OpenApi where
949 (<>) = genericMappend
949 (<>) = genericMappend
950−instance Monoid Swagger where
950+instance Monoid OpenApi where
951 mempty = genericMempty
951 mempty = genericMempty
952 mappend = (<>)
952 mappend = (<>)
953
953
@@ -1085,8 +1085,8 @@ instance (Eq a, Hashable a) => SwaggerMonoid (InsOrdHashSet a)
1085instance SwaggerMonoid MimeList
1085instance SwaggerMonoid MimeList
1086deriving instance SwaggerMonoid URL
1086deriving instance SwaggerMonoid URL
1087
1087
1088−instance SwaggerMonoid SwaggerType where
1088+instance SwaggerMonoid OpenApiType where
1089− swaggerMempty = SwaggerString
1089+ swaggerMempty = OpenApiString
1090 swaggerMappend _ y = y
1090 swaggerMappend _ y = y
1091
1091
1092instance SwaggerMonoid ParamLocation where
1092instance SwaggerMonoid ParamLocation where
@@ -1109,7 +1109,7 @@ instance Monoid a => SwaggerMonoid (Referenced a) where
1109instance ToJSON Style where
1109instance ToJSON Style where
1110 toJSON = genericToJSON (jsonPrefix "Style")
1110 toJSON = genericToJSON (jsonPrefix "Style")
1111
1111
1112−instance ToJSON SwaggerType where
1112+instance ToJSON OpenApiType where
1113 toJSON = genericToJSON (jsonPrefix "Swagger")
1113 toJSON = genericToJSON (jsonPrefix "Swagger")
1114
1114
1115instance ToJSON ParamLocation where
1115instance ToJSON ParamLocation where
@@ -1164,7 +1164,7 @@ instance ToJSON OAuth2AuthorizationCodeFlow where
1164instance FromJSON Style where
1164instance FromJSON Style where
1165 parseJSON = genericParseJSON (jsonPrefix "Style")
1165 parseJSON = genericParseJSON (jsonPrefix "Style")
1166
1166
1167−instance FromJSON SwaggerType where
1167+instance FromJSON OpenApiType where
1168 parseJSON = genericParseJSON (jsonPrefix "Swagger")
1168 parseJSON = genericParseJSON (jsonPrefix "Swagger")
1169
1169
1170instance FromJSON ParamLocation where
1170instance FromJSON ParamLocation where
@@ -1243,9 +1243,9 @@ instance ToJSON SecuritySchemeType where
1243 , "openIdConnectUrl" .= url
1243 , "openIdConnectUrl" .= url
1244 ]
1244 ]
1245
1245
1246−instance ToJSON Swagger where
1246+instance ToJSON OpenApi where
1247 toJSON a = sopSwaggerGenericToJSON a &
1247 toJSON a = sopSwaggerGenericToJSON a &
1248− if InsOrdHashMap.null (_swaggerPaths a)
1248+ if InsOrdHashMap.null (_openApiPaths a)
1249 then (<+> object ["paths" .= object []])
1249 then (<+> object ["paths" .= object []])
1250 else id
1250 else id
1251 toEncoding = sopSwaggerGenericToEncoding
1251 toEncoding = sopSwaggerGenericToEncoding
@@ -1269,17 +1269,17 @@ instance ToJSON Header where
1269-- | As for nullary schema for 0-arity type constructors, see
1269-- | As for nullary schema for 0-arity type constructors, see
1270-- <https://github.com/GetShopTV/swagger2/issues/167>.
1270-- <https://github.com/GetShopTV/swagger2/issues/167>.
1271--
1271--
1272−-- >>> encode (SwaggerItemsArray [])
1272+-- >>> encode (OpenApiItemsArray [])
1273-- "{\"example\":[],\"items\":{},\"maxItems\":0}"
1273-- "{\"example\":[],\"items\":{},\"maxItems\":0}"
1274--
1274--
1275−instance ToJSON SwaggerItems where
1275+instance ToJSON OpenApiItems where
1276− toJSON (SwaggerItemsObject x) = object [ "items" .= x ]
1276+ toJSON (OpenApiItemsObject x) = object [ "items" .= x ]
1277− toJSON (SwaggerItemsArray []) = object
1277+ toJSON (OpenApiItemsArray []) = object
1278 [ "items" .= object []
1278 [ "items" .= object []
1279 , "maxItems" .= (0 :: Int)
1279 , "maxItems" .= (0 :: Int)
1280 , "example" .= Array mempty
1280 , "example" .= Array mempty
1281 ]
1281 ]
1282− toJSON (SwaggerItemsArray x) = object [ "items" .= x ]
1282+ toJSON (OpenApiItemsArray x) = object [ "items" .= x ]
1283
1283
1284instance ToJSON Components where
1284instance ToJSON Components where
1285 toJSON = sopSwaggerGenericToJSON
1285 toJSON = sopSwaggerGenericToJSON
@@ -1386,7 +1386,7 @@ instance FromJSON SecuritySchemeType where
1386 _ -> empty
1386 _ -> empty
1387 parseJSON _ = empty
1387 parseJSON _ = empty
1388
1388
1389−instance FromJSON Swagger where
1389+instance FromJSON OpenApi where
1390 parseJSON = sopSwaggerGenericParseJSON
1390 parseJSON = sopSwaggerGenericParseJSON
1391
1391
1392instance FromJSON Server where
1392instance FromJSON Server where
@@ -1399,7 +1399,7 @@ instance FromJSON Schema where
1399 parseJSON = fmap nullaryCleanup . sopSwaggerGenericParseJSON
1399 parseJSON = fmap nullaryCleanup . sopSwaggerGenericParseJSON
1400 where nullaryCleanup :: Schema -> Schema
1400 where nullaryCleanup :: Schema -> Schema
1401 nullaryCleanup s =
1401 nullaryCleanup s =
1402− if _schemaItems s == Just (SwaggerItemsArray [])
1402+ if _schemaItems s == Just (OpenApiItemsArray [])
1403 then s { _schemaExample = Nothing
1403 then s { _schemaExample = Nothing
1404 , _schemaMaxItems = Nothing
1404 , _schemaMaxItems = Nothing
1405 }
1405 }
@@ -1408,11 +1408,11 @@ instance FromJSON Schema where
1408instance FromJSON Header where
1408instance FromJSON Header where
1409 parseJSON = sopSwaggerGenericParseJSON
1409 parseJSON = sopSwaggerGenericParseJSON
1410
1410
1411−instance FromJSON SwaggerItems where
1411+instance FromJSON OpenApiItems where
1412 parseJSON js@(Object obj)
1412 parseJSON js@(Object obj)
1413− | null obj = pure $ SwaggerItemsArray [] -- Nullary schema.
1413+ | null obj = pure $ OpenApiItemsArray [] -- Nullary schema.
1414− | otherwise = SwaggerItemsObject <$> parseJSON js
1414+ | otherwise = OpenApiItemsObject <$> parseJSON js
1415− parseJSON js@(Array _) = SwaggerItemsArray <$> parseJSON js
1415+ parseJSON js@(Array _) = OpenApiItemsArray <$> parseJSON js
1416 parseJSON _ = empty
1416 parseJSON _ = empty
1417
1417
1418instance FromJSON Components where
1418instance FromJSON Components where
@@ -1526,7 +1526,7 @@ instance HasSwaggerAesonOptions SecurityScheme where
1526 swaggerAesonOptions _ = mkSwaggerAesonOptions "securityScheme" & saoSubObject ?~ "type"
1526 swaggerAesonOptions _ = mkSwaggerAesonOptions "securityScheme" & saoSubObject ?~ "type"
1527instance HasSwaggerAesonOptions Schema where
1527instance HasSwaggerAesonOptions Schema where
1528 swaggerAesonOptions _ = mkSwaggerAesonOptions "schema" & saoSubObject ?~ "paramSchema"
1528 swaggerAesonOptions _ = mkSwaggerAesonOptions "schema" & saoSubObject ?~ "paramSchema"
1529−instance HasSwaggerAesonOptions Swagger where
1529+instance HasSwaggerAesonOptions OpenApi where
1530 swaggerAesonOptions _ = mkSwaggerAesonOptions "swagger" & saoAdditionalPairs .~ [("openapi", "3.0.0")]
1530 swaggerAesonOptions _ = mkSwaggerAesonOptions "swagger" & saoAdditionalPairs .~ [("openapi", "3.0.0")]
1531instance HasSwaggerAesonOptions Example where
1531instance HasSwaggerAesonOptions Example where
1532 swaggerAesonOptions _ = mkSwaggerAesonOptions "example"
1532 swaggerAesonOptions _ = mkSwaggerAesonOptions "example"
@@ -1545,7 +1545,7 @@ instance AesonDefaultValue OAuth2AuthorizationCodeFlow
1545instance AesonDefaultValue p => AesonDefaultValue (OAuth2Flow p)
1545instance AesonDefaultValue p => AesonDefaultValue (OAuth2Flow p)
1546instance AesonDefaultValue Responses
1546instance AesonDefaultValue Responses
1547instance AesonDefaultValue SecuritySchemeType
1547instance AesonDefaultValue SecuritySchemeType
1548−instance AesonDefaultValue SwaggerType
1548+instance AesonDefaultValue OpenApiType
1549instance AesonDefaultValue MimeList where defaultValue = Just mempty
1549instance AesonDefaultValue MimeList where defaultValue = Just mempty
1550instance AesonDefaultValue Info
1550instance AesonDefaultValue Info
1551instance AesonDefaultValue ParamLocation
1551instance AesonDefaultValue ParamLocation
src/Data/OpenApi/Internal/ParamSchema.hs+22−22
@@ -52,20 +52,20 @@ import GHC.TypeLits (TypeError, ErrorMessage(..))
52-- | Default schema for binary data (any sequence of octets).
52-- | Default schema for binary data (any sequence of octets).
53binarySchema :: Schema
53binarySchema :: Schema
54binarySchema = mempty
54binarySchema = mempty
55− & type_ ?~ SwaggerString
55+ & type_ ?~ OpenApiString
56 & format ?~ "binary"
56 & format ?~ "binary"
57
57
58-- | Default schema for binary data (base64 encoded).
58-- | Default schema for binary data (base64 encoded).
59byteSchema :: Schema
59byteSchema :: Schema
60byteSchema = mempty
60byteSchema = mempty
61− & type_ ?~ SwaggerString
61+ & type_ ?~ OpenApiString
62 & format ?~ "byte"
62 & format ?~ "byte"
63
63
64-- | Default schema for password string.
64-- | Default schema for password string.
65-- @"password"@ format is used to hint UIs the input needs to be obscured.
65-- @"password"@ format is used to hint UIs the input needs to be obscured.
66passwordSchema :: Schema
66passwordSchema :: Schema
67passwordSchema = mempty
67passwordSchema = mempty
68− & type_ ?~ SwaggerString
68+ & type_ ?~ OpenApiString
69 & format ?~ "password"
69 & format ?~ "password"
70
70
71-- | Convert a type into a plain @'Schema'@.
71-- | Convert a type into a plain @'Schema'@.
@@ -87,7 +87,7 @@ passwordSchema = mempty
87--
87--
88-- instance ToParamSchema Direction where
88-- instance ToParamSchema Direction where
89-- toParamSchema _ = mempty
89-- toParamSchema _ = mempty
90−-- & type_ ?~ SwaggerString
90+-- & type_ ?~ OpenApiString
91-- & enum_ ?~ [ \"Up\", \"Down\" ]
91-- & enum_ ?~ [ \"Up\", \"Down\" ]
92-- @
92-- @
93--
93--
@@ -119,17 +119,17 @@ class ToParamSchema a where
119 toParamSchema = genericToParamSchema defaultSchemaOptions
119 toParamSchema = genericToParamSchema defaultSchemaOptions
120
120
121instance {-# OVERLAPPING #-} ToParamSchema String where
121instance {-# OVERLAPPING #-} ToParamSchema String where
122− toParamSchema _ = mempty & type_ ?~ SwaggerString
122+ toParamSchema _ = mempty & type_ ?~ OpenApiString
123
123
124instance ToParamSchema Bool where
124instance ToParamSchema Bool where
125− toParamSchema _ = mempty & type_ ?~ SwaggerBoolean
125+ toParamSchema _ = mempty & type_ ?~ OpenApiBoolean
126
126
127instance ToParamSchema Integer where
127instance ToParamSchema Integer where
128− toParamSchema _ = mempty & type_ ?~ SwaggerInteger
128+ toParamSchema _ = mempty & type_ ?~ OpenApiInteger
129
129
130instance ToParamSchema Natural where
130instance ToParamSchema Natural where
131 toParamSchema _ = mempty
131 toParamSchema _ = mempty
132− & type_ ?~ SwaggerInteger
132+ & type_ ?~ OpenApiInteger
133 & minimum_ ?~ 0
133 & minimum_ ?~ 0
134 & exclusiveMinimum ?~ False
134 & exclusiveMinimum ?~ False
135
135
@@ -159,37 +159,37 @@ instance ToParamSchema Word64 where
159-- "{\"maximum\":127,\"minimum\":-128,\"type\":\"integer\"}"
159-- "{\"maximum\":127,\"minimum\":-128,\"type\":\"integer\"}"
160toParamSchemaBoundedIntegral :: forall a t. (Bounded a, Integral a) => Proxy a -> Schema
160toParamSchemaBoundedIntegral :: forall a t. (Bounded a, Integral a) => Proxy a -> Schema
161toParamSchemaBoundedIntegral _ = mempty
161toParamSchemaBoundedIntegral _ = mempty
162− & type_ ?~ SwaggerInteger
162+ & type_ ?~ OpenApiInteger
163 & minimum_ ?~ fromInteger (toInteger (minBound :: a))
163 & minimum_ ?~ fromInteger (toInteger (minBound :: a))
164 & maximum_ ?~ fromInteger (toInteger (maxBound :: a))
164 & maximum_ ?~ fromInteger (toInteger (maxBound :: a))
165
165
166instance ToParamSchema Char where
166instance ToParamSchema Char where
167 toParamSchema _ = mempty
167 toParamSchema _ = mempty
168− & type_ ?~ SwaggerString
168+ & type_ ?~ OpenApiString
169 & maxLength ?~ 1
169 & maxLength ?~ 1
170 & minLength ?~ 1
170 & minLength ?~ 1
171
171
172instance ToParamSchema Scientific where
172instance ToParamSchema Scientific where
173− toParamSchema _ = mempty & type_ ?~ SwaggerNumber
173+ toParamSchema _ = mempty & type_ ?~ OpenApiNumber
174
174
175instance HasResolution a => ToParamSchema (Fixed a) where
175instance HasResolution a => ToParamSchema (Fixed a) where
176 toParamSchema _ = mempty
176 toParamSchema _ = mempty
177− & type_ ?~ SwaggerNumber
177+ & type_ ?~ OpenApiNumber
178 & multipleOf ?~ (recip . fromInteger $ resolution (Proxy :: Proxy a))
178 & multipleOf ?~ (recip . fromInteger $ resolution (Proxy :: Proxy a))
179
179
180instance ToParamSchema Double where
180instance ToParamSchema Double where
181 toParamSchema _ = mempty
181 toParamSchema _ = mempty
182− & type_ ?~ SwaggerNumber
182+ & type_ ?~ OpenApiNumber
183 & format ?~ "double"
183 & format ?~ "double"
184
184
185instance ToParamSchema Float where
185instance ToParamSchema Float where
186 toParamSchema _ = mempty
186 toParamSchema _ = mempty
187− & type_ ?~ SwaggerNumber
187+ & type_ ?~ OpenApiNumber
188 & format ?~ "float"
188 & format ?~ "float"
189
189
190timeParamSchema :: String -> Schema
190timeParamSchema :: String -> Schema
191timeParamSchema fmt = mempty
191timeParamSchema fmt = mempty
192− & type_ ?~ SwaggerString
192+ & type_ ?~ OpenApiString
193 & format ?~ T.pack fmt
193 & format ?~ T.pack fmt
194
194
195-- | Format @"date"@ corresponds to @yyyy-mm-dd@ format.
195-- | Format @"date"@ corresponds to @yyyy-mm-dd@ format.
@@ -231,12 +231,12 @@ instance ToParamSchema TL.Text where
231
231
232instance ToParamSchema Version where
232instance ToParamSchema Version where
233 toParamSchema _ = mempty
233 toParamSchema _ = mempty
234− & type_ ?~ SwaggerString
234+ & type_ ?~ OpenApiString
235 & pattern ?~ "^\\d+(\\.\\d+)*$"
235 & pattern ?~ "^\\d+(\\.\\d+)*$"
236
236
237instance ToParamSchema SetCookie where
237instance ToParamSchema SetCookie where
238 toParamSchema _ = mempty
238 toParamSchema _ = mempty
239− & type_ ?~ SwaggerString
239+ & type_ ?~ OpenApiString
240
240
241type family ToParamSchemaByteStringError bs where
241type family ToParamSchemaByteStringError bs where
242 ToParamSchemaByteStringError bs = TypeError
242 ToParamSchemaByteStringError bs = TypeError
@@ -259,8 +259,8 @@ instance ToParamSchema a => ToParamSchema (Identity a) where toParamSchema _ = t
259
259
260instance ToParamSchema a => ToParamSchema [a] where
260instance ToParamSchema a => ToParamSchema [a] where
261 toParamSchema _ = mempty
261 toParamSchema _ = mempty
262− & type_ ?~ SwaggerArray
262+ & type_ ?~ OpenApiArray
263− & items ?~ SwaggerItemsObject (Inline $ toParamSchema (Proxy :: Proxy a))
263+ & items ?~ OpenApiItemsObject (Inline $ toParamSchema (Proxy :: Proxy a))
264
264
265instance ToParamSchema a => ToParamSchema (V.Vector a) where toParamSchema _ = toParamSchema (Proxy :: Proxy [a])
265instance ToParamSchema a => ToParamSchema (V.Vector a) where toParamSchema _ = toParamSchema (Proxy :: Proxy [a])
266instance ToParamSchema a => ToParamSchema (VP.Vector a) where toParamSchema _ = toParamSchema (Proxy :: Proxy [a])
266instance ToParamSchema a => ToParamSchema (VP.Vector a) where toParamSchema _ = toParamSchema (Proxy :: Proxy [a])
@@ -279,12 +279,12 @@ instance ToParamSchema a => ToParamSchema (HashSet a) where
279-- "{\"type\":\"string\",\"enum\":[\"_\"]}"
279-- "{\"type\":\"string\",\"enum\":[\"_\"]}"
280instance ToParamSchema () where
280instance ToParamSchema () where
281 toParamSchema _ = mempty
281 toParamSchema _ = mempty
282− & type_ ?~ SwaggerString
282+ & type_ ?~ OpenApiString
283 & enum_ ?~ ["_"]
283 & enum_ ?~ ["_"]
284
284
285instance ToParamSchema UUID where
285instance ToParamSchema UUID where
286 toParamSchema _ = mempty
286 toParamSchema _ = mempty
287− & type_ ?~ SwaggerString
287+ & type_ ?~ OpenApiString
288 & format ?~ "uuid"
288 & format ?~ "uuid"
289
289
290-- | A configurable generic @'Schema'@ creator.
290-- | A configurable generic @'Schema'@ creator.
@@ -322,7 +322,7 @@ instance (GEnumParamSchema f, GEnumParamSchema g) => GEnumParamSchema (f :+: g)
322
322
323instance Constructor c => GEnumParamSchema (C1 c U1) where
323instance Constructor c => GEnumParamSchema (C1 c U1) where
324 genumParamSchema opts _ s = s
324 genumParamSchema opts _ s = s
325− & type_ ?~ SwaggerString
325+ & type_ ?~ OpenApiString
326 & enum_ %~ addEnumValue tag
326 & enum_ %~ addEnumValue tag
327 where
327 where
328 tag = toJSON (constructorTagModifier opts (conName (Proxy3 :: Proxy3 c f p)))
328 tag = toJSON (constructorTagModifier opts (conName (Proxy3 :: Proxy3 c f p)))
src/Data/OpenApi/Internal/Schema.hs+44−44
@@ -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,15 +312,15 @@ 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
314
314
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 -> OpenApiItemsObject (Inline s)
323− _ -> SwaggerItemsArray (map Inline ys)
323+ _ -> OpenApiItemsArray (map Inline ys)
324 where
324 where
325 ys = map go (V.toList xs)
325 ys = map go (V.toList xs)
326 allSame = and ((zipWith (==)) ys (tail ys))
326 allSame = and ((zipWith (==)) ys (tail 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)
335
335
@@ -352,34 +352,34 @@ sketchSchema = sketch . toJSON
352sketchStrictSchema :: ToJSON a => a -> Schema
352sketchStrictSchema :: ToJSON a => a -> Schema
353sketchStrictSchema = go . toJSON
353sketchStrictSchema = go . toJSON
354 where
354 where
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 ?~ OpenApiItemsArray (map (Inline . go) (V.toList xs))
376 & uniqueItems ?~ allUnique
376 & uniqueItems ?~ allUnique
377 & enum_ ?~ [js]
377 & enum_ ?~ [js]
378 where
378 where
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,8 +395,8 @@ 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 ?~ OpenApiItemsObject ref
400
400
401instance {-# OVERLAPPING #-} ToSchema String where declareNamedSchema = plain . paramSchemaToSchema
401instance {-# OVERLAPPING #-} ToSchema String where declareNamedSchema = plain . paramSchemaToSchema
402instance ToSchema Bool where declareNamedSchema = plain . paramSchemaToSchema
402instance ToSchema Bool where declareNamedSchema = plain . paramSchemaToSchema
@@ -447,7 +447,7 @@ instance (ToSchema a, ToSchema b, ToSchema c, ToSchema d, ToSchema e, ToSchema f
447
447
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
452
452
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
510
510
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
513
513
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
519
519
@@ -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))
560
560
@@ -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)
605
605
606-- | A 'Schema' for a mapping with 'Bounded' 'Enum' keys.
606-- | A 'Schema' for a mapping with 'Bounded' 'Enum' keys.
@@ -659,8 +659,8 @@ paramSchemaToSchema = toParamSchema
659
659
660nullarySchema :: Schema
660nullarySchema :: Schema
661nullarySchema = mempty
661nullarySchema = mempty
662− & type_ ?~ SwaggerArray
662+ & type_ ?~ OpenApiArray
663− & items ?~ SwaggerItemsArray []
663+ & items ?~ OpenApiItemsArray []
664
664
665gtoNamedSchema :: GToSchema f => SchemaOptions -> Proxy f -> NamedSchema
665gtoNamedSchema :: GToSchema f => SchemaOptions -> Proxy f -> NamedSchema
666gtoNamedSchema opts proxy = undeclare $ gdeclareNamedSchema opts proxy mempty
666gtoNamedSchema opts proxy = undeclare $ gdeclareNamedSchema opts proxy mempty
@@ -690,7 +690,7 @@ instance (Selector s, GToSchema f, GToSchema (S1 s f)) => GToSchema (C1 c (S1 s
690 | unwrapUnaryRecords opts = fieldSchema
690 | unwrapUnaryRecords opts = fieldSchema
691 | otherwise =
691 | otherwise =
692 case schema ^. items of
692 case schema ^. items of
693− Just (SwaggerItemsArray [_]) -> fieldSchema
693+ Just (OpenApiItemsArray [_]) -> fieldSchema
694 _ -> do
694 _ -> do
695 declare defs
695 declare defs
696 return (unnamed schema)
696 return (unnamed schema)
@@ -718,10 +718,10 @@ gdeclareSchemaRef opts proxy = do
718 return $ Ref (Reference name)
718 return $ Ref (Reference name)
719 _ -> Inline <$> gdeclareSchema opts proxy
719 _ -> Inline <$> gdeclareSchema opts proxy
720
720
721−appendItem :: Referenced Schema -> Maybe SwaggerItems -> Maybe SwaggerItems
721+appendItem :: Referenced Schema -> Maybe OpenApiItems -> Maybe OpenApiItems
722−appendItem x Nothing = Just (SwaggerItemsArray [x])
722+appendItem x Nothing = Just (OpenApiItemsArray [x])
723−appendItem x (Just (SwaggerItemsArray xs)) = Just (SwaggerItemsArray (xs ++ [x]))
723+appendItem x (Just (OpenApiItemsArray xs)) = Just (OpenApiItemsArray (xs ++ [x]))
724−appendItem _ _ = error "GToSchema.appendItem: cannot append to SwaggerItemsObject"
724+appendItem _ _ = error "GToSchema.appendItem: cannot append to OpenApiItemsObject"
725
725
726withFieldSchema :: forall proxy s f. (Selector s, GToSchema f) =>
726withFieldSchema :: forall proxy s f. (Selector s, GToSchema f) =>
727 SchemaOptions -> proxy s f -> Bool -> Schema -> Declare (Definitions Schema) Schema
727 SchemaOptions -> proxy s f -> Bool -> Schema -> Declare (Definitions Schema) Schema
@@ -730,12 +730,12 @@ withFieldSchema opts _ isRequiredField schema = do
730 return $
730 return $
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)
775 where
775 where
776 declareSumSchema = gsumToSchema opts proxy
776 declareSumSchema = gsumToSchema opts proxy
777 (sumSchemas, All allNullary) = undeclare (runWriterT declareSumSchema)
777 (sumSchemas, All allNullary) = undeclare (runWriterT declareSumSchema)
778
778
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
782
782
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])
805
805
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)
815
815
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
837
837
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)]
src/Data/OpenApi/Internal/Schema/Validation.hs+33−33
@@ -353,8 +353,8 @@ validateArray xs = do
353 invalid ("array is too short (size should be >=" ++ show n ++ ")")
353 invalid ("array is too short (size should be >=" ++ show n ++ ")")
354
354
355 check items $ \case
355 check items $ \case
356− SwaggerItemsObject itemSchema -> traverse_ (validateWithSchemaRef itemSchema) xs
356+ OpenApiItemsObject itemSchema -> traverse_ (validateWithSchemaRef itemSchema) xs
357− SwaggerItemsArray itemSchemas -> do
357+ OpenApiItemsArray itemSchemas -> do
358 when (len /= length itemSchemas) $
358 when (len /= length itemSchemas) $
359 invalid ("array size is invalid (should be exactly " ++ show (length itemSchemas) ++ ")")
359 invalid ("array size is invalid (should be exactly " ++ show (length itemSchemas) ++ ")")
360 sequenceA_ (zipWith validateWithSchemaRef itemSchemas (Vector.toList xs))
360 sequenceA_ (zipWith validateWithSchemaRef itemSchemas (Vector.toList xs))
@@ -423,10 +423,10 @@ validateEnum val = do
423-- This is like 'inferParamSchemaTypes', but also works for objects:
423-- This is like 'inferParamSchemaTypes', but also works for objects:
424--
424--
425-- >>> inferSchemaTypes <$> decode "{\"minProperties\": 1}"
425-- >>> inferSchemaTypes <$> decode "{\"minProperties\": 1}"
426−-- Just [SwaggerObject]
426+-- Just [OpenApiObject]
427−inferSchemaTypes :: Schema -> [SwaggerType]
427+inferSchemaTypes :: Schema -> [OpenApiType]
428inferSchemaTypes sch = inferParamSchemaTypes sch ++
428inferSchemaTypes sch = inferParamSchemaTypes sch ++
429− [ SwaggerObject | any ($ sch)
429+ [ OpenApiObject | any ($ sch)
430 [ has (additionalProperties._Just)
430 [ has (additionalProperties._Just)
431 , has (maxProperties._Just)
431 , has (maxProperties._Just)
432 , has (minProperties._Just)
432 , has (minProperties._Just)
@@ -436,30 +436,30 @@ inferSchemaTypes sch = inferParamSchemaTypes sch ++
436-- | Infer schema type based on used properties.
436-- | Infer schema type based on used properties.
437--
437--
438-- >>> inferSchemaTypes <$> decode "{\"minLength\": 2}"
438-- >>> inferSchemaTypes <$> decode "{\"minLength\": 2}"
439−-- Just [SwaggerString]
439+-- Just [OpenApiString]
440--
440--
441-- >>> inferSchemaTypes <$> decode "{\"maxItems\": 0}"
441-- >>> inferSchemaTypes <$> decode "{\"maxItems\": 0}"
442−-- Just [SwaggerArray]
442+-- Just [OpenApiArray]
443--
443--
444−-- From numeric properties 'SwaggerInteger' type is inferred.
444+-- From numeric properties 'OpenApiInteger' type is inferred.
445−-- If you want 'SwaggerNumber' instead, you must specify it explicitly.
445+-- If you want 'OpenApiNumber' instead, you must specify it explicitly.
446--
446--
447-- >>> inferSchemaTypes <$> decode "{\"minimum\": 1}"
447-- >>> inferSchemaTypes <$> decode "{\"minimum\": 1}"
448−-- Just [SwaggerInteger]
448+-- Just [OpenApiInteger]
449−inferParamSchemaTypes :: Schema -> [SwaggerType]
449+inferParamSchemaTypes :: Schema -> [OpenApiType]
450inferParamSchemaTypes sch = concat
450inferParamSchemaTypes sch = concat
451− [ [ SwaggerArray | any ($ sch)
451+ [ [ OpenApiArray | any ($ sch)
452 [ has (items._Just)
452 [ has (items._Just)
453 , has (maxItems._Just)
453 , has (maxItems._Just)
454 , has (minItems._Just)
454 , has (minItems._Just)
455 , has (uniqueItems._Just) ] ]
455 , has (uniqueItems._Just) ] ]
456− , [ SwaggerInteger | any ($ sch)
456+ , [ OpenApiInteger | any ($ sch)
457 [ has (exclusiveMaximum._Just)
457 [ has (exclusiveMaximum._Just)
458 , has (exclusiveMinimum._Just)
458 , has (exclusiveMinimum._Just)
459 , has (maximum_._Just)
459 , has (maximum_._Just)
460 , has (minimum_._Just)
460 , has (minimum_._Just)
461 , has (multipleOf._Just) ] ]
461 , has (multipleOf._Just) ] ]
462− , [ SwaggerString | any ($ sch)
462+ , [ OpenApiString | any ($ sch)
463 [ has (maxLength._Just)
463 [ has (maxLength._Just)
464 , has (minLength._Just)
464 , has (minLength._Just)
465 , has (pattern._Just) ] ]
465 , has (pattern._Just) ] ]
@@ -483,13 +483,13 @@ validateSchemaType val = withSchema $ \sch ->
483
483
484 _ ->
484 _ ->
485 case (sch ^. type_, val) of
485 case (sch ^. type_, val) of
486− (Just SwaggerNull, Null) -> valid
486+ (Just OpenApiNull, Null) -> valid
487− (Just SwaggerBoolean, Bool _) -> valid
487+ (Just OpenApiBoolean, Bool _) -> valid
488− (Just SwaggerInteger, Number n) -> validateInteger n
488+ (Just OpenApiInteger, Number n) -> validateInteger n
489− (Just SwaggerNumber, Number n) -> validateNumber n
489+ (Just OpenApiNumber, Number n) -> validateNumber n
490− (Just SwaggerString, String s) -> validateString s
490+ (Just OpenApiString, String s) -> validateString s
491− (Just SwaggerArray, Array xs) -> validateArray xs
491+ (Just OpenApiArray, Array xs) -> validateArray xs
492− (Just SwaggerObject, Object o) -> validateObject o
492+ (Just OpenApiObject, Object o) -> validateObject o
493 (Nothing, Null) -> valid
493 (Nothing, Null) -> valid
494 (Nothing, Bool _) -> valid
494 (Nothing, Bool _) -> valid
495 -- Number by default
495 -- Number by default
@@ -502,11 +502,11 @@ validateSchemaType val = withSchema $ \sch ->
502validateParamSchemaType :: Value -> Validation Schema ()
502validateParamSchemaType :: Value -> Validation Schema ()
503validateParamSchemaType val = withSchema $ \sch ->
503validateParamSchemaType val = withSchema $ \sch ->
504 case (sch ^. type_, val) of
504 case (sch ^. type_, val) of
505− (Just SwaggerBoolean, Bool _) -> valid
505+ (Just OpenApiBoolean, Bool _) -> valid
506− (Just SwaggerInteger, Number n) -> validateInteger n
506+ (Just OpenApiInteger, Number n) -> validateInteger n
507− (Just SwaggerNumber, Number n) -> validateNumber n
507+ (Just OpenApiNumber, Number n) -> validateNumber n
508− (Just SwaggerString, String s) -> validateString s
508+ (Just OpenApiString, String s) -> validateString s
509− (Just SwaggerArray, Array xs) -> validateArray xs
509+ (Just OpenApiArray, Array xs) -> validateArray xs
510 (Nothing, Bool _) -> valid
510 (Nothing, Bool _) -> valid
511 -- Number by default
511 -- Number by default
512 (Nothing, Number n) -> validateNumber n
512 (Nothing, Number n) -> validateNumber n
@@ -514,11 +514,11 @@ validateParamSchemaType val = withSchema $ \sch ->
514 (Nothing, Array xs) -> validateArray xs
514 (Nothing, Array xs) -> validateArray xs
515 bad -> invalid $ "expected JSON value of type " ++ showType bad
515 bad -> invalid $ "expected JSON value of type " ++ showType bad
516
516
517−showType :: (Maybe SwaggerType, Value) -> String
517+showType :: (Maybe OpenApiType, Value) -> String
518showType (Just ty, _) = show ty
518showType (Just ty, _) = show ty
519−showType (Nothing, Null) = "SwaggerNull"
519+showType (Nothing, Null) = "OpenApiNull"
520−showType (Nothing, Bool _) = "SwaggerBoolean"
520+showType (Nothing, Bool _) = "OpenApiBoolean"
521−showType (Nothing, Number _) = "SwaggerNumber"
521+showType (Nothing, Number _) = "OpenApiNumber"
522−showType (Nothing, String _) = "SwaggerString"
522+showType (Nothing, String _) = "OpenApiString"
523−showType (Nothing, Array _) = "SwaggerArray"
523+showType (Nothing, Array _) = "OpenApiArray"
524−showType (Nothing, Object _) = "SwaggerObject"
524+showType (Nothing, Object _) = "OpenApiObject"
src/Data/OpenApi/Lens.hs+16−16
@@ -26,7 +26,7 @@ import Data.Text (Text)
26
26
27-- * Classy lenses
27-- * Classy lenses
28
28
29−makeFields ''Swagger
29+makeFields ''OpenApi
30makeFields ''Components
30makeFields ''Components
31makeFields ''Server
31makeFields ''Server
32makeFields ''RequestBody
32makeFields ''RequestBody
@@ -64,24 +64,24 @@ makePrisms ''SecuritySchemeType
64-- ** 'Referenced' prisms
64-- ** 'Referenced' prisms
65makePrisms ''Referenced
65makePrisms ''Referenced
66
66
67−-- ** 'SwaggerItems' prisms
67+-- ** 'OpenApiItems' prisms
68
68
69−_SwaggerItemsArray :: Review SwaggerItems [Referenced Schema]
69+_OpenApiItemsArray :: Review OpenApiItems [Referenced Schema]
70−_SwaggerItemsArray
70+_OpenApiItemsArray
71− = unto (\x -> SwaggerItemsArray x)
71+ = unto (\x -> OpenApiItemsArray x)
72{- \x -> case x of
72{- \x -> case x of
73− SwaggerItemsPrimitive c p -> Left (SwaggerItemsPrimitive c p)
73+ OpenApiItemsPrimitive c p -> Left (OpenApiItemsPrimitive c p)
74− SwaggerItemsObject o -> Left (SwaggerItemsObject o)
74+ OpenApiItemsObject o -> Left (OpenApiItemsObject o)
75− SwaggerItemsArray a -> Right a
75+ OpenApiItemsArray a -> Right a
76-}
76-}
77
77
78−_SwaggerItemsObject :: Review SwaggerItems (Referenced Schema)
78+_OpenApiItemsObject :: Review OpenApiItems (Referenced Schema)
79−_SwaggerItemsObject
79+_OpenApiItemsObject
80− = unto (\x -> SwaggerItemsObject x)
80+ = unto (\x -> OpenApiItemsObject x)
81{- \x -> case x of
81{- \x -> case x of
82− SwaggerItemsPrimitive c p -> Left (SwaggerItemsPrimitive c p)
82+ OpenApiItemsPrimitive c p -> Left (OpenApiItemsPrimitive c p)
83− SwaggerItemsObject o -> Right o
83+ OpenApiItemsObject o -> Right o
84− SwaggerItemsArray a -> Left (SwaggerItemsArray a)
84+ OpenApiItemsArray a -> Left (OpenApiItemsArray a)
85-}
85-}
86
86
87-- =============================================================
87-- =============================================================
@@ -99,7 +99,7 @@ instance At Responses where at n = responses . at n
99instance Ixed Operation where ix n = responses . ix n
99instance Ixed Operation where ix n = responses . ix n
100instance At Operation where at n = responses . at n
100instance At Operation where at n = responses . at n
101
101
102−instance HasType NamedSchema (Maybe SwaggerType) where type_ = schema.type_
102+instance HasType NamedSchema (Maybe OpenApiType) where type_ = schema.type_
103
103
104-- OVERLAPPABLE instances
104-- OVERLAPPABLE instances
105
105
@@ -112,7 +112,7 @@ instance
112instance
112instance
113 {-# OVERLAPPABLE #-}
113 {-# OVERLAPPABLE #-}
114 HasSchema s Schema
114 HasSchema s Schema
115− => HasItems s (Maybe SwaggerItems) where
115+ => HasItems s (Maybe OpenApiItems) where
116 items = schema.items
116 items = schema.items
117
117
118instance
118instance
src/Data/OpenApi/Operation.hs+13−13
@@ -59,10 +59,10 @@ import qualified Data.HashSet.InsOrd as InsOrdHS
59-- | Prepend path piece to all operations of the spec.
59-- | Prepend path piece to all operations of the spec.
60-- Leading and trailing slashes are trimmed/added automatically.
60-- Leading and trailing slashes are trimmed/added automatically.
61--
61--
62−-- >>> let api = (mempty :: Swagger) & paths .~ [("/info", mempty)]
62+-- >>> let api = (mempty :: OpenApi) & paths .~ [("/info", mempty)]
63-- >>> BSL.putStrLn $ encode $ prependPath "user/{user_id}" api ^. paths
63-- >>> BSL.putStrLn $ encode $ prependPath "user/{user_id}" api ^. paths
64-- {"/user/{user_id}/info":{}}
64-- {"/user/{user_id}/info":{}}
65−prependPath :: FilePath -> Swagger -> Swagger
65+prependPath :: FilePath -> OpenApi -> OpenApi
66prependPath path = paths %~ InsOrdHashMap.mapKeys (path </>)
66prependPath path = paths %~ InsOrdHashMap.mapKeys (path </>)
67 where
67 where
68 x </> y = case trim y of
68 x </> y = case trim y of
@@ -72,7 +72,7 @@ prependPath path = paths %~ InsOrdHashMap.mapKeys (path </>)
72 trim = dropWhile (== '/') . dropWhileEnd (== '/')
72 trim = dropWhile (== '/') . dropWhileEnd (== '/')
73
73
74-- | All operations of a Swagger spec.
74-- | All operations of a Swagger spec.
75−allOperations :: Traversal' Swagger Operation
75+allOperations :: Traversal' OpenApi Operation
76allOperations = paths.traverse.template
76allOperations = paths.traverse.template
77
77
78-- | @'operationsOf' sub@ will traverse only those operations
78-- | @'operationsOf' sub@ will traverse only those operations
@@ -80,13 +80,13 @@ allOperations = paths.traverse.template
80-- by both path and method.
80-- by both path and method.
81--
81--
82-- >>> let ok = (mempty :: Operation) & at 200 ?~ "OK"
82-- >>> let ok = (mempty :: Operation) & at 200 ?~ "OK"
83−-- >>> let api = (mempty :: Swagger) & paths .~ [("/user", mempty & get ?~ ok & post ?~ ok)]
83+-- >>> let api = (mempty :: OpenApi) & paths .~ [("/user", mempty & get ?~ ok & post ?~ ok)]
84−-- >>> let sub = (mempty :: Swagger) & paths .~ [("/user", mempty & get ?~ mempty)]
84+-- >>> let sub = (mempty :: OpenApi) & paths .~ [("/user", mempty & get ?~ mempty)]
85-- >>> BSL.putStrLn $ encode api
85-- >>> BSL.putStrLn $ encode api
86-- {"openapi":"3.0.0","info":{"version":"","title":""},"paths":{"/user":{"get":{"responses":{"200":{"description":"OK"}}},"post":{"responses":{"200":{"description":"OK"}}}}},"components":{}}
86-- {"openapi":"3.0.0","info":{"version":"","title":""},"paths":{"/user":{"get":{"responses":{"200":{"description":"OK"}}},"post":{"responses":{"200":{"description":"OK"}}}}},"components":{}}
87-- >>> BSL.putStrLn $ encode $ api & operationsOf sub . at 404 ?~ "Not found"
87-- >>> BSL.putStrLn $ encode $ api & operationsOf sub . at 404 ?~ "Not found"
88-- {"openapi":"3.0.0","info":{"version":"","title":""},"paths":{"/user":{"get":{"responses":{"404":{"description":"Not found"},"200":{"description":"OK"}}},"post":{"responses":{"200":{"description":"OK"}}}}},"components":{}}
88-- {"openapi":"3.0.0","info":{"version":"","title":""},"paths":{"/user":{"get":{"responses":{"404":{"description":"Not found"},"200":{"description":"OK"}}},"post":{"responses":{"200":{"description":"OK"}}}}},"components":{}}
89−operationsOf :: Swagger -> Traversal' Swagger Operation
89+operationsOf :: OpenApi -> Traversal' OpenApi Operation
90operationsOf sub = paths.itraversed.withIndex.subops
90operationsOf sub = paths.itraversed.withIndex.subops
91 where
91 where
92 -- | Traverse operations that correspond to paths and methods of the sub API.
92 -- | Traverse operations that correspond to paths and methods of the sub API.
@@ -108,12 +108,12 @@ operationsOf sub = paths.itraversed.withIndex.subops
108-- @
108-- @
109-- 'applyTags' = 'applyTagsFor' 'allOperations'
109-- 'applyTags' = 'applyTagsFor' 'allOperations'
110-- @
110-- @
111−applyTags :: [Tag] -> Swagger -> Swagger
111+applyTags :: [Tag] -> OpenApi -> OpenApi
112applyTags = applyTagsFor allOperations
112applyTags = applyTagsFor allOperations
113
113
114-- | Apply tags to a part of Swagger spec and update the global
114-- | Apply tags to a part of Swagger spec and update the global
115-- list of tags.
115-- list of tags.
116−applyTagsFor :: Traversal' Swagger Operation -> [Tag] -> Swagger -> Swagger
116+applyTagsFor :: Traversal' OpenApi Operation -> [Tag] -> OpenApi -> OpenApi
117applyTagsFor ops ts swag = swag
117applyTagsFor ops ts swag = swag
118 & ops . tags %~ (<> InsOrdHS.fromList (map _tagName ts))
118 & ops . tags %~ (<> InsOrdHS.fromList (map _tagName ts))
119 & tags %~ (<> InsOrdHS.fromList ts)
119 & tags %~ (<> InsOrdHS.fromList ts)
@@ -141,13 +141,13 @@ declareResponse cType proxy = do
141--
141--
142-- Example:
142-- Example:
143--
143--
144−-- >>> let api = (mempty :: Swagger) & paths .~ [("/user", mempty & get ?~ mempty)]
144+-- >>> let api = (mempty :: OpenApi) & paths .~ [("/user", mempty & get ?~ mempty)]
145-- >>> let res = declareResponse "application/json" (Proxy :: Proxy Day)
145-- >>> let res = declareResponse "application/json" (Proxy :: Proxy Day)
146-- >>> BSL.putStrLn $ encode $ api & setResponse 200 res
146-- >>> BSL.putStrLn $ encode $ api & setResponse 200 res
147-- {"openapi":"3.0.0","info":{"version":"","title":""},"paths":{"/user":{"get":{"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Day"}}},"description":""}}}}},"components":{"schemas":{"Day":{"example":"2016-07-22","format":"date","type":"string"}}}}
147-- {"openapi":"3.0.0","info":{"version":"","title":""},"paths":{"/user":{"get":{"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Day"}}},"description":""}}}}},"components":{"schemas":{"Day":{"example":"2016-07-22","format":"date","type":"string"}}}}
148--
148--
149-- See also @'setResponseWith'@.
149-- See also @'setResponseWith'@.
150−setResponse :: HttpStatusCode -> Declare (Definitions Schema) Response -> Swagger -> Swagger
150+setResponse :: HttpStatusCode -> Declare (Definitions Schema) Response -> OpenApi -> OpenApi
151setResponse = setResponseFor allOperations
151setResponse = setResponseFor allOperations
152
152
153-- | Set or update response for all operations.
153-- | Set or update response for all operations.
@@ -161,7 +161,7 @@ setResponse = setResponseFor allOperations
161-- @
161-- @
162--
162--
163-- See also @'setResponse'@.
163-- See also @'setResponse'@.
164−setResponseWith :: (Response -> Response -> Response) -> HttpStatusCode -> Declare (Definitions Schema) Response -> Swagger -> Swagger
164+setResponseWith :: (Response -> Response -> Response) -> HttpStatusCode -> Declare (Definitions Schema) Response -> OpenApi -> OpenApi
165setResponseWith = setResponseForWith allOperations
165setResponseWith = setResponseForWith allOperations
166
166
167-- | Set response for specified operations.
167-- | Set response for specified operations.
@@ -170,7 +170,7 @@ setResponseWith = setResponseForWith allOperations
170-- If the response already exists it will be overwritten.
170-- If the response already exists it will be overwritten.
171--
171--
172-- See also @'setResponseForWith'@.
172-- See also @'setResponseForWith'@.
173−setResponseFor :: Traversal' Swagger Operation -> HttpStatusCode -> Declare (Definitions Schema) Response -> Swagger -> Swagger
173+setResponseFor :: Traversal' OpenApi Operation -> HttpStatusCode -> Declare (Definitions Schema) Response -> OpenApi -> OpenApi
174setResponseFor ops code dres swag = swag
174setResponseFor ops code dres swag = swag
175 & components.schemas %~ (<> defs)
175 & components.schemas %~ (<> defs)
176 & ops . at code ?~ Inline res
176 & ops . at code ?~ Inline res
@@ -184,7 +184,7 @@ setResponseFor ops code dres swag = swag
184-- then just the new response is used.
184-- then just the new response is used.
185--
185--
186-- See also @'setResponseFor'@.
186-- See also @'setResponseFor'@.
187−setResponseForWith :: Traversal' Swagger Operation -> (Response -> Response -> Response) -> HttpStatusCode -> Declare (Definitions Schema) Response -> Swagger -> Swagger
187+setResponseForWith :: Traversal' OpenApi Operation -> (Response -> Response -> Response) -> HttpStatusCode -> Declare (Definitions Schema) Response -> OpenApi -> OpenApi
188setResponseForWith ops f code dres swag = swag
188setResponseForWith ops f code dres swag = swag
189 & components.schemas %~ (<> defs)
189 & components.schemas %~ (<> defs)
190 & ops . at code %~ Just . Inline . combine
190 & ops . at code %~ Just . Inline . combine
src/Data/OpenApi/Optics.hs+17−17
@@ -22,8 +22,8 @@
22-- Example from the "Data.OpenApi" module using @optics@:
22-- Example from the "Data.OpenApi" module using @optics@:
23--
23--
24-- >>> :{
24-- >>> :{
25−-- BSL.putStrLn $ encode $ (mempty :: Swagger)
25+-- BSL.putStrLn $ encode $ (mempty :: OpenApi)
26−-- & #components % #schemas .~ [ ("User", mempty & #type ?~ SwaggerString) ]
26+-- & #components % #schemas .~ [ ("User", mempty & #type ?~ OpenApiString) ]
27-- & #paths .~
27-- & #paths .~
28-- [ ("/user", mempty & #get ?~ (mempty
28-- [ ("/user", mempty & #get ?~ (mempty
29-- & at 200 ?~ ("OK" & #_Inline % #content % at "application/json" ?~ (mempty & #schema ?~ Ref (Reference "User")))
29-- & at 200 ?~ ("OK" & #_Inline % #content % at "application/json" ?~ (mempty & #schema ?~ Ref (Reference "User")))
@@ -40,7 +40,7 @@
40-- {"description":"No content"}
40-- {"description":"No content"}
41-- >>> :{
41-- >>> :{
42-- BSL.putStrLn $ encode $ (mempty :: Schema)
42-- BSL.putStrLn $ encode $ (mempty :: Schema)
43−-- & #type ?~ SwaggerBoolean
43+-- & #type ?~ OpenApiBoolean
44-- & #description ?~ "To be or not to be"
44-- & #description ?~ "To be or not to be"
45-- :}
45-- :}
46-- {"type":"boolean","description":"To be or not to be"}
46-- {"type":"boolean","description":"To be or not to be"}
@@ -65,7 +65,7 @@ import Optics.TH
65
65
66-- Lenses
66-- Lenses
67
67
68−makeFieldLabels ''Swagger
68+makeFieldLabels ''OpenApi
69makeFieldLabels ''Components
69makeFieldLabels ''Components
70makeFieldLabels ''Server
70makeFieldLabels ''Server
71makeFieldLabels ''ServerVariable
71makeFieldLabels ''ServerVariable
@@ -103,30 +103,30 @@ makeFieldLabels ''Link
103makePrismLabels ''SecuritySchemeType
103makePrismLabels ''SecuritySchemeType
104makePrismLabels ''Referenced
104makePrismLabels ''Referenced
105
105
106−-- SwaggerItems prisms
106+-- OpenApiItems prisms
107
107
108instance
108instance
109 ( a ~ [Referenced Schema]
109 ( a ~ [Referenced Schema]
110 , b ~ [Referenced Schema]
110 , b ~ [Referenced Schema]
111− ) => LabelOptic "_SwaggerItemsArray"
111+ ) => LabelOptic "_OpenApiItemsArray"
112 A_Review
112 A_Review
113− SwaggerItems
113+ OpenApiItems
114− SwaggerItems
114+ OpenApiItems
115 a
115 a
116 b where
116 b where
117− labelOptic = unto (\x -> SwaggerItemsArray x)
117+ labelOptic = unto (\x -> OpenApiItemsArray x)
118 {-# INLINE labelOptic #-}
118 {-# INLINE labelOptic #-}
119
119
120instance
120instance
121 ( a ~ Referenced Schema
121 ( a ~ Referenced Schema
122 , b ~ Referenced Schema
122 , b ~ Referenced Schema
123− ) => LabelOptic "_SwaggerItemsObject"
123+ ) => LabelOptic "_OpenApiItemsObject"
124 A_Review
124 A_Review
125− SwaggerItems
125+ OpenApiItems
126− SwaggerItems
126+ OpenApiItems
127 a
127 a
128 b where
128 b where
129− labelOptic = unto (\x -> SwaggerItemsObject x)
129+ labelOptic = unto (\x -> OpenApiItemsObject x)
130 {-# INLINE labelOptic #-}
130 {-# INLINE labelOptic #-}
131
131
132-- =============================================================
132-- =============================================================
@@ -155,8 +155,8 @@ instance At Operation where
155-- #type
155-- #type
156
156
157instance
157instance
158− ( a ~ Maybe SwaggerType
158+ ( a ~ Maybe OpenApiType
159− , b ~ Maybe SwaggerType
159+ , b ~ Maybe OpenApiType
160 ) => LabelOptic "type" A_Lens NamedSchema NamedSchema a b where
160 ) => LabelOptic "type" A_Lens NamedSchema NamedSchema a b where
161 labelOptic = #schema % #type
161 labelOptic = #schema % #type
162 {-# INLINE labelOptic #-}
162 {-# INLINE labelOptic #-}
@@ -180,8 +180,8 @@ instance
180-- #items
180-- #items
181
181
182instance
182instance
183− ( a ~ Maybe SwaggerItems
183+ ( a ~ Maybe OpenApiItems
184− , b ~ Maybe SwaggerItems
184+ , b ~ Maybe OpenApiItems
185 ) => LabelOptic "items" A_Lens NamedSchema NamedSchema a b where
185 ) => LabelOptic "items" A_Lens NamedSchema NamedSchema a b where
186 labelOptic = #schema % #items
186 labelOptic = #schema % #items
187 {-# INLINE labelOptic #-}
187 {-# INLINE labelOptic #-}
src/Data/OpenApi/Schema/Generator.hs+9−9
@@ -39,25 +39,25 @@ schemaGen defns schema =
39 [ inferredType ] -> schemaGen defns (schema & type_ ?~ inferredType)
39 [ inferredType ] -> schemaGen defns (schema & type_ ?~ inferredType)
40 -- Gen is not MonadFail
40 -- Gen is not MonadFail
41 _ -> error "unable to infer schema type"
41 _ -> error "unable to infer schema type"
42− Just SwaggerBoolean -> Bool <$> elements [True, False]
42+ Just OpenApiBoolean -> Bool <$> elements [True, False]
43− Just SwaggerNull -> pure Null
43+ Just OpenApiNull -> pure Null
44− Just SwaggerNumber
44+ Just OpenApiNumber
45 | Just min <- schema ^. minimum_
45 | Just min <- schema ^. minimum_
46 , Just max <- schema ^. maximum_ ->
46 , Just max <- schema ^. maximum_ ->
47 Number . fromFloatDigits <$>
47 Number . fromFloatDigits <$>
48 choose (toRealFloat min, toRealFloat max :: Double)
48 choose (toRealFloat min, toRealFloat max :: Double)
49 | otherwise -> Number .fromFloatDigits <$> (arbitrary :: Gen Double)
49 | otherwise -> Number .fromFloatDigits <$> (arbitrary :: Gen Double)
50− Just SwaggerInteger
50+ Just OpenApiInteger
51 | Just min <- schema ^. minimum_
51 | Just min <- schema ^. minimum_
52 , Just max <- schema ^. maximum_ ->
52 , Just max <- schema ^. maximum_ ->
53 Number . fromInteger <$>
53 Number . fromInteger <$>
54 choose (truncate min, truncate max)
54 choose (truncate min, truncate max)
55 | otherwise -> Number . fromInteger <$> arbitrary
55 | otherwise -> Number . fromInteger <$> arbitrary
56− Just SwaggerArray
56+ Just OpenApiArray
57 | Just 0 <- schema ^. maxLength -> pure $ Array V.empty
57 | Just 0 <- schema ^. maxLength -> pure $ Array V.empty
58 | Just items <- schema ^. items ->
58 | Just items <- schema ^. items ->
59 case items of
59 case items of
60− SwaggerItemsObject ref -> do
60+ OpenApiItemsObject ref -> do
61 size <- getSize
61 size <- getSize
62 let itemSchema = dereference defns ref
62 let itemSchema = dereference defns ref
63 minLength' = fromMaybe 0 $ fromInteger <$> schema ^. minItems
63 minLength' = fromMaybe 0 $ fromInteger <$> schema ^. minItems
@@ -65,17 +65,17 @@ schemaGen defns schema =
65 arrayLength <- choose (minLength', max minLength' maxLength')
65 arrayLength <- choose (minLength', max minLength' maxLength')
66 generatedArray <- vectorOf arrayLength $ schemaGen defns itemSchema
66 generatedArray <- vectorOf arrayLength $ schemaGen defns itemSchema
67 return . Array $ V.fromList generatedArray
67 return . Array $ V.fromList generatedArray
68− SwaggerItemsArray refs ->
68+ OpenApiItemsArray refs ->
69 let itemGens = schemaGen defns . dereference defns <$> refs
69 let itemGens = schemaGen defns . dereference defns <$> refs
70 in fmap (Array . V.fromList) $ sequence itemGens
70 in fmap (Array . V.fromList) $ sequence itemGens
71− Just SwaggerString -> do
71+ Just OpenApiString -> do
72 size <- getSize
72 size <- getSize
73 let minLength' = fromMaybe 0 $ fromInteger <$> schema ^. minLength
73 let minLength' = fromMaybe 0 $ fromInteger <$> schema ^. minLength
74 let maxLength' = fromMaybe size $ fromInteger <$> schema ^. maxLength
74 let maxLength' = fromMaybe size $ fromInteger <$> schema ^. maxLength
75 length <- choose (minLength', max minLength' maxLength')
75 length <- choose (minLength', max minLength' maxLength')
76 str <- vectorOf length arbitrary
76 str <- vectorOf length arbitrary
77 return . String $ T.pack str
77 return . String $ T.pack str
78− Just SwaggerObject -> do
78+ Just OpenApiObject -> do
79 size <- getSize
79 size <- getSize
80 let props = dereference defns <$> schema ^. properties
80 let props = dereference defns <$> schema ^. properties
81 reqKeys = S.fromList $ schema ^. required
81 reqKeys = S.fromList $ schema ^. required
src/Data/OpenApi/Schema/Validation.hs+3−3
@@ -71,11 +71,11 @@ import Data.OpenApi.Internal.Schema.Validation
71-- generally fails for @null@ JSON:
71-- generally fails for @null@ JSON:
72--
72--
73-- >>> validateToJSON (Nothing :: Maybe String)
73-- >>> validateToJSON (Nothing :: Maybe String)
74−-- ["expected JSON value of type SwaggerString"]
74+-- ["expected JSON value of type OpenApiString"]
75-- >>> validateToJSON ([Just "hello", Nothing] :: [Maybe String])
75-- >>> validateToJSON ([Just "hello", Nothing] :: [Maybe String])
76−-- ["expected JSON value of type SwaggerString"]
76+-- ["expected JSON value of type OpenApiString"]
77-- >>> validateToJSON (123, Nothing :: Maybe String)
77-- >>> validateToJSON (123, Nothing :: Maybe String)
78−-- ["expected JSON value of type SwaggerString"]
78+-- ["expected JSON value of type OpenApiString"]
79--
79--
80-- However, when @'Maybe' a@ is a type of a record field,
80-- However, when @'Maybe' a@ is a type of a record field,
81-- validation takes @'required'@ property of the @'Schema'@
81-- validation takes @'required'@ property of the @'Schema'@
test/Data/OpenApi/Schema/GeneratorSpec.hs+4−4
@@ -103,7 +103,7 @@ instance FromJSON WrongType where
103instance ToSchema WrongType where
103instance ToSchema WrongType where
104 declareNamedSchema _ = return . NamedSchema (Just "WrongType") $
104 declareNamedSchema _ = return . NamedSchema (Just "WrongType") $
105 mempty
105 mempty
106− & type_ ?~ SwaggerObject
106+ & type_ ?~ OpenApiObject
107
107
108
108
109data MissingRequired = MissingRequired
109data MissingRequired = MissingRequired
@@ -123,7 +123,7 @@ instance ToSchema MissingRequired where
123 boolSchema <- declareSchemaRef (Proxy :: Proxy Bool)
123 boolSchema <- declareSchemaRef (Proxy :: Proxy Bool)
124 return . NamedSchema (Just "MissingRequired") $
124 return . NamedSchema (Just "MissingRequired") $
125 mempty
125 mempty
126− & type_ ?~ SwaggerObject
126+ & type_ ?~ OpenApiObject
127 & properties .~ [("propA", stringSchema)
127 & properties .~ [("propA", stringSchema)
128 ,("propB", boolSchema)
128 ,("propB", boolSchema)
129 ]
129 ]
@@ -145,7 +145,7 @@ instance ToSchema MissingProperty where
145 stringSchema <- declareSchemaRef (Proxy :: Proxy String)
145 stringSchema <- declareSchemaRef (Proxy :: Proxy String)
146 return . NamedSchema (Just "MissingProperty") $
146 return . NamedSchema (Just "MissingProperty") $
147 mempty
147 mempty
148− & type_ ?~ SwaggerObject
148+ & type_ ?~ OpenApiObject
149 & properties .~ [("propC", stringSchema)]
149 & properties .~ [("propC", stringSchema)]
150 & required .~ ["propC"]
150 & required .~ ["propC"]
151
151
@@ -163,6 +163,6 @@ instance ToSchema WrongPropType where
163 boolSchema <- declareSchemaRef (Proxy :: Proxy Bool)
163 boolSchema <- declareSchemaRef (Proxy :: Proxy Bool)
164 return . NamedSchema (Just "WrongPropType") $
164 return . NamedSchema (Just "WrongPropType") $
165 mempty
165 mempty
166− & type_ ?~ SwaggerObject
166+ & type_ ?~ OpenApiObject
167 & properties .~ [("propE", boolSchema)]
167 & properties .~ [("propE", boolSchema)]
168 & required .~ ["propE"]
168 & required .~ ["propE"]
test/Data/OpenApi/Schema/ValidationSpec.hs+1−1
@@ -277,7 +277,7 @@ instance ToJSON FreeForm where
277
277
278instance ToSchema FreeForm where
278instance ToSchema FreeForm where
279 declareNamedSchema _ = pure $ NamedSchema (Just $ T.pack "FreeForm") $ mempty
279 declareNamedSchema _ = pure $ NamedSchema (Just $ T.pack "FreeForm") $ mempty
280− & type_ ?~ SwaggerObject
280+ & type_ ?~ OpenApiObject
281 & additionalProperties ?~ AdditionalPropertiesAllowed True
281 & additionalProperties ?~ AdditionalPropertiesAllowed True
282
282
283instance Arbitrary FreeForm where
283instance Arbitrary FreeForm where
test/Data/OpenApiSpec.hs+32−32
@@ -42,9 +42,9 @@ spec = do
42 context "Todo Example" $ swaggerExample <=> swaggerExampleJSON
42 context "Todo Example" $ swaggerExample <=> swaggerExampleJSON
43 context "PetStore Example" $ do
43 context "PetStore Example" $ do
44 it "decodes successfully" $ do
44 it "decodes successfully" $ do
45− fromJSON petstoreExampleJSON `shouldSatisfy` (\x -> case x of Success (_ :: Swagger) -> True; _ -> False)
45+ fromJSON petstoreExampleJSON `shouldSatisfy` (\x -> case x of Success (_ :: OpenApi) -> True; _ -> False)
46 it "roundtrips: fmap toJSON . fromJSON" $ do
46 it "roundtrips: fmap toJSON . fromJSON" $ do
47− (toJSON :: Swagger -> Value) <$> fromJSON petstoreExampleJSON `shouldBe` Success petstoreExampleJSON
47+ (toJSON :: OpenApi -> Value) <$> fromJSON petstoreExampleJSON `shouldBe` Success petstoreExampleJSON
48
48
49main :: IO ()
49main :: IO ()
50main = hspec spec
50main = hspec spec
@@ -132,15 +132,15 @@ operationExample = mempty
132 & description ?~ "ID of pet that needs to be updated"
132 & description ?~ "ID of pet that needs to be updated"
133 & required ?~ True
133 & required ?~ True
134 & in_ .~ ParamPath
134 & in_ .~ ParamPath
135− & schema ?~ Inline (mempty & type_ ?~ SwaggerString))]
135+ & schema ?~ Inline (mempty & type_ ?~ OpenApiString))]
136 & requestBody ?~ Inline (
136 & requestBody ?~ Inline (
137 mempty & content . at "application/x-www-form-urlencoded" ?~ (mempty & schema ?~ (Inline (mempty
137 mempty & content . at "application/x-www-form-urlencoded" ?~ (mempty & schema ?~ (Inline (mempty
138 & properties . at "petId" ?~ Inline (mempty
138 & properties . at "petId" ?~ Inline (mempty
139 & description ?~ "Updated name of the pet"
139 & description ?~ "Updated name of the pet"
140− & type_ ?~ SwaggerString)
140+ & type_ ?~ OpenApiString)
141 & properties . at "status" ?~ Inline (mempty
141 & properties . at "status" ?~ Inline (mempty
142 & description ?~ "Updated status of the pet"
142 & description ?~ "Updated status of the pet"
143− & type_ ?~ SwaggerString)))))
143+ & type_ ?~ OpenApiString)))))
144 & at 200 ?~ "Pet updated."
144 & at 200 ?~ "Pet updated."
145 & at 405 ?~ "Invalid input"
145 & at 405 ?~ "Invalid input"
146 & security .~ [SecurityRequirement [("petstore_auth", ["write:pets", "read:pets"])]]
146 & security .~ [SecurityRequirement [("petstore_auth", ["write:pets", "read:pets"])]]
@@ -208,7 +208,7 @@ operationExampleJSON = [aesonQQ|
208
208
209schemaPrimitiveExample :: Schema
209schemaPrimitiveExample :: Schema
210schemaPrimitiveExample = mempty
210schemaPrimitiveExample = mempty
211− & type_ ?~ SwaggerString
211+ & type_ ?~ OpenApiString
212 & format ?~ "email"
212 & format ?~ "email"
213
213
214schemaPrimitiveExampleJSON :: Value
214schemaPrimitiveExampleJSON :: Value
@@ -221,14 +221,14 @@ schemaPrimitiveExampleJSON = [aesonQQ|
221
221
222schemaSimpleModelExample :: Schema
222schemaSimpleModelExample :: Schema
223schemaSimpleModelExample = mempty
223schemaSimpleModelExample = mempty
224− & type_ ?~ SwaggerObject
224+ & type_ ?~ OpenApiObject
225 & required .~ [ "name" ]
225 & required .~ [ "name" ]
226 & properties .~
226 & properties .~
227− [ ("name", Inline (mempty & type_ ?~ SwaggerString))
227+ [ ("name", Inline (mempty & type_ ?~ OpenApiString))
228 , ("address", Ref (Reference "Address"))
228 , ("address", Ref (Reference "Address"))
229 , ("age", Inline $ mempty
229 , ("age", Inline $ mempty
230 & minimum_ ?~ 0
230 & minimum_ ?~ 0
231− & type_ ?~ SwaggerInteger
231+ & type_ ?~ OpenApiInteger
232 & format ?~ "int32" ) ]
232 & format ?~ "int32" ) ]
233
233
234schemaSimpleModelExampleJSON :: Value
234schemaSimpleModelExampleJSON :: Value
@@ -253,8 +253,8 @@ schemaSimpleModelExampleJSON = [aesonQQ|
253
253
254schemaModelDictExample :: Schema
254schemaModelDictExample :: Schema
255schemaModelDictExample = mempty
255schemaModelDictExample = mempty
256− & type_ ?~ SwaggerObject
256+ & type_ ?~ OpenApiObject
257− & additionalProperties ?~ AdditionalPropertiesSchema (Inline (mempty & type_ ?~ SwaggerString))
257+ & additionalProperties ?~ AdditionalPropertiesSchema (Inline (mempty & type_ ?~ OpenApiString))
258
258
259schemaModelDictExampleJSON :: Value
259schemaModelDictExampleJSON :: Value
260schemaModelDictExampleJSON = [aesonQQ|
260schemaModelDictExampleJSON = [aesonQQ|
@@ -268,7 +268,7 @@ schemaModelDictExampleJSON = [aesonQQ|
268
268
269schemaAdditionalExample :: Schema
269schemaAdditionalExample :: Schema
270schemaAdditionalExample = mempty
270schemaAdditionalExample = mempty
271− & type_ ?~ SwaggerObject
271+ & type_ ?~ OpenApiObject
272 & additionalProperties ?~ AdditionalPropertiesAllowed True
272 & additionalProperties ?~ AdditionalPropertiesAllowed True
273
273
274schemaAdditionalExampleJSON :: Value
274schemaAdditionalExampleJSON :: Value
@@ -281,13 +281,13 @@ schemaAdditionalExampleJSON = [aesonQQ|
281
281
282schemaWithExampleExample :: Schema
282schemaWithExampleExample :: Schema
283schemaWithExampleExample = mempty
283schemaWithExampleExample = mempty
284− & type_ ?~ SwaggerObject
284+ & type_ ?~ OpenApiObject
285 & properties .~
285 & properties .~
286 [ ("id", Inline $ mempty
286 [ ("id", Inline $ mempty
287− & type_ ?~ SwaggerInteger
287+ & type_ ?~ OpenApiInteger
288 & format ?~ "int64" )
288 & format ?~ "int64" )
289 , ("name", Inline $ mempty
289 , ("name", Inline $ mempty
290− & type_ ?~ SwaggerString) ]
290+ & type_ ?~ OpenApiString) ]
291 & required .~ [ "name" ]
291 & required .~ [ "name" ]
292 & example ?~ [aesonQQ|
292 & example ?~ [aesonQQ|
293 {
293 {
@@ -326,19 +326,19 @@ schemaWithExampleExampleJSON = [aesonQQ|
326definitionsExample :: HashMap Text Schema
326definitionsExample :: HashMap Text Schema
327definitionsExample =
327definitionsExample =
328 [ ("Category", mempty
328 [ ("Category", mempty
329− & type_ ?~ SwaggerObject
329+ & type_ ?~ OpenApiObject
330 & properties .~
330 & properties .~
331 [ ("id", Inline $ mempty
331 [ ("id", Inline $ mempty
332− & type_ ?~ SwaggerInteger
332+ & type_ ?~ OpenApiInteger
333 & format ?~ "int64")
333 & format ?~ "int64")
334− , ("name", Inline (mempty & type_ ?~ SwaggerString)) ] )
334+ , ("name", Inline (mempty & type_ ?~ OpenApiString)) ] )
335 , ("Tag", mempty
335 , ("Tag", mempty
336− & type_ ?~ SwaggerObject
336+ & type_ ?~ OpenApiObject
337 & properties .~
337 & properties .~
338 [ ("id", Inline $ mempty
338 [ ("id", Inline $ mempty
339− & type_ ?~ SwaggerInteger
339+ & type_ ?~ OpenApiInteger
340 & format ?~ "int64")
340 & format ?~ "int64")
341− , ("name", Inline (mempty & type_ ?~ SwaggerString)) ] ) ]
341+ , ("name", Inline (mempty & type_ ?~ OpenApiString)) ] ) ]
342
342
343definitionsExampleJSON :: Value
343definitionsExampleJSON :: Value
344definitionsExampleJSON = [aesonQQ|
344definitionsExampleJSON = [aesonQQ|
@@ -382,7 +382,7 @@ paramsDefinitionExample =
382 & required ?~ True
382 & required ?~ True
383 & in_ .~ ParamQuery
383 & in_ .~ ParamQuery
384 & schema ?~ Inline (mempty
384 & schema ?~ Inline (mempty
385− & type_ ?~ SwaggerInteger
385+ & type_ ?~ OpenApiInteger
386 & format ?~ "int32" ))
386 & format ?~ "int32" ))
387 , ("limitParam", mempty
387 , ("limitParam", mempty
388 & name .~ "limit"
388 & name .~ "limit"
@@ -390,7 +390,7 @@ paramsDefinitionExample =
390 & required ?~ True
390 & required ?~ True
391 & in_ .~ ParamQuery
391 & in_ .~ ParamQuery
392 & schema ?~ Inline (mempty
392 & schema ?~ Inline (mempty
393− & type_ ?~ SwaggerInteger
393+ & type_ ?~ OpenApiInteger
394 & format ?~ "int32" )) ]
394 & format ?~ "int32" )) ]
395
395
396paramsDefinitionExampleJSON :: Value
396paramsDefinitionExampleJSON :: Value
@@ -531,7 +531,7 @@ oAuth2SecurityDefinitionsExampleJSON = [aesonQQ|
531-- Swagger object
531-- Swagger object
532-- =======================================================================
532-- =======================================================================
533
533
534−emptyPathsFieldExample :: Swagger
534+emptyPathsFieldExample :: OpenApi
535emptyPathsFieldExample = mempty
535emptyPathsFieldExample = mempty
536
536
537emptyPathsFieldExampleJSON :: Value
537emptyPathsFieldExampleJSON :: Value
@@ -544,7 +544,7 @@ emptyPathsFieldExampleJSON = [aesonQQ|
544}
544}
545|]
545|]
546
546
547−swaggerExample :: Swagger
547+swaggerExample :: OpenApi
548swaggerExample = mempty
548swaggerExample = mempty
549 -- & basePath ?~ "/"
549 -- & basePath ?~ "/"
550 -- & schemes ?~ [Http]
550 -- & schemes ?~ [Http]
@@ -559,7 +559,7 @@ swaggerExample = mempty
559 & description .~ "OK"
559 & description .~ "OK"
560 & content . at "application/json" ?~ (mempty
560 & content . at "application/json" ?~ (mempty
561 & schema ?~ Inline (mempty
561 & schema ?~ Inline (mempty
562− & type_ ?~ SwaggerObject
562+ & type_ ?~ OpenApiObject
563 & example ?~ [aesonQQ|
563 & example ?~ [aesonQQ|
564 {
564 {
565 "created": 100,
565 "created": 100,
@@ -568,9 +568,9 @@ swaggerExample = mempty
568 & description ?~ "This is some real Todo right here"
568 & description ?~ "This is some real Todo right here"
569 & properties .~
569 & properties .~
570 [ ("created", Inline $ mempty
570 [ ("created", Inline $ mempty
571− & type_ ?~ SwaggerInteger
571+ & type_ ?~ OpenApiInteger
572 & format ?~ "int32")
572 & format ?~ "int32")
573− , ("description", Inline (mempty & type_ ?~ SwaggerString))])))
573+ , ("description", Inline (mempty & type_ ?~ OpenApiString))])))
574 & parameters .~
574 & parameters .~
575 [ Inline $ mempty
575 [ Inline $ mempty
576 & required ?~ True
576 & required ?~ True
@@ -578,7 +578,7 @@ swaggerExample = mempty
578 & description ?~ "TodoId param"
578 & description ?~ "TodoId param"
579 & in_ .~ ParamPath
579 & in_ .~ ParamPath
580 & schema ?~ Inline (mempty
580 & schema ?~ Inline (mempty
581− & type_ ?~ SwaggerString ) ]
581+ & type_ ?~ OpenApiString ) ]
582 & tags .~ InsOrdHS.fromList [ "todo" ] ))
582 & tags .~ InsOrdHS.fromList [ "todo" ] ))
583
583
584swaggerExampleJSON :: Value
584swaggerExampleJSON :: Value
@@ -917,14 +917,14 @@ petstoreExampleJSON = [aesonQQ|
917
917
918compositionSchemaExample :: Schema
918compositionSchemaExample :: Schema
919compositionSchemaExample = mempty
919compositionSchemaExample = mempty
920− & type_ ?~ SwaggerObject
920+ & type_ ?~ OpenApiObject
921 & Data.OpenApi.allOf ?~ [
921 & Data.OpenApi.allOf ?~ [
922 Ref (Reference "Other")
922 Ref (Reference "Other")
923 , Inline (mempty
923 , Inline (mempty
924− & type_ ?~ SwaggerObject
924+ & type_ ?~ OpenApiObject
925 & properties .~
925 & properties .~
926 [ ("greet", Inline $ mempty
926 [ ("greet", Inline $ mempty
927− & type_ ?~ SwaggerString) ])
927+ & type_ ?~ OpenApiString) ])
928 ]
928 ]
929
929
930compositionSchemaExampleJSON :: Value
930compositionSchemaExampleJSON :: Value