-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from stadiamaps/feat/swift-models
feat: swift package setup and OSRM models
- Loading branch information
Showing
23 changed files
with
1,328 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
inputs: | ||
bump_version_scheme: | ||
type: choice | ||
description: 'Bump version scheme' | ||
required: true | ||
default: 'patch' | ||
options: | ||
- 'patch' | ||
- 'minor' | ||
- 'major' | ||
|
||
jobs: | ||
release-on-push: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- uses: rymndhng/release-on-push-action@master | ||
with: | ||
bump_version_scheme: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && 'patch' || inputs.bump_version_scheme }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.build | ||
|
||
## User settings | ||
xcuserdata/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// swift-tools-version: 5.9 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "OSRM", | ||
platforms: [ | ||
.iOS(.v13) | ||
], | ||
products: [ | ||
.library( | ||
name: "OSRM", | ||
targets: ["OSRM"] | ||
) | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/Flight-School/AnyCodable", from: "0.6.1"), | ||
], | ||
targets: [ | ||
.target( | ||
name: "OSRM", | ||
dependencies: [ | ||
"AnyCodable" | ||
], | ||
path: "apple/Sources/OSRM" | ||
) | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,26 @@ | ||
# osrm-openapi | ||
OpenAPI spec for generating OSRM Models | ||
# OSRM OpenAPI | ||
|
||
OpenAPI spec and generation script to build ([Valhalla](https://github.com/valhalla/valhalla)-flavored) OSRM Models for various platforms. | ||
|
||
## Building OSRM Models | ||
|
||
### Setup MacOS | ||
|
||
The model generations script requires the openapi-generator and swiftformat cli tools. To install these using brew, run the following command. | ||
For more information see [OpenAPI Generator Install](https://openapi-generator.tech/docs/installation) and [SwiftFormat Install](https://github.com/nicklockwood/SwiftFormat?tab=readme-ov-file#how-do-i-install-it). | ||
|
||
``` | ||
brew install openapi-generator swiftformat | ||
``` | ||
|
||
### Generating Model Code | ||
|
||
```sh | ||
./generate_models.sh swift | ||
``` | ||
|
||
* `--clean` delete the .build and generated folder. | ||
|
||
## References | ||
|
||
- OpenAPI spec based on <https://github.com/1papaya/osrm-openapi>, released under the MIT license |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// Annotation.swift | ||
// | ||
// Generated by openapi-generator | ||
// https://openapi-generator.tech | ||
// | ||
|
||
import Foundation | ||
#if canImport(AnyCodable) | ||
import AnyCodable | ||
#endif | ||
|
||
public struct Annotation: Codable, Hashable { | ||
/** The distance, in metres, between each pair of coordinates */ | ||
public var distance: [Double]? | ||
/** The duration between each pair of coordinates, in seconds */ | ||
public var duration: [Double]? | ||
public var datasources: [Int]? | ||
public var nodes: [Int]? | ||
public var weight: [Int]? | ||
public var speed: [Double]? | ||
public var metadata: AnnotationMetadata? | ||
|
||
public init(distance: [Double]? = nil, duration: [Double]? = nil, datasources: [Int]? = nil, nodes: [Int]? = nil, weight: [Int]? = nil, speed: [Double]? = nil, metadata: AnnotationMetadata? = nil) { | ||
self.distance = distance | ||
self.duration = duration | ||
self.datasources = datasources | ||
self.nodes = nodes | ||
self.weight = weight | ||
self.speed = speed | ||
self.metadata = metadata | ||
} | ||
|
||
public enum CodingKeys: String, CodingKey, CaseIterable { | ||
case distance | ||
case duration | ||
case datasources | ||
case nodes | ||
case weight | ||
case speed | ||
case metadata | ||
} | ||
|
||
// Encodable protocol methods | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
try container.encodeIfPresent(distance, forKey: .distance) | ||
try container.encodeIfPresent(duration, forKey: .duration) | ||
try container.encodeIfPresent(datasources, forKey: .datasources) | ||
try container.encodeIfPresent(nodes, forKey: .nodes) | ||
try container.encodeIfPresent(weight, forKey: .weight) | ||
try container.encodeIfPresent(speed, forKey: .speed) | ||
try container.encodeIfPresent(metadata, forKey: .metadata) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// AnnotationMetadata.swift | ||
// | ||
// Generated by openapi-generator | ||
// https://openapi-generator.tech | ||
// | ||
|
||
import Foundation | ||
#if canImport(AnyCodable) | ||
import AnyCodable | ||
#endif | ||
|
||
public struct AnnotationMetadata: Codable, Hashable { | ||
public var datasourceNames: [String]? | ||
|
||
public init(datasourceNames: [String]? = nil) { | ||
self.datasourceNames = datasourceNames | ||
} | ||
|
||
public enum CodingKeys: String, CodingKey, CaseIterable { | ||
case datasourceNames = "datasource_names" | ||
} | ||
|
||
// Encodable protocol methods | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
try container.encodeIfPresent(datasourceNames, forKey: .datasourceNames) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// ApiResponse.swift | ||
// | ||
// Generated by openapi-generator | ||
// https://openapi-generator.tech | ||
// | ||
|
||
import Foundation | ||
#if canImport(AnyCodable) | ||
import AnyCodable | ||
#endif | ||
|
||
public struct ApiResponse: Codable, Hashable { | ||
public enum Code: String, Codable, CaseIterable { | ||
case ok = "Ok" | ||
case invalidUrl = "InvalidUrl" | ||
case invalidService = "InvalidService" | ||
case invalidVersion = "InvalidVersion" | ||
case invalidOptions = "InvalidOptions" | ||
case invalidQuery = "InvalidQuery" | ||
case invalidValue = "InvalidValue" | ||
case noSegment = "NoSegment" | ||
case tooBig = "TooBig" | ||
case noRoute = "NoRoute" | ||
case noTable = "NoTable" | ||
case notImplemented = "NotImplemented" | ||
case noTrips = "NoTrips" | ||
} | ||
|
||
public var code: Code | ||
public var message: String? | ||
public var dataVersion: Date? | ||
|
||
public init(code: Code, message: String? = nil, dataVersion: Date? = nil) { | ||
self.code = code | ||
self.message = message | ||
self.dataVersion = dataVersion | ||
} | ||
|
||
public enum CodingKeys: String, CodingKey, CaseIterable { | ||
case code | ||
case message | ||
case dataVersion = "data_version" | ||
} | ||
|
||
// Encodable protocol methods | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
try container.encode(code, forKey: .code) | ||
try container.encodeIfPresent(message, forKey: .message) | ||
try container.encodeIfPresent(dataVersion, forKey: .dataVersion) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// Intersection.swift | ||
// | ||
// Generated by openapi-generator | ||
// https://openapi-generator.tech | ||
// | ||
|
||
import Foundation | ||
#if canImport(AnyCodable) | ||
import AnyCodable | ||
#endif | ||
|
||
public struct Intersection: Codable, Hashable { | ||
public var location: [Double]? | ||
public var bearings: [Int]? | ||
public var classes: [String]? | ||
public var entry: [Bool]? | ||
public var _in: Int? | ||
public var out: Int? | ||
public var lanes: [Lane]? | ||
|
||
public init(location: [Double]? = nil, bearings: [Int]? = nil, classes: [String]? = nil, entry: [Bool]? = nil, _in: Int? = nil, out: Int? = nil, lanes: [Lane]? = nil) { | ||
self.location = location | ||
self.bearings = bearings | ||
self.classes = classes | ||
self.entry = entry | ||
self._in = _in | ||
self.out = out | ||
self.lanes = lanes | ||
} | ||
|
||
public enum CodingKeys: String, CodingKey, CaseIterable { | ||
case location | ||
case bearings | ||
case classes | ||
case entry | ||
case _in = "in" | ||
case out | ||
case lanes | ||
} | ||
|
||
// Encodable protocol methods | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
try container.encodeIfPresent(location, forKey: .location) | ||
try container.encodeIfPresent(bearings, forKey: .bearings) | ||
try container.encodeIfPresent(classes, forKey: .classes) | ||
try container.encodeIfPresent(entry, forKey: .entry) | ||
try container.encodeIfPresent(_in, forKey: ._in) | ||
try container.encodeIfPresent(out, forKey: .out) | ||
try container.encodeIfPresent(lanes, forKey: .lanes) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// Lane.swift | ||
// | ||
// Generated by openapi-generator | ||
// https://openapi-generator.tech | ||
// | ||
|
||
import Foundation | ||
#if canImport(AnyCodable) | ||
import AnyCodable | ||
#endif | ||
|
||
public struct Lane: Codable, Hashable { | ||
public var indications: [String]? | ||
public var valid: Bool? | ||
|
||
public init(indications: [String]? = nil, valid: Bool? = nil) { | ||
self.indications = indications | ||
self.valid = valid | ||
} | ||
|
||
public enum CodingKeys: String, CodingKey, CaseIterable { | ||
case indications | ||
case valid | ||
} | ||
|
||
// Encodable protocol methods | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
try container.encodeIfPresent(indications, forKey: .indications) | ||
try container.encodeIfPresent(valid, forKey: .valid) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// NearestResponse.swift | ||
// | ||
// Generated by openapi-generator | ||
// https://openapi-generator.tech | ||
// | ||
|
||
import Foundation | ||
#if canImport(AnyCodable) | ||
import AnyCodable | ||
#endif | ||
|
||
public struct NearestResponse: Codable, Hashable { | ||
public enum Code: String, Codable, CaseIterable { | ||
case ok = "Ok" | ||
case invalidUrl = "InvalidUrl" | ||
case invalidService = "InvalidService" | ||
case invalidVersion = "InvalidVersion" | ||
case invalidOptions = "InvalidOptions" | ||
case invalidQuery = "InvalidQuery" | ||
case invalidValue = "InvalidValue" | ||
case noSegment = "NoSegment" | ||
case tooBig = "TooBig" | ||
case noRoute = "NoRoute" | ||
case noTable = "NoTable" | ||
case notImplemented = "NotImplemented" | ||
case noTrips = "NoTrips" | ||
} | ||
|
||
public var code: Code | ||
public var message: String? | ||
public var dataVersion: Date? | ||
public var waypoints: [NearestWaypoint]? | ||
|
||
public init(code: Code, message: String? = nil, dataVersion: Date? = nil, waypoints: [NearestWaypoint]? = nil) { | ||
self.code = code | ||
self.message = message | ||
self.dataVersion = dataVersion | ||
self.waypoints = waypoints | ||
} | ||
|
||
public enum CodingKeys: String, CodingKey, CaseIterable { | ||
case code | ||
case message | ||
case dataVersion = "data_version" | ||
case waypoints | ||
} | ||
|
||
// Encodable protocol methods | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
try container.encode(code, forKey: .code) | ||
try container.encodeIfPresent(message, forKey: .message) | ||
try container.encodeIfPresent(dataVersion, forKey: .dataVersion) | ||
try container.encodeIfPresent(waypoints, forKey: .waypoints) | ||
} | ||
} |
Oops, something went wrong.