Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ public String toModelFilename(String name) {

@Override
public String getTypeDeclaration(Schema p) {
Schema<?> schema = ModelUtils.unaliasSchema(this.openAPI, p);
Schema<?> schema = ModelUtils.unaliasSchema(this.openAPI, p, importMapping);
Schema<?> target = ModelUtils.isGenerateAliasAsModel() ? p : schema;
if (ModelUtils.isArraySchema(target)) {
Schema<?> items = getSchemaItems((ArraySchema) schema);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.media.*;

import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenType;
Expand All @@ -35,6 +30,9 @@
import org.testng.annotations.Test;

import java.io.File;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;

public class AbstractJavaCodegenTest {

Expand Down Expand Up @@ -452,6 +450,16 @@ public void toDefaultValueTest() {
Assert.assertEquals(defaultLocalDate, LocalDate.parse(defaultValue));
}

@Test
public void getTypeDeclarationGivenImportMappingTest() {
final P_AbstractJavaCodegen codegen = new P_AbstractJavaCodegen();
codegen.importMapping().put("MyStringType", "com.example.foo");
codegen.setOpenAPI(new OpenAPI().components(new Components().addSchemas("MyStringType", new StringSchema())));
Schema<?> schema = new ArraySchema().items(new Schema().$ref("#/components/schemas/MyStringType"));
String defaultValue = codegen.getTypeDeclaration(schema);
Assert.assertEquals(defaultValue, "List<com.example.foo>");
}

@Test
public void getTypeDeclarationTest() {
final P_AbstractJavaCodegen codegen = new P_AbstractJavaCodegen();
Expand Down