Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

definitions beginning with lowercase letter don't compile #5

Open
balhoff opened this issue Mar 17, 2017 · 0 comments
Open

definitions beginning with lowercase letter don't compile #5

balhoff opened this issue Mar 17, 2017 · 0 comments

Comments

@balhoff
Copy link

balhoff commented Mar 17, 2017

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant