Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattpolzin/vaporopenapi
https://github.com/mattpolzin/vaporopenapi
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/mattpolzin/vaporopenapi
- Owner: mattpolzin
- License: mit
- Created: 2019-12-28T23:51:25.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-11-07T01:21:40.000Z (about 1 year ago)
- Last Synced: 2024-10-12T03:47:43.089Z (about 1 month ago)
- Language: Swift
- Size: 89.8 KB
- Stars: 57
- Watchers: 6
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# VaporOpenAPI
This is more of a prototype of a library, not a polished or feature-complete API by a long stretch. That said, folks have found it useful and I certainly encourage you to PR fixes and improvements if you also find this library useful!
As of the release of OpenAPIKit v3.0.0, this library produces OpenAPI v3.1 compatible documents instead of OpenAPI v3.0 compatible documents.
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 build out an OpenAPI description. You use custom methods to attach your routes to the app. These methods mirror the methods available in Vapor already.
You can use the library like this with Swift Concurrency:
```swift
enum WidgetController {
struct ShowRoute: RouteContext {
...
}
static func show(_ req: TypedRequest) try await -> 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")
}
```...and like this with a NIO EventLoopFuture:
```swift
enum WidgetController {
struct ShowRoute: RouteContext {
...
}
static func show(_ req: TypedRequest) -> EventLoopFuture {
...
}
}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")
}
```