Skip to content

Commit

Permalink
Fix FileArgument being 'default' too instead of only PlainFile in the…
Browse files Browse the repository at this point in the history
… json schema

Minor code improvements
  • Loading branch information
Grifs committed Jul 3, 2023
1 parent d22b02f commit 9a8ee81
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main/scala/io/viash/ViashExport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object ViashExport {
}

def exportConfigSchema(output: Option[Path], format: String): Unit = {
val data = CollectedSchemas.getJson.asJson
val data = CollectedSchemas.getJson
val str = data.toFormattedString(format)
if (output.isDefined) {
Files.write(output.get, str.getBytes())
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/io/viash/helpers/circe/RichJson.scala
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ class RichJson(json: Json) {

private val yamlPrinter = YamlPrinter(
preserveOrder = true,
dropNullKeys = true,
mappingStyle = YamlPrinter.FlowStyle.Block,
splitLines = true,
stringStyle = YamlPrinter.StringStyle.DoubleQuoted
Expand Down
6 changes: 2 additions & 4 deletions src/main/scala/io/viash/schemas/CollectedSchemas.scala
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ object CollectedSchemas {
(allMembers, baseClasses)
}

val schemaClasses = List(
lazy val schemaClasses = List(
getMembers[Config](),
getMembers[ViashProject](),
getMembers[Info](),
Expand Down Expand Up @@ -193,9 +193,7 @@ object CollectedSchemas {

def getKeyFromParamList(data: List[ParameterSchema]): String = data.find(p => p.name == "__this__").get.`type`

def getJson: Json = {
data.asJson
}
def getJson: Json = data.asJson

private def getNonAnnotated(members: Map[String,List[MemberInfo]], classes: List[Symbol]): List[String] = {
val issueMembers = members
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/io/viash/schemas/JsonSchema.scala
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ object JsonSchema {
!(
p.`type`.startsWith("Option[") ||
p.default.isDefined ||
(p.name == "type" && subclass == Some("file")) // Custom exception, file resources are "kind of" default
(p.name == "type" && thisParameter.`type` == "PlainFile") // Custom exception, file resources are "kind of" default
))
val requiredJson = required.map(p => Json.fromString(p.name))

Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/io/viash/e2e/export/MainExportSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MainExportSuite extends AnyFunSuite{
"export", "config_schema"
)

assert(stdout.startsWith("Config:"))
assert(stdout.startsWith("""- - name: "__this__""""))
assert(stdout.contains("""type: "OneOrMore[String]""""))
}

Expand Down

0 comments on commit 9a8ee81

Please sign in to comment.