forked from loafle/openapi-generator-original
parent
1540ae7951
commit
e3fe12eacf
@ -35,7 +35,7 @@ sidebar_label: spring
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |false|
|
||||
|withXml|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)| |false|
|
||||
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date (if you really have a good reason not to use threetenbp</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+) - note: this also sets "java8" to true</dd><dt>**threetenbp**</dt><dd>Backport of JSR310 (preferred for jdk < 1.8)</dd><dl>|threetenbp|
|
||||
|java8|Option. Use Java8 classes instead of third party equivalents|<dl><dt>**true**</dt><dd>Use Java 8 classes such as Base64</dd><dt>**false**</dt><dd>Various third party libraries as needed</dd><dl>|false|
|
||||
|java8|Option. Use Java8 classes instead of third party equivalents|<dl><dt>**true**</dt><dd>Use Java 8 classes such as Base64. Use java8 default interface when a responseWrapper is used</dd><dt>**false**</dt><dd>Various third party libraries as needed</dd><dl>|false|
|
||||
|disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false|
|
||||
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|
||||
|parentGroupId|parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null|
|
||||
@ -48,7 +48,6 @@ sidebar_label: spring
|
||||
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
|
||||
|delegatePattern|Whether to generate the server files using the delegate pattern| |false|
|
||||
|singleContentTypes|Whether to select only one produces/consumes content-type by operation.| |false|
|
||||
|java8|use java8 default interface| |true|
|
||||
|async|use async Callable controllers| |false|
|
||||
|reactive|wrap responses in Mono/Flux Reactor types (spring-boot only)| |false|
|
||||
|responseWrapper|wrap the responses in given type (Future,Callable,CompletableFuture,ListenableFuture,DeferredResult,HystrixCommand,RxObservable,RxSingle or fully qualified type)| |null|
|
||||
|
@ -175,7 +175,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
dateLibrary.setEnum(dateOptions);
|
||||
cliOptions.add(dateLibrary);
|
||||
|
||||
CliOption java8Mode = new CliOption(JAVA8_MODE, "Option. Use Java8 classes instead of third party equivalents").defaultValue(String.valueOf(this.java8Mode));
|
||||
CliOption java8Mode = CliOption.newBoolean(JAVA8_MODE, "Option. Use Java8 classes instead of third party equivalents", this.java8Mode);
|
||||
Map<String, String> java8ModeOptions = new HashMap<>();
|
||||
java8ModeOptions.put("true", "Use Java 8 classes such as Base64");
|
||||
java8ModeOptions.put("false", "Various third party libraries as needed");
|
||||
|
@ -21,7 +21,6 @@ import com.samskivert.mustache.Mustache;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.PathItem;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.languages.features.BeanValidationFeatures;
|
||||
@ -117,7 +116,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
cliOptions.add(CliOption.newBoolean(INTERFACE_ONLY, "Whether to generate only API interface stubs without the server files.", interfaceOnly));
|
||||
cliOptions.add(CliOption.newBoolean(DELEGATE_PATTERN, "Whether to generate the server files using the delegate pattern", delegatePattern));
|
||||
cliOptions.add(CliOption.newBoolean(SINGLE_CONTENT_TYPES, "Whether to select only one produces/consumes content-type by operation.", singleContentTypes));
|
||||
cliOptions.add(CliOption.newBoolean(JAVA_8, "use java8 default interface", java8));
|
||||
updateJava8CliOptions();
|
||||
cliOptions.add(CliOption.newBoolean(ASYNC, "use async Callable controllers", async));
|
||||
cliOptions.add(CliOption.newBoolean(REACTIVE, "wrap responses in Mono/Flux Reactor types (spring-boot only)", reactive));
|
||||
cliOptions.add(new CliOption(RESPONSE_WRAPPER, "wrap the responses in given type (Future,Callable,CompletableFuture,ListenableFuture,DeferredResult,HystrixCommand,RxObservable,RxSingle or fully qualified type)"));
|
||||
@ -142,6 +141,13 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
|
||||
}
|
||||
|
||||
private void updateJava8CliOptions() {
|
||||
CliOption option = cliOptions.stream().filter(o -> JAVA_8.equals(o.getOpt())).findFirst()
|
||||
.orElseThrow(() -> new RuntimeException("Missing java8 option"));
|
||||
Map<String, String> java8ModeOptions = option.getEnum();
|
||||
java8ModeOptions.put("true", "Use Java 8 classes such as Base64. Use java8 default interface when a responseWrapper is used");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.SERVER;
|
||||
|
@ -22,6 +22,7 @@ import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.ClientOptInput;
|
||||
import org.openapitools.codegen.ClientOpts;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
@ -35,11 +36,12 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import static java.util.stream.Collectors.groupingBy;
|
||||
import static org.openapitools.codegen.languages.SpringCodegen.RESPONSE_WRAPPER;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import static org.openapitools.codegen.languages.SpringCodegen.RESPONSE_WRAPPER;
|
||||
|
||||
public class SpringCodegenTest {
|
||||
|
||||
@Test
|
||||
@ -168,4 +170,13 @@ public class SpringCodegenTest {
|
||||
for (String line : lines)
|
||||
assertFalse(file.contains(line));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clientOptsUnicity() {
|
||||
SpringCodegen codegen = new SpringCodegen();
|
||||
codegen.cliOptions()
|
||||
.stream()
|
||||
.collect(groupingBy(CliOption::getOpt))
|
||||
.forEach((k,v) -> assertEquals(v.size(), 1, k + " is described multiple times"));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user