[BUG] [Rust] Rust-reqwest client fails because of null values in tags arrays from petstore.swagger.io
Created by: sverch
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
The rust-reqwest
client fails on the current contents of petstore.swagger.io
because of null
values in the tags
array of some pets.
openapi-generator version
4.1.2-SNAPSHOT
OpenAPI declaration file content or url
See http://petstore.swagger.io/v2/swagger.json
Command line used for generation
docker run --rm -v ${PWD}:/local/out/rust/ openapitools/openapi-generator-cli generate \
-i http://petstore.swagger.io/v2/swagger.json \
-g rust -o /local/out/rust/generated \
--additional-properties packageName=petstore_client \
--library=reqwest
Steps to reproduce
- Generate the client as above.
- Use it to call
find_pets_by_status
. - See the following error.
result = Err(Reqwest(Error(Json(Error("invalid type: null, expected struct Tag", line: 1, column: 2807)))))
Also, this is currently in the petstore api:
$ curl -X GET "https://petstore.swagger.io/v2/pet/findByStatus?status=pending" -H "accept: application/json" | jq ".[].tags"
...
[
null
]
...
And this is the relevant spec section:
$ curl --silent --output - http://petstore.swagger.io/v2/swagger.json | jq ".definitions.Pet.properties.tags"
{
"type": "array",
"xml": {
"name": "tag",
"wrapped": true
},
"items": {
"$ref": "#/definitions/Tag"
}
}
Related issues/PRs
No related issues found.
Suggest a fix
To get it working, I had to change this line in the Pet
model:
pub tags: Option<Vec<crate::models::Tag>>,
To this:
pub tags: Option<Vec<Option<crate::models::Tag>>>,
Although I don't know whether those nulls should have even been allowed in the first place.