forked from loafle/openapi-generator-original
[JAVA - jaxrs-reasteasy-eap] Add import to models (#179)
Call super management for managing imports in postProcessModelProperty
This commit is contained in:
parent
ad5d5f598e
commit
bd50d368eb
@ -147,6 +147,7 @@ public class JavaResteasyEapServerCodegen extends AbstractJavaJAXRSServerCodegen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
||||||
|
super.postProcessModelProperty(model, property);
|
||||||
// Add imports for Jackson
|
// Add imports for Jackson
|
||||||
if (!BooleanUtils.toBoolean(model.isEnum)) {
|
if (!BooleanUtils.toBoolean(model.isEnum)) {
|
||||||
model.imports.add("JsonProperty");
|
model.imports.add("JsonProperty");
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
package org.openapitools.codegen.java.jaxrs;
|
||||||
|
|
||||||
|
import io.swagger.util.Json;
|
||||||
|
import io.swagger.v3.oas.models.media.MapSchema;
|
||||||
|
import io.swagger.v3.oas.models.media.Schema;
|
||||||
|
import org.openapitools.codegen.CodegenModel;
|
||||||
|
import org.openapitools.codegen.languages.JavaResteasyEapServerCodegen;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
|
public class JavaResteasyEapServerCodegenModelTest {
|
||||||
|
|
||||||
|
@Test(description = "convert a simple java model with java8 types")
|
||||||
|
public void mapModelTest() {
|
||||||
|
final Schema model = new Schema()
|
||||||
|
.description("A model with a map")
|
||||||
|
.addProperties("map", new MapSchema());
|
||||||
|
|
||||||
|
final JavaResteasyEapServerCodegen codegen = new JavaResteasyEapServerCodegen();
|
||||||
|
final CodegenModel cm = codegen.fromModel("sample", model, Collections.singletonMap("sample", model));
|
||||||
|
|
||||||
|
assertEquals(cm.vars.get(0).baseType, "Map");
|
||||||
|
assertTrue(cm.imports.contains("HashMap"));
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user