Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
Package.resolved
10 changes: 8 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ let package = Package(
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "JSONSchema",
targets: ["JSONSchema"]),
targets: ["JSONSchema"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-collections.git", from: "1.0.0")
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "JSONSchema"),
name: "JSONSchema",
dependencies: [
.product(name: "OrderedCollections", package: "swift-collections")
]),
.testTarget(
name: "JSONSchemaTests",
dependencies: ["JSONSchema"]
Expand Down
8 changes: 6 additions & 2 deletions Sources/JSONSchema/JSONSchema.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import Foundation
import OrderedCollections

/// A type that represents a JSON Schema definition.
///
/// Use JSONSchema to create, manipulate, and encode/decode JSON Schema documents.
Expand Down Expand Up @@ -41,7 +44,7 @@
enum: [JSONValue]? = nil,
const: JSONValue? = nil,
/* */
properties: [String: JSONSchema] = [:],
properties: OrderedDictionary<String, JSONSchema> = [:],
required: [String] = [],
additionalProperties: AdditionalProperties? = nil
)
Expand Down Expand Up @@ -677,7 +680,8 @@ extension JSONSchema: Codable {
switch type {
case "object":
let properties =
try container.decodeIfPresent([String: JSONSchema].self, forKey: .properties) ?? [:]
try container.decodeIfPresent(
OrderedDictionary<String, JSONSchema>.self, forKey: .properties) ?? [:]
let required = try container.decodeIfPresent([String].self, forKey: .required) ?? []
let additionalProperties = try container.decodeIfPresent(
AdditionalProperties.self, forKey: .additionalProperties)
Expand Down
Loading