未在Swagger UI中显示Spring Boot验证信息

问题描述 投票:1回答:1

我的类是用Spring Boot Java编写的,而我使用Swagger 2来生成其文档。我正在使用spring-fox版本2.9.0

为了显示Swagger UI中的验证约束(@ min,@ max,@ pattern等),我在application.java中添加了以下几行,其中showExtensions(true),但是没用。Desired result in Swagger UI

为了获得想要的结果,我应该改变什么?

@Bean
UiConfiguration uiConfig() {
  return UiConfigurationBuilder.builder() 
      .deepLinking(true)
      .displayOperationId(false)
      .defaultModelsExpandDepth(1)
      .defaultModelExpandDepth(1)
      .defaultModelRendering(ModelRendering.EXAMPLE)
      .displayRequestDuration(false)
      .docExpansion(DocExpansion.NONE)
      .filter(false)
      .maxDisplayedTags(null)
      .operationsSorter(OperationsSorter.ALPHA)
      .showExtensions(true)
      .tagsSorter(TagsSorter.ALPHA)
      .supportedSubmitMethods(UiConfiguration.Constants.DEFAULT_SUBMIT_METHODS)
      .validatorUrl(null)
      .build();
}
java spring-boot swagger openapi springfox
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.