ng-openapi 0.0.25-alpha.2 → 0.0.25-alpha.4
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 +34 -16
- package/index.d.ts +1 -1
- package/index.js +34 -16
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -419,11 +419,16 @@ var TokenGenerator = class {
|
|
|
419
419
|
});
|
|
420
420
|
sourceFile.addImportDeclaration({
|
|
421
421
|
namedImports: [
|
|
422
|
-
"InjectionToken"
|
|
423
|
-
"HttpInterceptor"
|
|
422
|
+
"InjectionToken"
|
|
424
423
|
],
|
|
425
424
|
moduleSpecifier: "@angular/core"
|
|
426
425
|
});
|
|
426
|
+
sourceFile.addImportDeclaration({
|
|
427
|
+
namedImports: [
|
|
428
|
+
"HttpInterceptor"
|
|
429
|
+
],
|
|
430
|
+
moduleSpecifier: "@angular/common/http"
|
|
431
|
+
});
|
|
427
432
|
const basePathTokenName = this.getBasePathTokenName();
|
|
428
433
|
const interceptorsTokenName = this.getInterceptorsTokenName();
|
|
429
434
|
sourceFile.addVariableStatement({
|
|
@@ -456,7 +461,7 @@ var TokenGenerator = class {
|
|
|
456
461
|
}
|
|
457
462
|
],
|
|
458
463
|
leadingTrivia: `/**
|
|
459
|
-
* Injection token for the ${this.clientName} client HTTP
|
|
464
|
+
* Injection token for the ${this.clientName} client HTTP interceptor instances
|
|
460
465
|
*/
|
|
461
466
|
`
|
|
462
467
|
});
|
|
@@ -892,10 +897,10 @@ var ProviderGenerator = class {
|
|
|
892
897
|
},
|
|
893
898
|
{
|
|
894
899
|
name: "interceptors",
|
|
895
|
-
type: "HttpInterceptor[]",
|
|
900
|
+
type: "(new (...args: HttpInterceptor[]) => HttpInterceptor)[]",
|
|
896
901
|
hasQuestionToken: true,
|
|
897
902
|
docs: [
|
|
898
|
-
"Array of HTTP
|
|
903
|
+
"Array of HTTP interceptor classes to apply to this client"
|
|
899
904
|
]
|
|
900
905
|
}
|
|
901
906
|
]
|
|
@@ -914,11 +919,6 @@ const providers: Provider[] = [
|
|
|
914
919
|
provide: ${basePathTokenName},
|
|
915
920
|
useValue: config.basePath
|
|
916
921
|
},
|
|
917
|
-
// Client-specific interceptors token
|
|
918
|
-
{
|
|
919
|
-
provide: ${interceptorsTokenName},
|
|
920
|
-
useValue: config.interceptors || []
|
|
921
|
-
},
|
|
922
922
|
// Base interceptor that handles client-specific interceptors
|
|
923
923
|
{
|
|
924
924
|
provide: HTTP_INTERCEPTORS,
|
|
@@ -927,14 +927,32 @@ const providers: Provider[] = [
|
|
|
927
927
|
}
|
|
928
928
|
];
|
|
929
929
|
|
|
930
|
-
|
|
931
|
-
if (config.
|
|
932
|
-
const
|
|
930
|
+
// Add client-specific interceptor instances
|
|
931
|
+
if (config.interceptors && config.interceptors.length > 0) {
|
|
932
|
+
const interceptorInstances = config.interceptors.map(InterceptorClass => new InterceptorClass());
|
|
933
|
+
|
|
934
|
+
${hasDateInterceptor ? `// Add date interceptor if enabled (default: true)
|
|
935
|
+
if (config.enableDateTransform !== false) {
|
|
936
|
+
interceptorInstances.unshift(new DateInterceptor());
|
|
937
|
+
}` : `// Date transformation not available (dateType: 'string' was used in generation)`}
|
|
938
|
+
|
|
939
|
+
providers.push({
|
|
940
|
+
provide: ${interceptorsTokenName},
|
|
941
|
+
useValue: interceptorInstances
|
|
942
|
+
});
|
|
943
|
+
} ${hasDateInterceptor ? `else if (config.enableDateTransform !== false) {
|
|
944
|
+
// Only date interceptor enabled
|
|
933
945
|
providers.push({
|
|
934
946
|
provide: ${interceptorsTokenName},
|
|
935
|
-
useValue: [new DateInterceptor()
|
|
947
|
+
useValue: [new DateInterceptor()]
|
|
936
948
|
});
|
|
937
|
-
}` :
|
|
949
|
+
}` : ``} else {
|
|
950
|
+
// No interceptors
|
|
951
|
+
providers.push({
|
|
952
|
+
provide: ${interceptorsTokenName},
|
|
953
|
+
useValue: []
|
|
954
|
+
});
|
|
955
|
+
}
|
|
938
956
|
|
|
939
957
|
return makeEnvironmentProviders(providers);`;
|
|
940
958
|
sourceFile.addFunction({
|
|
@@ -952,7 +970,7 @@ return makeEnvironmentProviders(providers);`;
|
|
|
952
970
|
" providers: [",
|
|
953
971
|
` ${functionName}({`,
|
|
954
972
|
" basePath: 'https://api.example.com',",
|
|
955
|
-
" interceptors: [
|
|
973
|
+
" interceptors: [AuthInterceptor, LoggingInterceptor] // Classes, not instances",
|
|
956
974
|
" }),",
|
|
957
975
|
" // other providers...",
|
|
958
976
|
" ]",
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -466,11 +466,16 @@ var _TokenGenerator = class _TokenGenerator {
|
|
|
466
466
|
});
|
|
467
467
|
sourceFile.addImportDeclaration({
|
|
468
468
|
namedImports: [
|
|
469
|
-
"InjectionToken"
|
|
470
|
-
"HttpInterceptor"
|
|
469
|
+
"InjectionToken"
|
|
471
470
|
],
|
|
472
471
|
moduleSpecifier: "@angular/core"
|
|
473
472
|
});
|
|
473
|
+
sourceFile.addImportDeclaration({
|
|
474
|
+
namedImports: [
|
|
475
|
+
"HttpInterceptor"
|
|
476
|
+
],
|
|
477
|
+
moduleSpecifier: "@angular/common/http"
|
|
478
|
+
});
|
|
474
479
|
const basePathTokenName = this.getBasePathTokenName();
|
|
475
480
|
const interceptorsTokenName = this.getInterceptorsTokenName();
|
|
476
481
|
sourceFile.addVariableStatement({
|
|
@@ -503,7 +508,7 @@ var _TokenGenerator = class _TokenGenerator {
|
|
|
503
508
|
}
|
|
504
509
|
],
|
|
505
510
|
leadingTrivia: `/**
|
|
506
|
-
* Injection token for the ${this.clientName} client HTTP
|
|
511
|
+
* Injection token for the ${this.clientName} client HTTP interceptor instances
|
|
507
512
|
*/
|
|
508
513
|
`
|
|
509
514
|
});
|
|
@@ -935,10 +940,10 @@ var _ProviderGenerator = class _ProviderGenerator {
|
|
|
935
940
|
},
|
|
936
941
|
{
|
|
937
942
|
name: "interceptors",
|
|
938
|
-
type: "HttpInterceptor[]",
|
|
943
|
+
type: "(new (...args: HttpInterceptor[]) => HttpInterceptor)[]",
|
|
939
944
|
hasQuestionToken: true,
|
|
940
945
|
docs: [
|
|
941
|
-
"Array of HTTP
|
|
946
|
+
"Array of HTTP interceptor classes to apply to this client"
|
|
942
947
|
]
|
|
943
948
|
}
|
|
944
949
|
]
|
|
@@ -957,11 +962,6 @@ const providers: Provider[] = [
|
|
|
957
962
|
provide: ${basePathTokenName},
|
|
958
963
|
useValue: config.basePath
|
|
959
964
|
},
|
|
960
|
-
// Client-specific interceptors token
|
|
961
|
-
{
|
|
962
|
-
provide: ${interceptorsTokenName},
|
|
963
|
-
useValue: config.interceptors || []
|
|
964
|
-
},
|
|
965
965
|
// Base interceptor that handles client-specific interceptors
|
|
966
966
|
{
|
|
967
967
|
provide: HTTP_INTERCEPTORS,
|
|
@@ -970,14 +970,32 @@ const providers: Provider[] = [
|
|
|
970
970
|
}
|
|
971
971
|
];
|
|
972
972
|
|
|
973
|
-
|
|
974
|
-
if (config.
|
|
975
|
-
const
|
|
973
|
+
// Add client-specific interceptor instances
|
|
974
|
+
if (config.interceptors && config.interceptors.length > 0) {
|
|
975
|
+
const interceptorInstances = config.interceptors.map(InterceptorClass => new InterceptorClass());
|
|
976
|
+
|
|
977
|
+
${hasDateInterceptor ? `// Add date interceptor if enabled (default: true)
|
|
978
|
+
if (config.enableDateTransform !== false) {
|
|
979
|
+
interceptorInstances.unshift(new DateInterceptor());
|
|
980
|
+
}` : `// Date transformation not available (dateType: 'string' was used in generation)`}
|
|
981
|
+
|
|
982
|
+
providers.push({
|
|
983
|
+
provide: ${interceptorsTokenName},
|
|
984
|
+
useValue: interceptorInstances
|
|
985
|
+
});
|
|
986
|
+
} ${hasDateInterceptor ? `else if (config.enableDateTransform !== false) {
|
|
987
|
+
// Only date interceptor enabled
|
|
976
988
|
providers.push({
|
|
977
989
|
provide: ${interceptorsTokenName},
|
|
978
|
-
useValue: [new DateInterceptor()
|
|
990
|
+
useValue: [new DateInterceptor()]
|
|
979
991
|
});
|
|
980
|
-
}` :
|
|
992
|
+
}` : ``} else {
|
|
993
|
+
// No interceptors
|
|
994
|
+
providers.push({
|
|
995
|
+
provide: ${interceptorsTokenName},
|
|
996
|
+
useValue: []
|
|
997
|
+
});
|
|
998
|
+
}
|
|
981
999
|
|
|
982
1000
|
return makeEnvironmentProviders(providers);`;
|
|
983
1001
|
sourceFile.addFunction({
|
|
@@ -995,7 +1013,7 @@ return makeEnvironmentProviders(providers);`;
|
|
|
995
1013
|
" providers: [",
|
|
996
1014
|
` ${functionName}({`,
|
|
997
1015
|
" basePath: 'https://api.example.com',",
|
|
998
|
-
" interceptors: [
|
|
1016
|
+
" interceptors: [AuthInterceptor, LoggingInterceptor] // Classes, not instances",
|
|
999
1017
|
" }),",
|
|
1000
1018
|
" // other providers...",
|
|
1001
1019
|
" ]",
|