[FIX] remove accept type when void return

This commit is contained in:
Edouard DUPIN 2024-05-29 00:00:46 +02:00
parent 17664f1c2f
commit 6ebb9eb395
2 changed files with 15 additions and 6 deletions

View File

@ -319,6 +319,9 @@ public class TsApiGeneration {
if (produces.size() > 1) {
data.append("\n\t\t\t\taccept: produce,");
} else {
final String returnType = generateClassModelsTypescript(interfaceElement.returnTypes, tsGroup,
imports, false);
if (!"void".equals(returnType)) {
for (final String elem : produces) {
if (MediaType.APPLICATION_JSON.equals(elem)) {
data.append("\n\t\t\t\taccept: HTTPMimeType.JSON,");
@ -328,6 +331,7 @@ public class TsApiGeneration {
}
}
}
}
data.append("\n\t\t\t},");
data.append("\n\t\t\trestConfig,");
if (!interfaceElement.parameters.isEmpty()) {

View File

@ -64,6 +64,9 @@ public class ApiModel {
this.returnTypes.add(previousModel.add(clazz));
}
}
if (this.returnTypes.size() == 0) {
this.produces.clear();
}
return;
}
@ -91,6 +94,9 @@ public class ApiModel {
for (final ClassModel elem : this.returnTypes) {
LOGGER.warn(" - {}", elem);
}
if (this.returnTypes.size() == 0) {
this.produces.clear();
}
}
public ApiModel(final Class<?> clazz, final Method method, final String baseRestEndPoint,
@ -166,6 +172,5 @@ public class ApiModel {
if (this.unnamedElement.size() > 1) {
throw new IOException("Can not parse the API, enmpty element is more than 1 in " + this.name);
}
}
}