-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
79 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/scala/com/melvinlow/json/schema/generic/semiauto.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.melvinlow.json.schema.generic | ||
|
||
import com.melvinlow.json.schema.instances | ||
|
||
trait semiauto | ||
|
||
object semiauto extends semiauto with instances |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.melvinlow.json.schema | ||
|
||
import io.circe.Json | ||
|
||
trait instances_low_priority { | ||
given intJsonSchemaInstance[T <: Int]: JsonSchemaEncoder[T] with { | ||
def schema: Json = Json.obj("type" -> Json.fromString("integer")) | ||
} | ||
|
||
given stringJsonSchemaInstance[T <: String]: JsonSchemaEncoder[T] with { | ||
def schema: Json = Json.obj("type" -> Json.fromString("string")) | ||
} | ||
|
||
given longJsonSchemaInstance[T <: Long]: JsonSchemaEncoder[T] with { | ||
def schema: Json = Json.obj("type" -> Json.fromString("integer")) | ||
} | ||
|
||
given doubleJsonSchemaInstance[T <: Double]: JsonSchemaEncoder[T] with { | ||
def schema: Json = Json.obj("type" -> Json.fromString("number")) | ||
} | ||
|
||
given floatJsonSchemaEncoder[T <: Float]: JsonSchemaEncoder[T] with { | ||
def schema: Json = Json.obj("type" -> Json.fromString("number")) | ||
} | ||
|
||
given booleanJsonSchemaEncoder[T <: Boolean]: JsonSchemaEncoder[T] with { | ||
def schema: Json = Json.obj("type" -> Json.fromString("boolean")) | ||
} | ||
|
||
given listJsonSchemaEncoder[T: JsonSchemaEncoder]: JsonSchemaEncoder[List[T]] | ||
with { | ||
def schema: Json = | ||
Json | ||
.obj( | ||
"type" -> Json.fromString("array"), | ||
"items" -> JsonSchemaEncoder[T].schema | ||
) | ||
} | ||
|
||
given arrayJsonSchemaEncoder[T: JsonSchemaEncoder] | ||
: JsonSchemaEncoder[Array[T]] | ||
with { | ||
def schema: Json = | ||
Json | ||
.obj( | ||
"type" -> Json.fromString("array"), | ||
"items" -> JsonSchemaEncoder[T].schema | ||
) | ||
} | ||
} | ||
|
||
trait instances extends instances_low_priority { | ||
given nullJsonSchemaEncoder: JsonSchemaEncoder[Null] with { | ||
def schema: Json = Json.obj("type" -> Json.fromString("null")) | ||
} | ||
} | ||
|
||
object instances extends instances |
53 changes: 0 additions & 53 deletions
53
src/main/scala/com/melvinlow/json/schema/instances/pkg.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.melvinlow.json.schema | ||
|
||
import io.circe.Json | ||
|
||
object syntax { | ||
extension [T: JsonSchemaEncoder](inline dummy: T) { | ||
inline def jsonSchema: Json = JsonSchemaEncoder[T].schema | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters