https://github.com/lab5e/swift-simple
Simple API client sample in Swift that retrieves a list of collections
https://github.com/lab5e/swift-simple
iot lang-swift sample span swift
Last synced: 8 days ago
JSON representation
Simple API client sample in Swift that retrieves a list of collections
- Host: GitHub
- URL: https://github.com/lab5e/swift-simple
- Owner: lab5e
- License: apache-2.0
- Created: 2024-01-05T11:45:24.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-08T01:11:59.000Z (over 2 years ago)
- Last Synced: 2025-02-28T22:38:59.334Z (over 1 year ago)
- Topics: iot, lang-swift, sample, span, swift
- Language: Swift
- Homepage: https://www.lab5e.com/
- Size: 28.3 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# A Span API client sample in Swift
Build the sample with `swift build`.
To run it, create a new API token in the [Span dashboard](https://span.lab5e.com) and
run
```shell
swift run span-sample --api-token=[API token]
```
## Generating the client
Rather than using a prebuilt client the OpenAPI generator is a plugin in the
project as described in [this tutorial from Apple](https://swiftpackageindex.com/apple/swift-openapi-generator/1.1.0/tutorials/swift-openapi-generator/clientswiftpm).
You'll have to add the openapi.yaml file from the service but it's relatively
easy to update the yaml file as part of your build process.
The two YAML files in the Sources is used by the OpenAPI generator plugin to
build the client. The `Packages.swift` file contains the required dependencies.
## Getting the OpenAPI spec
The OpenAPI spec is available in several other repositories; you can download it with `wget` before building. This
will download the latest version of the specification:
```shell
cd Sources
rm -f openapi.yaml
wget https://raw.githubusercontent.com/lab5e/go-spanapi/main/api/openapi.yaml
```