swagger-codegen
swagger-codegen copied to clipboard
[JAVA] "accept" parameter conflicts with internal "accept" variable during generated APIs...
Description
Thanks for this time saving library :)
I was using it to generate some Java code from a Json Schema and it works, but it fails generating an API object, because of a conflict between a parameter and an internal variable. They are both named as accept.
Here the code snippet:
public ResponseEntity<TermsAndConditionsResponse> termsAndConditionsUsingPOSTWithHttpInfo(OrderData body, String accept) throws RestClientException {
Object postBody = body;
// verify the required parameter 'body' is set
if (body == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling termsAndConditionsUsingPOST");
}
// verify the required parameter 'accept' is set
if (accept == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'accept' when calling termsAndConditionsUsingPOST");
}
String path = UriComponentsBuilder.fromPath("/rs/api/v1/termsAndConditions").build().toUriString();
final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
final HttpHeaders headerParams = new HttpHeaders();
final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();
if (accept != null)
headerParams.add("Accept", apiClient.parameterToString(accept));
final String[] accepts = {
"text/html;charset=UTF-8", "text/plain"
};
final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
final String[] contentTypes = {
"application/json"
};
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
String[] authNames = new String[] { };
ParameterizedTypeReference<TermsAndConditionsResponse> returnType = new ParameterizedTypeReference<TermsAndConditionsResponse>() {};
return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
Swagger-codegen version
3.0.35
It happens also with previous versions.
Swagger declaration file content or url
Command line used for generation
Used the maven plugin with this configuration:
<plugin>
<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>3.0.35</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/api-docs.json</inputSpec>
<language>java</language>
<library>resttemplate</library>
<apiPackage>com.lastminute.rsimoni.flightcatalog</apiPackage>
<modelPackage>com.lastminute.rsimoni.flightcatalog.model</modelPackage>
<invokerPackage>com.lastminute.rsimoni.flightcatalog.handler</invokerPackage>
<generateApis>true</generateApis>
<generateApiTests>false</generateApiTests>
<generateApiDocumentation>false</generateApiDocumentation>
<generateModelTests>false</generateModelTests>
<generateModelDocumentation>false</generateModelDocumentation>
<generateSupportingFiles>true</generateSupportingFiles>
<configOptions>
<interfaceOnly>true</interfaceOnly>
<dateLibrary>java8</dateLibrary>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
Steps to reproduce
Simply running the plugin
Related issues/PRs
I searched similar issue, but didn't find anything
Suggest a fix/enhancement
Probably a check for conflicting names? But I didn't check the code...