Swagger Codegen basePath被忽略了

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

我正在尝试使用Swagger Codegen»2.2.1生成我的代码WS定义。

所有配置均正常工作,并且类由我的.yaml定义正确生成。

但是我有一个问题,属性basePath被忽略了。

我的@RestController仅使用paths定义生成:

https://springboot-base-save-return.appdes.xnet/saveBackendReturn

期望(使用basePathpaths定义::

https://springboot-base-save-return.appdes.xnet/v1/saveBackendReturn

我做错了什么?我忘了东西吗?


我的.yaml合同:

swagger: '2.0'
info:
  description: My Project
  version: 1.0.0
  title: Save Backend Return
host: springboot-base-save-return.appdes.xnet
basePath: /v1
tags:
  - name: saveBackendReturn
    description: Save Backend Return
schemes:
  - https
paths:
  /saveBackendReturn:
    post:
      tags:
        - saveBackendReturn
      summary: Save Backend Return
      description: My Project
      operationId: saveBackendReturn
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - in: body
          name: body
          description: My Project
          required: true
          schema:
            $ref: '#/definitions/saveBackendReturnRequest'
      responses:
        '200':
          description: Ok
          schema:
            $ref: '#/definitions/saveBackendReturnResponse'
        '400':
          description: Bad Request
        '401':
          description: Unauthorized
        '500':
          description: Internal Server Error
          schema:
            $ref: '#/definitions/Error'
      security:
        - basicAuth: []
spring yaml swagger swagger-codegen contract-first
1个回答
1
投票

对此进行搜索,我发现了issue

[这是HugoMario修复的错误(commit于2019年12月2日引用)

并且按照Helen的建议,我更新了Swagger Codegen:

  • 来自»2.2.1»旧版本(2016年8月7日)>]

  • 至»2.4.12»当前稳定版本(2020年1月15日)

  • »现在可以正常工作!


参考:

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