mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2026-03-24 12:09:17 +00:00
Support importMapping definitions for TypeScriptNodeClientCodegen (#3469)
* Support importMapping definitions for TypeScriptNodeClientCodegen * Use import mappings for all file references
This commit is contained in:
committed by
Esteban Gehring
parent
981b3a53ef
commit
74eeb07b22
@@ -18,7 +18,6 @@
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -33,6 +32,7 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptNodeClientCodegen.class);
|
||||
|
||||
public static final String NPM_REPOSITORY = "npmRepository";
|
||||
private static final String DEFAULT_IMPORT_PREFIX = "./";
|
||||
|
||||
protected String npmRepository = null;
|
||||
protected String apiSuffix = "Api";
|
||||
@@ -96,22 +96,37 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
|
||||
if (name.length() == 0) {
|
||||
return "default" + apiSuffix;
|
||||
}
|
||||
if (importMapping.containsKey(name)) {
|
||||
return importMapping.get(name);
|
||||
}
|
||||
return camelize(name, true) + apiSuffix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiImport(String name) {
|
||||
if (importMapping.containsKey(name)) {
|
||||
return importMapping.get(name);
|
||||
}
|
||||
|
||||
return apiPackage() + "/" + toApiFilename(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
return camelize(toModelName(name), true);
|
||||
if (importMapping.containsKey(name)) {
|
||||
return importMapping.get(name);
|
||||
}
|
||||
|
||||
return DEFAULT_IMPORT_PREFIX + camelize(toModelName(name), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelImport(String name) {
|
||||
return modelPackage() + "/" + toModelFilename(name);
|
||||
if (importMapping.containsKey(name)) {
|
||||
return importMapping.get(name);
|
||||
}
|
||||
|
||||
return modelPackage() + "/" + camelize(toModelName(name), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user