Skip to content

Fix query param array with reference#1

Merged
ramosbugs merged 2 commits intoramosbugs:mainfrom
villain-b:main
Feb 17, 2026
Merged

Fix query param array with reference#1
ramosbugs merged 2 commits intoramosbugs:mainfrom
villain-b:main

Conversation

@villain-b
Copy link
Contributor

@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.

villain-b and others added 2 commits February 5, 2026 16:15
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>()`).
@ramosbugs ramosbugs merged commit 2756ad3 into ramosbugs:main Feb 17, 2026
9 of 10 checks passed
@ramosbugs
Copy link
Owner

thanks!

@ramosbugs
Copy link
Owner

This is now released in 0.1.3

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.

2 participants