Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #3885
Closed
Open
Issue created Sep 13, 2019 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[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
  1. Generate the client as above.
  2. Use it to call find_pets_by_status.
  3. 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.

Assignee
Assign to
Time tracking