Giter Site home page Giter Site logo

swift-openapi-vapor's People

Contributors

0xtim avatar joannis avatar mahdibm avatar marius-se avatar tib avatar tomerd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swift-openapi-vapor's Issues

Add documentation on how to use Fluent(Kit)

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.

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.