forked from loafle/openapi-generator-original
Fix NPM build for Typescript-fetch (#3403)
* -Fix bug in fetch -> Missing "runtime" -Move fetch files to an "src" folder instead of doing everything at the root which removes the bugs when using the library itself -Fix the distribution of fetch using npm * Move the .ts files to an `src` folder which is more common in npm package * Add missing mustache * Add missing .npmignore
This commit is contained in:
committed by
Esteban Gehring
parent
b8295afa27
commit
9e659d13ed
@@ -50,9 +50,9 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
outputFolder = "generated-code/typescript-fetch";
|
||||
embeddedTemplateDir = templateDir = "typescript-fetch";
|
||||
|
||||
this.apiPackage = "apis";
|
||||
this.apiPackage = "src" + File.separator +"apis";
|
||||
this.modelPackage = "src" + File.separator + "models";
|
||||
this.apiTemplateFiles.put("apis.mustache", ".ts");
|
||||
this.modelPackage = "models";
|
||||
this.modelTemplateFiles.put("models.mustache", ".ts");
|
||||
this.addExtraReservedWords();
|
||||
|
||||
@@ -84,8 +84,8 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
super.processOpts();
|
||||
additionalProperties.put("isOriginalModelPropertyNaming", getModelPropertyNaming().equals("original"));
|
||||
additionalProperties.put("modelPropertyNaming", getModelPropertyNaming());
|
||||
supportingFiles.add(new SupportingFile("index.mustache", "", "index.ts"));
|
||||
supportingFiles.add(new SupportingFile("runtime.mustache", "", "runtime.ts"));
|
||||
supportingFiles.add(new SupportingFile("index.mustache", "src", "index.ts"));
|
||||
supportingFiles.add(new SupportingFile("runtime.mustache", "src", "runtime.ts"));
|
||||
supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json"));
|
||||
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
|
||||
|
||||
@@ -188,6 +188,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
//Files for building our lib
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
|
||||
supportingFiles.add(new SupportingFile("npmignore.mustache", "", ".npmignore"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -216,7 +217,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
// models for a given operation.
|
||||
List<Map<String, Object>> imports = (List<Map<String, Object>>) operations.get("imports");
|
||||
for (Map<String, Object> im : imports) {
|
||||
im.put("className", im.get("import").toString().replace("models.", ""));
|
||||
im.put("className", im.get("import").toString().replace(modelPackage() + ".", ""));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1
modules/openapi-generator/src/main/resources/typescript-fetch/npmignore.mustache
vendored
Normal file
1
modules/openapi-generator/src/main/resources/typescript-fetch/npmignore.mustache
vendored
Normal file
@@ -0,0 +1 @@
|
||||
README.md
|
||||
@@ -6,7 +6,7 @@
|
||||
"main": "./dist/index.js",
|
||||
"typings": "./dist/index.d.ts",
|
||||
"scripts" : {
|
||||
"build": "tsc --outDir dist/",
|
||||
"build": "tsc",
|
||||
"prepare": "npm run build"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "dist",
|
||||
"rootDir": ".",
|
||||
{{^supportsES6}}
|
||||
"lib": [
|
||||
"es6",
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "dist",
|
||||
"rootDir": ".",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
README.md
|
||||
@@ -6,7 +6,7 @@
|
||||
"main": "./dist/index.js",
|
||||
"typings": "./dist/index.d.ts",
|
||||
"scripts" : {
|
||||
"build": "tsc --outDir dist/",
|
||||
"build": "tsc",
|
||||
"prepare": "npm run build"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "dist",
|
||||
"rootDir": ".",
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
]
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "dist",
|
||||
"rootDir": ".",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "dist",
|
||||
"rootDir": ".",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
README.md
|
||||
@@ -6,7 +6,7 @@
|
||||
"main": "./dist/index.js",
|
||||
"typings": "./dist/index.d.ts",
|
||||
"scripts" : {
|
||||
"build": "tsc --outDir dist/",
|
||||
"build": "tsc",
|
||||
"prepare": "npm run build"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "dist",
|
||||
"rootDir": ".",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
|
||||
Reference in New Issue
Block a user