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 Object meta = null;
@JsonProperty("links")
private Object links = null;
@JsonProperty("errors")
private Errors errors = null;
...
}
但是swagger codegen maven插件3.0.0-SNAPSHOTNOT生成一个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 ann 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"#/difinitions/user">
responses.schema.properties.meta"object">
responses.schema.properties.links"object">
responses.schema.properties.errors"#/difinitions/errors">
3.0.0-SNAPSHOT在V2模型中有一个错误。我们需要使用swagger codegen maven插件的V2.3.1。
在我的例子中,我有两个模型(一个V2和一个V3(。儿子我创建了一个包含3个模块(源生成器V2、源生成器V3和我的项目(的Maven父级。
我在父母身上mvn clean install
,在我的项目上没有问题。