diff --git a/apple/Sources/OSRM/Models/Annotation.swift b/apple/Sources/OSRM/Models/Annotation.swift index e371843..fbc9847 100644 --- a/apple/Sources/OSRM/Models/Annotation.swift +++ b/apple/Sources/OSRM/Models/Annotation.swift @@ -12,9 +12,9 @@ import Foundation public struct Annotation: Codable, Hashable { /** The distance, in meters, between each pair of coordinates. */ - public var distance: [Double] + public var distance: [Double]? /** The duration between each pair of coordinates, in seconds. */ - public var duration: [Double] + public var duration: [Double]? /** The index of the datasource for the speed between each pair of coordinates. 0 is the default profile. Other values are supplied via --segment-speed-file to osrm-contract. This is OSRM-specific and not supported by most other routers. */ public var datasources: [Int]? /** The OSM node ID for each coordinate along the route (excluding the first/last user-supplied coordinates). This is not included in Valhalla-derived routers. */ @@ -24,7 +24,7 @@ public struct Annotation: Codable, Hashable { public var speed: [Double]? public var maxspeed: [SpeedLimit]? - public init(distance: [Double], duration: [Double], datasources: [Int]? = nil, nodes: [Int]? = nil, weight: [Int]? = nil, speed: [Double]? = nil, maxspeed: [SpeedLimit]? = nil) { + public init(distance: [Double]? = nil, duration: [Double]? = nil, datasources: [Int]? = nil, nodes: [Int]? = nil, weight: [Int]? = nil, speed: [Double]? = nil, maxspeed: [SpeedLimit]? = nil) { self.distance = distance self.duration = duration self.datasources = datasources @@ -48,8 +48,8 @@ public struct Annotation: Codable, Hashable { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(distance, forKey: .distance) - try container.encode(duration, forKey: .duration) + 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) diff --git a/apple/Sources/OSRM/Models/RouteStep.swift b/apple/Sources/OSRM/Models/RouteStep.swift index 4fe3127..1279467 100644 --- a/apple/Sources/OSRM/Models/RouteStep.swift +++ b/apple/Sources/OSRM/Models/RouteStep.swift @@ -34,8 +34,8 @@ public struct RouteStep: Codable, Hashable { public var ref: String? /** Pronunciation of the name (if available). The format of this varies by implementation/vendor. */ public var pronunciation: String? - public var destinations: AnyCodable? - public var exits: AnyCodable? + public var destinations: String? + public var exits: String? /** The mode of travel. */ public var mode: String public var maneuver: StepManeuver @@ -55,7 +55,7 @@ public struct RouteStep: Codable, Hashable { /** The unit of measure that is used locally along the step. This may be different from the unit used in maxspeed annotations, and is provided so that apps can localize their display. This is a Valhalla extension to the OSRM spec, and is only included when speed limits are present in the response. */ public var speedLimitUnit: String? - public init(distance: Double, duration: Double, geometry: AnyCodable, weight: Double? = nil, name: String? = nil, ref: String? = nil, pronunciation: String? = nil, destinations: AnyCodable? = nil, exits: AnyCodable? = nil, mode: String, maneuver: StepManeuver, intersections: [Intersection]? = nil, rotaryName: String? = nil, rotaryPronunciation: String? = nil, drivingSide: DrivingSide? = nil, voiceInstructions: [VoiceInstruction]? = nil, bannerInstructions: [BannerInstruction]? = nil, speedLimitSign: SpeedLimitSign? = nil, speedLimitUnit: String? = nil) { + public init(distance: Double, duration: Double, geometry: AnyCodable, weight: Double? = nil, name: String? = nil, ref: String? = nil, pronunciation: String? = nil, destinations: String? = nil, exits: String? = nil, mode: String, maneuver: StepManeuver, intersections: [Intersection]? = nil, rotaryName: String? = nil, rotaryPronunciation: String? = nil, drivingSide: DrivingSide? = nil, voiceInstructions: [VoiceInstruction]? = nil, bannerInstructions: [BannerInstruction]? = nil, speedLimitSign: SpeedLimitSign? = nil, speedLimitUnit: String? = nil) { self.distance = distance self.duration = duration self.geometry = geometry diff --git a/openapi.yaml b/openapi.yaml index a4033b9..8594aa4 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -212,11 +212,9 @@ components: Pronunciation of the name (if available). The format of this varies by implementation/vendor. destinations: - # FIXME - type: object + type: string exits: - # FIXME - type: object + type: string mode: type: string description: The mode of travel. @@ -273,9 +271,6 @@ components: and is only included when speed limits are present in the response. Annotation: type: object - required: - - distance - - duration properties: distance: type: array