@@ -68,56 +68,28 @@ data Swagger = Swagger
68 -- The metadata can be used by the clients if needed.
68 -- The metadata can be used by the clients if needed.
69 _swaggerInfo :: Info
69 _swaggerInfo :: Info
71− -- | The host (name or ip) serving the API. It MAY include a port.
71+ -- | An array of Server Objects, which provide connectivity information
72− -- If the host is not included, the host serving the documentation is to be used (including the port).
72+ -- to a target server. If the servers property is not provided, or is an empty array,
73− , _swaggerHost :: Maybe Host
73+ -- the default value would be a 'Server' object with a url value of @/@.
74−
74+ , _swaggerServers :: [Server]
75− -- | The base path on which the API is served, which is relative to the host.
76− -- If it is not included, the API is served directly under the host.
77− -- The value MUST start with a leading slash (/).
78− , _swaggerBasePath :: Maybe FilePath
80− -- | The transfer protocol of the API.
81− -- If the schemes is not included, the default scheme to be used is the one used to access the Swagger definition itself.
82− , _swaggerSchemes :: Maybe [Scheme]
84− -- | A list of MIME types the APIs can consume.
85− -- This is global to all APIs but can be overridden on specific API calls.
86− , _swaggerConsumes :: MimeList
88− -- | A list of MIME types the APIs can produce.
89− -- This is global to all APIs but can be overridden on specific API calls.
90− , _swaggerProduces :: MimeList
92 -- | The available paths and operations for the API.
76 -- | The available paths and operations for the API.
93− -- Holds the relative paths to the individual endpoints.
94− -- The path is appended to the @'basePath'@ in order to construct the full URL.
95 , _swaggerPaths :: InsOrdHashMap FilePath PathItem
77 , _swaggerPaths :: InsOrdHashMap FilePath PathItem
97− -- | An object to hold data types produced and consumed by operations.
79+ -- | An element to hold various schemas for the specification.
98− , _swaggerDefinitions :: Definitions Schema
80+ , _swaggerComponents :: Components
100− -- | An object to hold parameters that can be used across operations.
101− -- This property does not define global parameters for all operations.
102− , _swaggerParameters :: Definitions Param
104− -- | An object to hold responses that can be used across operations.
105− -- This property does not define global responses for all operations.
106− , _swaggerResponses :: Definitions Response
108− -- | Security scheme definitions that can be used across the specification.
109− , _swaggerSecurityDefinitions :: SecurityDefinitions
111− -- | A declaration of which security schemes are applied for the API as a whole.
82+ -- | A declaration of which security mechanisms can be used across the API.
112− -- The list of values describes alternative security schemes that can be used
83+ -- The list of values includes alternative security requirement objects that can be used.
113− -- (that is, there is a logical OR between the security requirements).
84+ -- Only one of the security requirement objects need to be satisfied to authorize a request.
114 -- Individual operations can override this definition.
85 -- Individual operations can override this definition.
86+ -- To make security optional, an empty security requirement can be included in the array.
115 , _swaggerSecurity :: [SecurityRequirement]
87 , _swaggerSecurity :: [SecurityRequirement]
117 -- | A list of tags used by the specification with additional metadata.
89 -- | A list of tags used by the specification with additional metadata.
118 -- The order of the tags can be used to reflect on their order by the parsing tools.
90 -- The order of the tags can be used to reflect on their order by the parsing tools.
119− -- Not all tags that are used by the Operation Object must be declared.
91+ -- Not all tags that are used by the 'Operation' Object must be declared.
120− -- The tags that are not declared may be organized randomly or based on the tools' logic.
92+ -- The tags that are not declared MAY be organized randomly or based on the tools' logic.
121 -- Each tag name in the list MUST be unique.
93 -- Each tag name in the list MUST be unique.
122 , _swaggerTags :: InsOrdHashSet Tag
94 , _swaggerTags :: InsOrdHashSet Tag
@@ -126,17 +98,17 @@ data Swagger = Swagger
126 } deriving (Eq, Show, Generic, Data, Typeable)
98 } deriving (Eq, Show, Generic, Data, Typeable)
128-- | The object provides metadata about the API.
100-- | The object provides metadata about the API.
129−-- The metadata can be used by the clients if needed,
101+-- The metadata MAY be used by the clients if needed,
130−-- and can be presented in the Swagger-UI for convenience.
102+-- and MAY be presented in editing or documentation generation tools for convenience.
131data Info = Info
103data Info = Info
132− { -- | The title of the application.
104+ { -- | The title of the API.
133 _infoTitle :: Text
105 _infoTitle :: Text
135− -- | A short description of the application.
107+ -- | A short description of the API.
136− -- GFM syntax can be used for rich text representation.
108+ -- [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
137 , _infoDescription :: Maybe Text
109 , _infoDescription :: Maybe Text
139− -- | The Terms of Service for the API.
111+ -- | A URL to the Terms of Service for the API. MUST be in the format of a URL.
140 , _infoTermsOfService :: Maybe Text
112 , _infoTermsOfService :: Maybe Text
142 -- | The contact information for the exposed API.
114 -- | The contact information for the exposed API.
@@ -145,8 +117,8 @@ data Info = Info
145 -- | The license information for the exposed API.
117 -- | The license information for the exposed API.
146 , _infoLicense :: Maybe License
118 , _infoLicense :: Maybe License
148− -- | Provides the version of the application API
120+ -- | The version of the OpenAPI document (which is distinct from the
149− -- (not to be confused with the specification version).
121+ -- OpenAPI Specification version or the API implementation version).
150 , _infoVersion :: Text
122 , _infoVersion :: Text
151 } deriving (Eq, Show, Generic, Data, Typeable)
123 } deriving (Eq, Show, Generic, Data, Typeable)
@@ -174,6 +146,54 @@ data License = License
174instance IsString License where
146instance IsString License where
175 fromString s = License (fromString s) Nothing
147 fromString s = License (fromString s) Nothing
149+-- | An object representing a Server.
151+ { -- | A URL to the target host. This URL supports Server Variables and MAY be relative,
152+ -- to indicate that the host location is relative to the location where
153+ -- the OpenAPI document is being served. Variable substitutions will be made when
154+ -- a variable is named in @{brackets}@.
157+ -- | An optional string describing the host designated by the URL.
158+ -- [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
159+ , _serverDescription :: Maybe Text
161+ -- | A map between a variable name and its value.
162+ -- The value is used for substitution in the server's URL template.
163+ , _serverVariables :: InsOrdHashMap Text ServerVariable
164+ } deriving (Eq, Show, Generic, Data, Typeable)
166+data ServerVariable = ServerVariable
167+ { -- | An enumeration of string values to be used if the substitution options
168+ -- are from a limited set. The array SHOULD NOT be empty.
169+ _serverVariableEnum :: Maybe (InsOrdHashSet Text) -- TODO NonEmpty
171+ -- | The default value to use for substitution, which SHALL be sent if an alternate value
172+ -- is not supplied. Note this behavior is different than the 'Schema\ Object's treatment
173+ -- of default values, because in those cases parameter values are optional.
174+ -- If the '_serverVariableEnum' is defined, the value SHOULD exist in the enum's values.
175+ , _serverVariableDefault :: Text
177+ -- | An optional description for the server variable.
178+ -- [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
179+ , _serverVariableDescription :: Maybe Text
180+ } deriving (Eq, Show, Generic, Data, Typeable)
182+-- | Holds a set of reusable objects for different aspects of the OAS.
183+-- All objects defined within the components object will have no effect on the API
184+-- unless they are explicitly referenced from properties outside the components object.
185+data Components = Components
186+ { _componentsSchemas :: Definitions Schema -- TODO check Schema itself
187+ , _componentsResponses :: Definitions Response
188+ , _componentsParameters :: Definitions Param
189+-- , _componentsExamples
190+ , _componentsRequestBodies :: Definitions RequestBody
191+ , _componentsHeader :: Definitions Header
192+ , _componentsSecuritySchemes :: Definitions SecurityScheme
193+-- , _componentsLinks
194+-- , _componentsCallbacks
195+ } deriving (Eq, Show, Generic, Data, Typeable)
177-- | The host (name or ip) serving the API. It MAY include a port.
197-- | The host (name or ip) serving the API. It MAY include a port.
178data Host = Host
198data Host = Host
179 { _hostName :: HostName -- ^ Host name.
199 { _hostName :: HostName -- ^ Host name.
@@ -209,8 +229,15 @@ data Scheme
209-- The path itself is still exposed to the documentation viewer
229-- The path itself is still exposed to the documentation viewer
210-- but they will not know which operations and parameters are available.
230-- but they will not know which operations and parameters are available.
211data PathItem = PathItem
231data PathItem = PathItem
232+ { -- | An optional, string summary, intended to apply to all operations in this path.
233+ _pathItemSummary :: Maybe Text
235+ -- | An optional, string description, intended to apply to all operations in this path.
236+ -- [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
237+ , _pathItemDescription :: Maybe Text
212− { -- | A definition of a GET operation on this path.
239+ -- | A definition of a GET operation on this path.
213− _pathItemGet :: Maybe Operation
240+ , _pathItemGet :: Maybe Operation
215 -- | A definition of a PUT operation on this path.
242 -- | A definition of a PUT operation on this path.
216 , _pathItemPut :: Maybe Operation
243 , _pathItemPut :: Maybe Operation
@@ -230,6 +257,12 @@ data PathItem = PathItem
230 -- | A definition of a PATCH operation on this path.
257 -- | A definition of a PATCH operation on this path.
231 , _pathItemPatch :: Maybe Operation
258 , _pathItemPatch :: Maybe Operation
260+ -- | A definition of a TRACE operation on this path.
261+ , _pathItemTrace :: Maybe Operation
263+ -- | An alternative server array to service all operations in this path.
264+ , _pathItemServers :: [Server]
233 -- | A list of parameters that are applicable for all the operations described under this path.
266 -- | A list of parameters that are applicable for all the operations described under this path.
234 -- These parameters can be overridden at the operation level, but cannot be removed there.
267 -- These parameters can be overridden at the operation level, but cannot be removed there.
235 -- The list MUST NOT include duplicated parameters.
268 -- The list MUST NOT include duplicated parameters.
@@ -248,7 +281,7 @@ data Operation = Operation
248 , _operationSummary :: Maybe Text
281 , _operationSummary :: Maybe Text
250 -- | A verbose explanation of the operation behavior.
283 -- | A verbose explanation of the operation behavior.
251− -- GFM syntax can be used for rich text representation.
284+ -- [CommonMark syntax](https://spec.commonmark.org/) can be used for rich text representation.
252 , _operationDescription :: Maybe Text
285 , _operationDescription :: Maybe Text
254 -- | Additional external documentation for this operation.
287 -- | Additional external documentation for this operation.
@@ -256,20 +289,11 @@ data Operation = Operation
257 -- | Unique string used to identify the operation.
290 -- | Unique string used to identify the operation.
258 -- The id MUST be unique among all operations described in the API.
291 -- The id MUST be unique among all operations described in the API.
292+ -- The operationId value is **case-sensitive**.
259− -- Tools and libraries MAY use the it to uniquely identify an operation,
293+ -- Tools and libraries MAY use the operationId to uniquely identify an operation, therefore,
260− -- therefore, it is recommended to follow common programming naming conventions.
294+ -- it is RECOMMENDED to follow common programming naming conventions.
261 , _operationOperationId :: Maybe Text
295 , _operationOperationId :: Maybe Text
263− -- | A list of MIME types the operation can consume.
264− -- This overrides the @'consumes'@.
265− -- @Just []@ MAY be used to clear the global definition.
266− , _operationConsumes :: Maybe MimeList
268− -- | A list of MIME types the operation can produce.
269− -- This overrides the @'produces'@.
270− -- @Just []@ MAY be used to clear the global definition.
271− , _operationProduces :: Maybe MimeList
273 -- | A list of parameters that are applicable for this operation.
297 -- | A list of parameters that are applicable for this operation.
274 -- If a parameter is already defined at the @'PathItem'@,
298 -- If a parameter is already defined at the @'PathItem'@,
275 -- the new definition will override it, but can never remove it.
299 -- the new definition will override it, but can never remove it.
@@ -277,12 +301,17 @@ data Operation = Operation
277 -- A unique parameter is defined by a combination of a name and location.
301 -- A unique parameter is defined by a combination of a name and location.
278 , _operationParameters :: [Referenced Param]
302 , _operationParameters :: [Referenced Param]
304+ -- | The request body applicable for this operation.
305+ -- The requestBody is only supported in HTTP methods where the HTTP 1.1
306+ -- specification [RFC7231](https://tools.ietf.org/html/rfc7231#section-4.3.1)
307+ -- has explicitly defined semantics for request bodies.
308+ -- In other cases where the HTTP spec is vague, requestBody SHALL be ignored by consumers.
309+ , _operationRequestBody :: Maybe (Referenced RequestBody)
280 -- | The list of possible responses as they are returned from executing this operation.
311 -- | The list of possible responses as they are returned from executing this operation.
281 , _operationResponses :: Responses
312 , _operationResponses :: Responses
283− -- | The transfer protocol for the operation.
314+ -- TODO callbacks
284− -- The value overrides @'schemes'@.
285− , _operationSchemes :: Maybe [Scheme]
287 -- | Declares this operation to be deprecated.
316 -- | Declares this operation to be deprecated.
288 -- Usage of the declared operation should be refrained.
317 -- Usage of the declared operation should be refrained.
@@ -295,6 +324,37 @@ data Operation = Operation
295 -- This definition overrides any declared top-level security.
324 -- This definition overrides any declared top-level security.
296 -- To remove a top-level security declaration, @Just []@ can be used.
325 -- To remove a top-level security declaration, @Just []@ can be used.
297 , _operationSecurity :: [SecurityRequirement]
326 , _operationSecurity :: [SecurityRequirement]
328+ -- | An alternative server array to service this operation.
329+ -- If an alternative server object is specified at the 'PathItem' Object or Root level,
330+ -- it will be overridden by this value.
331+ , _operationServers :: [Server]
332+ } deriving (Eq, Show, Generic, Data, Typeable)
334+-- | Describes a single request body.
335+data RequestBody = RequestBody
336+ { -- | A brief description of the request body. This could contain examples of use.
337+ -- [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
338+ _requestBodyDescription :: Maybe Text
340+ -- | The content of the request body.
341+ -- The key is a media type or media type range and the value describes it.
342+ -- For requests that match multiple keys, only the most specific key is applicable.
343+ -- e.g. @text/plain@ overrides @text/*@
344+ , _requestBodyContent :: InsOrdHashMap {-MediaType-} Text MediaTypeObject -- FIXME Data MediaType
346+ , _requestBodyRequired :: Maybe Bool
347+ } deriving (Eq, Show, Generic, Data, Typeable)
349+-- | Each Media Type Object provides schema and examples for the media type identified by its key.
350+data MediaTypeObject = MediaTypeObject
351+ { _mediaTypeSchema :: Maybe (Referenced Schema)
354+-- , _mediaTypeExample
355+-- , _mediaTypeExamples
357+-- , _mediaTypeEncoding :: InsOrdHashMap Text Encoding
298 } deriving (Eq, Show, Generic, Data, Typeable)
358 } deriving (Eq, Show, Generic, Data, Typeable)
300newtype MimeList = MimeList { getMimeList :: [MediaType] }
360newtype MimeList = MimeList { getMimeList :: [MediaType] }
@@ -494,14 +554,8 @@ data ParamLocation
494 -- This does not include the host or base path of the API.
554 -- This does not include the host or base path of the API.
495 -- For example, in @/items/{itemId}@, the path parameter is @itemId@.
555 -- For example, in @/items/{itemId}@, the path parameter is @itemId@.
496 | ParamPath
556 | ParamPath
497− -- | Used to describe the payload of an HTTP request when either @application/x-www-form-urlencoded@
557+ -- | Used to pass a specific cookie value to the API.
498− -- or @multipart/form-data@ are used as the content type of the request
558+ | ParamCookie
499− -- (in Swagger's definition, the @consumes@ property of an operation).
500− -- This is the only parameter type that can be used to send files, thus supporting the @'ParamFile'@ type.
501− -- Since form parameters are sent in the payload, they cannot be declared together with a body parameter for the same operation.
502− -- Form parameters have a different format based on the content-type used
503− -- (for further details, consult <http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4>).
505 deriving (Eq, Show, Generic, Data, Typeable)
559 deriving (Eq, Show, Generic, Data, Typeable)
507type Format = Text
561type Format = Text
@@ -650,25 +704,23 @@ type HttpStatusCode = Int
650-- | Describes a single response from an API Operation.
704-- | Describes a single response from an API Operation.
651data Response = Response
705data Response = Response
652 { -- | A short description of the response.
706 { -- | A short description of the response.
653− -- GFM syntax can be used for rich text representation.
707+ -- [CommonMark syntax](https://spec.commonmark.org/) can be used for rich text representation.
654 _responseDescription :: Text
708 _responseDescription :: Text
656− -- | A definition of the response structure.
710+ -- | A map containing descriptions of potential response payloads.
657− -- It can be a primitive, an array or an object.
711+ -- The key is a media type or media type range and the value describes it.
658− -- If this field does not exist, it means no content is returned as part of the response.
712+ -- For responses that match multiple keys, only the most specific key is applicable.
659− -- As an extension to the Schema Object, its root type value may also be "file".
713+ -- e.g. @text/plain@ overrides @text/*@.
660− -- This SHOULD be accompanied by a relevant produces mime-type.
714+ , _responseContent :: InsOrdHashMap Text MediaTypeObject
661− , _responseSchema :: Maybe (Referenced Schema)
663− -- | A list of headers that are sent with the response.
716+ -- | Maps a header name to its definition.
664− , _responseHeaders :: InsOrdHashMap HeaderName Header
717+ , _responseHeaders :: InsOrdHashMap HeaderName Header -- FIXME Referenced
666− -- | An example of the response message.
719+ -- TODO links
667− , _responseExamples :: Maybe Example
668 } deriving (Eq, Show, Generic, Data, Typeable)
720 } deriving (Eq, Show, Generic, Data, Typeable)
670instance IsString Response where
722instance IsString Response where
671− fromString s = Response (fromString s) Nothing mempty Nothing
723+ fromString s = Response (fromString s) mempty mempty
673type HeaderName = Text
725type HeaderName = Text
@@ -699,6 +751,7 @@ instance Data Example where
699data ApiKeyLocation
751data ApiKeyLocation
700 = ApiKeyQuery
752 = ApiKeyQuery
701 | ApiKeyHeader
753 | ApiKeyHeader
702 deriving (Eq, Show, Generic, Data, Typeable)
755 deriving (Eq, Show, Generic, Data, Typeable)
704data ApiKeyParams = ApiKeyParams
757data ApiKeyParams = ApiKeyParams
@@ -731,9 +784,10 @@ data OAuth2Params = OAuth2Params
731 } deriving (Eq, Show, Generic, Data, Typeable)
784 } deriving (Eq, Show, Generic, Data, Typeable)
733data SecuritySchemeType
786data SecuritySchemeType
734− = SecuritySchemeBasic
787+ = SecuritySchemeHttp
735 | SecuritySchemeApiKey ApiKeyParams
788 | SecuritySchemeApiKey ApiKeyParams
736 | SecuritySchemeOAuth2 OAuth2Params
789 | SecuritySchemeOAuth2 OAuth2Params
790+-- | SecuritySchemeOpenIdConnect -- FIXME
737 deriving (Eq, Show, Generic, Data, Typeable)
791 deriving (Eq, Show, Generic, Data, Typeable)
739data SecurityScheme = SecurityScheme
793data SecurityScheme = SecurityScheme
@@ -825,6 +879,7 @@ data AdditionalProperties
825-- Generic instances
879-- Generic instances
826-------------------------------------------------------------------------------
880-------------------------------------------------------------------------------
882+deriveGeneric ''Components
828deriveGeneric ''Header
883deriveGeneric ''Header
829deriveGeneric ''OAuth2Params
884deriveGeneric ''OAuth2Params
830deriveGeneric ''Operation
885deriveGeneric ''Operation
@@ -832,6 +887,8 @@ deriveGeneric ''Param
832deriveGeneric ''ParamOtherSchema
887deriveGeneric ''ParamOtherSchema
833deriveGeneric ''PathItem
888deriveGeneric ''PathItem
834deriveGeneric ''Response
889deriveGeneric ''Response
890+deriveGeneric ''RequestBody
891+deriveGeneric ''MediaTypeObject
835deriveGeneric ''Responses
892deriveGeneric ''Responses
836deriveGeneric ''SecurityScheme
893deriveGeneric ''SecurityScheme
837deriveGeneric ''Schema
894deriveGeneric ''Schema
@@ -860,6 +917,12 @@ instance Monoid Contact where
860 mempty = genericMempty
917 mempty = genericMempty
861 mappend = (<>)
918 mappend = (<>)
920+instance Semigroup Components where
921+ (<>) = genericMappend
922+instance Monoid Components where
923+ mempty = genericMempty
863instance Semigroup PathItem where
926instance Semigroup PathItem where
864 (<>) = genericMappend
927 (<>) = genericMappend
865instance Monoid PathItem where
928instance Monoid PathItem where
@@ -942,6 +1005,7 @@ instance Monoid SecurityDefinitions where
942-- =======================================================================
1005-- =======================================================================
944instance SwaggerMonoid Info
1007instance SwaggerMonoid Info
1008+instance SwaggerMonoid Components
945instance SwaggerMonoid PathItem
1009instance SwaggerMonoid PathItem
946instance SwaggerMonoid Schema
1010instance SwaggerMonoid Schema
947instance SwaggerMonoid (ParamSchema t)
1011instance SwaggerMonoid (ParamSchema t)
@@ -996,6 +1060,12 @@ instance ToJSON Contact where
996instance ToJSON License where
1060instance ToJSON License where
997 toJSON = genericToJSON (jsonPrefix "License")
1061 toJSON = genericToJSON (jsonPrefix "License")
1063+instance ToJSON Server where
1064+ toJSON = genericToJSON (jsonPrefix "Server")
1066+instance ToJSON ServerVariable where
1067+ toJSON = genericToJSON (jsonPrefix "ServerVariable")
999instance ToJSON ApiKeyLocation where
1069instance ToJSON ApiKeyLocation where
1000 toJSON = genericToJSON (jsonPrefix "ApiKey")
1070 toJSON = genericToJSON (jsonPrefix "ApiKey")
@@ -1030,6 +1100,12 @@ instance FromJSON Contact where
1030instance FromJSON License where
1100instance FromJSON License where
1031 parseJSON = genericParseJSON (jsonPrefix "License")
1101 parseJSON = genericParseJSON (jsonPrefix "License")
1103+instance FromJSON Server where
1104+ parseJSON = genericParseJSON (jsonPrefix "Server")
1106+instance FromJSON ServerVariable where
1107+ parseJSON = genericParseJSON (jsonPrefix "ServerVariable")
1033instance FromJSON ApiKeyLocation where
1109instance FromJSON ApiKeyLocation where
1034 parseJSON = genericParseJSON (jsonPrefix "ApiKey")
1110 parseJSON = genericParseJSON (jsonPrefix "ApiKey")
@@ -1069,8 +1145,8 @@ instance ToJSON OAuth2Params where
1069 toEncoding = sopSwaggerGenericToEncoding
1145 toEncoding = sopSwaggerGenericToEncoding
1071instance ToJSON SecuritySchemeType where
1147instance ToJSON SecuritySchemeType where
1072− toJSON SecuritySchemeBasic
1148+ toJSON SecuritySchemeHttp
1073− = object [ "type" .= ("basic" :: Text) ]
1149+ = object [ "type" .= ("http" :: Text) ]
1074 toJSON (SecuritySchemeApiKey params)
1150 toJSON (SecuritySchemeApiKey params)
1075 = toJSON params
1151 = toJSON params
1076 <+> object [ "type" .= ("apiKey" :: Text) ]
1152 <+> object [ "type" .= ("apiKey" :: Text) ]
@@ -1115,6 +1191,10 @@ instance ToJSON (ParamSchema t) => ToJSON (SwaggerItems t) where
1116 toJSON (SwaggerItemsArray x) = object [ "items" .= x ]
1192 toJSON (SwaggerItemsArray x) = object [ "items" .= x ]
1194+instance ToJSON Components where
1195+ toJSON = sopSwaggerGenericToJSON
1196+ toEncoding = sopSwaggerGenericToEncoding
1118instance ToJSON Host where
1198instance ToJSON Host where
1119 toJSON (Host host mport) = toJSON $
1199 toJSON (Host host mport) = toJSON $
1120 case mport of
1200 case mport of
@@ -1152,6 +1232,14 @@ instance ToJSON PathItem where
1152 toJSON = sopSwaggerGenericToJSON
1232 toJSON = sopSwaggerGenericToJSON
1153 toEncoding = sopSwaggerGenericToEncoding
1233 toEncoding = sopSwaggerGenericToEncoding
1235+instance ToJSON RequestBody where
1236+ toJSON = sopSwaggerGenericToJSON
1237+ toEncoding = sopSwaggerGenericToEncoding
1239+instance ToJSON MediaTypeObject where
1240+ toJSON = sopSwaggerGenericToJSON
1241+ toEncoding = sopSwaggerGenericToEncoding
1155instance ToJSON Example where
1243instance ToJSON Example where
1156 toJSON = toJSON . Map.mapKeys show . getExample
1244 toJSON = toJSON . Map.mapKeys show . getExample
@@ -1165,9 +1253,11 @@ referencedToJSON :: ToJSON a => Text -> Referenced a -> Value
1165referencedToJSON prefix (Ref (Reference ref)) = object [ "$ref" .= (prefix <> ref) ]
1253referencedToJSON prefix (Ref (Reference ref)) = object [ "$ref" .= (prefix <> ref) ]
1166referencedToJSON _ (Inline x) = toJSON x
1254referencedToJSON _ (Inline x) = toJSON x
1168instance ToJSON (Referenced Schema) where toJSON = referencedToJSON "#/definitions/"
1257instance ToJSON (Referenced Schema) where toJSON = referencedToJSON "#/definitions/"
1169instance ToJSON (Referenced Param) where toJSON = referencedToJSON "#/parameters/"
1258instance ToJSON (Referenced Param) where toJSON = referencedToJSON "#/parameters/"
1170instance ToJSON (Referenced Response) where toJSON = referencedToJSON "#/responses/"
1259instance ToJSON (Referenced Response) where toJSON = referencedToJSON "#/responses/"
1260+instance ToJSON (Referenced RequestBody) where toJSON = referencedToJSON "#/!!!!/"
1172instance ToJSON (SwaggerType t) where
1262instance ToJSON (SwaggerType t) where
1173 toJSON SwaggerArray = "array"
1263 toJSON SwaggerArray = "array"
@@ -1219,7 +1309,7 @@ instance FromJSON SecuritySchemeType where
1219 parseJSON js@(Object o) = do
1309 parseJSON js@(Object o) = do
1220 (t :: Text) <- o .: "type"
1310 (t :: Text) <- o .: "type"
1221 case t of
1311 case t of
1222− "basic" -> pure SecuritySchemeBasic
1312+ "http" -> pure SecuritySchemeHttp
1223 "apiKey" -> SecuritySchemeApiKey <$> parseJSON js
1313 "apiKey" -> SecuritySchemeApiKey <$> parseJSON js
1224 "oauth2" -> SecuritySchemeOAuth2 <$> parseJSON js
1314 "oauth2" -> SecuritySchemeOAuth2 <$> parseJSON js
1225 _ -> empty
1315 _ -> empty
@@ -1271,6 +1361,9 @@ instance FromJSON (SwaggerItems 'SwaggerKindSchema) where
1271 parseJSON js@(Array _) = SwaggerItemsArray <$> parseJSON js
1361 parseJSON js@(Array _) = SwaggerItemsArray <$> parseJSON js
1272 parseJSON _ = empty
1362 parseJSON _ = empty
1364+instance FromJSON Components where
1365+ parseJSON = sopSwaggerGenericParseJSON
1274instance FromJSON Host where
1367instance FromJSON Host where
1275 parseJSON (String s) = case map Text.unpack $ Text.split (== ':') s of
1368 parseJSON (String s) = case map Text.unpack $ Text.split (== ':') s of
1276 [host] -> return $ Host host Nothing
1369 [host] -> return $ Host host Nothing
@@ -1319,6 +1412,12 @@ instance FromJSON Operation where
1319instance FromJSON PathItem where
1412instance FromJSON PathItem where
1320 parseJSON = sopSwaggerGenericParseJSON
1413 parseJSON = sopSwaggerGenericParseJSON
1415+instance FromJSON RequestBody where
1416+ parseJSON = sopSwaggerGenericParseJSON
1418+instance FromJSON MediaTypeObject where
1419+ parseJSON = sopSwaggerGenericParseJSON
1322instance FromJSON SecurityDefinitions where
1421instance FromJSON SecurityDefinitions where
1323 parseJSON js = SecurityDefinitions <$> parseJSON js
1422 parseJSON js = SecurityDefinitions <$> parseJSON js
@@ -1339,9 +1438,11 @@ referencedParseJSON prefix js@(Object o) = do
1339 Just suffix -> pure (Reference suffix)
1438 Just suffix -> pure (Reference suffix)
1340referencedParseJSON _ _ = fail "referenceParseJSON: not an object"
1439referencedParseJSON _ _ = fail "referenceParseJSON: not an object"
1342instance FromJSON (Referenced Schema) where parseJSON = referencedParseJSON "#/definitions/"
1442instance FromJSON (Referenced Schema) where parseJSON = referencedParseJSON "#/definitions/"
1343instance FromJSON (Referenced Param) where parseJSON = referencedParseJSON "#/parameters/"
1443instance FromJSON (Referenced Param) where parseJSON = referencedParseJSON "#/parameters/"
1344instance FromJSON (Referenced Response) where parseJSON = referencedParseJSON "#/responses/"
1444instance FromJSON (Referenced Response) where parseJSON = referencedParseJSON "#/responses/"
1445+instance FromJSON (Referenced RequestBody) where parseJSON = referencedParseJSON "#/!!!!/"
1346instance FromJSON Xml where
1447instance FromJSON Xml where
1347 parseJSON = genericParseJSON (jsonPrefix "xml")
1448 parseJSON = genericParseJSON (jsonPrefix "xml")
@@ -1376,6 +1477,8 @@ instance FromJSON AdditionalProperties where
1376 parseJSON (Bool b) = pure $ AdditionalPropertiesAllowed b
1477 parseJSON (Bool b) = pure $ AdditionalPropertiesAllowed b
1377 parseJSON js = AdditionalPropertiesSchema <$> parseJSON js
1478 parseJSON js = AdditionalPropertiesSchema <$> parseJSON js
1480+instance HasSwaggerAesonOptions Components where
1481+ swaggerAesonOptions _ = mkSwaggerAesonOptions "components"
1379instance HasSwaggerAesonOptions Header where
1482instance HasSwaggerAesonOptions Header where
1380 swaggerAesonOptions _ = mkSwaggerAesonOptions "header" & saoSubObject ?~ "paramSchema"
1483 swaggerAesonOptions _ = mkSwaggerAesonOptions "header" & saoSubObject ?~ "paramSchema"
1381instance HasSwaggerAesonOptions OAuth2Params where
1484instance HasSwaggerAesonOptions OAuth2Params where
@@ -1390,6 +1493,10 @@ instance HasSwaggerAesonOptions PathItem where
1390 swaggerAesonOptions _ = mkSwaggerAesonOptions "pathItem"
1493 swaggerAesonOptions _ = mkSwaggerAesonOptions "pathItem"
1391instance HasSwaggerAesonOptions Response where
1494instance HasSwaggerAesonOptions Response where
1392 swaggerAesonOptions _ = mkSwaggerAesonOptions "response"
1495 swaggerAesonOptions _ = mkSwaggerAesonOptions "response"
1496+instance HasSwaggerAesonOptions RequestBody where
1497+ swaggerAesonOptions _ = mkSwaggerAesonOptions "requestBody"
1498+instance HasSwaggerAesonOptions MediaTypeObject where
1499+ swaggerAesonOptions _ = mkSwaggerAesonOptions "mediaType"
1393instance HasSwaggerAesonOptions Responses where
1500instance HasSwaggerAesonOptions Responses where
1394 swaggerAesonOptions _ = mkSwaggerAesonOptions "responses" & saoSubObject ?~ "responses"
1501 swaggerAesonOptions _ = mkSwaggerAesonOptions "responses" & saoSubObject ?~ "responses"
1395instance HasSwaggerAesonOptions SecurityScheme where
1502instance HasSwaggerAesonOptions SecurityScheme where
@@ -1397,7 +1504,7 @@ instance HasSwaggerAesonOptions SecurityScheme where
1397instance HasSwaggerAesonOptions Schema where
1504instance HasSwaggerAesonOptions Schema where
1398 swaggerAesonOptions _ = mkSwaggerAesonOptions "schema" & saoSubObject ?~ "paramSchema"
1505 swaggerAesonOptions _ = mkSwaggerAesonOptions "schema" & saoSubObject ?~ "paramSchema"
1399instance HasSwaggerAesonOptions Swagger where
1506instance HasSwaggerAesonOptions Swagger where
1400− swaggerAesonOptions _ = mkSwaggerAesonOptions "swagger" & saoAdditionalPairs .~ [("swagger", "2.0")]
1507+ swaggerAesonOptions _ = mkSwaggerAesonOptions "swagger" & saoAdditionalPairs .~ [("openapi", "3.0")]
1402instance HasSwaggerAesonOptions (ParamSchema ('SwaggerKindNormal t)) where
1509instance HasSwaggerAesonOptions (ParamSchema ('SwaggerKindNormal t)) where
1403 swaggerAesonOptions _ = mkSwaggerAesonOptions "paramSchema" & saoSubObject ?~ "items"
1510 swaggerAesonOptions _ = mkSwaggerAesonOptions "paramSchema" & saoSubObject ?~ "items"
@@ -1407,6 +1514,7 @@ instance HasSwaggerAesonOptions (ParamSchema 'SwaggerKindParamOtherSchema) where
1407instance HasSwaggerAesonOptions (ParamSchema 'SwaggerKindSchema) where
1514instance HasSwaggerAesonOptions (ParamSchema 'SwaggerKindSchema) where
1408 swaggerAesonOptions _ = mkSwaggerAesonOptions "paramSchema"
1515 swaggerAesonOptions _ = mkSwaggerAesonOptions "paramSchema"
1517+instance AesonDefaultValue Components
1410instance AesonDefaultValue (ParamSchema s)
1518instance AesonDefaultValue (ParamSchema s)
1411instance AesonDefaultValue OAuth2Flow
1519instance AesonDefaultValue OAuth2Flow
1412instance AesonDefaultValue Responses
1520instance AesonDefaultValue Responses