Swift OpenAPI URLSession Transport

repository·main·Indexed 42 days ago

https://github.com/apple/swift-openapi-urlsession

A client transport for the Swift OpenAPI Generator that leverages Apple's Foundation URLSession to perform HTTP operations. It provides the URLSessionTransport type and supports macOS 10.15+, iOS 13+, tvOS 13+, watchOS 6+, visionOS 1+, and Linux/Windows.

Tokens
820
Snippets
2
Records
6
Agent score
3%

What's inside Swift OpenAPI URLSession

  1. Install OpenAPIURLSession via Swift Package Manager

    main

    To use this transport, add the swift-openapi-urlsession package to your Package.swift file. First, add the package dependency, then include the OpenAPIURLSession product in your specific target's dependencies.

    // Add the package dependency
    .package(url: "https://github.com/apple/swift-openapi-urlsession", from: "1.0.0"),
    
    // Add the product to your target
    .target(name: "MyTarget", dependencies: [
        .product(name: "OpenAPIURLSession", package: "swift-openapi-urlsession"),
    ]),
  2. Install the URLSession Transport package

    main

    To use the URLSession transport with your generated Swift OpenAPI client, add swift-openapi-urlsession as a package dependency in your Package.swift file and include the OpenAPIURLSession product in your target's dependencies.

    // Add the package dependency
    .package(url: "https://github.com/apple/swift-openapi-urlsession", from: "1.0.0"),
    
    // Add the product to your target
    .target(name: "MyTarget", dependencies: [
        .product(name: "OpenAPIURLSession", package: "swift-openapi-urlsession"),
    ]),
  3. Supported platforms and streaming limitations

    main

    The OpenAPIURLSession transport is compatible with the following platforms and minimum versions:

    PlatformMinimum Version
    macOS10.15+
    iOS13+
    tvOS13+
    watchOS6+
    visionOS1+
    Linux✅

    Important Note on Streaming: Streaming support is only available on the following versions:

    • macOS 12+
    • iOS 15+
    • tvOS 15+
    • watchOS 8+
    • visionOS 1+

    For streaming support on Linux, use the AsyncHTTPClient Transport instead.

  4. Supported platforms and streaming capabilities

    main

    The OpenAPIURLSession transport supports the following platforms:

    PlatformMinimum Version
    macOS10.15+
    iOS13+
    tvOS13+
    watchOS6+
    visionOS1+
    Linux/WindowsSupported

    Important Note on Streaming: Streaming support is restricted to the following minimum versions:

    • macOS 12+
    • iOS 15+
    • tvOS 15+
    • watchOS 8+
    • visionOS 1+

    If you require streaming support on Linux, use the AsyncHTTPClient Transport instead.