mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-03 22:20:56 +00:00
Merge pull request #2074 from swagger-api/issue-2073
Update parser, inline resolver
This commit is contained in:
commit
f539fdcfea
@ -218,7 +218,12 @@ public class InlineModelResolver {
|
|||||||
Map<String, Model> modelsToAdd = new HashMap<String, Model>();
|
Map<String, Model> modelsToAdd = new HashMap<String, Model>();
|
||||||
for (String key : properties.keySet()) {
|
for (String key : properties.keySet()) {
|
||||||
Property property = properties.get(key);
|
Property property = properties.get(key);
|
||||||
if (property instanceof ObjectProperty && ((ObjectProperty)property).getProperties().size() > 0) {
|
if(property instanceof ObjectProperty && ((ObjectProperty)property).getProperties() == null) {
|
||||||
|
MapProperty mp = new MapProperty();
|
||||||
|
mp.setAdditionalProperties(new StringProperty());
|
||||||
|
properties.put(key, mp);
|
||||||
|
}
|
||||||
|
else if (property instanceof ObjectProperty && ((ObjectProperty)property).getProperties().size() > 0) {
|
||||||
String modelName = uniqueName(path + "_" + key);
|
String modelName = uniqueName(path + "_" + key);
|
||||||
|
|
||||||
ObjectProperty op = (ObjectProperty) property;
|
ObjectProperty op = (ObjectProperty) property;
|
||||||
@ -276,7 +281,6 @@ public class InlineModelResolver {
|
|||||||
swagger.addDefinition(modelName, innerModel);
|
swagger.addDefinition(modelName, innerModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (propsToUpdate.size() > 0) {
|
if (propsToUpdate.size() > 0) {
|
||||||
|
@ -1,35 +1,19 @@
|
|||||||
package io.swagger.codegen.languages;
|
package io.swagger.codegen.languages;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
import io.swagger.codegen.*;
|
||||||
import io.swagger.codegen.CliOption;
|
|
||||||
import io.swagger.codegen.CodegenConfig;
|
|
||||||
import io.swagger.codegen.CodegenConstants;
|
|
||||||
import io.swagger.codegen.CodegenModel;
|
|
||||||
import io.swagger.codegen.CodegenOperation;
|
|
||||||
import io.swagger.codegen.CodegenProperty;
|
|
||||||
import io.swagger.codegen.CodegenType;
|
|
||||||
import io.swagger.codegen.DefaultCodegen;
|
|
||||||
import io.swagger.codegen.SupportingFile;
|
|
||||||
import io.swagger.models.*;
|
import io.swagger.models.*;
|
||||||
import io.swagger.models.properties.ArrayProperty;
|
import io.swagger.models.properties.ArrayProperty;
|
||||||
import io.swagger.models.properties.MapProperty;
|
import io.swagger.models.properties.MapProperty;
|
||||||
import io.swagger.models.properties.Property;
|
import io.swagger.models.properties.Property;
|
||||||
import io.swagger.models.properties.RefProperty;
|
import io.swagger.models.properties.RefProperty;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public class JavascriptClientCodegen extends DefaultCodegen implements CodegenConfig {
|
public class JavascriptClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(JavascriptClientCodegen.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(JavascriptClientCodegen.class);
|
||||||
@ -133,6 +117,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
typeMapping.put("double", "Number");
|
typeMapping.put("double", "Number");
|
||||||
typeMapping.put("number", "Number");
|
typeMapping.put("number", "Number");
|
||||||
typeMapping.put("DateTime", "Date");
|
typeMapping.put("DateTime", "Date");
|
||||||
|
typeMapping.put("Date", "Date");
|
||||||
// binary not supported in JavaScript client right now, using String as a workaround
|
// binary not supported in JavaScript client right now, using String as a workaround
|
||||||
typeMapping.put("binary", "String");
|
typeMapping.put("binary", "String");
|
||||||
|
|
||||||
@ -358,7 +343,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
|
|
||||||
// method name cannot use reserved keyword, e.g. return
|
// method name cannot use reserved keyword, e.g. return
|
||||||
if (reservedWords.contains(operationId)) {
|
if (reservedWords.contains(operationId)) {
|
||||||
throw new RuntimeException(operationId + " (reserved word) cannot be used as method name");
|
operationId = escapeReservedWord(operationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return camelize(sanitizeName(operationId), true);
|
return camelize(sanitizeName(operationId), true);
|
||||||
|
4
pom.xml
4
pom.xml
@ -122,8 +122,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.0</version>
|
<version>3.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.6</source>
|
<source>1.7</source>
|
||||||
<target>1.6</target>
|
<target>1.7</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user