OpenAPI 3.0 swagger-codegen Array in RequestBody

991 views
Skip to first unread message

Jason Fitzpatrick

unread,
Feb 21, 2018, 6:12:03 AM2/21/18
to Swagger
I'm generating a client for a 3rd party API that has arrays in the request body of POST and PUT requests. When I generated my client with swagger-codegen, the methods for these endpoints will have only 1 object in the request body, instead of an array of objects.

I am currently using this package to generate:
`compile group: 'io.swagger', name: 'swagger-codegen-maven-plugin', version: '3.0.0-rc0'`

Any news on when an update is coming?

Also for those same endpoints, it is generating the local accepts array incorrectly in both the code and the doc as such:

final String[] localVarAccepts = {
    "application/json""application/json"
};


Here is an example of my spec:

"post": {
"operationId": "createMyModel",
"summary": "Create one or more MyModel objects",
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/MyModel"
}
}
}
}
},
"responses": {
"207": {
"description": "Success response",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": { "$ref": "#/components/schemas/MyModel" }
}
}
}
}
}
}

Here is what the Function signature ends up looking like:

public List<MyModel> createCampaign(MyModel body) throws ApiException

Here is what I want:

public List<MyModel> createCampaign(List<MyModel> body) throws ApiException

Any news on when the next release is? I see 3.0.0-rc0 was released about a month ago.

Thanks,
-Jason

Ron Ratovsky

unread,
Feb 21, 2018, 1:40:05 PM2/21/18
to swagger-sw...@googlegroups.com

Please file a ticket on the codegen project so the issue can be addressed.

We don’t have an ETA for the next RC, but SNAPSHOT releases constantly go out.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
swagger-swaggers...@googlegroups.com.
For more options, visit
https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages