简体   繁体   English

Swagger Codegen basePath 被忽略

[英]Swagger Codegen basePath is being ignored

I'm trying to generate some web services definitions using Swagger Codegen » 2.2.1我正在尝试使用Swagger Codegen » 2.2.1生成一些 Web 服务定义

All configs are working and the classes are generate correctly by my .yaml definitions.所有配置都在工作,并且我的.yaml定义正确生成了类。

Why the property basePath is being ignored?为什么忽略属性basePath


My @RestController generate using only paths definition:我的@RestController仅使用paths定义生成:

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

Expected (using basePath and paths definitions):预期(使用basePathpaths定义):

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

What am I doing wrong?我究竟做错了什么? Did I forget something?我忘记了什么吗?


My .yaml contract:我的.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: []

Searching more about this, I found the issue .搜索更多关于此的信息,我发现了问题

It's a bug fixed by HugoMario ( commit referenced on 2 Dec 2019 )这是HugoMario修复的错误( 提交参考于 2019 年 12 月 2 日

And following Helen suggestion, I update my Swagger Codegen:按照海伦的建议,我更新了我的 Swagger Codegen:

  • From » 2.2.1 » old release ( Aug 07, 2016 )来自 » 2.2.1 » 旧版本( 2016 年 8 月 7 日

  • To » 2.4.12 » current stable release ( Jan 15, 2020 )至 » 2.4.12 »当前稳定版本2020 年 1 月 15 日

Summary: » It's a bug of an outdated version » Now works fine!摘要: » 这是一个过时版本错误»现在可以正常工作了!


Maven dependecy for swagger-codegen-maven-plugin : swagger-codegen-maven-plugin Maven 依赖:

<dependency>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-codegen-maven-plugin</artifactId>
    <version>2.4.12</version>
</dependency>

Maven Central Repository ( check new releases ): Maven 中央存储库检查新版本):


Update Maven Project ( Eclipse shortcut F5 ) and make a clean build :更新 Maven 项目Eclipse 快捷键F5 )并进行干净的构建

mvn clean verify 
mvn install

Reference:参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM