github softwaremill/tapir v0.18.0

latest releases: v1.11.5, v1.11.4, v1.11.3...
3 years ago

Summary

The main features in this release:

  • Scala3 support: core, http4s & vertx servers, sttp client, as well as some json and datatypes integrations are available in the JVM flavor
  • content negotiation on server & client side
  • the structure of data is reflected only in schemas, not in validators. Validators are much simpler now, and part of schemas
  • server interpreters have been rewritten, and support two types of interceptors (request & endpoint interceptors). Some functionalities (logging, decode failure handling) are implemented as interceptors; custom interceptors can be added
  • exceptions are handled and result in the 500 status code
  • The generated documentation will now include an entry for 400 Bad Request by default, if none is specified by the user, enumerating the reasons on why request decoding might fail. This can be turned off or adjusted in OpenAPIDocsOptions.
  • ZIO Http server interpreter

Thanks to all the contributors for their cooperation, especially @mbore, @kubinio123, @bartekzylinski, @slabiakt, @danielleontiev, @hamnis, @majk-p, @MichalPawlicki, @PawelJ-PL, @endertunc, @ae0n!

Major breaking changes

  • SchemaTypes are not objects, but classes. If you specified the schema type manually, instead of e.g. SchemaType.SString you'll have to use SchemaType.SString()
  • server options have been significantly refactored. To create custom options, use e.g. AkkaServerOptions.customInterceptors
  • Validator.enum method has been renamed to Validator.enumeration, and .derivedEnum to .derivedEnumeration, as enum is now a keyword in Scala3
  • due to changes to companion objects in Scala3, .mapTo(Companion) is replaced with a macro: .mapTo[CaseClass]
  • akka server interpreter: removal of .toDirective
  • annotations have been moved; endpoint annotations to EndpointIO.annotations, and schema annotations to Schema.annotations. Instead of derivedEndpointInput, used EndpointInput.derived instead
  • options for interpreters are now passed as explicit parameters to the interpreters, not as implicit ones to individual methods. If no options are provided, default parameters are used. If you've used default parameters, you'll need to add () to the interpreter, as it is now a class, not an object. E.g. AkkaHttpServerInterpreter.toRoutes(endpoints) becomes:
AkkaHttpServerInterpreter().toRoutes(endpoints)

If you have custom options, you'll need to change code such as:

implicit val options = AkkaHttpServerOptions.customInterceptors(...)
AkkaHttpServerInterpreter.toRoutes(endpoints)

into:

val options = AkkaHttpServerOptions.customInterceptors(...)
AkkaHttpServerInterpreter(options).toRoutes(endpoints)

Other breaking changes

  • rewritten SchemaType.[SProduct|SCoproduct|SOpenProduct]
  • DecodeFailureHandler - minor changes in method signatures, the default one is now DefaultDecodeFailureHandler.handler
  • LogRequestHandling -> ServerLog
  • Codec is no longer a Mapping
  • play server interpreter: toRoute -> toRoutes
  • deprecated statusMapping in favor of oneOfMapping
  • enumerations in openapi model (parameters, parameter style) are now sealed trait families
  • schema improvements: SObjectInfo is replaced by SName; coproducts are more general, as they can include any child schemas (not only objects)
  • enums are referenced by default, there's no referenceEnums option in the documentation interpreters. To inline enums, you'll need to define the enum validator without a name, or remove the name from the derived schema.

What’s Changed since v0.18.0-M18

  • Change backend client for awsLambda (#1365) @bartekzylinski
  • Zhttp (#1337) @bartekzylinski
  • Fixed Validator methods names (#1362) @gruggiero
  • Annotations cleanup: scoping, schema annotations support (#1351) @adamw
  • Move methods to derive endpoint inputs/outputs to companion objects, rename the methods to derived (#1348) @adamw

Dependency updates since v0.18.0-M18

Don't miss a new tapir release

NewReleases is sending notifications on new releases.