Skip to content

Commit

Permalink
Update service spec
Browse files Browse the repository at this point in the history
  • Loading branch information
mbryzek committed Aug 3, 2024
1 parent 6fb8aba commit dd8a00d
Show file tree
Hide file tree
Showing 14 changed files with 505 additions and 545 deletions.
143 changes: 104 additions & 39 deletions generated/app/ApicollectiveApibuilderCommonV0Models.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Generated by API Builder - https://www.apibuilder.io
* Service version: 0.15.26
* apibuilder 0.15.11 app.apibuilder.io/apicollective/apibuilder-common/latest/play_2_x_json
* Service version: 0.16.53
* User agent: apibuilder app.apibuilder.io/apicollective/apibuilder-common/latest/play_2_x_json
*/
package io.apibuilder.common.v0.models {

Expand All @@ -19,6 +19,7 @@ package io.apibuilder.common.v0.models {
/**
* Represents a reference to another model.
*/

final case class Reference(
guid: _root_.java.util.UUID,
key: String
Expand All @@ -27,6 +28,38 @@ package io.apibuilder.common.v0.models {
final case class ReferenceGuid(
guid: _root_.java.util.UUID
)
sealed trait MembershipRole extends _root_.scala.Product with _root_.scala.Serializable

object MembershipRole {

case object Member extends MembershipRole { override def toString = "member" }
case object Admin extends MembershipRole { override def toString = "admin" }
/**
* UNDEFINED captures values that are sent either in error or
* that were added by the server after this library was
* generated. We want to make it easy and obvious for users of
* this library to handle this case gracefully.
*
* We use all CAPS for the variable name to avoid collisions
* with the camel cased values above.
*/
final case class UNDEFINED(override val toString: String) extends MembershipRole

/**
* all returns a list of all the valid, known values. We use
* lower case to avoid collisions with the camel cased values
* above.
*/
val all: scala.List[MembershipRole] = scala.List(Member, Admin)

private
val byName: Map[String, MembershipRole] = all.map(x => x.toString.toLowerCase -> x).toMap

def apply(value: String): MembershipRole = fromString(value).getOrElse(UNDEFINED(value))

def fromString(value: String): _root_.scala.Option[MembershipRole] = byName.get(value.toLowerCase)

}

}

Expand All @@ -39,35 +72,61 @@ package io.apibuilder.common.v0.models {
import play.api.libs.functional.syntax._
import io.apibuilder.common.v0.models.json._

private[v0] implicit val jsonReadsUUID = __.read[String].map { str =>
private[v0] implicit val jsonReadsUUID: play.api.libs.json.Reads[_root_.java.util.UUID] = __.read[String].map { str =>
_root_.java.util.UUID.fromString(str)
}

private[v0] implicit val jsonWritesUUID = new Writes[_root_.java.util.UUID] {
def writes(x: _root_.java.util.UUID) = JsString(x.toString)
}
private[v0] implicit val jsonWritesUUID: play.api.libs.json.Writes[_root_.java.util.UUID] = (x: _root_.java.util.UUID) => play.api.libs.json.JsString(x.toString)

private[v0] implicit val jsonReadsJodaDateTime = __.read[String].map { str =>
private[v0] implicit val jsonReadsJodaDateTime: play.api.libs.json.Reads[_root_.org.joda.time.DateTime] = __.read[String].map { str =>
_root_.org.joda.time.format.ISODateTimeFormat.dateTimeParser.parseDateTime(str)
}

private[v0] implicit val jsonWritesJodaDateTime = new Writes[_root_.org.joda.time.DateTime] {
def writes(x: _root_.org.joda.time.DateTime) = {
JsString(_root_.org.joda.time.format.ISODateTimeFormat.dateTime.print(x))
}
private[v0] implicit val jsonWritesJodaDateTime: play.api.libs.json.Writes[_root_.org.joda.time.DateTime] = (x: _root_.org.joda.time.DateTime) => {
play.api.libs.json.JsString(_root_.org.joda.time.format.ISODateTimeFormat.dateTime.print(x))
}

private[v0] implicit val jsonReadsJodaLocalDate = __.read[String].map { str =>
private[v0] implicit val jsonReadsJodaLocalDate: play.api.libs.json.Reads[_root_.org.joda.time.LocalDate] = __.read[String].map { str =>
_root_.org.joda.time.format.ISODateTimeFormat.dateTimeParser.parseLocalDate(str)
}

private[v0] implicit val jsonWritesJodaLocalDate = new Writes[_root_.org.joda.time.LocalDate] {
def writes(x: _root_.org.joda.time.LocalDate) = {
JsString(_root_.org.joda.time.format.ISODateTimeFormat.date.print(x))
private[v0] implicit val jsonWritesJodaLocalDate: play.api.libs.json.Writes[_root_.org.joda.time.LocalDate] = (x: _root_.org.joda.time.LocalDate) => {
play.api.libs.json.JsString(_root_.org.joda.time.format.ISODateTimeFormat.date.print(x))
}

implicit val jsonReadsApibuilderCommonMembershipRole: play.api.libs.json.Reads[io.apibuilder.common.v0.models.MembershipRole] = new play.api.libs.json.Reads[io.apibuilder.common.v0.models.MembershipRole] {
def reads(js: play.api.libs.json.JsValue): play.api.libs.json.JsResult[io.apibuilder.common.v0.models.MembershipRole] = {
js match {
case v: play.api.libs.json.JsString => play.api.libs.json.JsSuccess(io.apibuilder.common.v0.models.MembershipRole(v.value))
case _ => {
(js \ "value").validate[String] match {
case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(io.apibuilder.common.v0.models.MembershipRole(v))
case err: play.api.libs.json.JsError =>
(js \ "membership_role").validate[String] match {
case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(io.apibuilder.common.v0.models.MembershipRole(v))
case err: play.api.libs.json.JsError => err
}
}
}
}
}
}

def jsonWritesApibuilderCommonMembershipRole(obj: io.apibuilder.common.v0.models.MembershipRole) = {
play.api.libs.json.JsString(obj.toString)
}

def jsObjectMembershipRole(obj: io.apibuilder.common.v0.models.MembershipRole) = {
play.api.libs.json.Json.obj("value" -> play.api.libs.json.JsString(obj.toString))
}

implicit def jsonWritesApibuilderCommonMembershipRole: play.api.libs.json.Writes[MembershipRole] = {
(obj: io.apibuilder.common.v0.models.MembershipRole) => {
io.apibuilder.common.v0.models.json.jsonWritesApibuilderCommonMembershipRole(obj)
}
}

implicit def jsonReadsApibuilderCommonAudit: play.api.libs.json.Reads[Audit] = {
implicit def jsonReadsApibuilderCommonAudit: play.api.libs.json.Reads[io.apibuilder.common.v0.models.Audit] = {
for {
createdAt <- (__ \ "created_at").read[_root_.org.joda.time.DateTime]
createdBy <- (__ \ "created_by").read[io.apibuilder.common.v0.models.ReferenceGuid]
Expand All @@ -79,22 +138,20 @@ package io.apibuilder.common.v0.models {
def jsObjectAudit(obj: io.apibuilder.common.v0.models.Audit): play.api.libs.json.JsObject = {
play.api.libs.json.Json.obj(
"created_at" -> play.api.libs.json.JsString(_root_.org.joda.time.format.ISODateTimeFormat.dateTime.print(obj.createdAt)),
"created_by" -> jsObjectReferenceGuid(obj.createdBy),
"created_by" -> io.apibuilder.common.v0.models.json.jsObjectReferenceGuid(obj.createdBy),
"updated_at" -> play.api.libs.json.JsString(_root_.org.joda.time.format.ISODateTimeFormat.dateTime.print(obj.updatedAt)),
"updated_by" -> jsObjectReferenceGuid(obj.updatedBy)
"updated_by" -> io.apibuilder.common.v0.models.json.jsObjectReferenceGuid(obj.updatedBy)
)
}

implicit def jsonWritesApibuilderCommonAudit: play.api.libs.json.Writes[Audit] = {
new play.api.libs.json.Writes[io.apibuilder.common.v0.models.Audit] {
def writes(obj: io.apibuilder.common.v0.models.Audit) = {
jsObjectAudit(obj)
}
(obj: io.apibuilder.common.v0.models.Audit) => {
io.apibuilder.common.v0.models.json.jsObjectAudit(obj)
}
}

implicit def jsonReadsApibuilderCommonHealthcheck: play.api.libs.json.Reads[Healthcheck] = {
(__ \ "status").read[String].map { x => new Healthcheck(status = x) }
implicit def jsonReadsApibuilderCommonHealthcheck: play.api.libs.json.Reads[io.apibuilder.common.v0.models.Healthcheck] = {
(__ \ "status").read[String].map { x => Healthcheck(status = x) }
}

def jsObjectHealthcheck(obj: io.apibuilder.common.v0.models.Healthcheck): play.api.libs.json.JsObject = {
Expand All @@ -104,14 +161,12 @@ package io.apibuilder.common.v0.models {
}

implicit def jsonWritesApibuilderCommonHealthcheck: play.api.libs.json.Writes[Healthcheck] = {
new play.api.libs.json.Writes[io.apibuilder.common.v0.models.Healthcheck] {
def writes(obj: io.apibuilder.common.v0.models.Healthcheck) = {
jsObjectHealthcheck(obj)
}
(obj: io.apibuilder.common.v0.models.Healthcheck) => {
io.apibuilder.common.v0.models.json.jsObjectHealthcheck(obj)
}
}

implicit def jsonReadsApibuilderCommonReference: play.api.libs.json.Reads[Reference] = {
implicit def jsonReadsApibuilderCommonReference: play.api.libs.json.Reads[io.apibuilder.common.v0.models.Reference] = {
for {
guid <- (__ \ "guid").read[_root_.java.util.UUID]
key <- (__ \ "key").read[String]
Expand All @@ -126,15 +181,13 @@ package io.apibuilder.common.v0.models {
}

implicit def jsonWritesApibuilderCommonReference: play.api.libs.json.Writes[Reference] = {
new play.api.libs.json.Writes[io.apibuilder.common.v0.models.Reference] {
def writes(obj: io.apibuilder.common.v0.models.Reference) = {
jsObjectReference(obj)
}
(obj: io.apibuilder.common.v0.models.Reference) => {
io.apibuilder.common.v0.models.json.jsObjectReference(obj)
}
}

implicit def jsonReadsApibuilderCommonReferenceGuid: play.api.libs.json.Reads[ReferenceGuid] = {
(__ \ "guid").read[_root_.java.util.UUID].map { x => new ReferenceGuid(guid = x) }
implicit def jsonReadsApibuilderCommonReferenceGuid: play.api.libs.json.Reads[io.apibuilder.common.v0.models.ReferenceGuid] = {
(__ \ "guid").read[_root_.java.util.UUID].map { x => ReferenceGuid(guid = x) }
}

def jsObjectReferenceGuid(obj: io.apibuilder.common.v0.models.ReferenceGuid): play.api.libs.json.JsObject = {
Expand All @@ -144,10 +197,8 @@ package io.apibuilder.common.v0.models {
}

implicit def jsonWritesApibuilderCommonReferenceGuid: play.api.libs.json.Writes[ReferenceGuid] = {
new play.api.libs.json.Writes[io.apibuilder.common.v0.models.ReferenceGuid] {
def writes(obj: io.apibuilder.common.v0.models.ReferenceGuid) = {
jsObjectReferenceGuid(obj)
}
(obj: io.apibuilder.common.v0.models.ReferenceGuid) => {
io.apibuilder.common.v0.models.json.jsObjectReferenceGuid(obj)
}
}
}
Expand All @@ -161,6 +212,7 @@ package io.apibuilder.common.v0 {

// import models directly for backwards compatibility with prior versions of the generator
import Core._
import Models._

object Core {
implicit def pathBindableDateTimeIso8601(implicit stringBinder: QueryStringBindable[String]): PathBindable[_root_.org.joda.time.DateTime] = ApibuilderPathBindable(ApibuilderTypes.dateTimeIso8601)
Expand All @@ -170,6 +222,19 @@ package io.apibuilder.common.v0 {
implicit def queryStringBindableDateIso8601(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[_root_.org.joda.time.LocalDate] = ApibuilderQueryStringBindable(ApibuilderTypes.dateIso8601)
}

object Models {
import io.apibuilder.common.v0.models._

val membershipRoleConverter: ApibuilderTypeConverter[io.apibuilder.common.v0.models.MembershipRole] = new ApibuilderTypeConverter[io.apibuilder.common.v0.models.MembershipRole] {
override def convert(value: String): io.apibuilder.common.v0.models.MembershipRole = io.apibuilder.common.v0.models.MembershipRole(value)
override def convert(value: io.apibuilder.common.v0.models.MembershipRole): String = value.toString
override def example: io.apibuilder.common.v0.models.MembershipRole = io.apibuilder.common.v0.models.MembershipRole.Member
override def validValues: Seq[io.apibuilder.common.v0.models.MembershipRole] = io.apibuilder.common.v0.models.MembershipRole.all
}
implicit def pathBindableMembershipRole(implicit stringBinder: QueryStringBindable[String]): PathBindable[io.apibuilder.common.v0.models.MembershipRole] = ApibuilderPathBindable(membershipRoleConverter)
implicit def queryStringBindableMembershipRole(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[io.apibuilder.common.v0.models.MembershipRole] = ApibuilderQueryStringBindable(membershipRoleConverter)
}

trait ApibuilderTypeConverter[T] {

def convert(value: String): T
Expand Down
Loading

0 comments on commit dd8a00d

Please sign in to comment.