Skip to content

Commit

Permalink
Merge pull request #1827 from blast-hardcheese/remove-deprecations
Browse files Browse the repository at this point in the history
Remove deprecations
  • Loading branch information
blast-hardcheese authored Oct 10, 2023
2 parents c1aadd7 + 5bfd1c6 commit 1d0f72e
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 52 deletions.
3 changes: 0 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ addCommandAlias("runtimeAkkaHttpSuite", "; resetSample ; runExample scala akka-h

addCommandAlias("resetSample", "; " ++ (scalaFrameworks ++ javaFrameworks).map(x => s"sample-${x.projectName}/clean").mkString(" ; "))

// Deprecated command
addCommandAlias("example", "runtimeSuite")

addCommandAlias("cli", "runMain dev.guardrail.cli.CLI")
addCommandAlias("runtimeScalaSuite", "; resetSample ; runScalaExample ; " + scalaFrameworks.map(x => s"sample-${x.projectName}/test").mkString("; "))
addCommandAlias("runtimeJavaSuite", "; resetSample ; runJavaExample ; " + javaFrameworks.map(x => s"sample-${x.projectName}/test").mkString("; "))
Expand Down
6 changes: 0 additions & 6 deletions modules/core/src/main/scala/dev/guardrail/core/Tracker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,8 @@ trait HighPriorityTrackerSyntax extends LowPriorityTrackerSyntax {

def showHistory: String = tracker.history.mkString("")

@deprecated("Tracker.get will be removed once the migration has been completed. Please use the fold/traverse combinators to get values out.", "0.0.0")
def get: A = tracker.get

def unwrapTracker: A = tracker.get

@deprecated("Tracker.get will be removed once the migration has been completed. Please use the fold/traverse combinators to get values out.", "0.0.0")
def history: Vector[String] = tracker.history

def forceConvince[C](implicit ev: Tracker.Convincer[Option[A], C]): Tracker[C] =
tracker.map(x => ev(Option(x)))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,9 @@ package object extract {
private def extractFromNames[F: VendorExtension.VendorExtensible, T: Extractable](v: F, names: List[String]): Option[T] =
names.collectFirstSome(VendorExtension(v).extract[T](_))

private def extractWithFallback[F: VendorExtension.VendorExtensible, T: Extractable](v: F, name: String, fallbackName: String): Option[T] = {
private def extractName[F: VendorExtension.VendorExtensible, T: Extractable](v: F, name: String): Option[T] = {
val ve = VendorExtension(v)
ve.extract[T](name)
.orElse {
val value = ve.extract[T](fallbackName)
if (value.isDefined) {
println(s"WARNING: Deprecated vendor extension '${fallbackName}'; please migrate to use '${name}' instead")
}
value
}
}

def CustomTypeName[F: VendorExtension.VendorExtensible](v: F, vendorPrefixes: List[String]): Option[String] =
Expand All @@ -28,7 +21,7 @@ package object extract {
extractFromNames[F, String](v, vendorPrefixes.map(_ + "-map-type"))

def TracingLabel[F: VendorExtension.VendorExtensible](v: F): Option[String] =
extractWithFallback[F, String](v, "x-tracing-label", "x-scala-tracing-label")
extractName[F, String](v, "x-tracing-label")

def PackageName[F: VendorExtension.VendorExtensible](v: F, vendorPrefixes: List[String]): Option[String] =
extractFromNames[F, String](v, vendorPrefixes.map(_ + "-package"))
Expand All @@ -40,10 +33,10 @@ package object extract {
VendorExtension(v).extract[Boolean]("x-server-raw-response")

def EmptyValueIsNull[F: VendorExtension.VendorExtensible](v: F): Option[EmptyToNullBehaviour] =
extractWithFallback[F, EmptyToNullBehaviour](v, "x-empty-is-null", "x-scala-empty-is-null")
extractName[F, EmptyToNullBehaviour](v, "x-empty-is-null")

def FileHashAlgorithm[F: VendorExtension.VendorExtensible](v: F): Option[String] =
extractWithFallback[F, String](v, "x-file-hash", "x-scala-file-hash")
extractName[F, String](v, "x-file-hash")

def DataRedaction[F: VendorExtension.VendorExtensible](v: F): Option[RedactionBehaviour] =
VendorExtension(v).extract[RedactionBehaviour]("x-data-redaction")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,6 @@ object ModelResolver {
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 =>
Expand Down Expand Up @@ -196,7 +184,7 @@ object ModelResolver {
)
// Explicitly return `string` if ObjectSchema has enum values. Should this go?
.orRefine { case SchemaLiteral(x: ObjectSchema) if Option(x.getEnum).map(_.asScala).exists(_.nonEmpty) => x }(
extractFormat(fmt => stringType(None).map(log(fmt, _)))
extractFormat(fmt => stringType(None))
)
// First, match SchemaLiteral's that have conditionals on either the type or format
.orRefine { case SchemaLiteral(x: IntegerSchema) if x.getFormat() == "int32" => x }(const(intType()))
Expand All @@ -218,12 +206,12 @@ object ModelResolver {
.orRefine { case SchemaLiteral(x: EmailSchema) => x }(const(stringType(None)))
.orRefine { case SchemaLiteral(x: FileSchema) => x }(const(fileType(None)))
.orRefine { case SchemaLiteral(x: IntegerSchema) => x }(extractFormat(fmt => integerType(fmt)))
.orRefine { case SchemaLiteral(x: JsonSchema) => x }(extractFormat(fmt => objectType(fmt).map(log(fmt, _))))
.orRefine { case SchemaLiteral(x: MapSchema) => x }(extractFormat(fmt => objectType(fmt).map(log(fmt, _))))
.orRefine { case SchemaLiteral(x: NumberSchema) => x }(extractFormat(fmt => numberType(fmt).map(log(fmt, _))))
.orRefine { case SchemaLiteral(x: ObjectSchema) => x }(extractFormat(fmt => objectType(fmt).map(log(fmt, _))))
.orRefine { case SchemaLiteral(x: JsonSchema) => x }(extractFormat(fmt => objectType(fmt)))
.orRefine { case SchemaLiteral(x: MapSchema) => x }(extractFormat(fmt => objectType(fmt)))
.orRefine { case SchemaLiteral(x: NumberSchema) => x }(extractFormat(fmt => numberType(fmt)))
.orRefine { case SchemaLiteral(x: ObjectSchema) => x }(extractFormat(fmt => objectType(fmt)))
.orRefine { case SchemaLiteral(x: PasswordSchema) => x }(const(stringType(None)))
.orRefine { case SchemaLiteral(x: StringSchema) => x }(extractFormat(fmt => stringType(None).map(log(fmt, _))))
.orRefine { case SchemaLiteral(x: StringSchema) => x }(extractFormat(fmt => stringType(None)))
.orRefine { case SchemaLiteral(x: UUIDSchema) => x }(const(uuidType()))
// Finally, attempt to recover if we've gotten all the way down here without knowing what we're dealing with
.orRefineFallback { schemaProjection =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ package object syntax {
tpe.isPrimitiveType || tpe.isNamed("BigInteger") || tpe.isNamed("BigDecimal") || tpe.isNamed("String") || tpe.isNamed("OffsetDateTime") || tpe.isNamed(
"LocalDate"
)

@deprecated("Just use Type#asString", "0.0.0")
def name: Option[String] = Option(tpe.asString)
}

implicit class RichNode(private val n: Node) extends AnyVal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ class Issue145 extends AnyFunSpec with Matchers with SwaggerSpecRunner {
| properties:
| name:
| type: string
| x-scala-empty-is-null: true
| x-empty-is-null: true
| x-scala-type: CustomThing
| underscore_name:
| type: string
| x-scala-empty-is-null: true
| x-empty-is-null: true
| x-scala-type: CustomThing
| dash-name:
| type: string
| x-scala-empty-is-null: true
| x-empty-is-null: true
| x-scala-type: CustomThing
|""".stripMargin

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class FormFieldsServerTest extends AnyFunSuite with Matchers with SwaggerSpecRun
| in: formData
| type: file
| required: true
| x-scala-file-hash: SHA-512
| x-file-hash: SHA-512
| responses:
| 200:
| description: Success
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,11 @@ class Http4sClientGeneratorLoader extends ClientGeneratorLoader {
}

object Http4sClientGenerator {
@deprecated("Please specify which http4s version to use", "0.72.0")
def apply(): ClientTerms[ScalaLanguage, Target] =
new Http4sClientGenerator(Http4sVersion.V0_23)

def apply(version: Http4sVersion): ClientTerms[ScalaLanguage, Target] =
new Http4sClientGenerator(version)
}

class Http4sClientGenerator(version: Http4sVersion) extends ClientTerms[ScalaLanguage, Target] {
@deprecated("Please specify which http4s version to use", "0.72.0")
def this() = this(Http4sVersion.V0_23)

override implicit def MonadF: Monad[Target] = Target.targetInstances

def splitOperationParts(operationId: String): (List[String], String) = {
Expand Down

0 comments on commit 1d0f72e

Please sign in to comment.