@ng-openapi/http-resource 0.0.16 → 0.0.17-pr-28-bugfix-form-data-request-4fada97.0
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/index.cjs +5 -114
- package/index.js +5 -114
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -96,7 +96,7 @@ function getTypeScriptType(schemaOrType, config, formatOrNullable, isNullable, c
|
|
|
96
96
|
case "boolean":
|
|
97
97
|
return nullableType("boolean", nullable);
|
|
98
98
|
case "object":
|
|
99
|
-
return nullableType(context === "type" ? "Record<string,
|
|
99
|
+
return nullableType(context === "type" ? "Record<string, any>" : "any", nullable);
|
|
100
100
|
case "null":
|
|
101
101
|
return "null";
|
|
102
102
|
default:
|
|
@@ -113,78 +113,6 @@ function escapeString(str2) {
|
|
|
113
113
|
}
|
|
114
114
|
__name(escapeString, "escapeString");
|
|
115
115
|
|
|
116
|
-
// ../../shared/src/utils/functions/collect-used-types.ts
|
|
117
|
-
function collectUsedTypes(operations) {
|
|
118
|
-
const usedTypes = /* @__PURE__ */ new Set();
|
|
119
|
-
usedTypes.add("RequestOptions");
|
|
120
|
-
operations.forEach((operation) => {
|
|
121
|
-
operation.parameters?.forEach((param) => {
|
|
122
|
-
collectTypesFromSchema(param.schema || param, usedTypes);
|
|
123
|
-
});
|
|
124
|
-
if (operation.requestBody) {
|
|
125
|
-
collectTypesFromRequestBody(operation.requestBody, usedTypes);
|
|
126
|
-
}
|
|
127
|
-
if (operation.responses) {
|
|
128
|
-
Object.values(operation.responses).forEach((response) => {
|
|
129
|
-
collectTypesFromResponse(response, usedTypes);
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
return usedTypes;
|
|
134
|
-
}
|
|
135
|
-
__name(collectUsedTypes, "collectUsedTypes");
|
|
136
|
-
function collectTypesFromSchema(schema2, usedTypes) {
|
|
137
|
-
if (!schema2) return;
|
|
138
|
-
if (schema2.$ref) {
|
|
139
|
-
const refName = schema2.$ref.split("/").pop();
|
|
140
|
-
if (refName) {
|
|
141
|
-
usedTypes.add(pascalCase(refName));
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
if (schema2.type === "array" && schema2.items) {
|
|
145
|
-
collectTypesFromSchema(schema2.items, usedTypes);
|
|
146
|
-
}
|
|
147
|
-
if (schema2.type === "object" && schema2.properties) {
|
|
148
|
-
Object.values(schema2.properties).forEach((prop) => {
|
|
149
|
-
collectTypesFromSchema(prop, usedTypes);
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
if (schema2.allOf) {
|
|
153
|
-
schema2.allOf.forEach((subSchema) => {
|
|
154
|
-
collectTypesFromSchema(subSchema, usedTypes);
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
if (schema2.oneOf) {
|
|
158
|
-
schema2.oneOf.forEach((subSchema) => {
|
|
159
|
-
collectTypesFromSchema(subSchema, usedTypes);
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
if (schema2.anyOf) {
|
|
163
|
-
schema2.anyOf.forEach((subSchema) => {
|
|
164
|
-
collectTypesFromSchema(subSchema, usedTypes);
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
__name(collectTypesFromSchema, "collectTypesFromSchema");
|
|
169
|
-
function collectTypesFromRequestBody(requestBody, usedTypes) {
|
|
170
|
-
const content = requestBody.content || {};
|
|
171
|
-
Object.values(content).forEach((mediaType) => {
|
|
172
|
-
if (mediaType.schema) {
|
|
173
|
-
collectTypesFromSchema(mediaType.schema, usedTypes);
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
__name(collectTypesFromRequestBody, "collectTypesFromRequestBody");
|
|
178
|
-
function collectTypesFromResponse(response, usedTypes) {
|
|
179
|
-
const content = response.content || {};
|
|
180
|
-
Object.values(content).forEach((mediaType) => {
|
|
181
|
-
if (mediaType.schema) {
|
|
182
|
-
collectTypesFromSchema(mediaType.schema, usedTypes);
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
__name(collectTypesFromResponse, "collectTypesFromResponse");
|
|
187
|
-
|
|
188
116
|
// ../../shared/src/utils/functions/token-names.ts
|
|
189
117
|
function getClientContextTokenName(clientName = "default") {
|
|
190
118
|
const clientSuffix = clientName.toUpperCase().replace(/[^A-Z0-9]/g, "_");
|
|
@@ -3522,57 +3450,20 @@ var HttpResourceGenerator = class {
|
|
|
3522
3450
|
const sourceFile = this.project.createSourceFile(filePath, "", {
|
|
3523
3451
|
overwrite: true
|
|
3524
3452
|
});
|
|
3525
|
-
|
|
3526
|
-
this.addImports(sourceFile, usedTypes);
|
|
3453
|
+
this.addImports(sourceFile);
|
|
3527
3454
|
this.addServiceClass(sourceFile, resourceName, operations);
|
|
3528
|
-
sourceFile.formatText();
|
|
3455
|
+
sourceFile.fixMissingImports().organizeImports().formatText();
|
|
3529
3456
|
sourceFile.saveSync();
|
|
3530
3457
|
}
|
|
3531
|
-
addImports(sourceFile
|
|
3532
|
-
const basePathTokenName = getBasePathTokenName(this.config.clientName);
|
|
3533
|
-
const clientContextTokenName = getClientContextTokenName(this.config.clientName);
|
|
3458
|
+
addImports(sourceFile) {
|
|
3534
3459
|
sourceFile.addImportDeclarations([
|
|
3535
3460
|
{
|
|
3536
3461
|
namedImports: [
|
|
3537
|
-
"Injectable"
|
|
3538
|
-
"inject",
|
|
3539
|
-
"Signal"
|
|
3462
|
+
"Injectable"
|
|
3540
3463
|
],
|
|
3541
3464
|
moduleSpecifier: "@angular/core"
|
|
3542
|
-
},
|
|
3543
|
-
{
|
|
3544
|
-
namedImports: [
|
|
3545
|
-
"HttpResourceRef",
|
|
3546
|
-
"HttpContext",
|
|
3547
|
-
"httpResource",
|
|
3548
|
-
"HttpResourceRequest",
|
|
3549
|
-
"HttpResourceOptions",
|
|
3550
|
-
"HttpParams",
|
|
3551
|
-
"HttpContextToken",
|
|
3552
|
-
"HttpHeaders"
|
|
3553
|
-
],
|
|
3554
|
-
moduleSpecifier: "@angular/common/http"
|
|
3555
|
-
},
|
|
3556
|
-
{
|
|
3557
|
-
namedImports: [
|
|
3558
|
-
basePathTokenName,
|
|
3559
|
-
clientContextTokenName
|
|
3560
|
-
],
|
|
3561
|
-
moduleSpecifier: "../tokens"
|
|
3562
|
-
},
|
|
3563
|
-
{
|
|
3564
|
-
namedImports: [
|
|
3565
|
-
"HttpParamsBuilder"
|
|
3566
|
-
],
|
|
3567
|
-
moduleSpecifier: "../index"
|
|
3568
3465
|
}
|
|
3569
3466
|
]);
|
|
3570
|
-
if (usedTypes.size > 0) {
|
|
3571
|
-
sourceFile.addImportDeclaration({
|
|
3572
|
-
namedImports: Array.from(usedTypes).sort(),
|
|
3573
|
-
moduleSpecifier: "../models"
|
|
3574
|
-
});
|
|
3575
|
-
}
|
|
3576
3467
|
}
|
|
3577
3468
|
addServiceClass(sourceFile, resourceName, operations) {
|
|
3578
3469
|
const className = `${resourceName}`;
|
package/index.js
CHANGED
|
@@ -62,7 +62,7 @@ function getTypeScriptType(schemaOrType, config, formatOrNullable, isNullable, c
|
|
|
62
62
|
case "boolean":
|
|
63
63
|
return nullableType("boolean", nullable);
|
|
64
64
|
case "object":
|
|
65
|
-
return nullableType(context === "type" ? "Record<string,
|
|
65
|
+
return nullableType(context === "type" ? "Record<string, any>" : "any", nullable);
|
|
66
66
|
case "null":
|
|
67
67
|
return "null";
|
|
68
68
|
default:
|
|
@@ -79,78 +79,6 @@ function escapeString(str2) {
|
|
|
79
79
|
}
|
|
80
80
|
__name(escapeString, "escapeString");
|
|
81
81
|
|
|
82
|
-
// ../../shared/src/utils/functions/collect-used-types.ts
|
|
83
|
-
function collectUsedTypes(operations) {
|
|
84
|
-
const usedTypes = /* @__PURE__ */ new Set();
|
|
85
|
-
usedTypes.add("RequestOptions");
|
|
86
|
-
operations.forEach((operation) => {
|
|
87
|
-
operation.parameters?.forEach((param) => {
|
|
88
|
-
collectTypesFromSchema(param.schema || param, usedTypes);
|
|
89
|
-
});
|
|
90
|
-
if (operation.requestBody) {
|
|
91
|
-
collectTypesFromRequestBody(operation.requestBody, usedTypes);
|
|
92
|
-
}
|
|
93
|
-
if (operation.responses) {
|
|
94
|
-
Object.values(operation.responses).forEach((response) => {
|
|
95
|
-
collectTypesFromResponse(response, usedTypes);
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
return usedTypes;
|
|
100
|
-
}
|
|
101
|
-
__name(collectUsedTypes, "collectUsedTypes");
|
|
102
|
-
function collectTypesFromSchema(schema2, usedTypes) {
|
|
103
|
-
if (!schema2) return;
|
|
104
|
-
if (schema2.$ref) {
|
|
105
|
-
const refName = schema2.$ref.split("/").pop();
|
|
106
|
-
if (refName) {
|
|
107
|
-
usedTypes.add(pascalCase(refName));
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (schema2.type === "array" && schema2.items) {
|
|
111
|
-
collectTypesFromSchema(schema2.items, usedTypes);
|
|
112
|
-
}
|
|
113
|
-
if (schema2.type === "object" && schema2.properties) {
|
|
114
|
-
Object.values(schema2.properties).forEach((prop) => {
|
|
115
|
-
collectTypesFromSchema(prop, usedTypes);
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
if (schema2.allOf) {
|
|
119
|
-
schema2.allOf.forEach((subSchema) => {
|
|
120
|
-
collectTypesFromSchema(subSchema, usedTypes);
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
if (schema2.oneOf) {
|
|
124
|
-
schema2.oneOf.forEach((subSchema) => {
|
|
125
|
-
collectTypesFromSchema(subSchema, usedTypes);
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
if (schema2.anyOf) {
|
|
129
|
-
schema2.anyOf.forEach((subSchema) => {
|
|
130
|
-
collectTypesFromSchema(subSchema, usedTypes);
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
__name(collectTypesFromSchema, "collectTypesFromSchema");
|
|
135
|
-
function collectTypesFromRequestBody(requestBody, usedTypes) {
|
|
136
|
-
const content = requestBody.content || {};
|
|
137
|
-
Object.values(content).forEach((mediaType) => {
|
|
138
|
-
if (mediaType.schema) {
|
|
139
|
-
collectTypesFromSchema(mediaType.schema, usedTypes);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
__name(collectTypesFromRequestBody, "collectTypesFromRequestBody");
|
|
144
|
-
function collectTypesFromResponse(response, usedTypes) {
|
|
145
|
-
const content = response.content || {};
|
|
146
|
-
Object.values(content).forEach((mediaType) => {
|
|
147
|
-
if (mediaType.schema) {
|
|
148
|
-
collectTypesFromSchema(mediaType.schema, usedTypes);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
__name(collectTypesFromResponse, "collectTypesFromResponse");
|
|
153
|
-
|
|
154
82
|
// ../../shared/src/utils/functions/token-names.ts
|
|
155
83
|
function getClientContextTokenName(clientName = "default") {
|
|
156
84
|
const clientSuffix = clientName.toUpperCase().replace(/[^A-Z0-9]/g, "_");
|
|
@@ -3488,57 +3416,20 @@ var HttpResourceGenerator = class {
|
|
|
3488
3416
|
const sourceFile = this.project.createSourceFile(filePath, "", {
|
|
3489
3417
|
overwrite: true
|
|
3490
3418
|
});
|
|
3491
|
-
|
|
3492
|
-
this.addImports(sourceFile, usedTypes);
|
|
3419
|
+
this.addImports(sourceFile);
|
|
3493
3420
|
this.addServiceClass(sourceFile, resourceName, operations);
|
|
3494
|
-
sourceFile.formatText();
|
|
3421
|
+
sourceFile.fixMissingImports().organizeImports().formatText();
|
|
3495
3422
|
sourceFile.saveSync();
|
|
3496
3423
|
}
|
|
3497
|
-
addImports(sourceFile
|
|
3498
|
-
const basePathTokenName = getBasePathTokenName(this.config.clientName);
|
|
3499
|
-
const clientContextTokenName = getClientContextTokenName(this.config.clientName);
|
|
3424
|
+
addImports(sourceFile) {
|
|
3500
3425
|
sourceFile.addImportDeclarations([
|
|
3501
3426
|
{
|
|
3502
3427
|
namedImports: [
|
|
3503
|
-
"Injectable"
|
|
3504
|
-
"inject",
|
|
3505
|
-
"Signal"
|
|
3428
|
+
"Injectable"
|
|
3506
3429
|
],
|
|
3507
3430
|
moduleSpecifier: "@angular/core"
|
|
3508
|
-
},
|
|
3509
|
-
{
|
|
3510
|
-
namedImports: [
|
|
3511
|
-
"HttpResourceRef",
|
|
3512
|
-
"HttpContext",
|
|
3513
|
-
"httpResource",
|
|
3514
|
-
"HttpResourceRequest",
|
|
3515
|
-
"HttpResourceOptions",
|
|
3516
|
-
"HttpParams",
|
|
3517
|
-
"HttpContextToken",
|
|
3518
|
-
"HttpHeaders"
|
|
3519
|
-
],
|
|
3520
|
-
moduleSpecifier: "@angular/common/http"
|
|
3521
|
-
},
|
|
3522
|
-
{
|
|
3523
|
-
namedImports: [
|
|
3524
|
-
basePathTokenName,
|
|
3525
|
-
clientContextTokenName
|
|
3526
|
-
],
|
|
3527
|
-
moduleSpecifier: "../tokens"
|
|
3528
|
-
},
|
|
3529
|
-
{
|
|
3530
|
-
namedImports: [
|
|
3531
|
-
"HttpParamsBuilder"
|
|
3532
|
-
],
|
|
3533
|
-
moduleSpecifier: "../index"
|
|
3534
3431
|
}
|
|
3535
3432
|
]);
|
|
3536
|
-
if (usedTypes.size > 0) {
|
|
3537
|
-
sourceFile.addImportDeclaration({
|
|
3538
|
-
namedImports: Array.from(usedTypes).sort(),
|
|
3539
|
-
moduleSpecifier: "../models"
|
|
3540
|
-
});
|
|
3541
|
-
}
|
|
3542
3433
|
}
|
|
3543
3434
|
addServiceClass(sourceFile, resourceName, operations) {
|
|
3544
3435
|
const className = `${resourceName}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-openapi/http-resource",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17-pr-28-bugfix-form-data-request-4fada97.0",
|
|
4
4
|
"description": "HTTP Resource plugin for ng-openapi - Angular HTTP utilities with caching and state management",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|