[DEV] better zod export

This commit is contained in:
Edouard DUPIN 2024-03-15 07:57:13 +01:00
parent c13f910620
commit e1d9da70c8
2 changed files with 27 additions and 17 deletions

View File

@ -12,4 +12,6 @@ import org.kar.archidata.dataAccess.options.CheckFunctionVoid;
@Retention(RetentionPolicy.RUNTIME)
public @interface DataJson {
Class<? extends CheckFunctionInterface> checker() default CheckFunctionVoid.class;
Class<?> targetEntity() default Void.class;
}

View File

@ -296,13 +296,24 @@ public class DataFactoryTsApi {
}
final Class<?> parameterType = parameter.getType();
String parameterTypeString;
final Class<?> asyncType = apiAnnotationGetAsyncType(parameter);
if (parameterType == List.class) {
LOGGER.warn("Detext List param ==> not managed type ==> any[] !!!");
parameterTypeString = "any[]";
} else {
if (asyncType == null) {
LOGGER.warn("Detext List param ==> not managed type ==> any[] !!!");
parameterTypeString = "any[]";
} else {
final ClassElement tmp = DataFactoryZod.createTable(asyncType, previous);
includeModel.add(tmp.model[0]);
parameterTypeString = tmp.tsTypeName + "[]";
}
} else if (asyncType == null) {
final ClassElement tmp = DataFactoryZod.createTable(parameterType, previous);
includeModel.add(tmp.model[0]);
parameterTypeString = tmp.tsTypeName;
} else {
final ClassElement tmp = DataFactoryZod.createTable(asyncType, previous);
includeModel.add(tmp.model[0]);
parameterTypeString = tmp.tsTypeName;
}
final String pathParam = apiAnnotationGetPathParam(parameter);
final String queryParam = apiAnnotationGetQueryParam(parameter);
@ -313,21 +324,18 @@ public class DataFactoryTsApi {
pathParams.put(pathParam, parameterTypeString);
} else if (formDataParam != null) {
formDataParams.put(formDataParam, parameterTypeString);
} else if (asyncType != null) {
final ClassElement tmp = DataFactoryZod.createTable(asyncType, previous);
includeModel.add(tmp.model[0]);
emptyElement.add(tmp.tsTypeName);
} else if (parameterType == List.class) {
parameterTypeString = "any[]";
final Class<?> plop = parameterType.arrayType();
LOGGER.info("ArrayType = {}", plop);
} else {
final Class<?> asyncType = apiAnnotationGetAsyncType(parameter);
if (asyncType != null) {
final ClassElement tmp = DataFactoryZod.createTable(asyncType, previous);
includeModel.add(tmp.model[0]);
emptyElement.add(tmp.tsTypeName);
} else if (parameterType == List.class) {
parameterTypeString = "any[]";
final Class<?> plop = parameterType.arrayType();
LOGGER.info("ArrayType = {}", plop);
} else {
final ClassElement tmp = DataFactoryZod.createTable(parameterType, previous);
includeModel.add(tmp.model[0]);
emptyElement.add(tmp.tsTypeName);
}
final ClassElement tmp = DataFactoryZod.createTable(parameterType, previous);
includeModel.add(tmp.model[0]);
emptyElement.add(tmp.tsTypeName);
}
}
if (!queryParams.isEmpty()) {