Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

336 fix responses with no body return void #337

Merged
merged 6 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ As commented above, they both could be used at the same time, setting a double
<plugin>
<groupId>com.sngular</groupId>
<artifactId>scs-multiapi-maven-plugin</artifactId>
<version>5.4.0</version>
<version>5.4.1</version>
<executions>
<execution>
<id>asyncapi</id>
Expand Down Expand Up @@ -114,7 +114,7 @@ Apply the plugin in the `build.gradle` file and invoke the task.
```groovy
plugins {
id "java"
id "com.sngular.scs-multiapi-gradle-plugin' version '5.4.0"
id "com.sngular.scs-multiapi-gradle-plugin' version '5.4.1"

openapimodel {

Expand Down Expand Up @@ -153,7 +153,7 @@ which the plugin is designed.
<plugin>
<groupId>com.sngular</groupId>
<artifactId>scs-multiapi-maven-plugin</artifactId>
<version>5.4.0</version>
<version>5.4.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
Expand Down Expand Up @@ -584,7 +584,7 @@ file. Here is an example of a basic configuration:
<plugin>
<groupId>com.sngular</groupId>
<artifactId>scs-multiapi-maven-plugin</artifactId>
<version>5.4.0</version>
<version>5.4.1</version>
<executions>
<execution>
<goals>
Expand Down
2 changes: 1 addition & 1 deletion multiapi-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.sngular</groupId>
<artifactId>multiapi-engine</artifactId>
<version>5.4.0</version>
<version>5.4.1</version>
<packaging>jar</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ public class ${className?cap_first}Api {
*/
public <@compress single_line=true><#if operation.responseObjects[0].contentObjects[0]??>
${operation.responseObjects[0].contentObjects[0].dataType}
<#else>Void</#if></@compress> ${operation.operationId}<#compress>(<#if operation.parameterObjects?has_content><#list operation.parameterObjects as parameter>${parameter.dataType} ${parameter.name}<#if parameter?has_next || operation.requestObjects?has_content>, </#if></#list></#if><#if path.parameterObjects?has_content><#list path.parameterObjects as parameter>${parameter.dataType} ${parameter.name}<#if parameter?has_next || operation.requestObjects?has_content>, </#if></#list></#if><#if operation.requestObjects?has_content><#list operation.requestObjects as request><#list request.contentObjects as content>${content.dataType} ${content.dataType?api.getVariableNameString()} <#if content?has_next>, </#if></#list></#list></#if>)</#compress> throws RestClientException {
return ${operation.operationId}WithHttpInfo(<#compress><#if operation.parameterObjects?has_content><#list operation.parameterObjects as parameter>${parameter.name}<#if parameter?has_next || operation.requestObjects?has_content>, </#if></#list></#if><#if path.parameterObjects?has_content><#list path.parameterObjects as parameter>${parameter.name}<#if parameter?has_next || operation.requestObjects?has_content>, </#if></#list></#if><#if operation.requestObjects?has_content><#list operation.requestObjects as request><#list request.contentObjects as content>${content.dataType?api.getVariableNameString()}<#if content?has_next>, </#if></#list></#list></#if>)<#if operation.responseObjects[0].contentObjects[0]??>.getBody()</#if>;</#compress>
<#else>void</#if></@compress> ${operation.operationId}<#compress>(<#if operation.parameterObjects?has_content><#list operation.parameterObjects as parameter>${parameter.dataType} ${parameter.name}<#if parameter?has_next || operation.requestObjects?has_content>, </#if></#list></#if><#if path.parameterObjects?has_content><#list path.parameterObjects as parameter>${parameter.dataType} ${parameter.name}<#if parameter?has_next || operation.requestObjects?has_content>, </#if></#list></#if><#if operation.requestObjects?has_content><#list operation.requestObjects as request><#list request.contentObjects as content>${content.dataType} ${content.dataType?api.getVariableNameString()} <#if content?has_next>, </#if></#list></#list></#if>)</#compress> throws RestClientException {
<#if operation.responseObjects[0].contentObjects[0]??>return </#if>${operation.operationId}WithHttpInfo(<#compress><#if operation.parameterObjects?has_content><#list operation.parameterObjects as parameter>${parameter.name}<#if parameter?has_next || operation.requestObjects?has_content>, </#if></#list></#if><#if path.parameterObjects?has_content><#list path.parameterObjects as parameter>${parameter.name}<#if parameter?has_next || operation.requestObjects?has_content>, </#if></#list></#if><#if operation.requestObjects?has_content><#list operation.requestObjects as request><#list request.contentObjects as content>${content.dataType?api.getVariableNameString()}<#if content?has_next>, </#if></#list></#list></#if>)<#if operation.responseObjects[0].contentObjects[0]??>.getBody()</#if>;</#compress>
}

public <@compress single_line=true><#if operation.responseObjects[0].contentObjects[0]??>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public final class OpenApiGeneratorFixtures {
static final List<SpecFile> TEST_REST_CLIENT_GENERATION = List.of(
SpecFile
.builder()
.filePath("openapigenerator/testClientPackageWebClientApiGeneration/api-test.yml")
.filePath("openapigenerator/testRestClientApiGeneration/api-test.yml")
.apiPackage("com.sngular.multifileplugin.restclient")
.modelPackage("com.sngular.multifileplugin.restclient.model")
.clientPackage("com.sngular.multifileplugin.restclient.client")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,28 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/Error"
delete:
summary: Info for a specific test
operationId: deleteTestById
tags:
- test
parameters:
- name: testId
in: path
required: true
description: The id of the test to retrieve
schema:
type: integer
format: int32
responses:
'204':
description: No content response
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
security:
- BasicAuth: []
components:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,36 @@ public ResponseEntity<ApiTestInfoDTO> showTestByIdWithHttpInfo(Integer testId) t
return apiRestClient.invokeAPI("http://localhost:8080/v1","/test/{testId}", HttpMethod.GET, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}

/**
* DELETE /test/{testId}: Info for a specific test
* @param testId The id of the test to retrieve true
* @return No content response; (status code 204)
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public void deleteTestById(Integer testId) throws RestClientException {
deleteTestByIdWithHttpInfo(testId);
}

public ResponseEntity<Void> deleteTestByIdWithHttpInfo(Integer testId) throws RestClientException {

Object postBody = null;
final Map<String, Object> uriVariables = new HashMap<String, Object>();

uriVariables.put("testId", testId);
final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
final HttpHeaders headerParams = new HttpHeaders();
final MultiValueMap<String, String> cookieParams = new LinkedMultiValueMap<String, String>();
final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

final String[] localVarAccepts = {"application/json"};
final List<MediaType> localVarAccept = apiRestClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = {};
final MediaType localVarContentType = apiRestClient.selectHeaderContentType(localVarContentTypes);

String[] localVarAuthNames = new String[] {"BasicAuth"};

ParameterizedTypeReference<Void> localVarReturnType = new ParameterizedTypeReference<Void>() {};
return apiRestClient.invokeAPI("http://localhost:8080/v1","/test/{testId}", HttpMethod.DELETE, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}

}
6 changes: 3 additions & 3 deletions scs-multiapi-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repositories {
}

group = 'com.sngular'
version = '5.4.0'
version = '5.4.1'

def SCSMultiApiPluginGroupId = group
def SCSMultiApiPluginVersion = version
Expand All @@ -30,7 +30,7 @@ dependencies {
shadow localGroovy()
shadow gradleApi()

implementation 'com.sngular:multiapi-engine:5.4.0'
implementation 'com.sngular:multiapi-engine:5.4.1'
testImplementation 'org.assertj:assertj-core:3.24.2'
testImplementation 'com.puppycrawl.tools:checkstyle:10.12.3'
}
Expand Down Expand Up @@ -98,7 +98,7 @@ testing {

integrationTest(JvmTestSuite) {
dependencies {
implementation 'com.sngular:scs-multiapi-gradle-plugin:5.4.0'
implementation 'com.sngular:scs-multiapi-gradle-plugin:5.4.1'
implementation 'org.assertj:assertj-core:3.24.2'
}

Expand Down
10 changes: 8 additions & 2 deletions scs-multiapi-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.sngular</groupId>
<artifactId>scs-multiapi-maven-plugin</artifactId>
<version>5.4.0</version>
<version>5.4.1</version>
<packaging>maven-plugin</packaging>

<name>AsyncApi - OpenApi Code Generator Maven Plugin</name>
Expand Down Expand Up @@ -196,6 +196,12 @@
</roles>
<timezone>Europe/Madrid</timezone>
</developer>
<developer>
<id>carlosaf-sngular</id>
<name>Carlos Alonso Ferreira</name>
<email>[email protected]</email>
<organizationUrl>https://sngular.github.io/</organizationUrl>
</developer>
<developer>
<id>MarcosFreireSngular</id>
<name>Marcos Freire Patiño</name>
Expand Down Expand Up @@ -254,7 +260,7 @@
<dependency>
<groupId>com.sngular</groupId>
<artifactId>multiapi-engine</artifactId>
<version>5.4.0</version>
<version>5.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
Loading