Open tkalliom opened 1 year ago
@borsch the local component is still picked up with $ref: "./queryParameters.yaml#/components/parameters/manufacturerIdParam"
I think this is the same bug I experience in 6.5.0, where one referenced component is used instead of another referenced component.
paths:
/path1/{someId}:
get:
operationId: processPathParam
parameters:
- $ref: 'api-params/pathParams.yaml#/someId'
responses:
"200": { description: Ok }
/path2:
get:
operationId: processQueryParam
parameters:
- $ref: 'api-params/queryParams.yaml#/someId'
responses:
"200": { description: Ok }
Here the processQueryParam
method is generated with the someId
from pathParams.yaml, instead of the one from queryParams.yaml.
This issue is still present on openapi-generator 7.0.0
This issue is still present on openapi-generator 7.1.0
Bug Report Checklist
Description
If a component defined in the same file as an operation has the same name as one that is used on that operation via a
$ref
to another file, the local one is used instead of the one matching the file qualifier.(Of course, this kind of naming would not be great even if code generation worked; the matching names have probably been introduced inadvertently to our codebase.)
openapi-generator version
This issue was encountered on openapi-generator versions:
It is a regression; it was not present on
OpenAPI declaration file content or url
Root
catalog.yaml
:Auxiliary
queryParameters.yaml
:Generation Details
java -jar openapi-generator-cli.jar generate -i catalog.yaml -g spring
Steps to reproduce
Check the generated
src/main/java/org/openapitools/api/ProductsApi.java
file.Expected: the
String manufacturerId
parameter ofProductsApi::getProducts
should be annotated@Parameter(name = "manufacturerId", description = "") @Valid @RequestParam(value = "manufacturerId", required = false)
(i.e.queryParameters.yaml#/components/parameters/manufacturerIdParam
).Actual result: It is annotated
@Parameter(name = "manufacturerId", description = "", required = true) @PathVariable("manufacturerId")
(i.e.catalog.yaml#/components/parameters/manufacturerIdParam
) instead.Related issues/PRs
My guess is this was introduced by #13133
Suggest a fix
?