forked from loafle/openapi-generator-original
Resource stream for file is no longer an option, it's the default for Spring
This commit is contained in:
parent
58d4187054
commit
aa773dc7fd
@ -5,7 +5,6 @@ import io.swagger.codegen.languages.features.BeanValidationFeatures;
|
|||||||
import io.swagger.models.Operation;
|
import io.swagger.models.Operation;
|
||||||
import io.swagger.models.Path;
|
import io.swagger.models.Path;
|
||||||
import io.swagger.models.Swagger;
|
import io.swagger.models.Swagger;
|
||||||
import io.swagger.models.properties.Property;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -25,7 +24,6 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation
|
|||||||
public static final String SPRING_MVC_LIBRARY = "spring-mvc";
|
public static final String SPRING_MVC_LIBRARY = "spring-mvc";
|
||||||
public static final String SPRING_CLOUD_LIBRARY = "spring-cloud";
|
public static final String SPRING_CLOUD_LIBRARY = "spring-cloud";
|
||||||
public static final String IMPLICIT_HEADERS = "implicitHeaders";
|
public static final String IMPLICIT_HEADERS = "implicitHeaders";
|
||||||
public static final String RESOURCE_FILE_STREAMS = "resourceStreams";
|
|
||||||
|
|
||||||
protected String title = "swagger-petstore";
|
protected String title = "swagger-petstore";
|
||||||
protected String configPackage = "io.swagger.configuration";
|
protected String configPackage = "io.swagger.configuration";
|
||||||
@ -68,7 +66,6 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation
|
|||||||
cliOptions.add(CliOption.newBoolean(USE_TAGS, "use tags for creating interface and controller classnames"));
|
cliOptions.add(CliOption.newBoolean(USE_TAGS, "use tags for creating interface and controller classnames"));
|
||||||
cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations"));
|
cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations"));
|
||||||
cliOptions.add(CliOption.newBoolean(IMPLICIT_HEADERS, "Use of @ApiImplicitParams for headers."));
|
cliOptions.add(CliOption.newBoolean(IMPLICIT_HEADERS, "Use of @ApiImplicitParams for headers."));
|
||||||
cliOptions.add(CliOption.newBoolean(RESOURCE_FILE_STREAMS, "When \"file\" is specified as a type, generate the type as org.springframework.core.io.Resource, and FileSystemResource for example values."));
|
|
||||||
|
|
||||||
supportedLibraries.put(DEFAULT_LIBRARY, "Spring-boot Server application using the SpringFox integration.");
|
supportedLibraries.put(DEFAULT_LIBRARY, "Spring-boot Server application using the SpringFox integration.");
|
||||||
supportedLibraries.put(SPRING_MVC_LIBRARY, "Spring-MVC Server application using the SpringFox integration.");
|
supportedLibraries.put(SPRING_MVC_LIBRARY, "Spring-MVC Server application using the SpringFox integration.");
|
||||||
@ -151,11 +148,6 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation
|
|||||||
this.setUseBeanValidation(convertPropertyToBoolean(USE_BEANVALIDATION));
|
this.setUseBeanValidation(convertPropertyToBoolean(USE_BEANVALIDATION));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey(RESOURCE_FILE_STREAMS)) {
|
|
||||||
typeMapping.put("file", "Resource");
|
|
||||||
importMapping.put("Resource", "org.springframework.core.io.Resource");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (useBeanValidation) {
|
if (useBeanValidation) {
|
||||||
writePropertyBack(USE_BEANVALIDATION, useBeanValidation);
|
writePropertyBack(USE_BEANVALIDATION, useBeanValidation);
|
||||||
}
|
}
|
||||||
@ -165,6 +157,9 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation
|
|||||||
this.setImplicitHeaders(Boolean.valueOf(additionalProperties.get(IMPLICIT_HEADERS).toString()));
|
this.setImplicitHeaders(Boolean.valueOf(additionalProperties.get(IMPLICIT_HEADERS).toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typeMapping.put("file", "Resource");
|
||||||
|
importMapping.put("Resource", "org.springframework.core.io.Resource");
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ public class SpringOptionsProvider extends JavaOptionsProvider {
|
|||||||
public static final String USE_TAGS = "useTags";
|
public static final String USE_TAGS = "useTags";
|
||||||
public static final String USE_BEANVALIDATION = "false";
|
public static final String USE_BEANVALIDATION = "false";
|
||||||
public static final String IMPLICIT_HEADERS = "false";
|
public static final String IMPLICIT_HEADERS = "false";
|
||||||
public static final String RESOURCE_FILE_STREAMS = "false";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLanguage() {
|
public String getLanguage() {
|
||||||
@ -43,7 +42,6 @@ public class SpringOptionsProvider extends JavaOptionsProvider {
|
|||||||
options.put(SpringCodegen.USE_TAGS, USE_TAGS);
|
options.put(SpringCodegen.USE_TAGS, USE_TAGS);
|
||||||
options.put(SpringCodegen.USE_BEANVALIDATION, USE_BEANVALIDATION);
|
options.put(SpringCodegen.USE_BEANVALIDATION, USE_BEANVALIDATION);
|
||||||
options.put(SpringCodegen.IMPLICIT_HEADERS, IMPLICIT_HEADERS);
|
options.put(SpringCodegen.IMPLICIT_HEADERS, IMPLICIT_HEADERS);
|
||||||
options.put(SpringCodegen.RESOURCE_FILE_STREAMS, RESOURCE_FILE_STREAMS);
|
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user