Code Monkey home page Code Monkey logo

kitura-openapi's Introduction

Kitura

Docs Build Status - Master macOS Linux Apache 2 Slack Status

Kitura-OpenAPI

Kitura-OpenAPI is a library which makes it easy to add OpenAPI (aka Swagger) support to your Codable routing-based Kitura application.

By using Kitura-OpenAPI you can:

  1. Host an automatically generated OpenAPI definition of your application on a defined endpoint, for example /openapi.
  2. Host the SwaggerUI tool on a defined endpoint, for example /openapi/ui.

Getting Started

Add Kitura-OpenAPI to the dependencies within your application's Package.swift file. Substitute "x.x.x" with the latest Kitura-OpenAPI release.

.package(url: "https://github.com/IBM-Swift/Kitura-OpenAPI.git", from: "x.x.x")

Add KituraOpenAPI to your target's dependencies:

.target(name: "example", dependencies: ["KituraOpenAPI"]),

Import the package inside your application:

import KituraOpenAPI

Example

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.

For example:

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.

More information

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.

Community

We love to talk server-side Swift and Kitura. Join our Slack to meet the team!

License

This library is licensed under Apache 2.0. Full license text is available in LICENSE.

This library includes components from Swagger-UI, which is licensed under Apache 2.0. Full license text is available in swagger-ui/LICENSE.

kitura-openapi's People

Contributors

djones6 avatar helenmasters avatar ianpartridge avatar samwarfield avatar shial4 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.