Skip to content

Use custom circe decoders to generate schema #13

Description

@joshlemer

Not sure if it's possible, but it would be nice if we could use custom decoders so that the field names in our case classes weren't tied to the attributes they represent in the json. For example:

  case class Cat(a: String, b: Int)
  implicit val decoder: Decoder[Cat] = Decoder.forProduct2("the_a", "the_b")(Cat.apply)
  println(JsonSchema.deriveFor[Cat].asJson.pretty(Printer.spaces2))

//  {
//    "type" : "object",
//    "required" : [
//    "a",  <--- should be the_a
//    "b"   <--- should be the_b
//    ],
//    "properties" : {
//      "a" : {
//      "type" : "string"
//    },
//      "b" : {
//      "type" : "integer",
//      "format" : "int32"
//    }
//    }
//  }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions