java - swagger-codegen-maven-plugin 2.3.1 生成响应自定义对象但不在 3.0.0 中
问题描述
swagger-codegen-maven-plugin 2.3.1 生成一个 java 对象:
public InlineResponse2005 loginJsonapiPost(Auth auth) throws RestClientException { ...
public class InlineResponse2005 {
@JsonProperty("data")
private User data = null;
@JsonProperty("meta")
private Object meta = null;
@JsonProperty("links")
private Object links = null;
@JsonProperty("errors")
private Errors errors = null;
...
}
但 swagger-codegen-maven-plugin 3.0.0-SNAPSHOT不会生成 java 对象并返回 Object 对象:
public Object loginJsonapiPost(Object body) throws RestClientException { ...
我的招摇文件:
"/login.jsonapi": {
"post": {
"summary": "Create a session",
"tags": [
"Users"
],
"consumes": [
"application/json"
],
"description": " Authenticate a user with her/his email and password and return an\n access token suitable for authentication.\n",
"parameters": [
{
"name": "auth",
"in": "body",
"schema": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"password": {
"type": "string"
}
}
}
}
],
"responses": {
"200": {
"description": "Returning",
"schema": {
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/user"
},
"meta": {
"type": "object"
},
"links": {
"type": "object"
},
"errors": {
"$ref": "#/definitions/errors"
}
},
"required": [
"data"
]
}
},
"422": {
"description": "Returning",
"schema": {
"type": "object",
"properties": {
"errors": {
"$ref": "#/definitions/errors"
}
},
"required": [
"errors"
]
}
}
}
}
},
我的回应是:
response.schema.properties.data "#/definitions/user"
response.schema.properties.meta “对象”
response.schema.properties.links “对象”
response.schema.properties.errors "#/definitions/errors"
解决方案
3.0.0-SNAPSHOT 有一个 V2 模型的错误。我们需要使用 swagger-codegen-maven-plugin 的 V2.3.1。
就我而言,我有 2 个模型(一个 V2 和一个 V3)。儿子我用 3 个模块(源代码生成器 V2、源代码生成器 V3 和我的项目)创建了一个 Maven 父级。
我mvn clean install
在我的父母身上,我的项目没有问题。
推荐阅读
- c++ - 如何在 C++ 编译时读取文件?
- c# - 我可以在 Unity 中创建一个指向 GameObject 的指针吗?
- git - 从子模块触发动作作业
- c - 您如何使用迭代计算 C 中的负幂?
- html - 对 div 使用 "onclick = 'google.com'" 和 make 有什么区别?
- scala - 无法解决 ivy 依赖项:下载 com.github.jupyter:jvm-repr:0.4.0 时出错
- java - 从 Google 存储桶下载 zip 文件时出错
- sql - 查询以查找所有成员都注册的课程
- jquery - 如果匹配,比较 sting 和 data 属性添加类
- excel - 复制并粘贴到另一个工作表中