forked from loafle/openapi-generator-original
[Java] Discriminator lookup should not be case insensitive by default (#5894)
* Add 'discriminatorCaseSensitive' property * Discriminator value lookup should not be case insensitive * fix typo * run scripts * execute ./bin/utils/export_docs_generators.sh * fix discriminator mapping, add code comments
This commit is contained in:
parent
aca8089bdd
commit
8af6b7459c
@ -18,6 +18,7 @@ sidebar_label: groovy
|
||||
|developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org|
|
||||
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|
||||
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|groupId|groupId in generated pom.xml| |org.openapitools|
|
||||
|
@ -20,6 +20,7 @@ sidebar_label: java-inflector
|
||||
|developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org|
|
||||
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|
||||
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|groupId|groupId in generated pom.xml| |org.openapitools|
|
||||
|
@ -20,6 +20,7 @@ sidebar_label: java-msf4j
|
||||
|developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org|
|
||||
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|
||||
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|groupId|groupId in generated pom.xml| |org.openapitools|
|
||||
|
@ -21,6 +21,7 @@ sidebar_label: java-pkmst
|
||||
|developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org|
|
||||
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|
||||
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|eurekaUri|Eureka URI| |null|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|
@ -23,6 +23,7 @@ sidebar_label: java-play-framework
|
||||
|developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org|
|
||||
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|
||||
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|groupId|groupId in generated pom.xml| |org.openapitools|
|
||||
|
@ -20,6 +20,7 @@ sidebar_label: java-undertow-server
|
||||
|developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org|
|
||||
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|
||||
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|groupId|groupId in generated pom.xml| |org.openapitools|
|
||||
|
@ -20,6 +20,7 @@ sidebar_label: java-vertx-web
|
||||
|developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org|
|
||||
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|
||||
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|groupId|groupId in generated pom.xml| |org.openapitools|
|
||||
|
@ -20,6 +20,7 @@ sidebar_label: java-vertx
|
||||
|developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org|
|
||||
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|
||||
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|groupId|groupId in generated pom.xml| |org.openapitools|
|
||||
|
@ -21,6 +21,7 @@ sidebar_label: java
|
||||
|developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org|
|
||||
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|
||||
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|feignVersion|Version of OpenFeign: '10.x' (default), '9.x' (deprecated)| |false|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|
@ -20,6 +20,7 @@ sidebar_label: jaxrs-cxf-cdi
|
||||
|developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org|
|
||||
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|
||||
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|generateBuilders|Whether to generate builders for models.| |false|
|
||||
|
@ -20,6 +20,7 @@ sidebar_label: jaxrs-cxf-client
|
||||
|developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org|
|
||||
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|
||||
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|groupId|groupId in generated pom.xml| |org.openapitools|
|
||||
|
@ -21,6 +21,7 @@ sidebar_label: jaxrs-cxf-extended
|
||||
|developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org|
|
||||
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|
||||
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|generateJbossDeploymentDescriptor|Generate Jboss Deployment Descriptor| |false|
|
||||
|
@ -21,6 +21,7 @@ sidebar_label: jaxrs-cxf
|
||||
|developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org|
|
||||
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|
||||
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|generateJbossDeploymentDescriptor|Generate Jboss Deployment Descriptor| |false|
|
||||
|
@ -20,6 +20,7 @@ sidebar_label: jaxrs-jersey
|
||||
|developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org|
|
||||
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|
||||
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|groupId|groupId in generated pom.xml| |org.openapitools|
|
||||
|
@ -20,6 +20,7 @@ sidebar_label: jaxrs-resteasy-eap
|
||||
|developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org|
|
||||
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|
||||
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|generateJbossDeploymentDescriptor|Generate Jboss Deployment Descriptor| |true|
|
||||
|
@ -20,6 +20,7 @@ sidebar_label: jaxrs-resteasy
|
||||
|developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org|
|
||||
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|
||||
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|generateJbossDeploymentDescriptor|Generate Jboss Deployment Descriptor| |false|
|
||||
|
@ -20,6 +20,7 @@ sidebar_label: jaxrs-spec
|
||||
|developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org|
|
||||
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|
||||
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|generateBuilders|Whether to generate builders for models.| |false|
|
||||
|
@ -25,6 +25,7 @@ sidebar_label: spring
|
||||
|developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org|
|
||||
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|
||||
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|groupId|groupId in generated pom.xml| |org.openapitools|
|
||||
|
@ -46,7 +46,13 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
public Set<String> oneOf = new TreeSet<String>();
|
||||
public Set<String> allOf = new TreeSet<String>();
|
||||
|
||||
public String name, classname, title, description, classVarName, modelJson, dataType, xmlPrefix, xmlNamespace, xmlName;
|
||||
public String name;
|
||||
// The language-specific name of the class that implements this schema.
|
||||
// The name of the class is derived from the OpenAPI schema name with formatting rules applied.
|
||||
public String classname;
|
||||
// The value of the 'title' attribute in the OpenAPI document.
|
||||
public String title;
|
||||
public String description, classVarName, modelJson, dataType, xmlPrefix, xmlNamespace, xmlName;
|
||||
public String classFilename; // store the class file name, mainly used for import
|
||||
public String unescapedDescription;
|
||||
public CodegenDiscriminator discriminator;
|
||||
|
@ -59,6 +59,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
public static final String DISABLE_HTML_ESCAPING = "disableHtmlEscaping";
|
||||
public static final String BOOLEAN_GETTER_PREFIX = "booleanGetterPrefix";
|
||||
public static final String ADDITIONAL_MODEL_TYPE_ANNOTATIONS = "additionalModelTypeAnnotations";
|
||||
public static final String DISCRIMINATOR_CASE_SENSITIVE = "discriminatorCaseSensitive";
|
||||
|
||||
protected String dateLibrary = "threetenbp";
|
||||
protected boolean supportAsync = false;
|
||||
@ -84,6 +85,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
protected String sourceFolder = projectFolder + "/java";
|
||||
protected String testFolder = projectTestFolder + "/java";
|
||||
protected boolean fullJavaUtil;
|
||||
protected boolean discriminatorCaseSensitive = true; // True if the discriminator value lookup should be case-sensitive.
|
||||
protected String javaUtilPrefix = "";
|
||||
protected Boolean serializableModel = false;
|
||||
protected boolean serializeBigDecimalAsString = false;
|
||||
@ -189,6 +191,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
cliOptions.add(CliOption.newBoolean(CodegenConstants.SERIALIZABLE_MODEL, CodegenConstants.SERIALIZABLE_MODEL_DESC, this.getSerializableModel()));
|
||||
cliOptions.add(CliOption.newBoolean(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING, CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING_DESC, serializeBigDecimalAsString));
|
||||
cliOptions.add(CliOption.newBoolean(FULL_JAVA_UTIL, "whether to use fully qualified name for classes under java.util. This option only works for Java API client", fullJavaUtil));
|
||||
cliOptions.add(CliOption.newBoolean(DISCRIMINATOR_CASE_SENSITIVE, "Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client", discriminatorCaseSensitive));
|
||||
cliOptions.add(CliOption.newBoolean(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC, this.isHideGenerationTimestamp()));
|
||||
cliOptions.add(CliOption.newBoolean(WITH_XML, "whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)"));
|
||||
|
||||
@ -385,6 +388,15 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
if (additionalProperties.containsKey(FULL_JAVA_UTIL)) {
|
||||
this.setFullJavaUtil(Boolean.valueOf(additionalProperties.get(FULL_JAVA_UTIL).toString()));
|
||||
}
|
||||
if (additionalProperties.containsKey(DISCRIMINATOR_CASE_SENSITIVE)) {
|
||||
this.setDiscriminatorCaseSensitive(Boolean.valueOf(additionalProperties.get(DISCRIMINATOR_CASE_SENSITIVE).toString()));
|
||||
} else {
|
||||
// By default, the discriminator lookup should be case sensitive. There is nothing in the OpenAPI specification
|
||||
// that indicates the lookup should be case insensitive. However, some implementations perform
|
||||
// a case-insensitive lookup.
|
||||
this.setDiscriminatorCaseSensitive(Boolean.TRUE);
|
||||
}
|
||||
additionalProperties.put(DISCRIMINATOR_CASE_SENSITIVE, this.discriminatorCaseSensitive);
|
||||
|
||||
if (fullJavaUtil) {
|
||||
javaUtilPrefix = "java.util.";
|
||||
@ -1431,6 +1443,15 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
this.fullJavaUtil = fullJavaUtil;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether discriminator value lookup is case-sensitive or not.
|
||||
*
|
||||
* @param discriminatorCaseSensitive true if the discriminator value lookup should be case sensitive.
|
||||
*/
|
||||
public void setDiscriminatorCaseSensitive(boolean discriminatorCaseSensitive) {
|
||||
this.discriminatorCaseSensitive = discriminatorCaseSensitive;
|
||||
}
|
||||
|
||||
public void setWithXml(boolean withXml) {
|
||||
this.withXml = withXml;
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
for (Map<String, Object> mo : models) {
|
||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||
|
||||
// make sure discrimonator models are included in imports
|
||||
// make sure discriminator models are included in imports
|
||||
CodegenDiscriminator discriminator = cm.discriminator;
|
||||
if (discriminator != null) {
|
||||
Set<CodegenDiscriminator.MappedModel> mappedModels = discriminator.getMappedModels();
|
||||
|
@ -71,9 +71,9 @@ public class JSON {
|
||||
public Class getClassForElement(JsonElement readElement) {
|
||||
Map<String, Class> classByDiscriminatorValue = new HashMap<String, Class>();
|
||||
{{#mappedModels}}
|
||||
classByDiscriminatorValue.put("{{mappingName}}".toUpperCase(Locale.ROOT), {{modelName}}.class);
|
||||
classByDiscriminatorValue.put("{{mappingName}}"{{^discriminatorCaseSensitive}}.toUpperCase(Locale.ROOT){{/discriminatorCaseSensitive}}, {{modelName}}.class);
|
||||
{{/mappedModels}}
|
||||
classByDiscriminatorValue.put("{{classname}}".toUpperCase(Locale.ROOT), {{classname}}.class);
|
||||
classByDiscriminatorValue.put("{{name}}"{{^discriminatorCaseSensitive}}.toUpperCase(Locale.ROOT){{/discriminatorCaseSensitive}}, {{classname}}.class);
|
||||
return getClassByDiscriminator(classByDiscriminatorValue,
|
||||
getDiscriminatorValue(readElement, "{{{propertyBaseName}}}"));
|
||||
}
|
||||
@ -97,8 +97,15 @@ public class JSON {
|
||||
return element.getAsString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Java class that implements the OpenAPI schema for the specified discriminator value.
|
||||
*
|
||||
* @param classByDiscriminatorValue The map of discriminator values to Java classes.
|
||||
* @param discriminatorValue The value of the OpenAPI discriminator in the input data.
|
||||
* @return The Java class that implements the OpenAPI schema
|
||||
*/
|
||||
private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) {
|
||||
Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue.toUpperCase(Locale.ROOT));
|
||||
Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue{{^discriminatorCaseSensitive}}.toUpperCase(Locale.ROOT){{/discriminatorCaseSensitive}});
|
||||
if (null == clazz) {
|
||||
throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">");
|
||||
}
|
||||
|
@ -56,10 +56,10 @@ public class JSON {
|
||||
@Override
|
||||
public Class getClassForElement(JsonElement readElement) {
|
||||
Map<String, Class> classByDiscriminatorValue = new HashMap<String, Class>();
|
||||
classByDiscriminatorValue.put("Dog".toUpperCase(Locale.ROOT), Dog.class);
|
||||
classByDiscriminatorValue.put("Cat".toUpperCase(Locale.ROOT), Cat.class);
|
||||
classByDiscriminatorValue.put("BigCat".toUpperCase(Locale.ROOT), BigCat.class);
|
||||
classByDiscriminatorValue.put("Animal".toUpperCase(Locale.ROOT), Animal.class);
|
||||
classByDiscriminatorValue.put("Dog", Dog.class);
|
||||
classByDiscriminatorValue.put("Cat", Cat.class);
|
||||
classByDiscriminatorValue.put("BigCat", BigCat.class);
|
||||
classByDiscriminatorValue.put("Animal", Animal.class);
|
||||
return getClassByDiscriminator(classByDiscriminatorValue,
|
||||
getDiscriminatorValue(readElement, "className"));
|
||||
}
|
||||
@ -77,8 +77,15 @@ public class JSON {
|
||||
return element.getAsString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Java class that implements the OpenAPI schema for the specified discriminator value.
|
||||
*
|
||||
* @param classByDiscriminatorValue The map of discriminator values to Java classes.
|
||||
* @param discriminatorValue The value of the OpenAPI discriminator in the input data.
|
||||
* @return The Java class that implements the OpenAPI schema
|
||||
*/
|
||||
private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) {
|
||||
Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue.toUpperCase(Locale.ROOT));
|
||||
Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue);
|
||||
if (null == clazz) {
|
||||
throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">");
|
||||
}
|
||||
|
@ -56,10 +56,10 @@ public class JSON {
|
||||
@Override
|
||||
public Class getClassForElement(JsonElement readElement) {
|
||||
Map<String, Class> classByDiscriminatorValue = new HashMap<String, Class>();
|
||||
classByDiscriminatorValue.put("Dog".toUpperCase(Locale.ROOT), Dog.class);
|
||||
classByDiscriminatorValue.put("Cat".toUpperCase(Locale.ROOT), Cat.class);
|
||||
classByDiscriminatorValue.put("BigCat".toUpperCase(Locale.ROOT), BigCat.class);
|
||||
classByDiscriminatorValue.put("Animal".toUpperCase(Locale.ROOT), Animal.class);
|
||||
classByDiscriminatorValue.put("Dog", Dog.class);
|
||||
classByDiscriminatorValue.put("Cat", Cat.class);
|
||||
classByDiscriminatorValue.put("BigCat", BigCat.class);
|
||||
classByDiscriminatorValue.put("Animal", Animal.class);
|
||||
return getClassByDiscriminator(classByDiscriminatorValue,
|
||||
getDiscriminatorValue(readElement, "className"));
|
||||
}
|
||||
@ -77,8 +77,15 @@ public class JSON {
|
||||
return element.getAsString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Java class that implements the OpenAPI schema for the specified discriminator value.
|
||||
*
|
||||
* @param classByDiscriminatorValue The map of discriminator values to Java classes.
|
||||
* @param discriminatorValue The value of the OpenAPI discriminator in the input data.
|
||||
* @return The Java class that implements the OpenAPI schema
|
||||
*/
|
||||
private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) {
|
||||
Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue.toUpperCase(Locale.ROOT));
|
||||
Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue);
|
||||
if (null == clazz) {
|
||||
throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">");
|
||||
}
|
||||
|
@ -56,10 +56,10 @@ public class JSON {
|
||||
@Override
|
||||
public Class getClassForElement(JsonElement readElement) {
|
||||
Map<String, Class> classByDiscriminatorValue = new HashMap<String, Class>();
|
||||
classByDiscriminatorValue.put("Dog".toUpperCase(Locale.ROOT), Dog.class);
|
||||
classByDiscriminatorValue.put("Cat".toUpperCase(Locale.ROOT), Cat.class);
|
||||
classByDiscriminatorValue.put("BigCat".toUpperCase(Locale.ROOT), BigCat.class);
|
||||
classByDiscriminatorValue.put("Animal".toUpperCase(Locale.ROOT), Animal.class);
|
||||
classByDiscriminatorValue.put("Dog", Dog.class);
|
||||
classByDiscriminatorValue.put("Cat", Cat.class);
|
||||
classByDiscriminatorValue.put("BigCat", BigCat.class);
|
||||
classByDiscriminatorValue.put("Animal", Animal.class);
|
||||
return getClassByDiscriminator(classByDiscriminatorValue,
|
||||
getDiscriminatorValue(readElement, "className"));
|
||||
}
|
||||
@ -77,8 +77,15 @@ public class JSON {
|
||||
return element.getAsString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Java class that implements the OpenAPI schema for the specified discriminator value.
|
||||
*
|
||||
* @param classByDiscriminatorValue The map of discriminator values to Java classes.
|
||||
* @param discriminatorValue The value of the OpenAPI discriminator in the input data.
|
||||
* @return The Java class that implements the OpenAPI schema
|
||||
*/
|
||||
private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) {
|
||||
Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue.toUpperCase(Locale.ROOT));
|
||||
Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue);
|
||||
if (null == clazz) {
|
||||
throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user