ng-openapi 0.2.22-pr-85-testing-fd2f80a.0 → 0.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +20 -2
- package/index.js +19 -1
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -44,7 +44,7 @@ var fs4 = __toESM(require("fs"));
|
|
|
44
44
|
var path13 = __toESM(require("path"));
|
|
45
45
|
|
|
46
46
|
// package.json
|
|
47
|
-
var version = "0.2.
|
|
47
|
+
var version = "0.2.22";
|
|
48
48
|
|
|
49
49
|
// src/lib/core/generator.ts
|
|
50
50
|
var import_ts_morph7 = require("ts-morph");
|
|
@@ -2711,11 +2711,29 @@ var RequestParamsGenerator = class {
|
|
|
2711
2711
|
] : void 0
|
|
2712
2712
|
});
|
|
2713
2713
|
});
|
|
2714
|
-
|
|
2714
|
+
this.addMissingImports(sourceFile);
|
|
2715
|
+
sourceFile.formatText();
|
|
2715
2716
|
sourceFile.insertText(0, REQUEST_PARAMS_GENERATOR_HEADER_COMMENT);
|
|
2716
2717
|
sourceFile.saveSync();
|
|
2717
2718
|
this.addModelsBarrelExport(outputRoot);
|
|
2718
2719
|
}
|
|
2720
|
+
/**
|
|
2721
|
+
* `sourceFile.fixMissingImports()` fails with a tree-manipulation error when
|
|
2722
|
+
* the first statement of the file carries a JSDoc (as the interfaces here do),
|
|
2723
|
+
* so the same language-service code fix is applied as a plain text edit instead.
|
|
2724
|
+
*/
|
|
2725
|
+
addMissingImports(sourceFile) {
|
|
2726
|
+
const changes = this.project.getLanguageService().getCombinedCodeFix(sourceFile, "fixMissingImport").getChanges().filter((fileChange) => fileChange.getFilePath() === sourceFile.getFilePath()).flatMap((fileChange) => fileChange.getTextChanges()).sort((a, b) => b.getSpan().getStart() - a.getSpan().getStart());
|
|
2727
|
+
if (changes.length === 0) {
|
|
2728
|
+
return;
|
|
2729
|
+
}
|
|
2730
|
+
let text = sourceFile.getFullText();
|
|
2731
|
+
changes.forEach((change) => {
|
|
2732
|
+
const span = change.getSpan();
|
|
2733
|
+
text = text.slice(0, span.getStart()) + change.getNewText() + text.slice(span.getStart() + span.getLength());
|
|
2734
|
+
});
|
|
2735
|
+
sourceFile.replaceWithText(text);
|
|
2736
|
+
}
|
|
2719
2737
|
/**
|
|
2720
2738
|
* Method names are only unique per service class, so interfaces sharing the
|
|
2721
2739
|
* global request-params file fall back to a controller-prefixed name on collision.
|
package/index.js
CHANGED
|
@@ -2844,11 +2844,29 @@ var _RequestParamsGenerator = class _RequestParamsGenerator {
|
|
|
2844
2844
|
] : void 0
|
|
2845
2845
|
});
|
|
2846
2846
|
});
|
|
2847
|
-
|
|
2847
|
+
this.addMissingImports(sourceFile);
|
|
2848
|
+
sourceFile.formatText();
|
|
2848
2849
|
sourceFile.insertText(0, REQUEST_PARAMS_GENERATOR_HEADER_COMMENT);
|
|
2849
2850
|
sourceFile.saveSync();
|
|
2850
2851
|
this.addModelsBarrelExport(outputRoot);
|
|
2851
2852
|
}
|
|
2853
|
+
/**
|
|
2854
|
+
* `sourceFile.fixMissingImports()` fails with a tree-manipulation error when
|
|
2855
|
+
* the first statement of the file carries a JSDoc (as the interfaces here do),
|
|
2856
|
+
* so the same language-service code fix is applied as a plain text edit instead.
|
|
2857
|
+
*/
|
|
2858
|
+
addMissingImports(sourceFile) {
|
|
2859
|
+
const changes = this.project.getLanguageService().getCombinedCodeFix(sourceFile, "fixMissingImport").getChanges().filter((fileChange) => fileChange.getFilePath() === sourceFile.getFilePath()).flatMap((fileChange) => fileChange.getTextChanges()).sort((a, b) => b.getSpan().getStart() - a.getSpan().getStart());
|
|
2860
|
+
if (changes.length === 0) {
|
|
2861
|
+
return;
|
|
2862
|
+
}
|
|
2863
|
+
let text = sourceFile.getFullText();
|
|
2864
|
+
changes.forEach((change) => {
|
|
2865
|
+
const span = change.getSpan();
|
|
2866
|
+
text = text.slice(0, span.getStart()) + change.getNewText() + text.slice(span.getStart() + span.getLength());
|
|
2867
|
+
});
|
|
2868
|
+
sourceFile.replaceWithText(text);
|
|
2869
|
+
}
|
|
2852
2870
|
/**
|
|
2853
2871
|
* Method names are only unique per service class, so interfaces sharing the
|
|
2854
2872
|
* global request-params file fall back to a controller-prefixed name on collision.
|