-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Open
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
If a request contains multiple parameters with the same name but in different locations, the rust generator will create colliding prefixes for parameters with the same name.
Using the test.yaml
below the rust generator will generate the following invalid code:
pub async fn test_name_post (...) {
// add a prefix to parameters to efficiently prevent name collisions
let p_name = name;
let p_body_request = body_request;
let p_name = name2;
let p_name = name3;
let p_name = name4;
(...)
}
openapi-generator version
7.14
OpenAPI declaration file content or url
Test.yaml
openapi: 3.0.3
info:
title: Parameter Location Test API
description: API to test parameter location prefixing
version: 1.0.0
paths:
/test/{name}:
post:
summary: Test parameter locations
description: Endpoint with 'name' parameter in every possible location
parameters:
- name: name
in: path
required: true
description: Name in path parameter
schema:
type: string
- name: name
in: query
required: false
description: Name in query parameter
schema:
type: string
- name: name
in: header
required: false
description: Name in header parameter
schema:
type: string
- name: name
in: cookie
required: false
description: Name in cookie parameter
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
name:
type: string
description: Name in body parameter
application/x-www-form-urlencoded:
schema:
type: object
properties:
name:
type: string
description: Name in form parameter
responses:
'200':
description: OK
'400':
description: Bad request
'500':
description: Internal server error
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix
I will make a PR suggesting a fix