[Java] Remove JAX-RS dependency from generated java-native client. (#8320) (#9585)

This commit is contained in:
shartte
2021-06-18 09:05:55 +02:00
committed by GitHub
parent 75fc1383bc
commit 8a31064028
28 changed files with 124 additions and 212 deletions

View File

@@ -11,11 +11,9 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.ext.ContextResolver;
@javax.annotation.processing.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class JSON implements ContextResolver<ObjectMapper> {
public class JSON {
private ObjectMapper mapper;
public JSON() {
@@ -41,11 +39,6 @@ public class JSON implements ContextResolver<ObjectMapper> {
mapper.setDateFormat(dateFormat);
}
@Override
public ObjectMapper getContext(Class<?> type) {
return mapper;
}
/**
* Get the object mapper
*
@@ -178,10 +171,10 @@ public class JSON implements ContextResolver<ObjectMapper> {
visitedClasses.add(modelClass);
// Traverse the oneOf/anyOf composed schemas.
Map<String, GenericType> descendants = modelDescendants.get(modelClass);
Map<String, Class<?>> descendants = modelDescendants.get(modelClass);
if (descendants != null) {
for (GenericType childType : descendants.values()) {
if (isInstanceOf(childType.getRawType(), inst, visitedClasses)) {
for (Class<?> childType : descendants.values()) {
if (isInstanceOf(childType, inst, visitedClasses)) {
return true;
}
}
@@ -192,12 +185,12 @@ public class JSON implements ContextResolver<ObjectMapper> {
/**
* A map of discriminators for all model classes.
*/
private static Map<Class<?>, ClassDiscriminatorMapping> modelDiscriminators = new HashMap<Class<?>, ClassDiscriminatorMapping>();
private static Map<Class<?>, ClassDiscriminatorMapping> modelDiscriminators = new HashMap<>();
/**
* A map of oneOf/anyOf descendants for each model class.
*/
private static Map<Class<?>, Map<String, GenericType>> modelDescendants = new HashMap<Class<?>, Map<String, GenericType>>();
private static Map<Class<?>, Map<String, Class<?>>> modelDescendants = new HashMap<>();
/**
* Register a model class discriminator.
@@ -217,7 +210,7 @@ public class JSON implements ContextResolver<ObjectMapper> {
* @param modelClass the model class
* @param descendants a map of oneOf/anyOf descendants.
*/
public static void registerDescendants(Class<?> modelClass, Map<String, GenericType> descendants) {
public static void registerDescendants(Class<?> modelClass, Map<String, Class<?>> descendants) {
modelDescendants.put(modelClass, descendants);
}

View File

@@ -17,7 +17,6 @@ import org.openapitools.client.ApiException;
import java.util.Objects;
import java.lang.reflect.Type;
import java.util.Map;
import javax.ws.rs.core.GenericType;
import com.fasterxml.jackson.annotation.JsonValue;
@@ -46,7 +45,7 @@ public abstract class AbstractOpenApiSchema {
*
* @return an instance of the actual schema/object
*/
public abstract Map<String, GenericType> getSchemas();
public abstract Map<String, Class<?>> getSchemas();
/**
* Get the actual instance