Argus
Argus copied to clipboard
definitions beginning with lowercase letter don't compile
I noticed that definitions in the JSON schema must be capitalized for Argus to work. For this example adapted from the Argus readme:
package test
import argus.macros._
import io.circe._
import io.circe.syntax._
@fromSchemaJson("""
{
"title": "Example Schema",
"type": "object",
"definitions" : {
"address": {
"type": "object",
"properties": {
"number" : { "type": "integer" },
"street" : { "type": "string" }
}
},
"ErdosNumber": {
"type": "integer"
}
},
"properties": {
"name": {
"type": "array",
"items": { "type": "string" }
},
"age": {
"description": "Age in years",
"type": "integer"
},
"address" : { "$ref" : "#/definitions/address" },
"erdosNumber" : { "$ref" : "#/definitions/ErdosNumber" }
}
}
""", name = "Person")
object Schema
object TestArgus {
import Schema._
import Schema.Implicits._
val json = """
|{
| "name" : ["Bob", "Smith"],
| "age" : 26,
| "address" : {
| "number" : 31,
| "street" : "Main St"
| },
| "erdosNumber": 123
|}
""".stripMargin
// Decode into generated case class
val person = parser.decode[Person](json).right.toOption.get
// Update address
val personAddress = address(number = Some(42), street = Some("Alt St"))
val newPerson = person.copy(address = Some(personAddress))
// Encode base to json
newPerson.asJson
}
I get a compile error:
[error] .../src/main/scala/test/TestArgus.scala:7: not found: type address
[error] @fromSchemaJson("""
[error] ^
If I change the schema to use "Address" (and also the case class name to match), everything works. Is this intended?