KituraOpenAPI
public class KituraOpenAPI
KituraOpenAPI contains helper functions for the addition of endpoints to a Kitura Router
for serving:
- an OpenAPI definition of its routes and their associated data types,
- the SwaggerUI tool, that allows exploration and testing of the API via a web browser.
Usage Example:
import Kitura
import KituraOpenAPI
let router = Router()
KituraOpenAPI.addEndpoints(to: router) // Register default endpoints
The endpoints have default values defined by the defaultConfig property. You can customize
the endpoints by supplying a KituraOpenAPIConfig:
let config = KituraOpenAPIConfig(apiPath: "/swagger", swaggerUIPath: "/swagger/ui")
KituraOpenAPI.addEndpoints(to: router, with: config)
-
The default endpoints registered by
KituraOpenAPI.addEndpointsto serve the OpenAPI definition and the SwaggerUI tool. These values are/openapiandopenapi/ui, respectively.Declaration
Swift
public static var defaultConfig: KituraOpenAPIConfig -
Add endpoints to a Kitura
Router, to serve the OpenAPI document and SwaggerUI.Declaration
Swift
public static func addEndpoints(to router: Router, with config: KituraOpenAPIConfig = KituraOpenAPI.defaultConfig)Parameters
routerThe
Routerwhose routes should be described.configOptionally specify the paths to register. If not specified, the values described in
defaultConfigwill be used. -
Write Kitura’s OpenAPI definition to a file, describing all Codable routes that have been registered with the given
Router.Throws
NSError if the file cannot be written.Declaration
Swift
public static func writeOpenAPI(from router: Router, to filePath: String) throwsParameters
routerThe Router whose routes should be described.
filePathThe path to a file that should be written.
View on GitHub
KituraOpenAPI Class Reference