Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Add $schema to the assessmentResult.json serialization. #26

Merged
merged 1 commit into from
Feb 27, 2023
Merged
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
7 changes: 6 additions & 1 deletion Sources/ResultModel/AssessmentResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public protocol AssessmentResult : BranchNodeResult {
/// Abstract implementation to allow extending an assessment result while retaining the serializable type.
open class AbstractAssessmentResultObject : AbstractBranchNodeResultObject {
private enum CodingKeys : String, OrderedEnumCodingKey, OpenOrderedCodingKey {
case assessmentIdentifier, versionString, taskRunUUID, schemaIdentifier
case assessmentIdentifier, versionString, taskRunUUID, schemaIdentifier, jsonSchema = "$schema"
var relativeIndex: Int { 1 }
}

Expand Down Expand Up @@ -81,6 +81,9 @@ open class AbstractAssessmentResultObject : AbstractBranchNodeResultObject {
try container.encodeIfPresent(self.assessmentIdentifier, forKey: .assessmentIdentifier)
try container.encodeIfPresent(self.schemaIdentifier, forKey: .schemaIdentifier)
try container.encodeIfPresent(self.versionString, forKey: .versionString)
if let root = self as? DocumentableRootObject {
try container.encodeIfPresent(root.jsonSchema, forKey: .jsonSchema)
}
}

override open class func codingKeys() -> [CodingKey] {
Expand Down Expand Up @@ -122,6 +125,8 @@ open class AbstractAssessmentResultObject : AbstractBranchNodeResultObject {
to allow the controller for the task to set this on the ``AssessmentResult`` children
included in this run.
""".replacingOccurrences(of: "\n", with: " ").replacingOccurrences(of: " ", with: "\n"))
case .jsonSchema:
return .init(propertyType: .format(.uri), propertyDescription: "The json schema URI for this result.")
}
}
}
Expand Down