OpenAPITools / OpenAPITools/openapi-generator

[BUG][RUST] Description

Open
#14,069 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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

Query parameters with deep object and specific properties are not being fully qualified in the api function in Rust. Here is a snippet of what's causing the issue:

name: page
in: query
required: false
description: "In a list return, the data associated with the page number and size returned. 20 results per page, page 2 would be `page[size]=20&page[number]=2`"
explode: true
style: deepObject
schema:
  type: object
  properties:
    number:
      type: number
      description: The page to jump to
    size:
      type: number
      description: The number of resources returned per page.

This generates the following error:
image

This struct is properly generated, it's just not fully qualified

openapi-generator version

6.0.0

OpenAPI declaration file content or url

https://drive.google.com/file/d/16DDHJZrBgT0OrVbwO85VtmX4RAr54Qoi/view?usp=sharing

Generation Details

./run-in-docker.sh generate -i /gen/public-api.yml -g rust -o /gen/out/openapi

Steps to reproduce

Run the generator, and attempt to compile the code with the rust compiler.

Related issues/PRs
Suggest a fix

It appears the bug is caused here:

modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache -> line 20 col 386

It appears that it only sets up the fully qualified import if it's a body parameter, not a query parameter. In the case of explicit parameters however, it assumes that it would be a core type. I'm not sure how to detect if something is a generated parameter or not however.

cc @nshaaban-cPacket since I know you're working on some rust generator code right now.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache, especially line 20, and reproduce the issue with the provided run-in-docker.sh command and OpenAPI declaration. Compile the generated Rust client and inspect the API function's deep-object query parameter handling. Done means the generated code compiles and the explicit query properties are fully qualified.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend-api-design, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.