Skip to content
Open
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 @@ -589,6 +589,15 @@ private boolean markHttpResource(CodegenOperation op, Set<String> nicknames) {
return true;
}

@Override
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
// supporting files bundle puts server URL over additionalProperties, keep user supplied basePath
if (additionalProperties.containsKey("basePath")) {
objs.put("basePath", additionalProperties.get("basePath"));
}
return super.postProcessSupportingFileData(objs);
}

@Override
public ModelsMap postProcessModels(ModelsMap objs) {
ModelsMap result = super.postProcessModels(objs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,22 @@ public void testBasePath() throws IOException {
assertThat(fileContents).containsOnlyOnce("basePath = '/relative/url'");
}

@Test
public void testBasePathFromAdditionalProperties() throws IOException {
for (String basePath : new String[]{"", "/api"}) {
File output = Files.createTempDirectory("angular-base-path").toFile();
output.deleteOnExit();
CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName("typescript-angular")
.setInputSpec("src/test/resources/3_0/typescript-angular/issue_20760.yaml")
.setOutputDir(output.getAbsolutePath())
.addAdditionalProperty("basePath", basePath);
new DefaultGenerator().opts(configurator.toClientOptInput()).generate();
String baseService = Files.readString(output.toPath().resolve("api.base.service.ts"));
assertThat(baseService).containsOnlyOnce("protected basePath = '" + basePath + "';");
}
}

@Test
public void testEnumAsConst() throws IOException {
// GIVEN
Expand Down
Loading