Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mbryzek committed Jun 25, 2024
1 parent 19a380a commit 76b0a38
Show file tree
Hide file tree
Showing 22 changed files with 91 additions and 111 deletions.
10 changes: 4 additions & 6 deletions lib/src/test/resources/example-union-types-ning-client.txt
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ package io.apibuilder.example.union.types.v0.models {
}

implicit def jsonReadsApidocExampleUnionTypesUserUuid: play.api.libs.json.Reads[UserUuid] = {
(__ \ "value").read[_root_.java.util.UUID].map { x => new UserUuid(value = x) }
(__ \ "value").read[_root_.java.util.UUID].map { x => UserUuid(value = x) }
}

implicit def jsonReadsApidocExampleUnionTypesFoobar: play.api.libs.json.Reads[Foobar] = {
Expand All @@ -322,7 +322,6 @@ package io.apibuilder.example.union.types.v0.models {
case x: io.apibuilder.example.union.types.v0.models.FoobarUndefinedType => sys.error(s"The type[io.apibuilder.example.union.types.v0.models.FoobarUndefinedType] should never be serialized")
}
}

implicit def jsonWritesApidocExampleUnionTypesFoobar: play.api.libs.json.Writes[Foobar] = {
(obj: io.apibuilder.example.union.types.v0.models.Foobar) => {
jsObjectFoobar(obj)
Expand All @@ -332,9 +331,9 @@ package io.apibuilder.example.union.types.v0.models {
implicit def jsonReadsApidocExampleUnionTypesUser: play.api.libs.json.Reads[User] = (js: play.api.libs.json.JsValue) => {
def readDiscriminator(discriminator: String) = {
discriminator match {
case "registered_user" => js.validate[io.apibuilder.example.union.types.v0.models.RegisteredUser]
case "guest_user" => js.validate[io.apibuilder.example.union.types.v0.models.GuestUser]
case "uuid" => js.validate[io.apibuilder.example.union.types.v0.models.UserUuid]
case "registered_user" => jsonReadsApidocExampleUnionTypesRegisteredUser.reads(js)
case "guest_user" => jsonReadsApidocExampleUnionTypesGuestUser.reads(js)
case "uuid" => jsonReadsApidocExampleUnionTypesUuid.reads(js)
case other => play.api.libs.json.JsSuccess(io.apibuilder.example.union.types.v0.models.UserUndefinedType(other))
}
}
Expand All @@ -354,7 +353,6 @@ package io.apibuilder.example.union.types.v0.models {
}
}
}

implicit def jsonWritesApidocExampleUnionTypesUser: play.api.libs.json.Writes[User] = {
(obj: io.apibuilder.example.union.types.v0.models.User) => {
jsObjectUser(obj)
Expand Down
10 changes: 4 additions & 6 deletions lib/src/test/resources/example-union-types-play-23.txt
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ package io.apibuilder.example.union.types.v0.models {
}

implicit def jsonReadsApidocExampleUnionTypesUserUuid: play.api.libs.json.Reads[UserUuid] = {
(__ \ "value").read[_root_.java.util.UUID].map { x => new UserUuid(value = x) }
(__ \ "value").read[_root_.java.util.UUID].map { x => UserUuid(value = x) }
}

implicit def jsonReadsApidocExampleUnionTypesFoobar: play.api.libs.json.Reads[Foobar] = {
Expand All @@ -322,7 +322,6 @@ package io.apibuilder.example.union.types.v0.models {
case x: io.apibuilder.example.union.types.v0.models.FoobarUndefinedType => sys.error(s"The type[io.apibuilder.example.union.types.v0.models.FoobarUndefinedType] should never be serialized")
}
}

implicit def jsonWritesApidocExampleUnionTypesFoobar: play.api.libs.json.Writes[Foobar] = {
(obj: io.apibuilder.example.union.types.v0.models.Foobar) => {
jsObjectFoobar(obj)
Expand All @@ -332,9 +331,9 @@ package io.apibuilder.example.union.types.v0.models {
implicit def jsonReadsApidocExampleUnionTypesUser: play.api.libs.json.Reads[User] = (js: play.api.libs.json.JsValue) => {
def readDiscriminator(discriminator: String) = {
discriminator match {
case "registered_user" => js.validate[io.apibuilder.example.union.types.v0.models.RegisteredUser]
case "guest_user" => js.validate[io.apibuilder.example.union.types.v0.models.GuestUser]
case "uuid" => js.validate[io.apibuilder.example.union.types.v0.models.UserUuid]
case "registered_user" => jsonReadsApidocExampleUnionTypesRegisteredUser.reads(js)
case "guest_user" => jsonReadsApidocExampleUnionTypesGuestUser.reads(js)
case "uuid" => jsonReadsApidocExampleUnionTypesUuid.reads(js)
case other => play.api.libs.json.JsSuccess(io.apibuilder.example.union.types.v0.models.UserUndefinedType(other))
}
}
Expand All @@ -354,7 +353,6 @@ package io.apibuilder.example.union.types.v0.models {
}
}
}

implicit def jsonWritesApidocExampleUnionTypesUser: play.api.libs.json.Writes[User] = {
(obj: io.apibuilder.example.union.types.v0.models.User) => {
jsObjectUser(obj)
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] = {
(__ \ "status").read[String].map { x => new Healthcheck(status = x) }
}
(__ \ "status").read[String].map { x => Healthcheck(status = x) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ package com.gilt.quality.v0.models {
}

implicit def jsonReadsQualityAdjournForm: play.api.libs.json.Reads[AdjournForm] = {
(__ \ "adjourned_at").readNullable[_root_.org.joda.time.DateTime].map { x => new AdjournForm(adjournedAt = x) }
(__ \ "adjourned_at").readNullable[_root_.org.joda.time.DateTime].map { x => AdjournForm(adjournedAt = x) }
}

def jsObjectAdjournForm(obj: com.gilt.quality.v0.models.AdjournForm): play.api.libs.json.JsObject = {
Expand Down Expand Up @@ -839,7 +839,7 @@ package com.gilt.quality.v0.models {
}

implicit def jsonReadsQualityAuthenticationForm: play.api.libs.json.Reads[AuthenticationForm] = {
(__ \ "email").read[String].map { x => new AuthenticationForm(email = x) }
(__ \ "email").read[String].map { x => AuthenticationForm(email = x) }
}

def jsObjectAuthenticationForm(obj: com.gilt.quality.v0.models.AuthenticationForm): play.api.libs.json.JsObject = {
Expand Down Expand Up @@ -991,7 +991,7 @@ package com.gilt.quality.v0.models {
}

implicit def jsonReadsQualityHealthcheck: play.api.libs.json.Reads[Healthcheck] = {
(__ \ "status").read[String].map { x => new Healthcheck(status = x) }
(__ \ "status").read[String].map { x => Healthcheck(status = x) }
}

def jsObjectHealthcheck(obj: com.gilt.quality.v0.models.Healthcheck): play.api.libs.json.JsObject = {
Expand Down Expand Up @@ -1174,7 +1174,7 @@ package com.gilt.quality.v0.models {
}

implicit def jsonReadsQualityMeetingForm: play.api.libs.json.Reads[MeetingForm] = {
(__ \ "scheduled_at").read[_root_.org.joda.time.DateTime].map { x => new MeetingForm(scheduledAt = x) }
(__ \ "scheduled_at").read[_root_.org.joda.time.DateTime].map { x => MeetingForm(scheduledAt = x) }
}

def jsObjectMeetingForm(obj: com.gilt.quality.v0.models.MeetingForm): play.api.libs.json.JsObject = {
Expand Down Expand Up @@ -1535,7 +1535,7 @@ package com.gilt.quality.v0.models {
}

implicit def jsonReadsQualityUserForm: play.api.libs.json.Reads[UserForm] = {
(__ \ "email").read[String].map { x => new UserForm(email = x) }
(__ \ "email").read[String].map { x => UserForm(email = x) }
}

def jsObjectUserForm(obj: com.gilt.quality.v0.models.UserForm): play.api.libs.json.JsObject = {
Expand Down
28 changes: 13 additions & 15 deletions lib/src/test/resources/generators/play-26-apidoc-api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ package io.apibuilder.api.v0.models {
}

implicit def jsonReadsApidocApiAttributeValueForm: play.api.libs.json.Reads[AttributeValueForm] = {
(__ \ "value").read[String].map { x => new AttributeValueForm(value = x) }
(__ \ "value").read[String].map { x => AttributeValueForm(value = x) }
}

def jsObjectAttributeValueForm(obj: io.apibuilder.api.v0.models.AttributeValueForm): play.api.libs.json.JsObject = {
Expand Down Expand Up @@ -1166,7 +1166,7 @@ package io.apibuilder.api.v0.models {
}

implicit def jsonReadsApidocApiCleartextToken: play.api.libs.json.Reads[CleartextToken] = {
(__ \ "token").read[String].map { x => new CleartextToken(token = x) }
(__ \ "token").read[String].map { x => CleartextToken(token = x) }
}

def jsObjectCleartextToken(obj: io.apibuilder.api.v0.models.CleartextToken): play.api.libs.json.JsObject = {
Expand Down Expand Up @@ -1204,7 +1204,7 @@ package io.apibuilder.api.v0.models {
}

implicit def jsonReadsApidocApiDiffBreaking: play.api.libs.json.Reads[DiffBreaking] = {
(__ \ "description").read[String].map { x => new DiffBreaking(description = x) }
(__ \ "description").read[String].map { x => DiffBreaking(description = x) }
}

def jsObjectDiffBreaking(obj: io.apibuilder.api.v0.models.DiffBreaking): play.api.libs.json.JsObject = {
Expand All @@ -1220,7 +1220,7 @@ package io.apibuilder.api.v0.models {
}

implicit def jsonReadsApidocApiDiffNonBreaking: play.api.libs.json.Reads[DiffNonBreaking] = {
(__ \ "description").read[String].map { x => new DiffNonBreaking(description = x) }
(__ \ "description").read[String].map { x => DiffNonBreaking(description = x) }
}

def jsObjectDiffNonBreaking(obj: io.apibuilder.api.v0.models.DiffNonBreaking): play.api.libs.json.JsObject = {
Expand All @@ -1236,7 +1236,7 @@ package io.apibuilder.api.v0.models {
}

implicit def jsonReadsApidocApiDomain: play.api.libs.json.Reads[Domain] = {
(__ \ "name").read[String].map { x => new Domain(name = x) }
(__ \ "name").read[String].map { x => Domain(name = x) }
}

def jsObjectDomain(obj: io.apibuilder.api.v0.models.Domain): play.api.libs.json.JsObject = {
Expand All @@ -1252,7 +1252,7 @@ package io.apibuilder.api.v0.models {
}

implicit def jsonReadsApidocApiEmailVerificationConfirmationForm: play.api.libs.json.Reads[EmailVerificationConfirmationForm] = {
(__ \ "token").read[String].map { x => new EmailVerificationConfirmationForm(token = x) }
(__ \ "token").read[String].map { x => EmailVerificationConfirmationForm(token = x) }
}

def jsObjectEmailVerificationConfirmationForm(obj: io.apibuilder.api.v0.models.EmailVerificationConfirmationForm): play.api.libs.json.JsObject = {
Expand Down Expand Up @@ -1330,7 +1330,7 @@ package io.apibuilder.api.v0.models {
}

implicit def jsonReadsApidocApiGeneratorServiceForm: play.api.libs.json.Reads[GeneratorServiceForm] = {
(__ \ "uri").read[String].map { x => new GeneratorServiceForm(uri = x) }
(__ \ "uri").read[String].map { x => GeneratorServiceForm(uri = x) }
}

def jsObjectGeneratorServiceForm(obj: io.apibuilder.api.v0.models.GeneratorServiceForm): play.api.libs.json.JsObject = {
Expand Down Expand Up @@ -1444,7 +1444,7 @@ package io.apibuilder.api.v0.models {
}

implicit def jsonReadsApidocApiMoveForm: play.api.libs.json.Reads[MoveForm] = {
(__ \ "org_key").read[String].map { x => new MoveForm(orgKey = x) }
(__ \ "org_key").read[String].map { x => MoveForm(orgKey = x) }
}

def jsObjectMoveForm(obj: io.apibuilder.api.v0.models.MoveForm): play.api.libs.json.JsObject = {
Expand Down Expand Up @@ -1583,7 +1583,7 @@ package io.apibuilder.api.v0.models {
}

implicit def jsonReadsApidocApiPasswordResetRequest: play.api.libs.json.Reads[PasswordResetRequest] = {
(__ \ "email").read[String].map { x => new PasswordResetRequest(email = x) }
(__ \ "email").read[String].map { x => PasswordResetRequest(email = x) }
}

def jsObjectPasswordResetRequest(obj: io.apibuilder.api.v0.models.PasswordResetRequest): play.api.libs.json.JsObject = {
Expand All @@ -1599,7 +1599,7 @@ package io.apibuilder.api.v0.models {
}

implicit def jsonReadsApidocApiPasswordResetSuccess: play.api.libs.json.Reads[PasswordResetSuccess] = {
(__ \ "user_guid").read[_root_.java.util.UUID].map { x => new PasswordResetSuccess(userGuid = x) }
(__ \ "user_guid").read[_root_.java.util.UUID].map { x => PasswordResetSuccess(userGuid = x) }
}

def jsObjectPasswordResetSuccess(obj: io.apibuilder.api.v0.models.PasswordResetSuccess): play.api.libs.json.JsObject = {
Expand Down Expand Up @@ -1938,8 +1938,8 @@ package io.apibuilder.api.v0.models {
implicit def jsonReadsApidocApiDiff: play.api.libs.json.Reads[Diff] = (js: play.api.libs.json.JsValue) => {
def readDiscriminator(discriminator: String) = {
discriminator match {
case "diff_breaking" => js.validate[io.apibuilder.api.v0.models.DiffBreaking]
case "diff_non_breaking" => js.validate[io.apibuilder.api.v0.models.DiffNonBreaking]
case "diff_breaking" => jsonReadsApidocApiDiffBreaking.reads(js)
case "diff_non_breaking" => jsonReadsApidocApiDiffNonBreaking.reads(js)
case other => play.api.libs.json.JsSuccess(io.apibuilder.api.v0.models.DiffUndefinedType(other))
}
}
Expand All @@ -1958,7 +1958,6 @@ package io.apibuilder.api.v0.models {
}
}
}

implicit def jsonWritesApidocApiDiff: play.api.libs.json.Writes[Diff] = {
(obj: io.apibuilder.api.v0.models.Diff) => {
jsObjectDiff(obj)
Expand All @@ -1968,7 +1967,7 @@ package io.apibuilder.api.v0.models {
implicit def jsonReadsApidocApiItemDetail: play.api.libs.json.Reads[ItemDetail] = (js: play.api.libs.json.JsValue) => {
def readDiscriminator(discriminator: String) = {
discriminator match {
case "application_summary" => js.validate[io.apibuilder.api.v0.models.ApplicationSummary]
case "application_summary" => jsonReadsApidocApiApplicationSummary.reads(js)
case other => play.api.libs.json.JsSuccess(io.apibuilder.api.v0.models.ItemDetailUndefinedType(other))
}
}
Expand All @@ -1986,7 +1985,6 @@ package io.apibuilder.api.v0.models {
}
}
}

implicit def jsonWritesApidocApiItemDetail: play.api.libs.json.Writes[ItemDetail] = {
(obj: io.apibuilder.api.v0.models.ItemDetail) => {
jsObjectItemDetail(obj)
Expand Down
9 changes: 4 additions & 5 deletions lib/src/test/resources/generators/play-26-envelope.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,18 @@ package io.gregor.time.types.v0.models {
}

implicit def jsonReadsTimeTypesDateTimeUnionDateTime: play.api.libs.json.Reads[DateTimeUnionDateTime] = {
(__ \ "value").read[_root_.org.joda.time.DateTime].map { x => new DateTimeUnionDateTime(value = x) }
(__ \ "value").read[_root_.org.joda.time.DateTime].map { x => DateTimeUnionDateTime(value = x) }
}

implicit def jsonReadsTimeTypesDateTimeUnionLocalDate: play.api.libs.json.Reads[DateTimeUnionLocalDate] = {
(__ \ "value").read[_root_.org.joda.time.LocalDate].map { x => new DateTimeUnionLocalDate(value = x) }
(__ \ "value").read[_root_.org.joda.time.LocalDate].map { x => DateTimeUnionLocalDate(value = x) }
}

implicit def jsonReadsTimeTypesDateTimeUnion: play.api.libs.json.Reads[DateTimeUnion] = (js: play.api.libs.json.JsValue) => {
def readDiscriminator(discriminator: String) = {
discriminator match {
case "date-time-iso8601" => js.validate[io.gregor.time.types.v0.models.DateTimeUnionDateTime]
case "date-iso8601" => js.validate[io.gregor.time.types.v0.models.DateTimeUnionLocalDate]
case "date-time-iso8601" => jsonReadsTimeTypesDateTimeIso8601.reads(js)
case "date-iso8601" => jsonReadsTimeTypesDateIso8601.reads(js)
case other => play.api.libs.json.JsSuccess(io.gregor.time.types.v0.models.DateTimeUnionUndefinedType(other))
}
}
Expand All @@ -151,7 +151,6 @@ package io.gregor.time.types.v0.models {
}
}
}

implicit def jsonWritesTimeTypesDateTimeUnion: play.api.libs.json.Writes[DateTimeUnion] = {
(obj: io.gregor.time.types.v0.models.DateTimeUnion) => {
jsObjectDateTimeUnion(obj)
Expand Down
Loading

0 comments on commit 76b0a38

Please sign in to comment.