Java swagger codegen maven插件2.3.1生成响应自定义对象,但不在3.0.0中
swagger codegen maven插件2.3.1生成java对象:Java swagger codegen maven插件2.3.1生成响应自定义对象,但不在3.0.0中,java,maven,swagger,Java,Maven,Swagger,swagger codegen maven插件2.3.1生成java对象: public InlineResponse2005 loginJsonapiPost(Auth auth) throws RestClientException { ... public class InlineResponse2005 { @JsonProperty("data") private User data = null; @JsonProperty("meta") private Obje
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插件3.0.0-SNAPSHOT不生成java对象并返回对象:
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"
]
}
}
}
}
},
我的回答是:
"/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"
]
}
}
}
}
},
responses.schema.properties.data“#/definitions/user”
responses.schema.properties.meta“对象”
responses.schema.properties.links“对象”
responses.schema.properties.errors“#/definitions/errors”3.0.0-SNAPSHOT在V2模型中有一个bug。我们需要使用swagger codegen maven插件的V2.3.1 在我的例子中,我有两个模型(一个是V2,一个是V3)。我创建了一个包含3个模块的Maven父级(SourceGeneratorV2、SourceGeneratorV3和我的项目) 我
mvn clean install
安装在我的父母身上,我的项目没有问题