Swiftpack.co - Package - mattpolzin/VaporOpenAPI

VaporOpenAPI

This is currently in early stages of development, not a polished or feature-complete API by a long stretch.

See https://github.com/mattpolzin/VaporOpenAPIExample for an example of a simple app using this library.

You use VaporTypedRoutes.TypedRequest instead of Vapor.Request to form a request context that can be used to built out an OpenAPI description. You use custom methods to attach your routes to the app. These methods mirror the methods available in Vapor already.


enum WidgetController {
    struct ShowRoute: RouteContext {
        ...
    }
    
    static func show(_ req: TypedRequest<ShowRoute>) -> EventLoopFuture<Response> {
        ...
    }
}

func routes(_ app: Application) {
    app.get(
        "widgets",
        ":type".description("The type of widget"),
        ":id".parameterType(Int.self),
        use: WidgetController.show 
    ).tags("Widgets")
      .summary("Get a widget")
}

Github

link
Stars: 18

Used By

Total: 0

Releases

Update for OpenAPIKit v2 - 2020-09-28 02:40:31

Note that OpenAPIKit v2 introduces some breaking changes.

Update to OpenAPIKit v1.0 - 2020-05-14 01:20:36

⚠️ Breaking Changes ⚠️ OpenAPIKit v1.0 comes with some breaking changes, although now OpenAPIKit will be stable for the duration of the v1 major version.

Fix path param description when unspecified. - 2020-05-12 15:30:03

report an unspecified description as nil instead of an empty string.

Improve upon path parameter support - 2020-05-11 02:15:11

  • Add ability to specify the type of a path parameter.
  • Remove need to use a new RoutesBuilder replacement, which means you just use app.get/post/etc. to add routes to your app. This should also work with route groups.

⚠️ Breaking Changes ⚠️ Application.openAPI has been removed -- it was a RoutesBuilder replacement that is no longer needed. Anywhere you would have written app.openAPI.get(...) you can now write app.get(...).

Support JSON:API response schema guessing - 2020-05-09 04:23:07

Add ability to add descriptions to path parameters. - 2020-05-09 03:24:56

This feature comes with the addition of a new type of routes builder. If you want to add descriptions to path parameters, the route must be built with app.openAPI.get/post/etc. instead of app.get/post/etc. or app.routes.get/post/etc..

Bump VaporTypedRoutes version. - 2020-05-08 03:13:50

⚠️ Breaking Change ⚠️ New version of VaporTypedRoutes adds a new requirement to RouteContext (although it is perfectly acceptable to just set the new static property to nil).

Update VaporTypedRoutes and Vapor - 2020-05-05 07:22:35

Fixes a small breaking change made in Vapor 4.5.0

Update OpenAPIKit, move to requiring 4.x releases of Vapor. - 2020-04-22 04:09:15

Update OpenAPIKit version - 2020-04-09 06:31:11

⚠️ Breaking Changes ⚠️ OpenAPIKit has breaking changes across this version bump.

Modify `OpenAPIExampleProvider` expectation and default implementation. - 2020-03-22 19:49:13

static func openAPIExample(using encoder: JSONEncoder) throws -> String? -> static func openAPIExample(using encoder: JSONEncoder) throws -> AnyCodable?

The openAPIExample() function is now expected to return an AnyCodable instead of a String. This change facilities embedding examples into OpenAPI documentation as schemas instead of strings. This can improve rendering in some UIs such as ReDoc's.

Add (some) support for OpenAPI examples - 2020-03-22 07:20:04

Adds the OpenAPIExampleProvider protocol that request/response types can conform to in order to attempt to produce examples of themselves.

OpenAPIExampleProvider requires a type isEncodableandSampleable` to gain automatic conformance without implementing a couple of functions yourself.

Update OpenAPIReflection version for bug fix. - 2020-03-20 04:03:52

Initial Pre-release - 2020-03-08 02:13:52