Git Product home page Git Product logo

swift-openapi-foundation's Introduction

Foundation Client Transport for Swift OpenAPI Generator

A client transport that uses the Foundation framework to perform HTTP operations. It is not prescriptive about how this integration works, allowing libraries such as OAuthenticator to be integrated quickly and without any fuss.

Use the transport with client code generated by Swift OpenAPI Generator.

Supported platforms and minimum versions

macOS Linux iOS tvOS watchOS visionOS
✅ 10.15+ ✅ 13+ ✅ 13+ ✅ 6+ ✅ 1+

Usage

Add the package dependency in your Package.swift:

.package(url: "https://github.com/tonyarnold/swift-openapi-foundation", from: "0.0.1"),

Next, in your target, add OpenAPIURLSession to your dependencies:

.target(name: "MyTarget", dependencies: [
    .product(name: "OpenAPIURLSession", package: "swift-openapi-urlsession"),
]),

Then, to get started, check out FoundationClientTransport.

Examples

Assuming you've integrated a library such as OAuthenticator into your project, this is all you'll need to do:

let authenticator = Authenticator(config: ...)
let transport = FoundationClientTransport(responseProvider: authenticator.responseProvider)

let client = Client(
    serverURL: URL(string: "https://example.com")!,
    transport: transport
)

Integrating Other Libraries

Integrating an existing networking library with OpenAPIFoundation requires you to provide a responseProvider closure:

let responseProvider: (URLRequest) async throws -> (Data, URLResponse)  

This is usually as simple as adding an extension on the networking library's "main" type. You can see how OAuthenticator does this in their repository.

swift-openapi-foundation's People

Contributors

tonyarnold avatar

Stargazers

Tim Kersey avatar Matt Massicotte avatar

Watchers

 avatar  avatar

swift-openapi-foundation's Issues

My license?

Hello Tony!

I noticed that you added my license to a few files, and I know this is a crazy question, but did I actually write those things?

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.