Skip to content

Commit

Permalink
Make types explicit on json readers for scala (#698)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbryzek authored Jun 26, 2024
1 parent ba97e7d commit f1738e6
Show file tree
Hide file tree
Showing 37 changed files with 318 additions and 301 deletions.
10 changes: 5 additions & 5 deletions lib/src/test/resources/example-union-types-ning-client.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ package io.apibuilder.example.union.types.v0.models {
}
}

implicit def jsonReadsApidocExampleUnionTypesGuestUser: play.api.libs.json.Reads[GuestUser] = {
implicit def jsonReadsApidocExampleUnionTypesGuestUser: play.api.libs.json.Reads[io.apibuilder.example.union.types.v0.models.GuestUser] = {
for {
guid <- (__ \ "guid").read[_root_.java.util.UUID]
email <- (__ \ "email").read[String]
Expand All @@ -279,7 +279,7 @@ package io.apibuilder.example.union.types.v0.models {
}
}

implicit def jsonReadsApidocExampleUnionTypesRegisteredUser: play.api.libs.json.Reads[RegisteredUser] = {
implicit def jsonReadsApidocExampleUnionTypesRegisteredUser: play.api.libs.json.Reads[io.apibuilder.example.union.types.v0.models.RegisteredUser] = {
for {
guid <- (__ \ "guid").read[_root_.java.util.UUID]
email <- (__ \ "email").read[String]
Expand All @@ -301,11 +301,11 @@ package io.apibuilder.example.union.types.v0.models {
}
}

implicit def jsonReadsApidocExampleUnionTypesUserUuid: play.api.libs.json.Reads[UserUuid] = {
implicit def jsonReadsApidocExampleUnionTypesUserUuid: play.api.libs.json.Reads[io.apibuilder.example.union.types.v0.models.UserUuid] = {
(__ \ "value").read[_root_.java.util.UUID].map { x => UserUuid(value = x) }
}

implicit def jsonReadsApidocExampleUnionTypesFoobar: play.api.libs.json.Reads[Foobar] = {
implicit def jsonReadsApidocExampleUnionTypesFoobar: play.api.libs.json.Reads[io.apibuilder.example.union.types.v0.models.Foobar] = {
(
(__ \ "foo").read(jsonReadsApidocExampleUnionTypesFoo).asInstanceOf[play.api.libs.json.Reads[Foobar]]
orElse
Expand All @@ -328,7 +328,7 @@ package io.apibuilder.example.union.types.v0.models {
}
}

implicit def jsonReadsApidocExampleUnionTypesUser: play.api.libs.json.Reads[User] = (js: play.api.libs.json.JsValue) => {
implicit def jsonReadsApidocExampleUnionTypesUser: play.api.libs.json.Reads[io.apibuilder.example.union.types.v0.models.User] = (js: play.api.libs.json.JsValue) => {
def readDiscriminator(discriminator: String) = {
discriminator match {
case "registered_user" => jsonReadsApidocExampleUnionTypesRegisteredUser.reads(js)
Expand Down
10 changes: 5 additions & 5 deletions lib/src/test/resources/example-union-types-play-23.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ package io.apibuilder.example.union.types.v0.models {
}
}

implicit def jsonReadsApidocExampleUnionTypesGuestUser: play.api.libs.json.Reads[GuestUser] = {
implicit def jsonReadsApidocExampleUnionTypesGuestUser: play.api.libs.json.Reads[io.apibuilder.example.union.types.v0.models.GuestUser] = {
for {
guid <- (__ \ "guid").read[_root_.java.util.UUID]
email <- (__ \ "email").read[String]
Expand All @@ -279,7 +279,7 @@ package io.apibuilder.example.union.types.v0.models {
}
}

implicit def jsonReadsApidocExampleUnionTypesRegisteredUser: play.api.libs.json.Reads[RegisteredUser] = {
implicit def jsonReadsApidocExampleUnionTypesRegisteredUser: play.api.libs.json.Reads[io.apibuilder.example.union.types.v0.models.RegisteredUser] = {
for {
guid <- (__ \ "guid").read[_root_.java.util.UUID]
email <- (__ \ "email").read[String]
Expand All @@ -301,11 +301,11 @@ package io.apibuilder.example.union.types.v0.models {
}
}

implicit def jsonReadsApidocExampleUnionTypesUserUuid: play.api.libs.json.Reads[UserUuid] = {
implicit def jsonReadsApidocExampleUnionTypesUserUuid: play.api.libs.json.Reads[io.apibuilder.example.union.types.v0.models.UserUuid] = {
(__ \ "value").read[_root_.java.util.UUID].map { x => UserUuid(value = x) }
}

implicit def jsonReadsApidocExampleUnionTypesFoobar: play.api.libs.json.Reads[Foobar] = {
implicit def jsonReadsApidocExampleUnionTypesFoobar: play.api.libs.json.Reads[io.apibuilder.example.union.types.v0.models.Foobar] = {
(
(__ \ "foo").read(jsonReadsApidocExampleUnionTypesFoo).asInstanceOf[play.api.libs.json.Reads[Foobar]]
orElse
Expand All @@ -328,7 +328,7 @@ package io.apibuilder.example.union.types.v0.models {
}
}

implicit def jsonReadsApidocExampleUnionTypesUser: play.api.libs.json.Reads[User] = (js: play.api.libs.json.JsValue) => {
implicit def jsonReadsApidocExampleUnionTypesUser: play.api.libs.json.Reads[io.apibuilder.example.union.types.v0.models.User] = (js: play.api.libs.json.JsValue) => {
def readDiscriminator(discriminator: String) = {
discriminator match {
case "registered_user" => jsonReadsApidocExampleUnionTypesRegisteredUser.reads(js)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ package com.gilt.test.v0.models {
play.api.libs.json.JsString(_root_.org.joda.time.format.ISODateTimeFormat.date.print(x))
}

implicit def jsonReadsTestUser: play.api.libs.json.Reads[User] = {
implicit def jsonReadsTestUser: play.api.libs.json.Reads[com.gilt.test.v0.models.User] = {
for {
email <- (__ \ "email").read[String]
role <- (__ \ "role").read[String]
Expand All @@ -75,7 +75,7 @@ package com.gilt.test.v0.models {
}
}

implicit def jsonReadsTestUserPatch: play.api.libs.json.Reads[UserPatch] = {
implicit def jsonReadsTestUserPatch: play.api.libs.json.Reads[com.gilt.test.v0.models.UserPatch] = {
for {
groups <- (__ \ "groups").readNullable[Seq[String]]
permissions <- (__ \ "permissions").read[Seq[String]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ package com.gilt.test.v0.models {
play.api.libs.json.JsString(_root_.org.joda.time.format.ISODateTimeFormat.date.print(x))
}

implicit def jsonReadsTestUser: play.api.libs.json.Reads[User] = {
implicit def jsonReadsTestUser: play.api.libs.json.Reads[com.gilt.test.v0.models.User] = {
for {
email <- (__ \ "email").read[String]
role <- (__ \ "role").read[String]
Expand All @@ -75,7 +75,7 @@ package com.gilt.test.v0.models {
}
}

implicit def jsonReadsTestUserPatch: play.api.libs.json.Reads[UserPatch] = {
implicit def jsonReadsTestUserPatch: play.api.libs.json.Reads[com.gilt.test.v0.models.UserPatch] = {
for {
groups <- (__ \ "groups").readNullable[Seq[String]]
permissions <- (__ \ "permissions").read[Seq[String]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ package com.gilt.test.v0.models {
play.api.libs.json.JsString(_root_.org.joda.time.format.ISODateTimeFormat.date.print(x))
}

implicit def jsonReadsTestUser: play.api.libs.json.Reads[User] = {
implicit def jsonReadsTestUser: play.api.libs.json.Reads[com.gilt.test.v0.models.User] = {
for {
email <- (__ \ "email").read[String]
role <- (__ \ "role").read[String]
Expand All @@ -75,7 +75,7 @@ package com.gilt.test.v0.models {
}
}

implicit def jsonReadsTestUserPatch: play.api.libs.json.Reads[UserPatch] = {
implicit def jsonReadsTestUserPatch: play.api.libs.json.Reads[com.gilt.test.v0.models.UserPatch] = {
for {
groups <- (__ \ "groups").readNullable[Seq[String]]
permissions <- (__ \ "permissions").read[Seq[String]]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
implicit def jsonReadsQualityHealthcheck: play.api.libs.json.Reads[Healthcheck] = {
implicit def jsonReadsQualityHealthcheck: play.api.libs.json.Reads[com.gilt.quality.v0.models.Healthcheck] = {
(__ \ "status").read[String].map { x => Healthcheck(status = x) }
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
implicit def jsonReadsQualityPlan: play.api.libs.json.Reads[Plan] = {
implicit def jsonReadsQualityPlan: play.api.libs.json.Reads[com.gilt.quality.v0.models.Plan] = {
for {
id <- (__ \ "id").read[Long]
incidentId <- (__ \ "incident_id").read[Long]
Expand Down
Loading

0 comments on commit f1738e6

Please sign in to comment.