Skip to content

Commit

Permalink
Merge pull request guardrail-dev#1598 from blast-hardcheese/issue-1597
Browse files Browse the repository at this point in the history
Suppress "Deprecated behavior" log if x-${lang}-type is present
  • Loading branch information
blast-hardcheese authored Oct 14, 2022
2 parents 00cee7b + 2847bfc commit 166b3d4
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions modules/core/src/main/scala/dev/guardrail/SwaggerUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,27 @@ object SwaggerUtil {
import Cl._
import Fw._

def log(fmt: Option[String], t: L#Type): L#Type = {
fmt.foreach { fmt =>
println(
s"Warning: Deprecated behavior: Unsupported format '$fmt' for type '${rawSchema.unwrapTracker
.getType()}', falling back to $t. Please switch definitions to x-scala-type for custom types. (${rawSchema.showHistory})"
)
}

t
}

for {
schemaProjection <- rawSchema
.downField("$ref", _.get$ref())
.indexedDistribute
.fold[F[Tracker[SchemaProjection]]](rawSchema.map(SchemaLiteral(_): SchemaProjection).pure[F]) { ref =>
Sw.dereferenceSchema(ref, components).map(_.map(schema => SchemaRef(SchemaLiteral(schema), ref.unwrapTracker)))
}
customTpe <- customType.indexedDistribute.flatTraverse(x => liftCustomType[L, F](x))
log = { (fmt: Option[String], t: L#Type) =>
fmt.foreach { fmt =>
if (customTpe.isEmpty) {
println(
s"Warning: Deprecated behavior: Unsupported format '$fmt' for type '${rawSchema.unwrapTracker
.getType()}', falling back to $t. Please switch definitions to x-scala-type for custom types. (${rawSchema.showHistory})"
)
}
}

t: L#Type
}

(renderType, reifiedRawType) <- {
def extractFormat(func: Option[String] => F[L#Type]): Tracker[Schema[_]] => F[(L#Type, ReifiedRawType)] = { schema =>
val rawType = schema.downField("type", _.getType())
Expand Down

0 comments on commit 166b3d4

Please sign in to comment.