/** * Generated by API Builder - https://www.apibuilder.io * Service version: 0.0.6 * User agent: apibuilder app.apibuilder.io/flow/postman-generator-attributes/0.0.6/http4s_0_17 */ package io.flow.postman.generator.attributes.v0.models { /** * Attribute instructs the generator to add Basic Auth info to the whole Postman * collection. Attribute should be defined on the root level of the ApiBuilder * specification * * @param username Specifies the username to be used in Postman Collection auth definition. It may * be also a variable reference. * @param password Specified the password to be used in Postman Collection auth definition. It may * be also a variable reference. Leave this string empty, when only a username is * needed. */ final case class BasicAuth( username: String, password: String ) /** * Attribute instructs the generator to add a setup step with the referenced entity * creation. This attribute should be attached to the field (that holds an * identifier) inside model or to the resource path (that holds one path param). * * @param relatedServiceNamespace ApiBuilder service's namespace, in which a target operation is specified. * @param resourceType Resource type, that holds a referenced operation. * @param operationMethod Referenced operation method. * @param operationPath Operation path corresponding with the selected {{operation_method}}. * @param identifierField A field name. When the referenced operation is called, identifier_field is used * to extract the corresponding field from the response JSON. If the response JSON * is an array, then a value is extracted from the first object. * @param queryParams Optionally, the specified query params will be used to execute a referenced * operation. * @param deleteOperationPath Optionally, the referenced entity's DELETE operation path can be put here. If * specified, the generator will add a cleanup step for the referenced object. */ final case class ObjectReference( relatedServiceNamespace: String, resourceType: String, operationMethod: io.apibuilder.spec.v0.models.Method, operationPath: String, identifierField: String, queryParams: _root_.scala.Option[Map[String, String]] = None, deleteOperationPath: _root_.scala.Option[String] = None ) /** * Attribute instructs the generator to substitute a field value (when generating * examples) with specified value or variable reference. Attribute should be * attached to a field inside model. * * @param substitute Value, which will be put into the field marked by this attribute. It may be also * a variable reference. */ final case class ValueSubstitute( substitute: String ) /** * A set of attribute names, that are recognized by Postman Generator */ sealed trait AttributeName extends _root_.scala.Product with _root_.scala.Serializable object AttributeName { case object PostmanBasicAuth extends AttributeName { override def toString = "postman-basic-auth" } case object ObjectReference extends AttributeName { override def toString = "object-reference" } case object ValueSubstitute extends AttributeName { override def toString = "value-substitute" } /** * 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 AttributeName /** * 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[AttributeName] = scala.List(PostmanBasicAuth, ObjectReference, ValueSubstitute) private val byName: Map[String, AttributeName] = all.map(x => x.toString.toLowerCase -> x).toMap def apply(value: String): AttributeName = fromString(value).getOrElse(UNDEFINED(value)) def fromString(value: String): _root_.scala.Option[AttributeName] = byName.get(value.toLowerCase) } } package io.flow.postman.generator.attributes.v0.models { package object json { import io.circe.Decoder._ import io.circe.Encoder._ import scala.language.implicitConversions // See below - Make Scala 2.11 Either monadic import scala.util.Try import io.circe.{Json, JsonObject, Encoder, Decoder, DecodingFailure} import io.circe.syntax._ import io.apibuilder.spec.v0.models.json._ import io.flow.postman.generator.attributes.v0.models.json._ // Make Scala 2.11 Either monadic private[v0] implicit def eitherOps[A,B](e: Either[A,B]) = cats.implicits.catsSyntaxEither(e) private[v0] implicit val decodeUUID: Decoder[_root_.java.util.UUID] = Decoder.decodeString.emapTry(str => Try(_root_.java.util.UUID.fromString(str))) private[v0] implicit val encodeUUID: Encoder[_root_.java.util.UUID] = Encoder.encodeString.contramap[_root_.java.util.UUID](uuid => uuid.toString) private[v0] implicit val decodeInstant: Decoder[_root_.java.time.Instant] = Decoder.decodeString.emapTry(str => Try(_root_.java.time.OffsetDateTime.parse(str).toInstant)) private[v0] implicit val encodeInstant: Encoder[_root_.java.time.Instant] = Encoder.encodeString.contramap[_root_.java.time.Instant](_.toString) private[v0] implicit val decodeLocalDate: Decoder[_root_.java.time.LocalDate] = Decoder.decodeString.emapTry(str => Try(_root_.java.time.LocalDate.parse(str))) private[v0] implicit val encodeLocalDate: Encoder[_root_.java.time.LocalDate] = Encoder.encodeString.contramap[_root_.java.time.LocalDate](_.toString) implicit val jsonDecoderPostmanGeneratorAttributesAttributeName: Decoder[io.flow.postman.generator.attributes.v0.models.AttributeName] = Decoder.decodeString.map(io.flow.postman.generator.attributes.v0.models.AttributeName(_)) implicit val jsonEncoderPostmanGeneratorAttributesAttributeName: Encoder[io.flow.postman.generator.attributes.v0.models.AttributeName] = Encoder.encodeString.contramap[io.flow.postman.generator.attributes.v0.models.AttributeName](_.toString) implicit def decodePostmanGeneratorAttributesBasicAuth: Decoder[BasicAuth] = Decoder.instance { c => for { username <- c.downField("username").as[String] password <- c.downField("password").as[String] } yield { BasicAuth( username = username, password = password ) } } implicit def encodePostmanGeneratorAttributesBasicAuth: Encoder[BasicAuth] = Encoder.instance { t => Json.fromFields(Seq( Some("username" -> t.username.asJson), Some("password" -> t.password.asJson) ).flatten) } implicit def decodePostmanGeneratorAttributesObjectReference: Decoder[ObjectReference] = Decoder.instance { c => for { relatedServiceNamespace <- c.downField("related_service_namespace").as[String] resourceType <- c.downField("resource_type").as[String] operationMethod <- c.downField("operation_method").as[io.apibuilder.spec.v0.models.Method] operationPath <- c.downField("operation_path").as[String] identifierField <- c.downField("identifier_field").as[String] queryParams <- c.downField("query_params").as[Option[Map[String, String]]] deleteOperationPath <- c.downField("delete_operation_path").as[Option[String]] } yield { ObjectReference( relatedServiceNamespace = relatedServiceNamespace, resourceType = resourceType, operationMethod = operationMethod, operationPath = operationPath, identifierField = identifierField, queryParams = queryParams, deleteOperationPath = deleteOperationPath ) } } implicit def encodePostmanGeneratorAttributesObjectReference: Encoder[ObjectReference] = Encoder.instance { t => Json.fromFields(Seq( Some("related_service_namespace" -> t.relatedServiceNamespace.asJson), Some("resource_type" -> t.resourceType.asJson), Some("operation_method" -> t.operationMethod.asJson), Some("operation_path" -> t.operationPath.asJson), Some("identifier_field" -> t.identifierField.asJson), t.queryParams.map(t => "query_params" -> t.asJson), t.deleteOperationPath.map(t => "delete_operation_path" -> t.asJson) ).flatten) } implicit def decodePostmanGeneratorAttributesValueSubstitute: Decoder[ValueSubstitute] = Decoder.instance { c => for { substitute <- c.downField("substitute").as[String] } yield { ValueSubstitute( substitute = substitute ) } } implicit def encodePostmanGeneratorAttributesValueSubstitute: Encoder[ValueSubstitute] = Encoder.instance { t => Json.fromFields(Seq( Some("substitute" -> t.substitute.asJson) ).flatten) } } }