By using Kitura-OpenAPI you can:
- Host an automatically generated OpenAPI definition of your application on a defined endpoint, for example
- Host the SwaggerUI tool on a defined endpoint, for example
Kitura-OpenAPI to the dependencies within your application's
Package.swift file. Substitute
"x.x.x" with the latest
.package(url: "https://github.com/IBM-Swift/Kitura-OpenAPI.git", from: "x.x.x")
KituraOpenAPI to your target's dependencies:
.target(name: "example", dependencies: ["KituraOpenAPI"]),
Import the package inside your application:
Inside your application, add a call to
KituraOpenAPI.addEndpoints(to:with:) during startup, passing through the Kitura
Router that you want to host the OpenAPI endpoints on. The
with parameter optionally allows you to configure where the endpoints are hosted.
KituraOpenAPI.addEndpoints(to: router) // Use the default endpoints
You can then visit
/openapi in a web browser to view the generated OpenAPI definition, and
/openapi/ui to view SwaggerUI.
Kitura-OpenAPI works by using Kitura's ability to introspect the registered Codable routes at runtime. This feature was added in Kitura 2.4. Hence, if you are not using Codable routing you unfortunately cannot take advantage of this feature. This is because only Codable routes provide the strong type information required in order to generate an OpenAPI definition at runtime.
We love to talk server-side Swift and Kitura. Join our Slack to meet the team!
This library is licensed under Apache 2.0. Full license text is available in LICENSE.
Help us keep the lights on
1.0.3 - Jul 24, 2018
Fix SwaggerUI when deployed into cloud.
1.0.2 - Jun 8, 2018
1.0.1 - Jun 1, 2018
1.0.0 - Jun 1, 2018