Невозможно отобразить это определение
В предоставленном определении не указано допустимое поле версии. я использую Spring (не SpringBoot)
Пожалуйста, укажите допустимое поле версии Swagger или OpenAPI. Поддерживаемые поля версии: swagger: "2.0" и те, которые соответствуют openapi: 3.x.y (например, openapi: 3.1.0).
Редактор Swagger работает нормально, но при запуске определенного проект, я получаю эту ошибку. Впервые использую Swagger.
мой /v3/api-docs был сгенерирован в ASCII, я не знаю, как это исправить и почему это произошло
Сначала я думал, что это происходит из-за гона, я использовал его, чтобы заменить MessageConverter по умолчанию.
@Configuration
@ComponentScan(basePackages = {"org.springdoc"})
@Import({org.springdoc.core.configuration.SpringDocConfiguration.class,
org.springdoc.webmvc.core.configuration.SpringDocWebMvcConfiguration.class,
org.springdoc.webmvc.ui.SwaggerConfig.class,
org.springdoc.core.properties.SwaggerUiConfigProperties.class,
org.springdoc.core.properties.SwaggerUiOAuthProperties.class,
org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration.class})
public class OpenApiConfig {
@Bean
public GroupedOpenApi defaultApi() {
return GroupedOpenApi.builder()
.group("all")
.packagesToScan("com.example") // Replace with your package
.pathsToMatch("/api/**") // Replace with your URL path matcher
.build();
}
@Bean
public OpenAPI apiInfo() {
return new OpenAPI()
.openapi("3.1.0")
.info(new Info()
.title("Your API Title")
.description("Description of your API")
.version("1.0")
.contact(new Contact()
.name("Your Name")
.email("your.email@example.com")
.url("http://yourwebsite.com"))
.license(new License()
.name("Apache 2.0")
.url("http://www.apache.org/licenses/LICENSE-2.0.html")));
}
}
Файл конфигурации Gson
@Configuration
@EnableWebMvc
public class GsonConfig implements WebMvcConfigurer {
@Bean
public Gson gson() {
// Create a GsonBuilder to configure Gson
GsonBuilder gsonBuilder = new GsonBuilder();
// Configure Gson here
gsonBuilder.setDateFormat("yyyy-MM-dd HH:mm:ss");
gsonBuilder.setPrettyPrinting();
gsonBuilder.setFieldNamingPolicy(LOWER_CASE_WITH_UNDERSCORES);
// Create and return the custom Gson instance
return gsonBuilder.create();
}
@Bean
public GsonHttpMessageConverter gsonHttpMessageConverter(Gson gson) {
GsonHttpMessageConverter gsonConverter = new GsonHttpMessageConverter();
gsonConverter.setGson(gson);
return gsonConverter;
}
@Override
public void configureMessageConverters(List
Подробнее здесь: https://stackoverflow.com/questions/790 ... ify-a-vali