You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Starting from version 6.5.0 (id 'org.openapi.generator' version '6.5.0') - the below openapi.yaml produces code that fails compilation.
The scenario is defining an array of integers which have a validation rule defined (I used min/max ranges - there might be other scenarios as well).
The relevant generated method in the interface is:
default ResponseEntity<String> getDemo(
@NotNull @Parameter(name = "type", description = "The type of Demo.", required = true, in = ParameterIn.QUERY) @Valid @RequestParam(value = "type", required = true) List<SomeEnum> type,
@Parameter(name = "rangedValues", description = "The values within ranged.", in = ParameterIn.QUERY) @Valid @RequestParam(value = "rangedValues", required = false) List<@Valid RangedValue> rangedValues
) {
return getDelegate().getDemo(type, rangedValues);
}
I believe the extra @Valid within the List<... is redundant but have not verified that.
openapi-generator version
The problem occurs in 6.5.0 only, in 6.4.0 it works fine.
OpenAPI declaration file content or url
openapi: "3.0.0"info:
title: Demo APIdescription: A Demo APIversion: 0.0.1servers:
- url: https://localhost:8080/api/1tags:
- name: demodescription: Contains all the demo APIscomponents:
schemas:
SomeEnum:
type: stringenum:
- value1
- another-value
- best_value
- thevalueRangedValueList:
type: arrayitems:
$ref: "#/components/schemas/RangedValue"RangedValue:
properties:
value:
type: integerminimum: 5maximum: 50paths:
/demo:
get:
tags:
- demodescription: "A demo API"operationId: "getDemo"parameters:
- in: queryname: typedescription: The type of Demo.schema:
type: arrayitems:
$ref: "#/components/schemas/SomeEnum"required: true
- in: queryname: rangedValuesdescription: The values within ranged.schema:
$ref: "#/components/schemas/RangedValueList"required: falseresponses:
"200":
description: successcontent:
application/json:
schema:
type: string
Generation Details
I recreated the issue with the following gradle setup:
I am not certain that this is the root cause - but it seems very relevant.
Suggest a fix
See the above related commit - if it is the root cause I do not know how best to fix it as I'm assuming it solves a concrete problem, so removing it will not be enough.
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
Starting from version 6.5.0 (
id 'org.openapi.generator' version '6.5.0'
) - the belowopenapi.yaml
produces code that fails compilation.The scenario is defining an array of integers which have a validation rule defined (I used min/max ranges - there might be other scenarios as well).
The relevant generated method in the interface is:
I believe the extra
@Valid
within theList<...
is redundant but have not verified that.openapi-generator version
The problem occurs in 6.5.0 only, in 6.4.0 it works fine.
OpenAPI declaration file content or url
Generation Details
I recreated the issue with the following
gradle
setup:This is the main class in my app:
I'm using
gradle
v8.0.2.Steps to reproduce
Running the below command triggers the issue:
Related issues/PRs
Judging by the diffs between 6.4.0 and 6.5.0 and the description of the commit - this seems like a likely culprit:
92b9663
The relevant code seems to be this method:
I am not certain that this is the root cause - but it seems very relevant.
Suggest a fix
See the above related commit - if it is the root cause I do not know how best to fix it as I'm assuming it solves a concrete problem, so removing it will not be enough.
The text was updated successfully, but these errors were encountered: