我正在使用 Camel REST DSL 为 REST 端点设置验证框架。我遇到了 RestConfiguration 属性“producerApiDoc”。我有一个 swagger/openAPI YAML 文件并试图将其作为参数传递给进行请求验证,但验证没有发生。以下是进行此配置的代码。
这是 Camel REST DSL 文档链接!
public class EmployeeRouterConfig extends RouteBuilder {
@Override
public void configure() throws Exception {
// Rest and Swagger configuration
restConfiguration().bindingMode(RestBindingMode.json).producerApiDoc("C:\\project\\workspace\\employee-management\\schema\\Employee-system-services-api-35.yaml")
.component("servlet")
.dataFormatProperty("prettyPrint", "true")
.dataFormatProperty("json.in.enableFeatures",
"FAIL_ON_NUMBERS_FOR_ENUMS,USE_BIG_DECIMAL_FOR_FLOATS" +
",FAIL_ON_UNKNOWN_PROPERTIES,ADJUST_DATES_TO_CONTEXT_TIME_ZONE")
.dataFormatProperty("json.in.disableFeatures", "FAIL_ON_EMPTY_BEANS")
.enableCORS(true).port(env.getProperty("server.port", "8080"))
.contextPath(contextPath.substring(0, contextPath.length() -
2)).apiContextPath("/api-doc") .apiProperty("api.title","Employee Management").apiProperty("api.version", "1.0.0").clientRequestValidation(true);
我希望根据指定的 yaml 文件进行验证并抛出错误请求异常,但实际上验证没有发生,流程继续成功 OK 消息