ng-openapi 0.0.25-alpha.3 → 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 +27 -14
- package/index.d.ts +1 -1
- package/index.js +27 -14
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -461,7 +461,7 @@ var TokenGenerator = class {
|
|
|
461
461
|
}
|
|
462
462
|
],
|
|
463
463
|
leadingTrivia: `/**
|
|
464
|
-
* Injection token for the ${this.clientName} client HTTP
|
|
464
|
+
* Injection token for the ${this.clientName} client HTTP interceptor instances
|
|
465
465
|
*/
|
|
466
466
|
`
|
|
467
467
|
});
|
|
@@ -897,10 +897,10 @@ var ProviderGenerator = class {
|
|
|
897
897
|
},
|
|
898
898
|
{
|
|
899
899
|
name: "interceptors",
|
|
900
|
-
type: "HttpInterceptor[]",
|
|
900
|
+
type: "(new (...args: HttpInterceptor[]) => HttpInterceptor)[]",
|
|
901
901
|
hasQuestionToken: true,
|
|
902
902
|
docs: [
|
|
903
|
-
"Array of HTTP
|
|
903
|
+
"Array of HTTP interceptor classes to apply to this client"
|
|
904
904
|
]
|
|
905
905
|
}
|
|
906
906
|
]
|
|
@@ -919,11 +919,6 @@ const providers: Provider[] = [
|
|
|
919
919
|
provide: ${basePathTokenName},
|
|
920
920
|
useValue: config.basePath
|
|
921
921
|
},
|
|
922
|
-
// Client-specific interceptors token
|
|
923
|
-
{
|
|
924
|
-
provide: ${interceptorsTokenName},
|
|
925
|
-
useValue: config.interceptors || []
|
|
926
|
-
},
|
|
927
922
|
// Base interceptor that handles client-specific interceptors
|
|
928
923
|
{
|
|
929
924
|
provide: HTTP_INTERCEPTORS,
|
|
@@ -932,14 +927,32 @@ const providers: Provider[] = [
|
|
|
932
927
|
}
|
|
933
928
|
];
|
|
934
929
|
|
|
935
|
-
|
|
936
|
-
if (config.
|
|
937
|
-
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
|
+
|
|
938
939
|
providers.push({
|
|
939
940
|
provide: ${interceptorsTokenName},
|
|
940
|
-
useValue:
|
|
941
|
+
useValue: interceptorInstances
|
|
941
942
|
});
|
|
942
|
-
}
|
|
943
|
+
} ${hasDateInterceptor ? `else if (config.enableDateTransform !== false) {
|
|
944
|
+
// Only date interceptor enabled
|
|
945
|
+
providers.push({
|
|
946
|
+
provide: ${interceptorsTokenName},
|
|
947
|
+
useValue: [new DateInterceptor()]
|
|
948
|
+
});
|
|
949
|
+
}` : ``} else {
|
|
950
|
+
// No interceptors
|
|
951
|
+
providers.push({
|
|
952
|
+
provide: ${interceptorsTokenName},
|
|
953
|
+
useValue: []
|
|
954
|
+
});
|
|
955
|
+
}
|
|
943
956
|
|
|
944
957
|
return makeEnvironmentProviders(providers);`;
|
|
945
958
|
sourceFile.addFunction({
|
|
@@ -957,7 +970,7 @@ return makeEnvironmentProviders(providers);`;
|
|
|
957
970
|
" providers: [",
|
|
958
971
|
` ${functionName}({`,
|
|
959
972
|
" basePath: 'https://api.example.com',",
|
|
960
|
-
" interceptors: [
|
|
973
|
+
" interceptors: [AuthInterceptor, LoggingInterceptor] // Classes, not instances",
|
|
961
974
|
" }),",
|
|
962
975
|
" // other providers...",
|
|
963
976
|
" ]",
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -508,7 +508,7 @@ var _TokenGenerator = class _TokenGenerator {
|
|
|
508
508
|
}
|
|
509
509
|
],
|
|
510
510
|
leadingTrivia: `/**
|
|
511
|
-
* Injection token for the ${this.clientName} client HTTP
|
|
511
|
+
* Injection token for the ${this.clientName} client HTTP interceptor instances
|
|
512
512
|
*/
|
|
513
513
|
`
|
|
514
514
|
});
|
|
@@ -940,10 +940,10 @@ var _ProviderGenerator = class _ProviderGenerator {
|
|
|
940
940
|
},
|
|
941
941
|
{
|
|
942
942
|
name: "interceptors",
|
|
943
|
-
type: "HttpInterceptor[]",
|
|
943
|
+
type: "(new (...args: HttpInterceptor[]) => HttpInterceptor)[]",
|
|
944
944
|
hasQuestionToken: true,
|
|
945
945
|
docs: [
|
|
946
|
-
"Array of HTTP
|
|
946
|
+
"Array of HTTP interceptor classes to apply to this client"
|
|
947
947
|
]
|
|
948
948
|
}
|
|
949
949
|
]
|
|
@@ -962,11 +962,6 @@ const providers: Provider[] = [
|
|
|
962
962
|
provide: ${basePathTokenName},
|
|
963
963
|
useValue: config.basePath
|
|
964
964
|
},
|
|
965
|
-
// Client-specific interceptors token
|
|
966
|
-
{
|
|
967
|
-
provide: ${interceptorsTokenName},
|
|
968
|
-
useValue: config.interceptors || []
|
|
969
|
-
},
|
|
970
965
|
// Base interceptor that handles client-specific interceptors
|
|
971
966
|
{
|
|
972
967
|
provide: HTTP_INTERCEPTORS,
|
|
@@ -975,14 +970,32 @@ const providers: Provider[] = [
|
|
|
975
970
|
}
|
|
976
971
|
];
|
|
977
972
|
|
|
978
|
-
|
|
979
|
-
if (config.
|
|
980
|
-
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
|
+
|
|
981
982
|
providers.push({
|
|
982
983
|
provide: ${interceptorsTokenName},
|
|
983
|
-
useValue:
|
|
984
|
+
useValue: interceptorInstances
|
|
984
985
|
});
|
|
985
|
-
}
|
|
986
|
+
} ${hasDateInterceptor ? `else if (config.enableDateTransform !== false) {
|
|
987
|
+
// Only date interceptor enabled
|
|
988
|
+
providers.push({
|
|
989
|
+
provide: ${interceptorsTokenName},
|
|
990
|
+
useValue: [new DateInterceptor()]
|
|
991
|
+
});
|
|
992
|
+
}` : ``} else {
|
|
993
|
+
// No interceptors
|
|
994
|
+
providers.push({
|
|
995
|
+
provide: ${interceptorsTokenName},
|
|
996
|
+
useValue: []
|
|
997
|
+
});
|
|
998
|
+
}
|
|
986
999
|
|
|
987
1000
|
return makeEnvironmentProviders(providers);`;
|
|
988
1001
|
sourceFile.addFunction({
|
|
@@ -1000,7 +1013,7 @@ return makeEnvironmentProviders(providers);`;
|
|
|
1000
1013
|
" providers: [",
|
|
1001
1014
|
` ${functionName}({`,
|
|
1002
1015
|
" basePath: 'https://api.example.com',",
|
|
1003
|
-
" interceptors: [
|
|
1016
|
+
" interceptors: [AuthInterceptor, LoggingInterceptor] // Classes, not instances",
|
|
1004
1017
|
" }),",
|
|
1005
1018
|
" // other providers...",
|
|
1006
1019
|
" ]",
|