Skip to content

Commit 64c1547

Browse files
rob-deutschmacjohnny
authored andcommitted
typescript-fetch: Only generate npm package if npmName specified (#4472)
* Only generate npm package if npmName specified * additionalProperties not available in constructor
1 parent bdd34a3 commit 64c1547

46 files changed

Lines changed: 13 additions & 78 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ public TypeScriptFetchClientCodegen() {
5454
outputFolder = "generated-code/typescript-fetch";
5555
embeddedTemplateDir = templateDir = "typescript-fetch";
5656

57-
this.apiPackage = "src" + File.separator +"apis";
58-
this.modelPackage = "src" + File.separator + "models";
5957
this.apiTemplateFiles.put("apis.mustache", ".ts");
6058
this.modelTemplateFiles.put("models.mustache", ".ts");
6159
this.addExtraReservedWords();
@@ -98,10 +96,17 @@ public void processOpts() {
9896
super.processOpts();
9997
additionalProperties.put("isOriginalModelPropertyNaming", getModelPropertyNaming().equals("original"));
10098
additionalProperties.put("modelPropertyNaming", getModelPropertyNaming());
101-
supportingFiles.add(new SupportingFile("index.mustache", "src", "index.ts"));
102-
supportingFiles.add(new SupportingFile("runtime.mustache", "src", "runtime.ts"));
103-
supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json"));
104-
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
99+
100+
String sourceDir = "";
101+
if (additionalProperties.containsKey(NPM_NAME)) {
102+
sourceDir = "src" + File.separator;
103+
}
104+
105+
this.apiPackage = sourceDir + "apis";
106+
this.modelPackage = sourceDir + "models";
107+
108+
supportingFiles.add(new SupportingFile("index.mustache", sourceDir, "index.ts"));
109+
supportingFiles.add(new SupportingFile("runtime.mustache", sourceDir, "runtime.ts"));
105110

106111
if (additionalProperties.containsKey(USE_SINGLE_REQUEST_PARAMETER)) {
107112
this.setUseSingleRequestParameter(convertPropertyToBoolean(USE_SINGLE_REQUEST_PARAMETER));
@@ -211,7 +216,9 @@ private void addNpmPackageGeneration() {
211216
//Files for building our lib
212217
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
213218
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
219+
supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json"));
214220
supportingFiles.add(new SupportingFile("npmignore.mustache", "", ".npmignore"));
221+
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
215222
}
216223

217224
@Override

samples/client/petstore/typescript-fetch/builds/default/.gitignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

samples/client/petstore/typescript-fetch/builds/default/src/apis/PetApi.ts renamed to samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts

File renamed without changes.

samples/client/petstore/typescript-fetch/builds/default/src/apis/StoreApi.ts renamed to samples/client/petstore/typescript-fetch/builds/default/apis/StoreApi.ts

File renamed without changes.

samples/client/petstore/typescript-fetch/builds/default/src/apis/UserApi.ts renamed to samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts

File renamed without changes.

samples/client/petstore/typescript-fetch/builds/default/src/apis/index.ts renamed to samples/client/petstore/typescript-fetch/builds/default/apis/index.ts

File renamed without changes.

samples/client/petstore/typescript-fetch/builds/default/src/index.ts renamed to samples/client/petstore/typescript-fetch/builds/default/index.ts

File renamed without changes.

samples/client/petstore/typescript-fetch/builds/default/src/models/Category.ts renamed to samples/client/petstore/typescript-fetch/builds/default/models/Category.ts

File renamed without changes.

samples/client/petstore/typescript-fetch/builds/default/src/models/ModelApiResponse.ts renamed to samples/client/petstore/typescript-fetch/builds/default/models/ModelApiResponse.ts

File renamed without changes.

samples/client/petstore/typescript-fetch/builds/default/src/models/Order.ts renamed to samples/client/petstore/typescript-fetch/builds/default/models/Order.ts

File renamed without changes.

0 commit comments

Comments
 (0)