ng-openapi 0.0.7 → 0.0.8
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 +68 -6
- package/index.js +68 -6
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -903,20 +903,51 @@ var ServiceMethodBodyGenerator = class {
|
|
|
903
903
|
});
|
|
904
904
|
continue;
|
|
905
905
|
}
|
|
906
|
+
const isPrimitive = this.isPrimitiveType(schema);
|
|
906
907
|
const inferredType = this.inferResponseTypeFromContentType(contentType);
|
|
907
908
|
let priority = 3;
|
|
908
|
-
|
|
909
|
+
let finalType = inferredType;
|
|
910
|
+
if (inferredType === "json" && isPrimitive) {
|
|
911
|
+
finalType = "text";
|
|
912
|
+
priority = 2;
|
|
913
|
+
} else if (inferredType === "json") {
|
|
909
914
|
priority = 2;
|
|
910
915
|
}
|
|
911
916
|
responseTypes.push({
|
|
912
|
-
type:
|
|
917
|
+
type: finalType,
|
|
913
918
|
priority,
|
|
914
|
-
contentType
|
|
919
|
+
contentType,
|
|
920
|
+
isPrimitive
|
|
915
921
|
});
|
|
916
922
|
}
|
|
917
923
|
responseTypes.sort((a, b) => a.priority - b.priority);
|
|
918
924
|
return responseTypes[0]?.type || "json";
|
|
919
925
|
}
|
|
926
|
+
isPrimitiveType(schema) {
|
|
927
|
+
if (!schema) return false;
|
|
928
|
+
const primitiveTypes = [
|
|
929
|
+
"string",
|
|
930
|
+
"number",
|
|
931
|
+
"integer",
|
|
932
|
+
"boolean"
|
|
933
|
+
];
|
|
934
|
+
if (primitiveTypes.includes(schema.type)) {
|
|
935
|
+
return true;
|
|
936
|
+
}
|
|
937
|
+
if (schema.type === "array") {
|
|
938
|
+
return false;
|
|
939
|
+
}
|
|
940
|
+
if (schema.type === "object" || schema.properties) {
|
|
941
|
+
return false;
|
|
942
|
+
}
|
|
943
|
+
if (schema.$ref) {
|
|
944
|
+
return false;
|
|
945
|
+
}
|
|
946
|
+
if (schema.allOf || schema.oneOf || schema.anyOf) {
|
|
947
|
+
return false;
|
|
948
|
+
}
|
|
949
|
+
return false;
|
|
950
|
+
}
|
|
920
951
|
createGenerationContext(operation) {
|
|
921
952
|
return {
|
|
922
953
|
pathParams: operation.parameters?.filter((p) => p.in === "path") || [],
|
|
@@ -1327,20 +1358,51 @@ var ServiceMethodOverloadsGenerator = class {
|
|
|
1327
1358
|
});
|
|
1328
1359
|
continue;
|
|
1329
1360
|
}
|
|
1361
|
+
const isPrimitive = this.isPrimitiveType(schema);
|
|
1330
1362
|
const inferredType = this.inferResponseTypeFromContentType(contentType);
|
|
1331
1363
|
let priority = 3;
|
|
1332
|
-
|
|
1364
|
+
let finalType = inferredType;
|
|
1365
|
+
if (inferredType === "json" && isPrimitive) {
|
|
1366
|
+
finalType = "text";
|
|
1367
|
+
priority = 2;
|
|
1368
|
+
} else if (inferredType === "json") {
|
|
1333
1369
|
priority = 2;
|
|
1334
1370
|
}
|
|
1335
1371
|
responseTypes.push({
|
|
1336
|
-
type:
|
|
1372
|
+
type: finalType,
|
|
1337
1373
|
priority,
|
|
1338
|
-
contentType
|
|
1374
|
+
contentType,
|
|
1375
|
+
isPrimitive
|
|
1339
1376
|
});
|
|
1340
1377
|
}
|
|
1341
1378
|
responseTypes.sort((a, b) => a.priority - b.priority);
|
|
1342
1379
|
return responseTypes[0]?.type || "json";
|
|
1343
1380
|
}
|
|
1381
|
+
isPrimitiveType(schema) {
|
|
1382
|
+
if (!schema) return false;
|
|
1383
|
+
const primitiveTypes = [
|
|
1384
|
+
"string",
|
|
1385
|
+
"number",
|
|
1386
|
+
"integer",
|
|
1387
|
+
"boolean"
|
|
1388
|
+
];
|
|
1389
|
+
if (primitiveTypes.includes(schema.type)) {
|
|
1390
|
+
return true;
|
|
1391
|
+
}
|
|
1392
|
+
if (schema.type === "array") {
|
|
1393
|
+
return false;
|
|
1394
|
+
}
|
|
1395
|
+
if (schema.type === "object" || schema.properties) {
|
|
1396
|
+
return false;
|
|
1397
|
+
}
|
|
1398
|
+
if (schema.$ref) {
|
|
1399
|
+
return false;
|
|
1400
|
+
}
|
|
1401
|
+
if (schema.allOf || schema.oneOf || schema.anyOf) {
|
|
1402
|
+
return false;
|
|
1403
|
+
}
|
|
1404
|
+
return false;
|
|
1405
|
+
}
|
|
1344
1406
|
getResponseType(response) {
|
|
1345
1407
|
const responseType = this.getResponseTypeFromResponse(response);
|
|
1346
1408
|
switch (responseType) {
|
package/index.js
CHANGED
|
@@ -942,20 +942,51 @@ var _ServiceMethodBodyGenerator = class _ServiceMethodBodyGenerator {
|
|
|
942
942
|
});
|
|
943
943
|
continue;
|
|
944
944
|
}
|
|
945
|
+
const isPrimitive = this.isPrimitiveType(schema);
|
|
945
946
|
const inferredType = this.inferResponseTypeFromContentType(contentType);
|
|
946
947
|
let priority = 3;
|
|
947
|
-
|
|
948
|
+
let finalType = inferredType;
|
|
949
|
+
if (inferredType === "json" && isPrimitive) {
|
|
950
|
+
finalType = "text";
|
|
951
|
+
priority = 2;
|
|
952
|
+
} else if (inferredType === "json") {
|
|
948
953
|
priority = 2;
|
|
949
954
|
}
|
|
950
955
|
responseTypes.push({
|
|
951
|
-
type:
|
|
956
|
+
type: finalType,
|
|
952
957
|
priority,
|
|
953
|
-
contentType
|
|
958
|
+
contentType,
|
|
959
|
+
isPrimitive
|
|
954
960
|
});
|
|
955
961
|
}
|
|
956
962
|
responseTypes.sort((a, b) => a.priority - b.priority);
|
|
957
963
|
return ((_c = responseTypes[0]) == null ? void 0 : _c.type) || "json";
|
|
958
964
|
}
|
|
965
|
+
isPrimitiveType(schema) {
|
|
966
|
+
if (!schema) return false;
|
|
967
|
+
const primitiveTypes = [
|
|
968
|
+
"string",
|
|
969
|
+
"number",
|
|
970
|
+
"integer",
|
|
971
|
+
"boolean"
|
|
972
|
+
];
|
|
973
|
+
if (primitiveTypes.includes(schema.type)) {
|
|
974
|
+
return true;
|
|
975
|
+
}
|
|
976
|
+
if (schema.type === "array") {
|
|
977
|
+
return false;
|
|
978
|
+
}
|
|
979
|
+
if (schema.type === "object" || schema.properties) {
|
|
980
|
+
return false;
|
|
981
|
+
}
|
|
982
|
+
if (schema.$ref) {
|
|
983
|
+
return false;
|
|
984
|
+
}
|
|
985
|
+
if (schema.allOf || schema.oneOf || schema.anyOf) {
|
|
986
|
+
return false;
|
|
987
|
+
}
|
|
988
|
+
return false;
|
|
989
|
+
}
|
|
959
990
|
createGenerationContext(operation) {
|
|
960
991
|
var _a, _b;
|
|
961
992
|
return {
|
|
@@ -1371,20 +1402,51 @@ var _ServiceMethodOverloadsGenerator = class _ServiceMethodOverloadsGenerator {
|
|
|
1371
1402
|
});
|
|
1372
1403
|
continue;
|
|
1373
1404
|
}
|
|
1405
|
+
const isPrimitive = this.isPrimitiveType(schema);
|
|
1374
1406
|
const inferredType = this.inferResponseTypeFromContentType(contentType);
|
|
1375
1407
|
let priority = 3;
|
|
1376
|
-
|
|
1408
|
+
let finalType = inferredType;
|
|
1409
|
+
if (inferredType === "json" && isPrimitive) {
|
|
1410
|
+
finalType = "text";
|
|
1411
|
+
priority = 2;
|
|
1412
|
+
} else if (inferredType === "json") {
|
|
1377
1413
|
priority = 2;
|
|
1378
1414
|
}
|
|
1379
1415
|
responseTypes.push({
|
|
1380
|
-
type:
|
|
1416
|
+
type: finalType,
|
|
1381
1417
|
priority,
|
|
1382
|
-
contentType
|
|
1418
|
+
contentType,
|
|
1419
|
+
isPrimitive
|
|
1383
1420
|
});
|
|
1384
1421
|
}
|
|
1385
1422
|
responseTypes.sort((a, b) => a.priority - b.priority);
|
|
1386
1423
|
return ((_c = responseTypes[0]) == null ? void 0 : _c.type) || "json";
|
|
1387
1424
|
}
|
|
1425
|
+
isPrimitiveType(schema) {
|
|
1426
|
+
if (!schema) return false;
|
|
1427
|
+
const primitiveTypes = [
|
|
1428
|
+
"string",
|
|
1429
|
+
"number",
|
|
1430
|
+
"integer",
|
|
1431
|
+
"boolean"
|
|
1432
|
+
];
|
|
1433
|
+
if (primitiveTypes.includes(schema.type)) {
|
|
1434
|
+
return true;
|
|
1435
|
+
}
|
|
1436
|
+
if (schema.type === "array") {
|
|
1437
|
+
return false;
|
|
1438
|
+
}
|
|
1439
|
+
if (schema.type === "object" || schema.properties) {
|
|
1440
|
+
return false;
|
|
1441
|
+
}
|
|
1442
|
+
if (schema.$ref) {
|
|
1443
|
+
return false;
|
|
1444
|
+
}
|
|
1445
|
+
if (schema.allOf || schema.oneOf || schema.anyOf) {
|
|
1446
|
+
return false;
|
|
1447
|
+
}
|
|
1448
|
+
return false;
|
|
1449
|
+
}
|
|
1388
1450
|
getResponseType(response) {
|
|
1389
1451
|
const responseType = this.getResponseTypeFromResponse(response);
|
|
1390
1452
|
switch (responseType) {
|