gpt4 book ai didi

spring - Swagger Codegen basePath 被忽略

转载 作者:行者123 更新时间:2023-12-03 18:31:30 39 4
gpt4 key购买 nike

我正在尝试使用 生成一些 Web 服务定义Swagger Codegen » 2.2.1
所有配置都在工作,我的 .yaml 正确生成了类定义。

Why the property basePath is being ignored?



我的 @RestController仅使用 paths 生成定义:
https://springboot-base-save-return.appdes.xnet/saveBackendReturn
预期(使用 basePathpaths 定义):
https://springboot-base-save-return.appdes.xnet/v1/saveBackendReturn
我究竟做错了什么?我忘记了什么吗?

我的 .yaml契约(Contract):
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: []

最佳答案

搜索更多相关信息,我找到了 issue .
这是由 HugoMario 修复的错误( commit 引用于 2019 年 12 月 2 日)

  • [Spring] Fixes #5244 Include basePath @RequestMapping in Spring API template
  • 发布于 master (#8131) » v2.4.12/v2.4.11

  • 并关注 Helen建议,我更新我的 Swagger Codegen:
  • 来自 » 2.2.1 » 旧版本(2016 年 8 月 7 日)
  • 致 » 2.4.12 » 当前稳定版本 (2020 年 1 月 15 日)

  • Summary:» It's a bug of an outdated version» Now works fine!



    Maven 依赖于 swagger-codegen-maven-plugin :
    <dependency>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-codegen-maven-plugin</artifactId>
    <version>2.4.12</version>
    </dependency>
    Maven 中央存储库 (检查新版本):
  • https://mvnrepository.com/artifact/io.swagger/swagger-codegen-maven-plugin

  • 更新 Maven 项目 (Eclipse 快捷方式 F5 )并创建一个 清洁构建 :
    mvn clean verify 
    mvn install

    引用:
  • https://github.com/swagger-api/swagger-codegen
  • 关于spring - Swagger Codegen basePath 被忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59918115/

    39 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com