Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarrod Young committed Jul 27, 2021
1 parent 5a5e88c commit 480eae1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
36 changes: 18 additions & 18 deletions swagger/src/main/scala/org/http4s/rho/swagger/TypeBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ object TypeBuilder {
private[this] val logger = getLogger

def collectModels(t: Type, alreadyKnown: Set[Model], sfs: SwaggerFormats, et: Type)(implicit
st: ShowType): Set[Model] =
st: ShowType): Set[Model] =
try collectModels(t.dealias, alreadyKnown, ListSet.empty, sfs, et)
catch { case NonFatal(_) => Set.empty }

private def collectModels(
t: Type,
alreadyKnown: Set[Model],
known: TypeSet,
sfs: SwaggerFormats,
et: Type)(implicit st: ShowType): Set[Model] = {
t: Type,
alreadyKnown: Set[Model],
known: TypeSet,
sfs: SwaggerFormats,
et: Type)(implicit st: ShowType): Set[Model] = {

def go(t: Type, alreadyKnown: Set[Model], known: TypeSet): Set[Model] =
t.dealias match {
Expand All @@ -50,7 +50,7 @@ object TypeBuilder {
go(tpe.typeArgs.last, alreadyKnown, known + tpe)

case tpe
if (tpe.isCollection || tpe.isOption || tpe.isEffect(et)) && tpe.typeArgs.nonEmpty =>
if (tpe.isCollection || tpe.isOption || tpe.isEffect(et)) && tpe.typeArgs.nonEmpty =>
go(tpe.typeArgs.head, alreadyKnown, known + tpe)

case tpe if tpe.isStream =>
Expand All @@ -75,7 +75,7 @@ object TypeBuilder {
}.toSet

case tpe @ TypeRef(_, sym: Symbol, tpeArgs: List[Type])
if isCaseClass(sym) || isSumType(sym) =>
if isCaseClass(sym) || isSumType(sym) =>
val symIsSumType = isSumType(sym)
val maybeParentSumType = sym.asClass.baseClasses.drop(1).find(isSumType)

Expand Down Expand Up @@ -157,7 +157,7 @@ object TypeBuilder {
}

private def modelToSwagger(tpe: Type, sfs: SwaggerFormats)(implicit
st: ShowType): Option[ModelImpl] =
st: ShowType): Option[ModelImpl] =
try {
val TypeRef(_, sym: Symbol, tpeArgs: List[Type]) = tpe
val constructor = tpe.member(termNames.CONSTRUCTOR)
Expand Down Expand Up @@ -185,7 +185,7 @@ object TypeBuilder {
}

private def paramSymToProp(sym: Symbol, tpeArgs: List[Type], sfs: SwaggerFormats)(pSym: Symbol)(
implicit st: ShowType): (String, Property) = {
implicit st: ShowType): (String, Property) = {
val pType = pSym.typeSignature.substituteTypes(sym.asClass.typeParams, tpeArgs)
val required = !(pSym.asTerm.isParamWithDefault || pType.isOption)
val prop = typeToProperty(pType, sfs)
Expand Down Expand Up @@ -245,15 +245,15 @@ object TypeBuilder {
object DataType {

case class ValueDataType(
name: String,
format: Option[String] = None,
qualifiedName: Option[String] = None)
extends DataType
name: String,
format: Option[String] = None,
qualifiedName: Option[String] = None)
extends DataType
case class ContainerDataType(
name: String,
typeArg: Option[DataType] = None,
uniqueItems: Boolean = false)
extends DataType
name: String,
typeArg: Option[DataType] = None,
uniqueItems: Boolean = false)
extends DataType
case class ComplexDataType(name: String, qualifiedName: Option[String] = None) extends DataType
case class EnumDataType(enums: Set[String]) extends DataType { val name = "string" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ package object model {
modelOfWithFormats(DefaultSwaggerFormats)

def modelOfWithFormats[T](
formats: SwaggerFormats)(implicit t: TypeTag[T], st: ShowType): Set[Model] =
formats: SwaggerFormats)(implicit t: TypeTag[T], st: ShowType): Set[Model] =
TypeBuilder.collectModels(t.tpe, Set.empty, formats, typeOf[IO[_]])
}

Expand Down

0 comments on commit 480eae1

Please sign in to comment.