昂首阔步| Springboot 3.2 |提供的定义未指定有效的版本字段

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

enter image description here

如何修复Spring Boot 3.2下实现Swagger后Theprovideddefinition does notspecify a valid version field的错误

<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
    <version>2.3.0</version>
</dependency>
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Override
    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
        final Collection<HttpMessageConverter<?>> myConverters = new ArrayList<>();

        final Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
        builder.serializerByType(ObjectId.class, new ToStringSerializer());

        final HttpMessageConverter<Object> converter = new MappingJackson2HttpMessageConverter(builder.build());
        myConverters.add(converter);
        myConverters.addAll(converters);

        converters.clear();
        converters.addAll(myConverters);
    }
springdoc:
  writer-with-default-pretty-printer: true
  swagger-ui:
    display-request-duration: true
    disable-swagger-default-url: true
  api-docs:
    version: openapi_3_1

下面我就给你答案!

swagger-ui swagger-2.0 springdoc-openapi-ui spring-boot-3
1个回答
0
投票

要解决此问题,只需在 openapi 部分添加以下参数即可!

然后就可以正常工作了!

application.yml

© www.soinside.com 2019 - 2024. All rights reserved.