-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Closed
Closed
Copy link
Labels
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- 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
When enum parameters (referenced via $ref in OpenAPI specs) are used as query parameters, the generated code attempts to call .to_string() on Option. This causes Rust's type inference to fail because it can
t distinguish between primitive types and enums/models.
It's generating code like this:
if let Some(ref param_value) = time_bucket {
req_builder = req_builder.query(&[("timeBucket", ¶m_value.to_string())]);
but it should probably be:
if let Some(ref param_value) = time_bucket {
req_builder = req_builder.query(&[("timeBucket", &serde_json::to_string(param_value)?)]);
openapi-generator version
7.11.0
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: Minimal Enum Query Param Test
version: 1.0.0
paths:
/data:
get:
operationId: getData
parameters:
- name: timeBucket
in: query
required: false
schema:
$ref: '#/components/schemas/TimeBucket'
responses:
'200':
description: OK
components:
schemas:
TimeBucket:
type: string
enum:
- day
- month
- year
EOF)
⎿ openapi: 3.0.3
info:
title: Minimal Enum Query Param Test
version: 1.0.0
paths:
/data:
get:
operationId: getData
parameters:
- name: timeBucket
in: query
required: false
schema:
$ref: '#/components/schemas/TimeBucket'
responses:
'200':
description: OK
components:
schemas:
TimeBucket:
type: string
enum:
- day
- month
- year
I will be creating a PR to propose a fix.