JAX-RS

Spring Cloud Contract 支持 JAX-RS 2 Client API。基类需要定义 受保护的 WebTarget webTarget 和服务器初始化。测试 JAX-RS API 的唯一选项是启动 Web 服务器。此外,带有正文的请求需要设置内容类型。否则,application/octet-stream 的默认设置将被使用。

The Spring Cloud Contract supports the JAX-RS 2 Client API. The base class needs to define protected WebTarget webTarget and server initialization. The only option for testing JAX-RS API is to start a web server. Also, a request with a body needs to have a content type be set. Otherwise, the default of application/octet-stream gets used.

要使用 JAX-RS 模块,请使用以下设置:

To use JAX-RS mode, use the following setting:

testMode = 'JAXRSCLIENT'

以下示例显示了生成的测试 API:

The following example shows a generated test API:

Unresolved directive in jax-rs.adoc - include::{verifier_root_path}/src/test/groovy/org/springframework/cloud/contract/verifier/builder/JaxRsClientMethodBuilderSpec.groovy[]