首页 > 解决方案 > 如何在 Swagger Codegen Spring 服务器存根中没有 responseWrapper

问题描述

我希望 Swagger Codegen 在没有响应包装器的情况下生成 Delegate 接口:

这是生成的内容(删除了不相关的内容):

public interface MyApi {

    MyApiDelegate getDelegate();

    default ResponseEntity<NotificationEntity> httpGetUsingGET(...) {
        ...
    }

这就是我想要生成的(注意;没有ResponseEntity包装器:

    default NotificationEntity httpGetUsingGET(...)

这是输入 Swagger 规范

'/api/notification/{encryptedId}':
    get:
      tags:
        - Notifications
      summary: Get a specific NotificationModel
      operationId: httpGetUsingGET
      produces:
        - application/json
      parameters:
        - name: encryptedId
          in: path
          description: encryptedId
          required: true
          type: string
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/NotificationEntity'

这并不是说我不喜欢响应包装器的想法。现有的代码库只是返回没有包装器的实体。

我正在使用 SwaggerHub 生成它并将responseWrapperSpring Server Stub 的配置留空。但我怀疑正在应用默认值。我查看了 Swagger Codegen 源,找不到指定“NONE”的方法。

标签: swagger-codegen

解决方案


推荐阅读