我正在尝试使用生成一些网络服务定义Swagger 代码生成 » 2.2.1
所有配置都正常工作,并且我的类已正确生成.yaml
定义。
为何选择该物业basePath
被忽视了?
My @RestController
仅使用生成paths
定义:
https://springboot-base-save-return.appdes.xnet/saveBackendReturn
预期(使用basePath
and paths
定义):
https://springboot-base-save-return.appdes.xnet/v1/saveBackendReturn
我究竟做错了什么?我是不是忘记了什么?
My .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: []
搜索更多相关信息,我发现issue https://github.com/swagger-api/swagger-codegen/issues/5244.
这是一个错误,已修复雨果·马里奥 https://github.com/swagger-api/swagger-codegen/commits?author=HugoMario (commit https://github.com/swagger-api/swagger-codegen/commit/f1569a03092ba28f52c69053e107acd5f01f0467引用日期:2019 年 12 月 2 日)
-
[Spring] 修复 #5244 在 Spring API 模板中包含 basePath @RequestMapping https://github.com/swagger-api/swagger-codegen/pull/8131
-
发布于大师 (#8131) https://github.com/swagger-api/swagger-codegen/pull/8131/commits/ff11895e80f29f548621448d0fcd3482a7c4ed1e » v2.4.12 https://github.com/swagger-api/swagger-codegen/releases/tag/v2.4.12 / v2.4.11 https://github.com/swagger-api/swagger-codegen/releases/tag/v2.4.11
和以下Helen https://stackoverflow.com/users/113116/helen建议,我更新我的 Swagger Codegen:
-
From » 2.2.1 https://github.com/swagger-api/swagger-codegen/releases/tag/v2.2.1» 旧版本(2016 年 8 月 7 日)
-
To » 2.4.12 https://github.com/swagger-api/swagger-codegen/releases/tag/v2.4.12 » 当前稳定版本 (2020 年 1 月 15 日)
Summary:“ 它是bug of an 过时的版本
» 现在工作正常了!
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 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 https://github.com/swagger-api/swagger-codegen
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)