Skip to content

[BUG] [Rust] Text/plain response interpreted as json, causing error #20617

@gabriel-v

Description

@gabriel-v

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Generated code attempts to use JSON to read a text/plain string response.

openapi-generator version

Used docker latest version

REPOSITORY                                          TAG                            IMAGE ID       CREATED         SIZE
openapitools/openapi-generator-cli                  latest                         ec2c9381a2be   2 days ago      303MB
OpenAPI declaration file content or url

https://github.com/SeekStorm/SeekStorm/blob/42810560e4cbb22a6ad59cfd31c65c837e5a223e/src/seekstorm_server/openapi/openapi.yml#L110-L112

Generation Details

https://github.com/liquidinvestigations/hoover3/blob/bea9f7ba9a297ed8845dea2650ce254d67fdb6ff/packages/seekstorm-client/generate.sh

Results in this function

https://github.com/liquidinvestigations/hoover3/blob/bea9f7ba9a297ed8845dea2650ce254d67fdb6ff/packages/seekstorm-client/src/apis/api_key_api.rs#L67

The function attemps to do serde_json::from_str(&content).map_err(Error::from) on a response marked text/plain, which causes crash (since the json expects to see a quote surrounded string, not a plain string)

Expected output: return Ok(content.to_string()) instead of attempting json parse of text/plain response

Steps to reproduce
Related issues/PRs

Nothing about text/plain vs. json confusion

Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions