Skip to content
Open
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
8 changes: 8 additions & 0 deletions Sources/ProjectSpec/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ extension Project {
public init(basePath: Path = "", jsonDictionary: JSONDictionary) throws {
self.basePath = basePath

let validKeys = Set(["name", "settings", "settingGroups", "settingPresets", "configs", "targets", "aggregateTargets", "projectReferences", "schemes", "breakpoints", "fileGroups", "configFiles", "attributes", "breakpoints", "packages", "localPackages", "options", "targetTemplates", "include", "templates", "schemeTemplates"])

for key in jsonDictionary.keys {
if !validKeys.contains(key) {
throw SpecValidationError(errors: [.unknownDictionaryKey(key)])
}
}

let jsonDictionary = Project.resolveProject(jsonDictionary: jsonDictionary)

name = try jsonDictionary.json(atKeyPath: "name")
Expand Down
3 changes: 3 additions & 0 deletions Sources/ProjectSpec/SpecValidationError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public struct SpecValidationError: Error, CustomStringConvertible {
case multipleDefaultTestPlans
case duplicateDependencies(target: String, dependencyReference: String)
case invalidPluginPackageReference(plugin: String, package: String)
case unknownDictionaryKey(String)

public var description: String {
switch self {
Expand Down Expand Up @@ -109,6 +110,8 @@ public struct SpecValidationError: Error, CustomStringConvertible {
return "Target \(target.quoted) has the dependency \(dependencyReference.quoted) multiple times"
case let .invalidPluginPackageReference(plugin, package):
return "Plugin \(plugin) has invalid package reference \(package)"
case let .unknownDictionaryKey(key):
return "Unknown key \(key)"
}
}
}
Expand Down
Loading