防止swagger使用MessageSource

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

我正在使用 OpenApi 生成器 https://openapi-generator.tech/ 生成将在基于 SpringBoot 6 的服务中使用的 REST API 接口。 以下是 API 定义 (registration.yml) 的摘录:

...
paths:
  /registration/register:
    post:
      description: Register a user
      operationId: registerUser
      tags:
        - registration
...

我注意到,一旦 Swagger 网页 (http://localhost:8080/swagger-ui/index.html) 打开,它就会开始通过

MessageSource.resolveCode()
查找消息。 它使用
description
字段“注册用户” 中的文本作为消息代码,通过
MessageSource.resolveCode()
查找相应的消息文本 然而,如上所示,此类消息已经是文本消息,而不是消息代码。是的,它们是硬编码的,但我对此很满意。 是否可以对其进行配置,以便 Swagger 不搜索这些消息?

不确定它是否有帮助,但这是在这种情况下调用

MessageSource.resolveCode()
时的堆栈顶部:

resolveCode:77, DBMessageSource
resolveCodeWithoutArguments:368, AbstractMessageSource (org.springframework.context.support)
getMessageInternal:212, AbstractMessageSource (org.springframework.context.support)
getMessage:153, AbstractMessageSource (org.springframework.context.support)
resolve:88, PropertyResolverUtils (org.springdoc.core.utils)
parse:130, OperationService (org.springdoc.core.service)
calculatePath:459, AbstractOpenApiResource (org.springdoc.api)
calculatePath:654, AbstractOpenApiResource (org.springdoc.api)
lambda$calculatePath$11:219, OpenApiResource (org.springdoc.webmvc.api)
...

选项:

springdoc:
  api-docs:
    enabled: false

application.yml

完全禁用我不需要的招摇网页

java spring-boot swagger internationalization openapi
1个回答
0
投票

该选项尚可用于解决问题

springdoc:
  disable-i18n: true
© www.soinside.com 2019 - 2024. All rights reserved.