EndpointGen

zio.http.gen.openapi.EndpointGen
See theEndpointGen companion object
final case class EndpointGen(config: Config)

Attributes

Companion
object
Source
EndpointGen.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Type members

Classlikes

Attributes

Source
EndpointGen.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Source
EndpointGen.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Value members

Concrete methods

def addNumericValidations[T : ClassTag](minOpt: Option[T], maxOpt: Option[T]): List[Annotation]

Attributes

Source
EndpointGen.scala
def addStringValidations(minLength: Option[Int], maxLength: Option[Int]): List[Annotation]

Attributes

Source
EndpointGen.scala
def aliasedSchemaToCode(openAPI: OpenAPI, name: String, wrapped: JsonSchema): Option[File]

Value parameters

wrapped

primitive type to be aliased as name

Attributes

Returns

Code.File that have the following structure (e.g. for name="Name", and wrapped = String):

         package base.components
         import zio.prelude.Newtype
         import zio.schema.Schema
         object Name extends Newtype[String] {
           implicit val schema: Schema[Name.Type] = Schema.primitive[String].transform(wrap, unwrap)
         }
Source
EndpointGen.scala
def fromOpenAPI(openAPI: OpenAPI): Files

Attributes

Source
EndpointGen.scala
def mapCaseClasses[T <: ScalaType](f: CaseClass => CaseClass)(code: T): T

Given a function to alter a case class, this function will apply it to any structure recursively.

Given a function to alter a case class, this function will apply it to any structure recursively.

Value parameters

code

the structure to apply transformation of case classes on

f

function to transform a zio.http.gen.scala.Code.CaseClass

Attributes

Returns

the transformed structure

Source
EndpointGen.scala
def mapField(subtypeToTraits: Map[String, Set[String]], aliasedPrimitives: Map[String, ScalaType], encapsulatingName: => String): Field => Field

Attributes

Source
EndpointGen.scala
def mapType[T <: ScalaType](getEncapsulatingName: T => String, subtypeToTraits: Map[String, Set[String]], aliasedPrimitives: Map[String, ScalaType])(codeStructureToAlter: T): T

The types may not be valid in case we reference a concrete subtype of a sealed trait, as the subtype is defined as an inner class encapsulated inside the trait's companion. Therefore, we can alter the type to include the enclosing trait/object's name. The following function will be used to alter the type of all fields needed. The mapCaseClasses helper takes a function that alters a case class, and lifts it such that we can apply it to any structure, and it'll take care to recurse when needed.

The types may not be valid in case we reference a concrete subtype of a sealed trait, as the subtype is defined as an inner class encapsulated inside the trait's companion. Therefore, we can alter the type to include the enclosing trait/object's name. The following function will be used to alter the type of all fields needed. The mapCaseClasses helper takes a function that alters a case class, and lifts it such that we can apply it to any structure, and it'll take care to recurse when needed.

Another issue we fix here, is when we have aliased primitives. In that case we need to append .Type to the aliased primitive type.

Value parameters

codeStructureToAlter

the structure to modify

getEncapsulatingName

used to get the name of the code structure we operate on (Object/CaseClass/Enum)

subtypeToTraits

mappings of subtypes to their mixins - if theres only one, we assume subtype is nested.

Attributes

Returns

the modified structure

Source
EndpointGen.scala

Given the type parameter of a field, we may want to alter it, e.g. by prepending the enclosing trait/object's name. This function will recursively alter the type of a field. Recursion is needed for types that contain a type parameter. e.g. transforming:

Given the type parameter of a field, we may want to alter it, e.g. by prepending the enclosing trait/object's name. This function will recursively alter the type of a field. Recursion is needed for types that contain a type parameter. e.g. transforming:

Chunk[Option[Zebra]]

to

Chunk[Option[Animal.Zebra]]

Value parameters

f

a function that may alter the type, None means no altering is needed.

sType

the original type we want to alter

Attributes

Returns

The altered type, or gives back the input if no modification was needed.

Source
EndpointGen.scala
def schemaToCode(schema: JsonSchema, openAPI: OpenAPI, name: String, annotations: Chunk[MetaData], mixins: List[String] = ..., abstractMembers: List[Object] = ...): Option[File]

Attributes

Source
EndpointGen.scala
def schemaToField(schema: JsonSchema, openAPI: OpenAPI, name: String, annotations: Chunk[MetaData]): Option[Field]

Attributes

Source
EndpointGen.scala

Inherited methods

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product