[FEAT] update well produce when woid is return

This commit is contained in:
Edouard DUPIN 2024-05-01 23:10:27 +02:00
parent 866e28a645
commit 46d1284174
3 changed files with 39 additions and 7 deletions

View File

@ -310,7 +310,7 @@ public class DataFactoryTsApi {
}
final String methodDescription = apiAnnotationGetOperationDescription(method);
final List<String> consumes = apiAnnotationGetConsumes(clazz, method);
final List<String> produces = apiAnnotationProduces(clazz, method);
List<String> produces = apiAnnotationProduces(clazz, method);
LOGGER.trace(" [{}] {} => {}/{}", methodType, methodName, basicPath, methodPath);
if (methodDescription != null) {
LOGGER.trace(" description: {}", methodDescription);
@ -326,10 +326,18 @@ public class DataFactoryTsApi {
if (returnTypeModelRaw == Response.class) {
LOGGER.info("Get type: {}", returnTypeModelRaw);
}
if (returnTypeModelRaw == Response.class) {
isUnmanagedReturnType = true;
if (returnTypeModelRaw == Response.class || returnTypeModelRaw == void.class
|| returnTypeModelRaw == Void.class) {
if (returnTypeModelRaw == Response.class) {
isUnmanagedReturnType = true;
}
returnTypeModel = new Class<?>[] { Void.class };
tmpReturn = new ArrayList<>();
produces = null;
} else if (returnTypeModelRaw == Map.class) {
LOGGER.warn("Not manage the Map Model ... set any");
returnTypeModel = new Class<?>[] { Map.class };
tmpReturn = DataFactoryZod.createTables(returnTypeModel, previous);
} else if (returnTypeModelRaw == List.class) {
final ParameterizedType listType = (ParameterizedType) method.getGenericReturnType();
returnTypeModelRaw = (Class<?>) listType.getActualTypeArguments()[0];
@ -340,6 +348,18 @@ public class DataFactoryTsApi {
returnTypeModel = new Class<?>[] { returnTypeModelRaw };
tmpReturn = DataFactoryZod.createTables(returnTypeModel, previous);
}
} else if (returnTypeModel.length >= 0 && (returnTypeModel[0] == Response.class
|| returnTypeModel[0] == Void.class || returnTypeModel[0] == void.class)) {
if (returnTypeModel[0] == Response.class) {
isUnmanagedReturnType = true;
}
returnTypeModel = new Class<?>[] { Void.class };
tmpReturn = new ArrayList<>();
produces = null;
} else if (returnTypeModel.length > 0 && returnTypeModel[0] == Map.class) {
LOGGER.warn("Not manage the Map Model ...");
returnTypeModel = new Class<?>[] { Map.class };
tmpReturn = DataFactoryZod.createTables(returnTypeModel, previous);
} else {
tmpReturn = DataFactoryZod.createTables(returnTypeModel, previous);
}
@ -458,7 +478,7 @@ public class DataFactoryTsApi {
if (!pathParams.isEmpty()) {
builder.append("\n\t\t\tparams,");
}
if (produces.size() > 1) {
if (produces != null && produces.size() > 1) {
builder.append("\n\t\t\tproduce,");
}
if (emptyElement.size() == 1 || formDataParams.size() != 0) {
@ -506,7 +526,7 @@ public class DataFactoryTsApi {
}
builder.append("\n\t\t},");
}
if (produces.size() > 1) {
if (produces != null && produces.size() > 1) {
builder.append("\n\t\tproduce: ");
String isFist = null;
for (final String elem : produces) {

View File

@ -13,6 +13,7 @@ import java.time.LocalTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
@ -247,6 +248,8 @@ public class DataFactoryZod {
public static GeneratedTypes createBasicType() throws Exception {
final GeneratedTypes previous = new GeneratedTypes();
previous.add(new ClassElement(new Class<?>[] { Void.class, void.class }, "void", "void", null, null, true));
// Map is binded to any ==> can not determine this complex model for now
previous.add(new ClassElement(new Class<?>[] { Map.class }, "any", "any", null, null, true));
previous.add(new ClassElement(new Class<?>[] { String.class }, "zod.string()", "string", null, "zod.string()",
true));
previous.add(new ClassElement(new Class<?>[] { InputStream.class, FormDataContentDisposition.class },

View File

@ -2,6 +2,15 @@ package org.kar.archidata.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.persistence.Column;
@JsonInclude(JsonInclude.Include.NON_NULL)
public record GetToken(
String jwt) {}
public class GetToken {
@Column(length = -1, nullable = false)
public String jwt;
public GetToken(final String jwt) {
this.jwt = jwt;
}
}