@@ -1,9 +1,10 @@
1module Data.Swagger.Internal where
1module Data.Swagger.Internal where
3+import Data.HashMap.Strict (HashMap)
3−import Data.Text (Text)
4+import Data.Text (Text)
4−import Network (HostName, PortNumber)
5+import Network (HostName, PortNumber)
5−import Network.HTTP.Media (MediaType)
6+import Network.HTTP.Media (MediaType)
6−import Network.URL (URL)
7+import Network.URL (URL)
8-- | This is the root document object for the API specification.
9-- | This is the root document object for the API specification.
9data Swagger = Swagger
10data Swagger = Swagger
@@ -130,13 +131,109 @@ data SwaggerScheme
130data SwaggerPaths = SwaggerPaths
131data SwaggerPaths = SwaggerPaths
131 { -- | Holds the relative paths to the individual endpoints.
132 { -- | Holds the relative paths to the individual endpoints.
132 -- The path is appended to the @'swaggerBasePath'@ in order to construct the full URL.
133 -- The path is appended to the @'swaggerBasePath'@ in order to construct the full URL.
133− swaggerPathsMap :: [SwaggerPath]
134+ swaggerPathsMap :: HashMap FilePath SwaggerPathItem
135 -- | Allows extensions to the Swagger Schema.
136 -- | Allows extensions to the Swagger Schema.
136 , swaggerPathsExtensions :: [SwaggerExtension]
137 , swaggerPathsExtensions :: [SwaggerExtension]
137 } deriving (Show)
138 } deriving (Show)
139−data SwaggerPath = SwaggerPath
140+-- | Describes the operations available on a single path.
141+-- A @'SwaggerPathItem'@ may be empty, due to ACL constraints.
142+-- The path itself is still exposed to the documentation viewer
143+-- but they will not know which operations and parameters are available.
144+data SwaggerPathItem = SwaggerPathItem
145+ { -- | A definition of a GET operation on this path.
146+ swaggerPathItemGet :: Maybe SwaggerOperation
148+ -- | A definition of a PUT operation on this path.
149+ , swaggerPathItemPut :: Maybe SwaggerOperation
151+ -- | A definition of a POST operation on this path.
152+ , swaggerPathItemPost :: Maybe SwaggerOperation
154+ -- | A definition of a DELETE operation on this path.
155+ , swaggerPathItemDelete :: Maybe SwaggerOperation
157+ -- | A definition of a OPTIONS operation on this path.
158+ , swaggerPathItemOptions :: Maybe SwaggerOperation
160+ -- | A definition of a HEAD operation on this path.
161+ , swaggerPathItemHead :: Maybe SwaggerOperation
163+ -- | A definition of a PATCH operation on this path.
164+ , swaggerPathItemPatch :: Maybe SwaggerOperation
166+ -- | A list of parameters that are applicable for all the operations described under this path.
167+ -- These parameters can be overridden at the operation level, but cannot be removed there.
168+ -- The list MUST NOT include duplicated parameters.
169+ -- A unique parameter is defined by a combination of a name and location.
170+ , swaggerPathItemParameters :: [SwaggerParameter]
173+-- | Describes a single API operation on a path.
174+data SwaggerOperation = SwaggerOperation
175+ { -- | A list of tags for API documentation control.
176+ -- Tags can be used for logical grouping of operations by resources or any other qualifier.
177+ swaggerOperationTags :: [Text]
179+ -- | A short summary of what the operation does.
180+ -- For maximum readability in the swagger-ui, this field SHOULD be less than 120 characters.
181+ , swaggerOperationSummary :: Maybe Text
183+ -- | A verbose explanation of the operation behavior.
184+ -- GFM syntax can be used for rich text representation.
185+ , swaggerOperationDescription :: Maybe Text
187+ -- | Additional external documentation for this operation.
188+ , swaggerOperationExternalDocs :: Maybe SwaggerExternalDocs
190+ -- | Unique string used to identify the operation.
191+ -- The id MUST be unique among all operations described in the API.
192+ -- Tools and libraries MAY use the it to uniquely identify an operation,
193+ -- therefore, it is recommended to follow common programming naming conventions.
194+ , swaggerOperationOperationId :: Maybe Text
196+ -- | A list of MIME types the operation can consume.
197+ -- This overrides the @'swaggerConsumes'@.
198+ -- @Just []@ MAY be used to clear the global definition.
199+ , swaggerOperationConsumes :: Maybe [MediaType]
201+ -- | A list of MIME types the operation can produce.
202+ -- This overrides the @'swaggerProduces'@.
203+ -- @Just []@ MAY be used to clear the global definition.
204+ , swaggerOperationProduces :: Maybe [MediaType]
206+ -- | A list of parameters that are applicable for this operation.
207+ -- If a parameter is already defined at the @'SwaggerPathItem'@,
208+ -- the new definition will override it, but can never remove it.
209+ -- The list MUST NOT include duplicated parameters.
210+ -- A unique parameter is defined by a combination of a name and location.
211+ , swaggerOperationParameters :: [SwaggerParameter]
213+ -- | The list of possible responses as they are returned from executing this operation.
214+ , swaggerOperationResponses :: SwaggerResponses
216+ -- | The transfer protocol for the operation.
217+ -- The value overrides @'swaggerSchemes'@.
218+ , swaggerOperationSchemes :: Maybe [SwaggerScheme]
220+ -- | Declares this operation to be deprecated.
221+ -- Usage of the declared operation should be refrained.
222+ -- Default value is @False@.
223+ , swaggerOperationDeprecated :: Bool
225+ -- | A declaration of which security schemes are applied for this operation.
226+ -- The list of values describes alternative security schemes that can be used
227+ -- (that is, there is a logical OR between the security requirements).
228+ -- This definition overrides any declared top-level security.
229+ -- To remove a top-level security declaration, @Just []@ can be used.
230+ , swaggerOperationSecurity :: [SwaggerSecurityRequirement]
233+data SwaggerParameter = SwaggerParameter
236+data SwaggerResponses = SwaggerResponses
140 deriving (Show)
237 deriving (Show)
142data SwaggerExtension = SwaggerExtension
239data SwaggerExtension = SwaggerExtension