Skip to content

Fix query param array with reference#1

Open
villain-b wants to merge 1 commit intoramosbugs:mainfrom
villain-b:main
Open

Fix query param array with reference#1
villain-b wants to merge 1 commit intoramosbugs:mainfrom
villain-b:main

Conversation

@villain-b
Copy link

@villain-b villain-b commented Feb 5, 2026

Summary

This commit fixes an error in the codegen for API request param defined as array which references another schema object. The generated code to parse an individual array item used the argument type (Vec<TheType>) so the generated code didn't compile (trying to p.parse::<Vec<TheType>>() instead of p.parse::<TheType>()).

Tests

I'm using the following OpenAPI definition:

components:
  schemas:
    OrderState:
      type: string
      enum:
        - CREATED
[...]
paths:
  /some:
    get:
      operationId: getOrders
      parameters:
[...]
        - name: states
          in: query
          schema:
            type: array
            items:
              $ref: '#/components/schemas/OrderState'
[...]

I would expect it to generate correct Rust code that can parse the OrderState string into an enum (it works for request body and responses).

Without the change

I'm getting the following compilation error:

error[E0277]: the trait bound `Vec<OrderState>: FromStr` is not satisfied
     |
     |                         p.parse::<Vec<crate::models::OrderState>>()
     |                           ^^^^^ the trait `FromStr` is not implemented for `Vec<OrderState>`

With the change

Code compiles.

This commit fixes an error in the codegen for API request param defined
as array which reference another schema object. The generated code to
parse an individual array item used the argument type (`Vec<TheType>`) so
the generated code didn't compile (trying to `p.parse::<Vec<TheType>>()`
instead of `p.parse::<TheType>()`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant