swift-server / swift-openapi-vapor Goto Github PK
View Code? Open in Web Editor NEWVapor Bindings for the OpenAPI Generator
License: Apache License 2.0
Vapor Bindings for the OpenAPI Generator
License: Apache License 2.0
We should allow users to configure the body: HTTPBodyStreamStrategy = .collect
parameter when registering routes.
Noticed in:
apple/swift-openapi-generator#360
Currently, I am working on a side project using this Vapor OpenAPI generated package. I am missing documentation on how to use Fluent with the generated code. I would like to use Fluent and I think this is going to be a big use case.
An example of my code:
import FluentKit
import Foundation
import OpenAPIRuntime
import Vapor
struct UserController: APIProtocol {
typealias CreationInput = Operations.createUser.Input
typealias CreationOutput = Operations.createUser.Output
private let db: any Database
init(db: any Database) {
self.db = db
}
/// Create a user
///
/// - Remark: HTTP `POST /users`.
/// - Remark: Generated from `#/paths//users/post(createUser)`.
func createUser(_ input: CreationInput) async throws -> CreationOutput {
guard case let CreationInput.Body.json(input) = input.body else { fatalError() }
let user = try User
.Signup(name: input.name, email: input.email, password: input.password)
.createUser()
try await user.save(on: db)
let newUser = Components.Schemas.User(
name: user.name,
createdAt: user.createdAt ?? .now,
updatedAt: user.updatedAt ?? .now
)
let jsonBody: CreationOutput.Created.Body = .json(newUser)
let body = CreationOutput.Created(body: jsonBody)
return .created(body)
}
}
Which results in a warning: Stored property 'db' of 'Sendable'-conforming struct 'UserController' has non-sendable type 'any Database'
. Therefore, I would like to request documentation on how I am supposed to build out my Vapor app with FluentKit.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.