Ignored | Statements | Branches | Functions | Lines | statements: 102 branches: 47 functions: 12 |
97.79% (1679 / 1717) |
97.53% (1143 / 1172) |
96.51% (221 / 229) |
97.79% (1679 / 1717) |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 | 2 2 2 2 2 2 2 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 2 1 2 2 2 2 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 520 520 520 1 1 2 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 2 119541 2 3 3 9 8 3 2 356 2 157496 2 129 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 1 1 1 2 2 1 1 1 2 2 2 2 2 2 2 2 2 2 58 2 2 2 2 2 2 2 2 2 2 2 2 2 325 325 325 10 325 325 325 2133 2133 1631 502 160 13 13 20 39 20 6 6 5 5 4 4 112 342 153 482 70 70 18 8 2 8 8 6 6 4 2 4 18 2 2 43 43 349 349 325 325 325 325 325 8 325 325 325 325 325 325 325 325 90 90 235 235 235 235 235 235 2 14 14 14 14 1045 821 6 821 815 14 14 14 14 28 64 14 14 62 14 14 14 14 156 156 156 4 156 14 532 610 610 610 610 610 610 14 563 14 1155 1155 485 670 670 670 670 670 670 670 670 670 670 670 670 552 670 670 670 841 841 670 670 670 1155 76 76 1155 200 200 1155 670 1340 6 670 28 28 34 34 34 28 670 670 670 670 325 670 670 670 670 12276 7285 670 670 670 670 14 14 14 14 14 2 22091 22091 22091 22091 22091 22091 22091 22091 22091 22091 2895 19196 892 18304 884 884 17420 17420 3240 18 3222 3222 3222 3222 3222 3222 830 830 4442 4442 4442 442 4000 3600 2600 2600 1000 200 800 4000 4000 2400 4442 4442 4442 67 4442 61 4442 860 860 85 4442 8134 8134 224 224 626 626 400 400 214 214 230 230 8134 200 8134 8134 774 45 729 17420 2 8 8 8 800 800 8 2 1531 1531 1531 1531 1531 1531 1531 1531 1531 18 18 1531 18052 1531 1531 1531 1531 2 227 227 2 1186 1186 1186 1186 1186 1186 1186 390 390 1186 1186 1186 1186 2 285 285 285 285 285 285 285 285 46 46 239 6 6 6 10 6 6 239 8 8 8 4 4 8 8 8 4 4 4 4 4 4 4 2 2 2 2 8 8 2 6 6 6 6 6 2 223 223 223 239 2 234 234 234 234 234 234 234 947 234 234 234 2 2 2 2 28 28 28 28 28 12 12 12 12 12 14 14 2 2 2 2 2 2 2 2 2 2 68 68 2 2 16 16 2 2 14 14 11 11 11 4 4 4 6 2 4 6 4 4 4 4 4 4 14 10 10 10 10 10 4 4 43 43 224 167 40 40 2 2 4 4 4 4 2 2 2 2 117 167 167 11 4 4 7 7 7 2 2 154 163 156 156 156 223 234 234 2 209 166 166 43 2 248 248 248 3 3 245 245 295 295 241 241 241 54 54 245 2 248 248 248 248 248 508 248 248 248 248 248 248 248 2 2 6 6 6 4 4 2 240 8 8 8 234 234 234 12 4 4 2 2 2 2 2 2 2 2 2 2 8 8 8 4 4 2 2 2 8 8 248 248 248 2 242 242 242 242 242 484 242 3 3 3 239 239 239 727 46 239 499 52 52 44 32 32 44 8 8 349 349 499 499 4 499 122 239 239 239 239 235 235 235 40 40 195 191 195 195 203 8 195 975 195 195 195 40 12 28 28 195 195 195 195 7 242 242 2 18 18 18 160 4 18 18 18 144 144 144 18 142 144 2 2 18 144 162 162 4 162 305 10 18 7 16 16 16 16 16 18 18 54 240 240 50 50 318 50 190 18 144 162 162 162 162 162 18 16 2 2 6 6 4 4 2 2 4 4 4 2 2 4 2 2 2 2 2 1244 1244 3878 3878 1782 3878 744 3878 1005 28 2 2 2 2 4 4 4 2 2 2 2 2 2 16 26 10 10 20 2873 76 76 3876 1244 2 246 246 492 236 256 236 256 30 30 2 30 30 6 30 30 30 30 226 246 492 204 288 288 288 246 42 288 246 2 14 14 14 2 39648 2 437 2 130795 2 228 228 228 32 32 228 228 228 228 2 10 10 10 10 10 10 10 10 18 32 4 12 4 4 14 10 10 10 10 10 8 8 10 10 10 10 10 2 10 4 4 10 2 10 10 4 6 6 6 6 2 4 4 4 4 2 2 2 2 2 2 2 2 2 2 2 2 124 124 124 124 44 80 80 124 80 4 4 4 2 2 2 80 80 80 2 80 2 2 82 6 6 2 2 2 2 2 2 72 12 10 10 12 72 8 2 2 8 8 8 8 8 8 8 8 8 8 12 12 12 4 12 12 12 12 8 4 4 2 2 8 2 98 98 98 98 98 98 98 98 98 49 49 678 678 678 676 676 676 674 674 674 98 98 96 672 672 41 182 182 1263 41 230 41 668 764 764 764 764 762 762 762 170 170 170 762 1269 2 2 1269 1269 1267 1267 1265 1265 1265 1265 1265 1261 1261 170 170 170 170 752 170 170 750 750 748 748 2 564 564 564 2632 2632 175 175 175 564 2 130311 130311 130311 130311 130311 130311 130311 130311 130311 130311 130311 44791 85520 85520 85520 85520 85520 85520 125164 361 125164 125164 125164 11325 11325 1523 1523 9802 3615 3615 11325 5138 6187 125164 125164 85498 39666 39666 39664 39664 39664 39662 1523 1523 1521 1521 1519 1519 1517 2386 2386 2386 46 46 46 44 2384 2384 2382 2382 2380 2380 2378 2378 2376 39646 39646 39646 39646 39646 85498 21115 165 165 261 21115 64383 2754 64383 64383 64244 4000 60244 60244 60236 4 60236 7503 7503 2495 2495 44 44 2868 2868 526 1009 2868 2810 2810 250 250 2810 25889 25889 278 278 732 732 539 539 417 417 415 417 228 228 25889 18627 60236 60219 60219 8798 60219 8798 10561 8774 8774 8772 8772 8770 3794 3794 8770 8768 5931 5931 5929 5929 5925 5925 5921 13693 13693 13691 13691 13689 5190 5190 13071 46645 46645 38781 38781 46488 26920 2294 2294 46446 46446 45594 12018 100 98 2 2 2 2 12016 29193 29193 29191 29191 29189 29189 29187 58496 58496 5850 58496 58457 58457 1062 58457 58457 1475 1475 1453 1475 1475 58457 58446 58446 1304 1304 590 1304 58446 58446 58444 780 2 58444 58442 58442 8 58436 2 4 12 4 2 2 2 1 1 1 1 1 4 4 4 3 3 4 4 4 4 2 771038 771038 769274 1764 3528 11652 1764 1764 1764 1764 4 1764 1764 1764 1764 1764 2 3 3 3 3 3 3 3 3 2 2 2 55 55 55 55 55 55 5 55 2 59 59 59 59 207 207 59 59 59 59 59 59 59 59 647 647 321 321 321 310 11 5 11 56 140 56 56 28 28 14 28 270 270 117 153 25 128 2 126 16 16 110 210 110 192 59 59 59 137 59 647 647 647 59 59 59 59 59 62 59 59 2 3 3 6 3 3 3 9 9 3 3 3 3 3 3 3 9 3 3 3 3 3 3 3 3 3 9 3 3 2 1 1 1 1 1 1 1 1 1 1 1 2 2 3 3 3 3 3 7 2 2 2 2 1 1 1 1 2 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 3 2 2 2 1 1 1 6 1 148 148 148 148 148 148 148 1 1 6 1 352 352 352 352 352 74 74 74 74 74 74 90 74 74 74 74 1 6 74 1 1 1 121 121 121 55 1 4 28 1 1 2 131 131 131 4 127 18 109 6 6 2 6 6 13 13 6 3 6 16 8 8 2 2 103 37 66 27 39 131 149 149 131 131 485 485 131 16 131 131 78 16 62 27 46 35 53 13 131 131 2 24 24 24 2 4 2 10 2 2 1 1 1 1 | //#!/usr/bin/env node /* * lib.swgg.js (2019.9.15) * https://github.com/kaizhu256/node-swgg * this zero-dependency package will run a virtual swagger-ui server with persistent-storage in the browser, that your webapp can use (in-place of a real backend), with a working web-demo * */ /* istanbul instrument in package swgg */ /* istanbul ignore next */ /* jslint utility2:true */ (function (globalThis) { "use strict"; let ArrayPrototypeFlat; let TextXxcoder; let consoleError; let local; // init globalThis globalThis.globalThis = globalThis.globalThis || globalThis; // init debug_inline Iif (!globalThis["debug\u0049nline"]) { consoleError = console.error; globalThis["debug\u0049nline"] = function (...argList) { /* * this function will both print <argList> to stderr * and return <argList>[0] */ // debug argList globalThis["debug\u0049nlineArgList"] = argList; consoleError("\n\ndebug\u0049nline"); consoleError.apply(console, argList); consoleError("\n"); // return arg0 for inspection return argList[0]; }; } // polyfill ArrayPrototypeFlat = function (depth) { /* * this function will polyfill Array.prototype.flat * https://github.com/jonathantneal/array-flat-polyfill */ depth = ( globalThis.isNaN(depth) ? 1 : Number(depth) ); if (!depth) { return Array.prototype.slice.call(this); } return Array.prototype.reduce.call(this, function (acc, cur) { if (Array.isArray(cur)) { // recurse acc.push.apply(acc, ArrayPrototypeFlat.call(cur, depth - 1)); } else { acc.push(cur); } return acc; }, []); }; Array.prototype.flat = Array.prototype.flat || ArrayPrototypeFlat; Array.prototype.flatMap = Array.prototype.flatMap || function flatMap( ...argList ) { /* * this function will polyfill Array.prototype.flatMap * https://github.com/jonathantneal/array-flat-polyfill */ return this.map(...argList).flat(); }; (function () { try { globalThis.TextDecoder = ( globalThis.TextDecoder || require("util").TextDecoder ); globalThis.TextEncoder = ( globalThis.TextEncoder || require("util").TextEncoder ); } catch (ignore) {} }()); TextXxcoder = function () { /* * this function will polyfill TextDecoder/TextEncoder * https://gist.github.com/Yaffle/5458286 */ return; }; TextXxcoder.prototype.decode = function (octets) { /* * this function will polyfill TextDecoder.prototype.decode * https://gist.github.com/Yaffle/5458286 */ let bytesNeeded; let codePoint; let ii; let kk; let octet; let string; string = ""; ii = 0; while (ii < octets.length) { octet = octets[ii]; bytesNeeded = 0; codePoint = 0; if (octet <= 0x7F) { bytesNeeded = 0; codePoint = octet & 0xFF; } else if (octet <= 0xDF) { bytesNeeded = 1; codePoint = octet & 0x1F; } else if (octet <= 0xEF) { bytesNeeded = 2; codePoint = octet & 0x0F; } else if (octet <= 0xF4) { bytesNeeded = 3; codePoint = octet & 0x07; } if (octets.length - ii - bytesNeeded > 0) { kk = 0; while (kk < bytesNeeded) { octet = octets[ii + kk + 1]; codePoint = (codePoint << 6) | (octet & 0x3F); kk += 1; } } else { codePoint = 0xFFFD; bytesNeeded = octets.length - ii; } string += String.fromCodePoint(codePoint); ii += bytesNeeded + 1; } return string; }; TextXxcoder.prototype.encode = function (string) { /* * this function will polyfill TextEncoder.prototype.encode * https://gist.github.com/Yaffle/5458286 */ let bits; let cc; let codePoint; let ii; let length; let octets; octets = []; length = string.length; ii = 0; while (ii < length) { codePoint = string.codePointAt(ii); cc = 0; bits = 0; if (codePoint <= 0x0000007F) { cc = 0; bits = 0x00; } else if (codePoint <= 0x000007FF) { cc = 6; bits = 0xC0; } else if (codePoint <= 0x0000FFFF) { cc = 12; bits = 0xE0; } else if (codePoint <= 0x001FFFFF) { cc = 18; bits = 0xF0; } octets.push(bits | (codePoint >> cc)); cc -= 6; while (cc >= 0) { octets.push(0x80 | ((codePoint >> cc) & 0x3F)); cc -= 6; } ii += ( codePoint >= 0x10000 ? 2 : 1 ); } return octets; }; globalThis.TextDecoder = globalThis.TextDecoder || TextXxcoder; globalThis.TextEncoder = globalThis.TextEncoder || TextXxcoder; // init local local = {}; local.local = local; globalThis.globalLocal = local; // init isBrowser local.isBrowser = ( typeof globalThis.XMLHttpRequest === "function" && globalThis.navigator && typeof globalThis.navigator.userAgent === "string" ); // init function local.assertOrThrow = function (passed, message) { /* * this function will throw err.<message> if <passed> is falsy */ let err; Eif (passed) { return; } err = ( ( message && typeof message.message === "string" && typeof message.stack === "string" ) // if message is errObj, then leave as is ? message : new Error( typeof message === "string" // if message is a string, then leave as is ? message // else JSON.stringify message : JSON.stringify(message, null, 4) ) ); throw err; }; local.fsRmrfSync = function (dir) { /* * this function will sync "rm -rf" <dir> */ let child_process; try { child_process = require("child_process"); } catch (ignore) { return; } child_process.spawnSync("rm", [ "-rf", dir ], { stdio: [ "ignore", 1, 2 ] }); }; local.fsWriteFileWithMkdirpSync = function (file, data) { /* * this function will sync write <data> to <file> with "mkdir -p" */ let fs; try { fs = require("fs"); } catch (ignore) { return; } // try to write file try { fs.writeFileSync(file, data); } catch (ignore) { // mkdir -p require("child_process").spawnSync( "mkdir", [ "-p", require("path").dirname(file) ], { stdio: [ "ignore", 1, 2 ] } ); // rewrite file fs.writeFileSync(file, data); } }; local.functionOrNop = function (fnc) { /* * this function will if <fnc> exists, * return <fnc>, * else return <nop> */ return fnc || local.nop; }; local.nop = function () { /* * this function will do nothing */ return; }; local.objectAssignDefault = function (target, source) { /* * this function will if items from <target> are * null, undefined, or empty-string, * then overwrite them with items from <source> */ target = target || {}; Object.keys(source || {}).forEach(function (key) { if ( target[key] === null || target[key] === undefined || target[key] === "" ) { target[key] = target[key] || source[key]; } }); return target; }; local.value = function (val) { /* * this function will return <val> */ return val; }; local.valueOrEmptyList = function (val) { /* * this function will return <val> or [] */ return val || []; }; local.valueOrEmptyObject = function (val) { /* * this function will return <val> or {} */ return val || {}; }; local.valueOrEmptyString = function (val) { /* * this function will return <val> or "" */ return val || ""; }; // require builtin if (!local.isBrowser) { local.assert = require("assert"); local.buffer = require("buffer"); local.child_process = require("child_process"); local.cluster = require("cluster"); local.crypto = require("crypto"); local.dgram = require("dgram"); local.dns = require("dns"); local.domain = require("domain"); local.events = require("events"); local.fs = require("fs"); local.http = require("http"); local.https = require("https"); local.net = require("net"); local.os = require("os"); local.path = require("path"); local.querystring = require("querystring"); local.readline = require("readline"); local.repl = require("repl"); local.stream = require("stream"); local.string_decoder = require("string_decoder"); local.timers = require("timers"); local.tls = require("tls"); local.tty = require("tty"); local.url = require("url"); local.util = require("util"); local.vm = require("vm"); local.zlib = require("zlib"); } }((typeof globalThis === "object" && globalThis) || (function () { return Function("return this")(); // jslint ignore:line }()))); (function (local) { "use strict"; /* istanbul ignore next */ // run shared js-env code - init-before (function () { // init local local = ( globalThis.utility2_rollup // || globalThis.utility2_rollup_old // || require("./assets.utility2.rollup.js") || globalThis.globalLocal ); // init exports if (local.isBrowser) { globalThis.utility2_swgg = local; } else { module.exports = local; module.exports.__dirname = __dirname; } // init lib main local.swgg = local; /* validateLineSortedReset */ // init lib utility2 local.utility2 = globalThis.utility2_rollup || ( local.isBrowser ? globalThis.utility2 : (function () { try { return require("./lib.utility2.js"); } catch (ignore) { return require("./assets.utility2.rollup.js"); } }()) ); local.utility2.objectSetDefault(local, local.utility2); // init lib swgg globalThis.swgg = local; local.utility2.swgg = local; /* validateLineSortedReset */ // init assets and templates // https://github.com/json-schema-org/json-schema-org.github.io/blob/eb4805e94c3e27932352344767d19cc4c3c3381c/draft-04/schema /* jslint ignore:start */ // curl -Ls https://raw.githubusercontent.com/json-schema-org/json-schema-org.github.io/eb4805e94c3e27932352344767d19cc4c3c3381c/draft-04/schema > /tmp/aa.json; node -e "console.log(JSON.stringify(require('/tmp/aa.json')));" local.assetsDict["/assets.swgg.json-schema.json"] = JSON.stringify( {"id":"http://json-schema.org/draft-04/schema#","$schema":"http://json-schema.org/draft-04/schema#","description":"Core schema meta-schema","definitions":{"schemaArray":{"type":"array","minItems":1,"items":{"$ref":"#"}},"positiveInteger":{"type":"integer","minimum":0},"positiveIntegerDefault0":{"allOf":[{"$ref":"#/definitions/positiveInteger"},{"default":0}]},"simpleTypes":{"enum":["array","boolean","integer","null","number","object","string"]},"stringArray":{"type":"array","items":{"type":"string"},"minItems":1,"uniqueItems":true}},"type":"object","properties":{"id":{"type":"string","format":"uri"},"$schema":{"type":"string","format":"uri"},"title":{"type":"string"},"description":{"type":"string"},"default":{},"multipleOf":{"type":"number","minimum":0,"exclusiveMinimum":true},"maximum":{"type":"number"},"exclusiveMaximum":{"type":"boolean","default":false},"minimum":{"type":"number"},"exclusiveMinimum":{"type":"boolean","default":false},"maxLength":{"$ref":"#/definitions/positiveInteger"},"minLength":{"$ref":"#/definitions/positiveIntegerDefault0"},"pattern":{"type":"string","format":"regex"},"additionalItems":{"anyOf":[{"type":"boolean"},{"$ref":"#"}],"default":{}},"items":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/schemaArray"}],"default":{}},"maxItems":{"$ref":"#/definitions/positiveInteger"},"minItems":{"$ref":"#/definitions/positiveIntegerDefault0"},"uniqueItems":{"type":"boolean","default":false},"maxProperties":{"$ref":"#/definitions/positiveInteger"},"minProperties":{"$ref":"#/definitions/positiveIntegerDefault0"},"required":{"$ref":"#/definitions/stringArray"},"additionalProperties":{"anyOf":[{"type":"boolean"},{"$ref":"#"}],"default":{}},"definitions":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"properties":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"patternProperties":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"dependencies":{"type":"object","additionalProperties":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/stringArray"}]}},"enum":{"type":"array","minItems":1,"uniqueItems":true},"type":{"anyOf":[{"$ref":"#/definitions/simpleTypes"},{"type":"array","items":{"$ref":"#/definitions/simpleTypes"},"minItems":1,"uniqueItems":true}]},"allOf":{"$ref":"#/definitions/schemaArray"},"anyOf":{"$ref":"#/definitions/schemaArray"},"oneOf":{"$ref":"#/definitions/schemaArray"},"not":{"$ref":"#"}},"dependencies":{"exclusiveMaximum":["maximum"],"exclusiveMinimum":["minimum"]},"default":{}} ); // https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/schemas/v2.0/schema.json // curl -Ls https://raw.githubusercontent.com/OAI/OpenAPI-Specification/3.0.0/schemas/v2.0/schema.json > /tmp/aa.json; node -e "console.log(JSON.stringify(require('/tmp/aa.json')));" local.assetsDict["/assets.swgg.schema.json"] = JSON.stringify( {"title":"A JSON Schema for Swagger 2.0 API.","id":"http://swagger.io/v2/schema.json#","$schema":"http://json-schema.org/draft-04/schema#","type":"object","required":["swagger","info","paths"],"additionalProperties":false,"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}},"properties":{"swagger":{"type":"string","enum":["2.0"],"description":"The Swagger version of this document."},"info":{"$ref":"#/definitions/info"},"host":{"type":"string","pattern":"^[^{}/ :\\\\]+(?::\\d+)?$","description":"The host (name or ip) of the API. Example: 'swagger.io'"},"basePath":{"type":"string","pattern":"^/","description":"The base path to the API. Example: '/api'."},"schemes":{"$ref":"#/definitions/schemesList"},"consumes":{"description":"A list of MIME types accepted by the API.","allOf":[{"$ref":"#/definitions/mediaTypeList"}]},"produces":{"description":"A list of MIME types the API can produce.","allOf":[{"$ref":"#/definitions/mediaTypeList"}]},"paths":{"$ref":"#/definitions/paths"},"definitions":{"$ref":"#/definitions/definitions"},"parameters":{"$ref":"#/definitions/parameterDefinitions"},"responses":{"$ref":"#/definitions/responseDefinitions"},"security":{"$ref":"#/definitions/security"},"securityDefinitions":{"$ref":"#/definitions/securityDefinitions"},"tags":{"type":"array","items":{"$ref":"#/definitions/tag"},"uniqueItems":true},"externalDocs":{"$ref":"#/definitions/externalDocs"}},"definitions":{"info":{"type":"object","description":"General information about the API.","required":["version","title"],"additionalProperties":false,"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}},"properties":{"title":{"type":"string","description":"A unique and precise title of the API."},"version":{"type":"string","description":"A semantic version number of the API."},"description":{"type":"string","description":"A longer description of the API. Should be different from the title. GitHub Flavored Markdown is allowed."},"termsOfService":{"type":"string","description":"The terms of service for the API."},"contact":{"$ref":"#/definitions/contact"},"license":{"$ref":"#/definitions/license"}}},"contact":{"type":"object","description":"Contact information for the owners of the API.","additionalProperties":false,"properties":{"name":{"type":"string","description":"The identifying name of the contact person/organization."},"url":{"type":"string","description":"The URL pointing to the contact information.","format":"uri"},"email":{"type":"string","description":"The email address of the contact person/organization.","format":"email"}},"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}}},"license":{"type":"object","required":["name"],"additionalProperties":false,"properties":{"name":{"type":"string","description":"The name of the license type. It's encouraged to use an OSI compatible license."},"url":{"type":"string","description":"The URL pointing to the license.","format":"uri"}},"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}}},"paths":{"type":"object","description":"Relative paths to the individual endpoints. They must be relative to the 'basePath'.","patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"},"^/":{"$ref":"#/definitions/pathItem"}},"additionalProperties":false},"definitions":{"type":"object","additionalProperties":{"$ref":"#/definitions/schema"},"description":"One or more JSON objects describing the schemas being consumed and produced by the API."},"parameterDefinitions":{"type":"object","additionalProperties":{"$ref":"#/definitions/parameter"},"description":"One or more JSON representations for parameters"},"responseDefinitions":{"type":"object","additionalProperties":{"$ref":"#/definitions/response"},"description":"One or more JSON representations for parameters"},"externalDocs":{"type":"object","additionalProperties":false,"description":"information about external documentation","required":["url"],"properties":{"description":{"type":"string"},"url":{"type":"string","format":"uri"}},"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}}},"examples":{"type":"object","additionalProperties":true},"mimeType":{"type":"string","description":"The MIME type of the HTTP message."},"operation":{"type":"object","required":["responses"],"additionalProperties":false,"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}},"properties":{"tags":{"type":"array","items":{"type":"string"},"uniqueItems":true},"summary":{"type":"string","description":"A brief summary of the operation."},"description":{"type":"string","description":"A longer description of the operation, GitHub Flavored Markdown is allowed."},"externalDocs":{"$ref":"#/definitions/externalDocs"},"operationId":{"type":"string","description":"A unique identifier of the operation."},"produces":{"description":"A list of MIME types the API can produce.","allOf":[{"$ref":"#/definitions/mediaTypeList"}]},"consumes":{"description":"A list of MIME types the API can consume.","allOf":[{"$ref":"#/definitions/mediaTypeList"}]},"parameters":{"$ref":"#/definitions/parametersList"},"responses":{"$ref":"#/definitions/responses"},"schemes":{"$ref":"#/definitions/schemesList"},"deprecated":{"type":"boolean","default":false},"security":{"$ref":"#/definitions/security"}}},"pathItem":{"type":"object","additionalProperties":false,"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}},"properties":{"$ref":{"type":"string"},"get":{"$ref":"#/definitions/operation"},"put":{"$ref":"#/definitions/operation"},"post":{"$ref":"#/definitions/operation"},"delete":{"$ref":"#/definitions/operation"},"options":{"$ref":"#/definitions/operation"},"head":{"$ref":"#/definitions/operation"},"patch":{"$ref":"#/definitions/operation"},"parameters":{"$ref":"#/definitions/parametersList"}}},"responses":{"type":"object","description":"Response objects names can either be any valid HTTP status code or 'default'.","minProperties":1,"additionalProperties":false,"patternProperties":{"^([0-9]{3})$|^(default)$":{"$ref":"#/definitions/responseValue"},"^x-":{"$ref":"#/definitions/vendorExtension"}},"not":{"type":"object","additionalProperties":false,"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}}}},"responseValue":{"oneOf":[{"$ref":"#/definitions/response"},{"$ref":"#/definitions/jsonReference"}]},"response":{"type":"object","required":["description"],"properties":{"description":{"type":"string"},"schema":{"oneOf":[{"$ref":"#/definitions/schema"},{"$ref":"#/definitions/fileSchema"}]},"headers":{"$ref":"#/definitions/headers"},"examples":{"$ref":"#/definitions/examples"}},"additionalProperties":false,"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}}},"headers":{"type":"object","additionalProperties":{"$ref":"#/definitions/header"}},"header":{"type":"object","additionalProperties":false,"required":["type"],"properties":{"type":{"type":"string","enum":["string","number","integer","boolean","array"]},"format":{"type":"string"},"items":{"$ref":"#/definitions/primitivesItems"},"collectionFormat":{"$ref":"#/definitions/collectionFormat"},"default":{"$ref":"#/definitions/default"},"maximum":{"$ref":"#/definitions/maximum"},"exclusiveMaximum":{"$ref":"#/definitions/exclusiveMaximum"},"minimum":{"$ref":"#/definitions/minimum"},"exclusiveMinimum":{"$ref":"#/definitions/exclusiveMinimum"},"maxLength":{"$ref":"#/definitions/maxLength"},"minLength":{"$ref":"#/definitions/minLength"},"pattern":{"$ref":"#/definitions/pattern"},"maxItems":{"$ref":"#/definitions/maxItems"},"minItems":{"$ref":"#/definitions/minItems"},"uniqueItems":{"$ref":"#/definitions/uniqueItems"},"enum":{"$ref":"#/definitions/enum"},"multipleOf":{"$ref":"#/definitions/multipleOf"},"description":{"type":"string"}},"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}}},"vendorExtension":{"description":"Any property starting with x- is valid.","additionalProperties":true,"additionalItems":true},"bodyParameter":{"type":"object","required":["name","in","schema"],"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}},"properties":{"description":{"type":"string","description":"A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed."},"name":{"type":"string","description":"The name of the parameter."},"in":{"type":"string","description":"Determines the location of the parameter.","enum":["body"]},"required":{"type":"boolean","description":"Determines whether or not this parameter is required or optional.","default":false},"schema":{"$ref":"#/definitions/schema"}},"additionalProperties":false},"headerParameterSubSchema":{"additionalProperties":false,"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}},"properties":{"required":{"type":"boolean","description":"Determines whether or not this parameter is required or optional.","default":false},"in":{"type":"string","description":"Determines the location of the parameter.","enum":["header"]},"description":{"type":"string","description":"A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed."},"name":{"type":"string","description":"The name of the parameter."},"type":{"type":"string","enum":["string","number","boolean","integer","array"]},"format":{"type":"string"},"items":{"$ref":"#/definitions/primitivesItems"},"collectionFormat":{"$ref":"#/definitions/collectionFormat"},"default":{"$ref":"#/definitions/default"},"maximum":{"$ref":"#/definitions/maximum"},"exclusiveMaximum":{"$ref":"#/definitions/exclusiveMaximum"},"minimum":{"$ref":"#/definitions/minimum"},"exclusiveMinimum":{"$ref":"#/definitions/exclusiveMinimum"},"maxLength":{"$ref":"#/definitions/maxLength"},"minLength":{"$ref":"#/definitions/minLength"},"pattern":{"$ref":"#/definitions/pattern"},"maxItems":{"$ref":"#/definitions/maxItems"},"minItems":{"$ref":"#/definitions/minItems"},"uniqueItems":{"$ref":"#/definitions/uniqueItems"},"enum":{"$ref":"#/definitions/enum"},"multipleOf":{"$ref":"#/definitions/multipleOf"}}},"queryParameterSubSchema":{"additionalProperties":false,"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}},"properties":{"required":{"type":"boolean","description":"Determines whether or not this parameter is required or optional.","default":false},"in":{"type":"string","description":"Determines the location of the parameter.","enum":["query"]},"description":{"type":"string","description":"A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed."},"name":{"type":"string","description":"The name of the parameter."},"allowEmptyValue":{"type":"boolean","default":false,"description":"allows sending a parameter by name only or with an empty value."},"type":{"type":"string","enum":["string","number","boolean","integer","array"]},"format":{"type":"string"},"items":{"$ref":"#/definitions/primitivesItems"},"collectionFormat":{"$ref":"#/definitions/collectionFormatWithMulti"},"default":{"$ref":"#/definitions/default"},"maximum":{"$ref":"#/definitions/maximum"},"exclusiveMaximum":{"$ref":"#/definitions/exclusiveMaximum"},"minimum":{"$ref":"#/definitions/minimum"},"exclusiveMinimum":{"$ref":"#/definitions/exclusiveMinimum"},"maxLength":{"$ref":"#/definitions/maxLength"},"minLength":{"$ref":"#/definitions/minLength"},"pattern":{"$ref":"#/definitions/pattern"},"maxItems":{"$ref":"#/definitions/maxItems"},"minItems":{"$ref":"#/definitions/minItems"},"uniqueItems":{"$ref":"#/definitions/uniqueItems"},"enum":{"$ref":"#/definitions/enum"},"multipleOf":{"$ref":"#/definitions/multipleOf"}}},"formDataParameterSubSchema":{"additionalProperties":false,"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}},"properties":{"required":{"type":"boolean","description":"Determines whether or not this parameter is required or optional.","default":false},"in":{"type":"string","description":"Determines the location of the parameter.","enum":["formData"]},"description":{"type":"string","description":"A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed."},"name":{"type":"string","description":"The name of the parameter."},"allowEmptyValue":{"type":"boolean","default":false,"description":"allows sending a parameter by name only or with an empty value."},"type":{"type":"string","enum":["string","number","boolean","integer","array","file"]},"format":{"type":"string"},"items":{"$ref":"#/definitions/primitivesItems"},"collectionFormat":{"$ref":"#/definitions/collectionFormatWithMulti"},"default":{"$ref":"#/definitions/default"},"maximum":{"$ref":"#/definitions/maximum"},"exclusiveMaximum":{"$ref":"#/definitions/exclusiveMaximum"},"minimum":{"$ref":"#/definitions/minimum"},"exclusiveMinimum":{"$ref":"#/definitions/exclusiveMinimum"},"maxLength":{"$ref":"#/definitions/maxLength"},"minLength":{"$ref":"#/definitions/minLength"},"pattern":{"$ref":"#/definitions/pattern"},"maxItems":{"$ref":"#/definitions/maxItems"},"minItems":{"$ref":"#/definitions/minItems"},"uniqueItems":{"$ref":"#/definitions/uniqueItems"},"enum":{"$ref":"#/definitions/enum"},"multipleOf":{"$ref":"#/definitions/multipleOf"}}},"pathParameterSubSchema":{"additionalProperties":false,"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}},"required":["required"],"properties":{"required":{"type":"boolean","enum":[true],"description":"Determines whether or not this parameter is required or optional."},"in":{"type":"string","description":"Determines the location of the parameter.","enum":["path"]},"description":{"type":"string","description":"A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed."},"name":{"type":"string","description":"The name of the parameter."},"type":{"type":"string","enum":["string","number","boolean","integer","array"]},"format":{"type":"string"},"items":{"$ref":"#/definitions/primitivesItems"},"collectionFormat":{"$ref":"#/definitions/collectionFormat"},"default":{"$ref":"#/definitions/default"},"maximum":{"$ref":"#/definitions/maximum"},"exclusiveMaximum":{"$ref":"#/definitions/exclusiveMaximum"},"minimum":{"$ref":"#/definitions/minimum"},"exclusiveMinimum":{"$ref":"#/definitions/exclusiveMinimum"},"maxLength":{"$ref":"#/definitions/maxLength"},"minLength":{"$ref":"#/definitions/minLength"},"pattern":{"$ref":"#/definitions/pattern"},"maxItems":{"$ref":"#/definitions/maxItems"},"minItems":{"$ref":"#/definitions/minItems"},"uniqueItems":{"$ref":"#/definitions/uniqueItems"},"enum":{"$ref":"#/definitions/enum"},"multipleOf":{"$ref":"#/definitions/multipleOf"}}},"nonBodyParameter":{"type":"object","required":["name","in","type"],"oneOf":[{"$ref":"#/definitions/headerParameterSubSchema"},{"$ref":"#/definitions/formDataParameterSubSchema"},{"$ref":"#/definitions/queryParameterSubSchema"},{"$ref":"#/definitions/pathParameterSubSchema"}]},"parameter":{"oneOf":[{"$ref":"#/definitions/bodyParameter"},{"$ref":"#/definitions/nonBodyParameter"}]},"schema":{"type":"object","description":"A deterministic version of a JSON Schema object.","patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}},"properties":{"$ref":{"type":"string"},"format":{"type":"string"},"title":{"$ref":"http://json-schema.org/draft-04/schema#/properties/title"},"description":{"$ref":"http://json-schema.org/draft-04/schema#/properties/description"},"default":{"$ref":"http://json-schema.org/draft-04/schema#/properties/default"},"multipleOf":{"$ref":"http://json-schema.org/draft-04/schema#/properties/multipleOf"},"maximum":{"$ref":"http://json-schema.org/draft-04/schema#/properties/maximum"},"exclusiveMaximum":{"$ref":"http://json-schema.org/draft-04/schema#/properties/exclusiveMaximum"},"minimum":{"$ref":"http://json-schema.org/draft-04/schema#/properties/minimum"},"exclusiveMinimum":{"$ref":"http://json-schema.org/draft-04/schema#/properties/exclusiveMinimum"},"maxLength":{"$ref":"http://json-schema.org/draft-04/schema#/definitions/positiveInteger"},"minLength":{"$ref":"http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"},"pattern":{"$ref":"http://json-schema.org/draft-04/schema#/properties/pattern"},"maxItems":{"$ref":"http://json-schema.org/draft-04/schema#/definitions/positiveInteger"},"minItems":{"$ref":"http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"},"uniqueItems":{"$ref":"http://json-schema.org/draft-04/schema#/properties/uniqueItems"},"maxProperties":{"$ref":"http://json-schema.org/draft-04/schema#/definitions/positiveInteger"},"minProperties":{"$ref":"http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"},"required":{"$ref":"http://json-schema.org/draft-04/schema#/definitions/stringArray"},"enum":{"$ref":"http://json-schema.org/draft-04/schema#/properties/enum"},"additionalProperties":{"anyOf":[{"$ref":"#/definitions/schema"},{"type":"boolean"}],"default":{}},"type":{"$ref":"http://json-schema.org/draft-04/schema#/properties/type"},"items":{"anyOf":[{"$ref":"#/definitions/schema"},{"type":"array","minItems":1,"items":{"$ref":"#/definitions/schema"}}],"default":{}},"allOf":{"type":"array","minItems":1,"items":{"$ref":"#/definitions/schema"}},"properties":{"type":"object","additionalProperties":{"$ref":"#/definitions/schema"},"default":{}},"discriminator":{"type":"string"},"readOnly":{"type":"boolean","default":false},"xml":{"$ref":"#/definitions/xml"},"externalDocs":{"$ref":"#/definitions/externalDocs"},"example":{}},"additionalProperties":false},"fileSchema":{"type":"object","description":"A deterministic version of a JSON Schema object.","patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}},"required":["type"],"properties":{"format":{"type":"string"},"title":{"$ref":"http://json-schema.org/draft-04/schema#/properties/title"},"description":{"$ref":"http://json-schema.org/draft-04/schema#/properties/description"},"default":{"$ref":"http://json-schema.org/draft-04/schema#/properties/default"},"required":{"$ref":"http://json-schema.org/draft-04/schema#/definitions/stringArray"},"type":{"type":"string","enum":["file"]},"readOnly":{"type":"boolean","default":false},"externalDocs":{"$ref":"#/definitions/externalDocs"},"example":{}},"additionalProperties":false},"primitivesItems":{"type":"object","additionalProperties":false,"properties":{"type":{"type":"string","enum":["string","number","integer","boolean","array"]},"format":{"type":"string"},"items":{"$ref":"#/definitions/primitivesItems"},"collectionFormat":{"$ref":"#/definitions/collectionFormat"},"default":{"$ref":"#/definitions/default"},"maximum":{"$ref":"#/definitions/maximum"},"exclusiveMaximum":{"$ref":"#/definitions/exclusiveMaximum"},"minimum":{"$ref":"#/definitions/minimum"},"exclusiveMinimum":{"$ref":"#/definitions/exclusiveMinimum"},"maxLength":{"$ref":"#/definitions/maxLength"},"minLength":{"$ref":"#/definitions/minLength"},"pattern":{"$ref":"#/definitions/pattern"},"maxItems":{"$ref":"#/definitions/maxItems"},"minItems":{"$ref":"#/definitions/minItems"},"uniqueItems":{"$ref":"#/definitions/uniqueItems"},"enum":{"$ref":"#/definitions/enum"},"multipleOf":{"$ref":"#/definitions/multipleOf"}},"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}}},"security":{"type":"array","items":{"$ref":"#/definitions/securityRequirement"},"uniqueItems":true},"securityRequirement":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"},"uniqueItems":true}},"xml":{"type":"object","additionalProperties":false,"properties":{"name":{"type":"string"},"namespace":{"type":"string"},"prefix":{"type":"string"},"attribute":{"type":"boolean","default":false},"wrapped":{"type":"boolean","default":false}},"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}}},"tag":{"type":"object","additionalProperties":false,"required":["name"],"properties":{"name":{"type":"string"},"description":{"type":"string"},"externalDocs":{"$ref":"#/definitions/externalDocs"}},"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}}},"securityDefinitions":{"type":"object","additionalProperties":{"oneOf":[{"$ref":"#/definitions/basicAuthenticationSecurity"},{"$ref":"#/definitions/apiKeySecurity"},{"$ref":"#/definitions/oauth2ImplicitSecurity"},{"$ref":"#/definitions/oauth2PasswordSecurity"},{"$ref":"#/definitions/oauth2ApplicationSecurity"},{"$ref":"#/definitions/oauth2AccessCodeSecurity"}]}},"basicAuthenticationSecurity":{"type":"object","additionalProperties":false,"required":["type"],"properties":{"type":{"type":"string","enum":["basic"]},"description":{"type":"string"}},"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}}},"apiKeySecurity":{"type":"object","additionalProperties":false,"required":["type","name","in"],"properties":{"type":{"type":"string","enum":["apiKey"]},"name":{"type":"string"},"in":{"type":"string","enum":["header","query"]},"description":{"type":"string"}},"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}}},"oauth2ImplicitSecurity":{"type":"object","additionalProperties":false,"required":["type","flow","authorizationUrl"],"properties":{"type":{"type":"string","enum":["oauth2"]},"flow":{"type":"string","enum":["implicit"]},"scopes":{"$ref":"#/definitions/oauth2Scopes"},"authorizationUrl":{"type":"string","format":"uri"},"description":{"type":"string"}},"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}}},"oauth2PasswordSecurity":{"type":"object","additionalProperties":false,"required":["type","flow","tokenUrl"],"properties":{"type":{"type":"string","enum":["oauth2"]},"flow":{"type":"string","enum":["password"]},"scopes":{"$ref":"#/definitions/oauth2Scopes"},"tokenUrl":{"type":"string","format":"uri"},"description":{"type":"string"}},"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}}},"oauth2ApplicationSecurity":{"type":"object","additionalProperties":false,"required":["type","flow","tokenUrl"],"properties":{"type":{"type":"string","enum":["oauth2"]},"flow":{"type":"string","enum":["application"]},"scopes":{"$ref":"#/definitions/oauth2Scopes"},"tokenUrl":{"type":"string","format":"uri"},"description":{"type":"string"}},"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}}},"oauth2AccessCodeSecurity":{"type":"object","additionalProperties":false,"required":["type","flow","authorizationUrl","tokenUrl"],"properties":{"type":{"type":"string","enum":["oauth2"]},"flow":{"type":"string","enum":["accessCode"]},"scopes":{"$ref":"#/definitions/oauth2Scopes"},"authorizationUrl":{"type":"string","format":"uri"},"tokenUrl":{"type":"string","format":"uri"},"description":{"type":"string"}},"patternProperties":{"^x-":{"$ref":"#/definitions/vendorExtension"}}},"oauth2Scopes":{"type":"object","additionalProperties":{"type":"string"}},"mediaTypeList":{"type":"array","items":{"$ref":"#/definitions/mimeType"},"uniqueItems":true},"parametersList":{"type":"array","description":"The parameters needed to send a valid API call.","additionalItems":false,"items":{"oneOf":[{"$ref":"#/definitions/parameter"},{"$ref":"#/definitions/jsonReference"}]},"uniqueItems":true},"schemesList":{"type":"array","description":"The transfer protocol of the API.","items":{"type":"string","enum":["http","https","ws","wss"]},"uniqueItems":true},"collectionFormat":{"type":"string","enum":["csv","ssv","tsv","pipes"],"default":"csv"},"collectionFormatWithMulti":{"type":"string","enum":["csv","ssv","tsv","pipes","multi"],"default":"csv"},"title":{"$ref":"http://json-schema.org/draft-04/schema#/properties/title"},"description":{"$ref":"http://json-schema.org/draft-04/schema#/properties/description"},"default":{"$ref":"http://json-schema.org/draft-04/schema#/properties/default"},"multipleOf":{"$ref":"http://json-schema.org/draft-04/schema#/properties/multipleOf"},"maximum":{"$ref":"http://json-schema.org/draft-04/schema#/properties/maximum"},"exclusiveMaximum":{"$ref":"http://json-schema.org/draft-04/schema#/properties/exclusiveMaximum"},"minimum":{"$ref":"http://json-schema.org/draft-04/schema#/properties/minimum"},"exclusiveMinimum":{"$ref":"http://json-schema.org/draft-04/schema#/properties/exclusiveMinimum"},"maxLength":{"$ref":"http://json-schema.org/draft-04/schema#/definitions/positiveInteger"},"minLength":{"$ref":"http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"},"pattern":{"$ref":"http://json-schema.org/draft-04/schema#/properties/pattern"},"maxItems":{"$ref":"http://json-schema.org/draft-04/schema#/definitions/positiveInteger"},"minItems":{"$ref":"http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"},"uniqueItems":{"$ref":"http://json-schema.org/draft-04/schema#/properties/uniqueItems"},"enum":{"$ref":"http://json-schema.org/draft-04/schema#/properties/enum"},"jsonReference":{"type":"object","required":["$ref"],"additionalProperties":false,"properties":{"$ref":{"type":"string"}}}}} ); local.assetsDict["/assets.swgg.swagger.json"] = local.assetsDict["/assets.swgg.swagger.json"] || ""; // https://petstore.swagger.io/v2/swagger.json // curl -Ls https://petstore.swagger.io/v2/swagger.json > /tmp/aa.json; node -e "console.log(JSON.stringify(require('/tmp/aa.json')));" local.assetsDict["/assets.swgg.swagger.petstore.json"] = JSON.stringify( {"swagger":"2.0","info":{"description":"This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.","version":"1.0.0","title":"Swagger Petstore","termsOfService":"http://swagger.io/terms/","contact":{"email":"apiteam@swagger.io"},"license":{"name":"Apache 2.0","url":"http://www.apache.org/licenses/LICENSE-2.0.html"}},"host":"petstore.swagger.io","basePath":"/v2","tags":[{"name":"pet","description":"Everything about your Pets","externalDocs":{"description":"Find out more","url":"http://swagger.io"}},{"name":"store","description":"Access to Petstore orders"},{"name":"user","description":"Operations about user","externalDocs":{"description":"Find out more about our store","url":"http://swagger.io"}}],"schemes":["http"],"paths":{"/pet":{"post":{"tags":["pet"],"summary":"Add a new pet to the store","description":"","operationId":"addPet","consumes":["application/json","application/xml"],"produces":["application/xml","application/json"],"parameters":[{"in":"body","name":"body","description":"Pet object that needs to be added to the store","required":true,"schema":{"$ref":"#/definitions/Pet"}}],"responses":{"405":{"description":"Invalid input"}},"security":[{"petstore_auth":["write:pets","read:pets"]}]},"put":{"tags":["pet"],"summary":"Update an existing pet","description":"","operationId":"updatePet","consumes":["application/json","application/xml"],"produces":["application/xml","application/json"],"parameters":[{"in":"body","name":"body","description":"Pet object that needs to be added to the store","required":true,"schema":{"$ref":"#/definitions/Pet"}}],"responses":{"400":{"description":"Invalid ID supplied"},"404":{"description":"Pet not found"},"405":{"description":"Validation exception"}},"security":[{"petstore_auth":["write:pets","read:pets"]}]}},"/pet/findByStatus":{"get":{"tags":["pet"],"summary":"Finds Pets by status","description":"Multiple status values can be provided with comma separated strings","operationId":"findPetsByStatus","produces":["application/xml","application/json"],"parameters":[{"name":"status","in":"query","description":"Status values that need to be considered for filter","required":true,"type":"array","items":{"type":"string","enum":["available","pending","sold"],"default":"available"},"collectionFormat":"multi"}],"responses":{"200":{"description":"successful operation","schema":{"type":"array","items":{"$ref":"#/definitions/Pet"}}},"400":{"description":"Invalid status value"}},"security":[{"petstore_auth":["write:pets","read:pets"]}]}},"/pet/findByTags":{"get":{"tags":["pet"],"summary":"Finds Pets by tags","description":"Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.","operationId":"findPetsByTags","produces":["application/xml","application/json"],"parameters":[{"name":"tags","in":"query","description":"Tags to filter by","required":true,"type":"array","items":{"type":"string"},"collectionFormat":"multi"}],"responses":{"200":{"description":"successful operation","schema":{"type":"array","items":{"$ref":"#/definitions/Pet"}}},"400":{"description":"Invalid tag value"}},"security":[{"petstore_auth":["write:pets","read:pets"]}],"deprecated":true}},"/pet/{petId}":{"get":{"tags":["pet"],"summary":"Find pet by ID","description":"Returns a single pet","operationId":"getPetById","produces":["application/xml","application/json"],"parameters":[{"name":"petId","in":"path","description":"ID of pet to return","required":true,"type":"integer","format":"int64"}],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/Pet"}},"400":{"description":"Invalid ID supplied"},"404":{"description":"Pet not found"}},"security":[{"api_key":[]}]},"post":{"tags":["pet"],"summary":"Updates a pet in the store with form data","description":"","operationId":"updatePetWithForm","consumes":["application/x-www-form-urlencoded"],"produces":["application/xml","application/json"],"parameters":[{"name":"petId","in":"path","description":"ID of pet that needs to be updated","required":true,"type":"integer","format":"int64"},{"name":"name","in":"formData","description":"Updated name of the pet","required":false,"type":"string"},{"name":"status","in":"formData","description":"Updated status of the pet","required":false,"type":"string"}],"responses":{"405":{"description":"Invalid input"}},"security":[{"petstore_auth":["write:pets","read:pets"]}]},"delete":{"tags":["pet"],"summary":"Deletes a pet","description":"","operationId":"deletePet","produces":["application/xml","application/json"],"parameters":[{"name":"api_key","in":"header","required":false,"type":"string"},{"name":"petId","in":"path","description":"Pet id to delete","required":true,"type":"integer","format":"int64"}],"responses":{"400":{"description":"Invalid ID supplied"},"404":{"description":"Pet not found"}},"security":[{"petstore_auth":["write:pets","read:pets"]}]}},"/pet/{petId}/uploadImage":{"post":{"tags":["pet"],"summary":"uploads an image","description":"","operationId":"uploadFile","consumes":["multipart/form-data"],"produces":["application/json"],"parameters":[{"name":"petId","in":"path","description":"ID of pet to update","required":true,"type":"integer","format":"int64"},{"name":"additionalMetadata","in":"formData","description":"Additional data to pass to server","required":false,"type":"string"},{"name":"file","in":"formData","description":"file to upload","required":false,"type":"file"}],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/ApiResponse"}}},"security":[{"petstore_auth":["write:pets","read:pets"]}]}},"/store/inventory":{"get":{"tags":["store"],"summary":"Returns pet inventories by status","description":"Returns a map of status codes to quantities","operationId":"getInventory","produces":["application/json"],"parameters":[],"responses":{"200":{"description":"successful operation","schema":{"type":"object","additionalProperties":{"type":"integer","format":"int32"}}}},"security":[{"api_key":[]}]}},"/store/order":{"post":{"tags":["store"],"summary":"Place an order for a pet","description":"","operationId":"placeOrder","produces":["application/xml","application/json"],"parameters":[{"in":"body","name":"body","description":"order placed for purchasing the pet","required":true,"schema":{"$ref":"#/definitions/Order"}}],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/Order"}},"400":{"description":"Invalid Order"}}}},"/store/order/{orderId}":{"get":{"tags":["store"],"summary":"Find purchase order by ID","description":"For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions","operationId":"getOrderById","produces":["application/xml","application/json"],"parameters":[{"name":"orderId","in":"path","description":"ID of pet that needs to be fetched","required":true,"type":"integer","maximum":10,"minimum":1,"format":"int64"}],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/Order"}},"400":{"description":"Invalid ID supplied"},"404":{"description":"Order not found"}}},"delete":{"tags":["store"],"summary":"Delete purchase order by ID","description":"For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors","operationId":"deleteOrder","produces":["application/xml","application/json"],"parameters":[{"name":"orderId","in":"path","description":"ID of the order that needs to be deleted","required":true,"type":"integer","minimum":1,"format":"int64"}],"responses":{"400":{"description":"Invalid ID supplied"},"404":{"description":"Order not found"}}}},"/user":{"post":{"tags":["user"],"summary":"Create user","description":"This can only be done by the logged in user.","operationId":"createUser","produces":["application/xml","application/json"],"parameters":[{"in":"body","name":"body","description":"Created user object","required":true,"schema":{"$ref":"#/definitions/User"}}],"responses":{"default":{"description":"successful operation"}}}},"/user/createWithArray":{"post":{"tags":["user"],"summary":"Creates list of users with given input array","description":"","operationId":"createUsersWithArrayInput","produces":["application/xml","application/json"],"parameters":[{"in":"body","name":"body","description":"List of user object","required":true,"schema":{"type":"array","items":{"$ref":"#/definitions/User"}}}],"responses":{"default":{"description":"successful operation"}}}},"/user/createWithList":{"post":{"tags":["user"],"summary":"Creates list of users with given input array","description":"","operationId":"createUsersWithListInput","produces":["application/xml","application/json"],"parameters":[{"in":"body","name":"body","description":"List of user object","required":true,"schema":{"type":"array","items":{"$ref":"#/definitions/User"}}}],"responses":{"default":{"description":"successful operation"}}}},"/user/login":{"get":{"tags":["user"],"summary":"Logs user into the system","description":"","operationId":"loginUser","produces":["application/xml","application/json"],"parameters":[{"name":"username","in":"query","description":"The user name for login","required":true,"type":"string"},{"name":"password","in":"query","description":"The password for login in clear text","required":true,"type":"string"}],"responses":{"200":{"description":"successful operation","schema":{"type":"string"},"headers":{"X-Rate-Limit":{"type":"integer","format":"int32","description":"calls per hour allowed by the user"},"X-Expires-After":{"type":"string","format":"date-time","description":"date in UTC when token expires"}}},"400":{"description":"Invalid username/password supplied"}}}},"/user/logout":{"get":{"tags":["user"],"summary":"Logs out current logged in user session","description":"","operationId":"logoutUser","produces":["application/xml","application/json"],"parameters":[],"responses":{"default":{"description":"successful operation"}}}},"/user/{username}":{"get":{"tags":["user"],"summary":"Get user by user name","description":"","operationId":"getUserByName","produces":["application/xml","application/json"],"parameters":[{"name":"username","in":"path","description":"The name that needs to be fetched. Use user1 for testing. ","required":true,"type":"string"}],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/User"}},"400":{"description":"Invalid username supplied"},"404":{"description":"User not found"}}},"put":{"tags":["user"],"summary":"Updated user","description":"This can only be done by the logged in user.","operationId":"updateUser","produces":["application/xml","application/json"],"parameters":[{"name":"username","in":"path","description":"name that need to be updated","required":true,"type":"string"},{"in":"body","name":"body","description":"Updated user object","required":true,"schema":{"$ref":"#/definitions/User"}}],"responses":{"400":{"description":"Invalid user supplied"},"404":{"description":"User not found"}}},"delete":{"tags":["user"],"summary":"Delete user","description":"This can only be done by the logged in user.","operationId":"deleteUser","produces":["application/xml","application/json"],"parameters":[{"name":"username","in":"path","description":"The name that needs to be deleted","required":true,"type":"string"}],"responses":{"400":{"description":"Invalid username supplied"},"404":{"description":"User not found"}}}}},"securityDefinitions":{"petstore_auth":{"type":"oauth2","authorizationUrl":"http://petstore.swagger.io/oauth/dialog","flow":"implicit","scopes":{"write:pets":"modify pets in your account","read:pets":"read your pets"}},"api_key":{"type":"apiKey","name":"api_key","in":"header"}},"definitions":{"Order":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"petId":{"type":"integer","format":"int64"},"quantity":{"type":"integer","format":"int32"},"shipDate":{"type":"string","format":"date-time"},"status":{"type":"string","description":"Order Status","enum":["placed","approved","delivered"]},"complete":{"type":"boolean","default":false}},"xml":{"name":"Order"}},"Category":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"}},"xml":{"name":"Category"}},"User":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"username":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"email":{"type":"string"},"password":{"type":"string"},"phone":{"type":"string"},"userStatus":{"type":"integer","format":"int32","description":"User Status"}},"xml":{"name":"User"}},"Tag":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"}},"xml":{"name":"Tag"}},"Pet":{"type":"object","required":["name","photoUrls"],"properties":{"id":{"type":"integer","format":"int64"},"category":{"$ref":"#/definitions/Category"},"name":{"type":"string","example":"doggie"},"photoUrls":{"type":"array","xml":{"name":"photoUrl","wrapped":true},"items":{"type":"string"}},"tags":{"type":"array","xml":{"name":"tag","wrapped":true},"items":{"$ref":"#/definitions/Tag"}},"status":{"type":"string","description":"pet status in the store","enum":["available","pending","sold"]}},"xml":{"name":"Pet"}},"ApiResponse":{"type":"object","properties":{"code":{"type":"integer","format":"int32"},"type":{"type":"string"},"message":{"type":"string"}}}},"externalDocs":{"description":"Find out more about Swagger","url":"http://swagger.io"}} ); local.swaggerErrorTypeDict = { arrayMaxItems: '{{type2}} {{prefix0}} must have <= {{schema.maxItems}} items', arrayMinItems: '{{type2}} {{prefix0}} must have >= {{schema.minItems}} items', arrayUniqueItems: '{{type2}} {{prefix0}} must have unique items (has duplicate item {{tmp jsonStringify}})', itemEnum: '{{type2}} {{prefix0}} can only have items from the list {{schema.enum jsonStringify}}', itemAnyOf: '{{tmp}} (from schama.anyOf {{schema2}})', itemNot: '{{type2}} {{prefix0}} must not validate against schama.not {{schema2}}', itemOneOf: '{{type2}} {{prefix0}} did not validate against exactly one schema (validated {{tmp}}) in schema.oneOf {{schema2}}', itemType: 'value {{prefix0}} is not a valid {{type2}}', numberMultipleOf: '{{type2}} {{prefix0}} must be a multiple of {{schema.multipleOf}}', numberExclusiveMaximum: '{{type2}} {{prefix0}} must be < {{schema.maximum}}', numberExclusiveMinimum: '{{type2}} {{prefix0}} must be > {{schema.minimum}}', numberMaximum: '{{type2}} {{prefix0}} must be <= {{schema.maximum}}', numberMinimum: '{{type2}} {{prefix0}} must be >= {{schema.minimum}}', objectAdditionalProperties: '{{type2}} {{prefix0}} cannot have additional property {{key jsonStringify}}', objectDependencies: '{{type2}} {{prefix0}} with item {{key jsonStringify}} must have dependency {{key2 jsonStringify}}', objectMaxProperties: '{{type2}} {{prefix0}} must have <= {{schema.maxProperties}} properties', objectMinProperties: '{{type2}} {{prefix0}} must have >= {{schema.minProperties}} properties', objectRequired: '{{type2}} {{prefix0}} is required', schemaDereferenceCircular: 'cannot dereference circular-reference schema {{schema2}}', schemaDereference: 'cannot dereference schema {{schema2}}', // https://github.com/swagger-api/swagger-editor/tree/v3.1.20/src/plugins/validation/semantic-validators/validators // shGrep swagger-editor/src/plugins/validation/semantic-validators/validators 'message:' // form-data.js:90: "Parameter \"in: formdata\" is invalid, did you mean \"in: formData\" ( camelCase )?", semanticFormData1: "Parameter {{prefix0}} is invalid, did you mean \"in: formData\" ( camelCase )?", // form-data.js:109: "Parameters cannot have both a \"in: body\" and \"in: formData\", as \"formData\" _will_ be the body" semanticFormData2: "Parameters cannot have both a \"in: body\" and \"in: formData\", as \"formData\" _will_ be the body", // form-data.js:131: "Parameters with \"type: file\" must have \"in: formData\"", semanticFormData3: "Parameter {{prefix0}} with \"type: file\" must have \"in: formData\"", // form-data.js:140: "Operations with Parameters of \"type: file\" must include \"multipart/form-data\" in their \"consumes\" property", semanticFormData4: "Operation {{prefix0}} with Parameters of \"type: file\" must include \"multipart/form-data\" in their \"consumes\" property", // form-data.js:163: "Operations with Parameters of \"in: formData\" must include \"application/x-www-form-urlencoded\" or \"multipart/form-data\" in their \"consumes\" property", semanticFormData5: "Operation {{prefix0}} with Parameters of \"in: formData\" must include \"application/x-www-form-urlencoded\" or \"multipart/form-data\" in their \"consumes\" property", // items-required-for-array-objects.js:27: "Schema objects with 'array' type require an 'items' property" semanticItemsRequiredForArrayObjects1: "Schema {{schema2}} with 'array' type require an 'items' property", // items-required-for-array-objects.js:38: "Schema properties specified as 'required' must be defined" semanticItemsRequiredForArrayObjects2: "{{type2}} {{prefix0}} must have property {{key jsonStringify}}", // items-required-for-array-objects.js:50: "Headers with 'array' type require an 'items' property" semanticItemsRequiredForArrayObjects3: "Headers with 'array' type require an 'items' property", // items-required-for-array-objects.js:59: "Model properties with 'array' type require an 'items' property" semanticItemsRequiredForArrayObjects4: "Model properties with 'array' type require an 'items' property", // operation-ids.js:40: "operationIds must be unique" semanticOperationIds1: 'operationId {{prefix0}} must be unique', // operations.js:30: "Operations cannot have both a \"body\" parameter and \"formData\" parameter" semanticOperations1: "Operation {{prefix0}} cannot have both a \"body\" parameter and \"formData\" parameter", // operations.js:38: "Operations must have no more than one body parameter" semanticOperations2: "Operation {{prefix0}} must have no more than one body parameter", // operations.js:53: "Operation parameters must have unique 'name' + 'in' properties" semanticOperations3: "Operation parameters {{prefix0}} must have unique 'name' + 'in' properties", // parameters.js:18: "Parameters with 'array' type require an 'items' property." semanticParameters1: "Parameters with 'array' type require an 'items' property.", // parameters.js:24: "Non-body parameters require a 'type' property." semanticParameters2: "Non-body parameter {{prefix0}} require a 'type' property.", // paths.js:48: "Query strings in paths are not allowed." semanticPaths1: "Query strings in path {{prefix2 jsonStringify}} are not allowed", // paths.js:79: "Equivalent paths are not allowed." semanticPaths2: 'Equivalent paths {{pathList jsonStringify}} are not allowed', // paths.js:94: "Path parameters must have unique 'name' + 'in' properties" semanticPaths3: "Path parameter ${parameterDefinition.name jsonStringify} must be unique", // paths.js:107: `Path parameter ${parameterDefinition.name} was defined but never used` semanticPaths4: 'Path parameter ${parameterDefinition.name} was defined but never used', // paths.js:119: "Empty path parameter declarations are not valid" semanticPaths5: "Empty path parameter declarations are not valid - {{prefix2 jsonStringify}}", // paths.js:131: `Declared path parameter "${parameter}" needs to be defined as a path parameter at either the path or operation level` semanticPaths6: 'Declared path parameter {{name jsonStringify}} needs to be defined as a path parameter {{prefix2 jsonStringify}} at either the path or operation level', // paths.js:141: `Path parameter ${parameterDefinition.name} was defined but never used` semanticPaths7: 'Path parameter {{prefix0}} was defined but never used', // refs.js:37: "Definition was declared but never used in document" semanticRefs1: 'Definition was declared but never used in document', // schema.js:61: "Read only properties cannot marked as required by a schema." semanticSchema1: "Read only property {{prefix0}} cannot be marked as required by a schema.", // security-definitions.js:33: `${path} must have required string 'type' param`, semanticSecurityDefinitions1: '${path} must have required string "type" param', // security-definitions.js:44: "apiKey authorization must have required 'in' param, valid values are 'query' or 'header'.", semanticSecurityDefinitions2: 'apiKey authorization must have required "in" param, valid values are "query" or "header".', // security-definitions.js:52: "apiKey authorization must have required 'name' string param. The name of the header or query parameter to be used.", semanticSecurityDefinitions3: "apiKey authorization must have required 'name' string param. The name of the header or query parameter to be used.", // security-definitions.js:66: "oauth2 authorization must have required 'flow' string param. Valid values are 'implicit', 'password', 'application' or 'accessCode'", semanticSecurityDefinitions4: "oauth2 authorization must have required 'flow' string param. Valid values are 'implicit', 'password', 'application' or 'accessCode'", // security-definitions.js:73: "oauth2 authorization implicit flow must have required 'authorizationUrl' parameter.", semanticSecurityDefinitions5: "oauth2 authorization implicit flow must have required 'authorizationUrl' parameter.", // security-definitions.js:81: "oauth2 authorization accessCode flow must have required 'authorizationUrl' and 'tokenUrl' string parameters.", semanticSecurityDefinitions6: "oauth2 authorization accessCode flow must have required 'authorizationUrl' and 'tokenUrl' string parameters.", // security-definitions.js:89: "oauth2 authorization password flow must have required 'tokenUrl' string parameter.", semanticSecurityDefinitions7: "oauth2 authorization password flow must have required 'tokenUrl' string parameter.", // security-definitions.js:97: "oauth2 authorization application flow must have required 'tokenUrl' string parameter.", semanticSecurityDefinitions8: "oauth2 authorization application flow must have required 'tokenUrl' string parameter.", // security-definitions.js:106: "'scopes' is required property type object. The available scopes for the OAuth2 security scheme.", semanticSecurityDefinitions9: "'scopes' is required property type object. The available scopes for the OAuth2 security scheme.", // security.js:23: "security requirements must match a security definition", semanticSecurity1: "security requirements must match a security definition", // security.js:37: `Security scope definition ${scope} could not be resolved`, semanticSecurity2: 'Security scope definition ${scope} could not be resolved', // walker.js:27: "\"type\" should be a string" semanticWalker1: "type {{prefix0}} should be a string", // walker.js:39: "Minimum cannot be more than maximum" semanticWalker2: 'Minimum cannot be more than maximum - {{prefix0}}', // walker.js:48: "minProperties cannot be more than maxProperties" semanticWalker3: 'minProperties cannot be more than maxProperties - {{prefix0}}', // walker.js:57: "minLength cannot be more than maxLength" semanticWalker4: 'minLength cannot be more than maxLength - {{prefix0}}', // walker.js:76: `${path[path.length - 2]} $refs cannot match any of the following: ${humanFriendlyRefBlacklist}` // semanticWalker5: '${path[path.length - 2]} $refs cannot match any of the following: ${humanFriendlyRefBlacklist}', // walker.js:89: "$ref paths must begin with `#/`" semanticWalker6: '$ref {{prefix0}} must begin with "#/"', // walker.js:108: "Values alongside a $ref will be ignored." semanticWalker7: 'Values alongside a $ref will be ignored.', stringMaxLength: '{{type2}} {{prefix0}} must have <= {{schema.maxLength}} characters', stringMinLength: '{{type2}} {{prefix0}} must have >= {{schema.minLength}} characters', stringPattern: '{{type2}} {{prefix0}} must match regexp pattern {{schema.pattern jsonStringify}}' }; local.templateApiDict = { "crudCountManyByQuery": { "_method": "GET", "_path": "/{{_tags0}}/crudCountManyByQuery", "parameters": [ { "default": "{\"id\":{\"$exists\":true}}", "description": "query param", "format": "json", "in": "query", "name": "_queryWhere", "type": "string" } ], "summary": "count many {{_schemaName}} objects by query" }, "crudErrorDelete": { "_method": "DELETE", "_path": "/{{_tags0}}/crudErrorDelete", "responses": { "500": { "description": "500 error - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "return error response" }, "crudErrorGet": { "_method": "GET", "_path": "/{{_tags0}}/crudErrorGet", "responses": { "500": { "description": "500 error - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "return error response" }, "crudErrorHead": { "_method": "HEAD", "_path": "/{{_tags0}}/crudErrorHead", "responses": { "500": { "description": "500 error - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "return error response" }, "crudErrorLogin": { "_method": "GET", "_path": "/{{_tags0}}/crudErrorLogin", "responses": { "500": { "description": "500 error - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "login by password" }, "crudErrorOptions": { "_method": "OPTIONS", "_path": "/{{_tags0}}/crudErrorOptions", "responses": { "500": { "description": "500 error - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "return error response" }, "crudErrorPatch": { "_method": "PATCH", "_path": "/{{_tags0}}/crudErrorPatch", "responses": { "500": { "description": "500 error - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "return error response" }, "crudErrorPost": { "_method": "POST", "_path": "/{{_tags0}}/crudErrorPost", "responses": { "500": { "description": "500 error - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "return error response" }, "crudErrorPre": { "_method": "GET", "_path": "/{{_tags0}}/crudErrorPre", "responses": { "500": { "description": "500 error - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "return error response" }, "crudErrorPut": { "_method": "PUT", "_path": "/{{_tags0}}/crudErrorPut", "responses": { "500": { "description": "500 error - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "return error response" }, "crudGetManyByQuery": { "_method": "GET", "_path": "/{{_tags0}}/crudGetManyByQuery", "parameters": [ { "default": "{\"id\":{\"$exists\":true}}", "description": "query param", "format": "json", "in": "query", "name": "_queryWhere", "required": true, "type": "string" }, { "default": null, "description": "projection-fields param", "format": "json", "in": "query", "name": "_queryFields", "type": "string", "x-swgg-collectionFormat": "json", "x-swgg-items": { "type": "string" }, "x-swgg-type": "array" }, { "default": 20, "description": "cursor-limit param", "in": "query", "name": "_queryLimit", "required": true, "type": "integer" }, { "default": 0, "description": "cursor-skip param", "in": "query", "name": "_querySkip", "type": "integer" }, { "default": [ { "fieldName": "id" }, { "fieldName": "_timeUpdated", "isDescending": true } ], "description": "cursor-sort param", "format": "json", "in": "query", "name": "_querySort", "type": "string", "x-swgg-collectionFormat": "json", "x-swgg-items": { "type": "object" }, "x-swgg-type": "array" } ], "responses": { "200": { "description": "200 ok - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "get many {{_schemaName}} objects by query" }, "crudGetOneById": { "_idName": "{{_idName}}", "_method": "GET", "_path": "/{{_tags0}}/crudGetOneById.{{_idName}}.{{_idBackend}}", "parameters": [ { "description": "{{_schemaName}} {{_idName}}", "in": "query", "name": "{{_idName}}", "required": true, "type": "string" } ], "responses": { "200": { "description": "200 ok - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "get one {{_schemaName}} object by {{_idName}}" }, "crudGetOneByQuery": { "_method": "GET", "_path": "/{{_tags0}}/crudGetOneByQuery", "parameters": [ { "default": "{\"id\":{\"$exists\":true}}", "description": "query param", "format": "json", "in": "query", "name": "_queryWhere", "required": true, "type": "string" } ], "responses": { "200": { "description": "200 ok - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "get one {{_schemaName}} object by query" }, "crudNullDelete": { "_method": "DELETE", "_path": "/{{_tags0}}/crudNullDelete", "responses": { "200": { "description": "200 ok - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "return null response" }, "crudNullGet": { "_method": "GET", "_path": "/{{_tags0}}/crudNullGet", "responses": { "200": { "description": "200 ok - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "return null response" }, "crudNullHead": { "_method": "HEAD", "_path": "/{{_tags0}}/crudNullHead", "responses": { "200": { "description": "200 ok - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "return null response" }, "crudNullOptions": { "_method": "OPTIONS", "_path": "/{{_tags0}}/crudNullOptions", "responses": { "200": { "description": "200 ok - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "return null response" }, "crudNullPatch": { "_method": "PATCH", "_path": "/{{_tags0}}/crudNullPatch", "responses": { "200": { "description": "200 ok - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "return null response" }, "crudNullPost": { "_method": "POST", "_path": "/{{_tags0}}/crudNullPost", "responses": { "200": { "description": "200 ok - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "return null response" }, "crudNullPut": { "_method": "PUT", "_path": "/{{_tags0}}/crudNullPut", "responses": { "200": { "description": "200 ok - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "return null response" }, "crudRemoveManyByQuery": { "_method": "DELETE", "_path": "/{{_tags0}}/crudRemoveManyByQuery", "parameters": [ { "default": "{\"id\":\"undefined\"}", "description": "query param", "format": "json", "in": "query", "name": "_queryWhere", "required": true, "type": "string" } ], "responses": { "200": { "description": "200 ok - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "remove many {{_schemaName}} objects by query" }, "crudRemoveOneById": { "_idName": "{{_idName}}", "_method": "DELETE", "_path": "/{{_tags0}}/crudRemoveOneById.{{_idName}}.{{_idBackend}}", "parameters": [ { "description": "{{_schemaName}} {{_idName}}", "in": "query", "name": "{{_idName}}", "required": true, "type": "string" } ], "summary": "remove one {{_schemaName}} object by {{_idName}}" }, "crudSetManyById": { "_method": "PUT", "_path": "/{{_tags0}}/crudSetManyById", "parameters": [ { "description": "{{_schemaName}} object", "in": "body", "name": "body", "required": true, "schema": { "items": { "$ref": "#/definitions/{{_schemaName}}" }, "type": "array" } } ], "responses": { "200": { "description": "200 ok - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "create or replace many {{_schemaName}} objects" }, "crudSetOneById": { "_idName": "{{_idName}}", "_method": "PUT", "_path": "/{{_tags0}}/crudSetOneById.{{_idName}}.{{_idBackend}}", "parameters": [ { "description": "{{_schemaName}} {{_idName}}", "in": "query", "name": "{{_idName}}", "type": "string" }, { "description": "{{_schemaName}} object", "in": "body", "name": "body", "required": true, "schema": { "$ref": "#/definitions/{{_schemaName}}" } } ], "responses": { "200": { "description": "200 ok - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "create or replace one {{_schemaName}} object by {{_idName}}" }, "crudUpdateOneById": { "_idName": "{{_idName}}", "_method": "PATCH", "_path": "/{{_tags0}}/crudUpdateOneById.{{_idName}}.{{_idBackend}}", "parameters": [ { "description": "{{_schemaName}} {{_idName}}", "in": "query", "name": "{{_idName}}", "type": "string" }, { "description": "{{_schemaName}} object", "in": "body", "name": "body", "required": true, "schema": { "$ref": "#/definitions/{{_schemaName}}" }, "x-swgg-notRequired": true } ], "responses": { "200": { "description": "200 ok - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "create or update one {{_schemaName}} object by {{_idName}}" }, "fileGetOneById": { "_idName": "{{_idName}}", "_method": "GET", "_path": "/{{_tags0}}/fileGetOneById.{{_idName}}.{{_idBackend}}", "parameters": [ { "description": "{{_schemaName}} {{_idName}}", "in": "query", "name": "{{_idName}}", "required": true, "type": "string" } ], "responses": { "200": { "description": "200 ok - http://jsonapi.org/format/#document-structure-top-level", "schema": { "type": "file" } } }, "summary": "get one {{_schemaName}} file by {{_idName}}", "x-swgg-consumes0": "application/octet-stream" }, "fileUploadManyByForm": { "_fileUploadNumber": "{{_fileUploadNumber}}", "_method": "POST", "_path": "/{{_tags0}}/fileUploadManyByForm.{{_fileUploadNumber}}", "consumes": [ "multipart/form-data" ], "parameters": [ { "description": "{{_schemaName}} file description", "in": "formData", "name": "fileDescription", "type": "string" }, { "description": "{{_schemaName}} file to upload by form", "in": "formData", "name": "file1", "type": "file" } ], "responses": { "200": { "description": "200 ok - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "upload many {{_schemaName}} files by form", "x-swgg-consumes0": "multipart/form-data" }, "userLoginByPassword": { "_method": "GET", "_path": "/{{_tags0}}/userLoginByPassword", "parameters": [ { "description": "The user name for login", "in": "query", "name": "username", "required": true, "type": "string" }, { "description": "The password for login in clear text", "in": "query", "name": "password", "required": true, "type": "string" } ], "responses": { "200": { "description": "200 ok - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "login by password" }, "userLogout": { "_method": "GET", "_path": "/{{_tags0}}/userLogout", "responses": { "200": { "description": "200 ok - http://jsonapi.org/format/#document-structure-top-level", "schema": { "$ref": "#/definitions/BuiltinJsonapiResponse" } } }, "summary": "logout" } } ; // JSON.stringify templateApiDict items to prevent side-effects Object.keys(local.templateApiDict).forEach(function (key) { local.templateApiDict[key] = JSON.stringify(local.templateApiDict[key]); }); // https://swaggerhub.com/wp-content/uploads/2017/10/Swagger-Icon.svg local.templateSwaggerUiLogoMediumBase64 = '\ iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAMAAAAL34HQAAAC6FBMVEUAAABqn0BqmUBumUBtmj9tmUBt\ mT9tmkBtmj9tmT9tmUBsmkBsmUBtmj9smkBsmUBsmT9tm0BtmkFvmTxsnEFtmT9smT9smUBtmT9tmkBs\ mkBtmkBsmj9tmz+AgABqmj9smT9tmUBtmkBsmkBsmj9tm0BVqlVgn0BtmkBsmj9tmUBxnDltkkltmD5s\ mT9tmj9smkBtmUFsmEBsmUBtmkBtmT9vnUEA/wBsmj5smkBsmkBmmTNtmj5smj9smT9rmz9smT9smj9t\ mj9um0Fvmz1tmj9qmz5wmT1smj9smkBtmj9mmTNsmT9tmkBrmj9tmEFtmT9smkBtmUBsmUBtmD9roUNt\ mT9smkCAv0Bsm0Bqnj5tmz5smUBrmUBtmkBsmj9smkBtmT9smUBtmkBsmUBtmUBsmkFsnTttmkBwl0Bt\ mkBtmT9tmUCRs2+kwIe2zZ92oEyauXttmkBrmkDj7Nv///+/0qt/p1htmj+JrWTa5s/I2bdtmT9pljxt\ mkCkwIj2+fObunxsmEB0okZsmUBtmT9Vqittmj9rmkGtx5TS4MRumj7b5tDt8+j2+fSStHBrmEFsmT/k\ 7Ny2zKBtmT5um0Ftmj9umD5smj9tmj9tmkBsmT9tmkBsmj9smT9tmj9smT5tnD5smj9tmT9smUBtmUJs\ mEDI2bhrmD/R38Nsmj+sxpNtmz9/pljt8ue1zJ+IrWSauXyjv4dsmT5tmT9rmj+txpS/06xrmj9sm0Bs\ mT+Rs3C2zaBsmkBtmUBsmUBtmkBrmUBsmkFinTttmUBsmkBtpDdqnEBsmkBsmT9smD9tmUBtmD1smT9t\ mUBtmUBolzpsmT9umj9smz5tmT9qlUBumT9tnj2txpNsmT9rmjxrnEJtmT9smj9rmUFsmUBtmT9smT9r\ mT1rmD5smkBxqjltmT9smUBtmT9tmkBtm0BsmUBsmUBmmURtmUBsmT9smkBsmj9unEBrmz5tmUBtmT9s\ m0Bvm0OD9tkQAAAA+HRSTlMAGDxkgYyWn6myvL+vnYt4ZlQ/Hjt6pcvx/9SwiT0CNXa39Pe9OAMIW7Zs\ EgdS9fmsSzSg6IonAU7EuAVi1sFFVd7KTy7JKRn+/I0KfeNRL9pv+PBNE7mQBEAdXntrk4anraODgGdH\ Gu8gzM6P//////+ITP/////y////5hG7////Vwvn4QZ+K///Vv////9Dzf//RjPFJZLqpJ5grqrtLTFt\ buwjXP85/0n/Wf///////1ppef//cn+Z//+Xm4d3X1MNw3QOJM/pYdwq7nOUFt1dIXUMQRX/xiYfkdk3\ UP36Mj6cCfYo1asc89cP6+Lg5SxKcL5jF9reEmcAAAc2SURBVHgB7NGDYQNAAAXQX9v8sW2ntt0Gtfdf\ oQOUl0Oqt8ID8O9fS2tbe0dnV3dPb1//wODQ8MjoGJprfGJyappvsFhtw3Y0gcPpcnv4Ia9vwh+AQcGQ\ dZpf4glHojAiFu9OUEAylQ5At0w2QWG5fAEaFUtlNmjGD01m5+YpYWEROiwtU9LKKlRbK1OB9Q2otJnd\ ohLbO7tQJbjnoTL7B1Dj8IhKhcegwPEJFTs9g6xKlRrU6pBynqMW6xeQcLlFYfojr6jRNRp0Q61u0YjA\ HTXLQlywSu3u6xDlpgHVXQgppmiE2wERXTTkAQIeacwTvuyZBoXwwrxdfbltxFEcnzLTU88tMzMzMzMz\ k7PaZhWvvG1ll+3KUrNhLjvMTOU2KTP/L0WtZGfvaH6Nxj77ee5Rv7EmI82MInT2JeigSx9SIg8/go7a\ 71HRNPoYOuxxyTryCWgVhnX9B5BzCoXuru5CAXpPKqPh0BjW4yYAOXdAz4giuEuM2yiP9oLySq6bIyvW\ 54B66mmV7RlQvuvayHLLFVC7q0zPgvLcvFkJH1Tmeui558EUy/ayXA/MCy8qvZtB9bgWs0qgXlJaL18K\ pujazNLcxutuUzqPgarazaqBOkZpvALBPQz+ATkEf6u7zRxQuslrN1COmwgjbCQ/dBMRqF0VdQq4iP8t\ EiJzTBXcq4oZCa6S3kDk0O8OGAVuW0WMhsYofj0hcpkaNMaQrLHm61XsZAXQuFcNchJ0avqxajnrknFq\ QydCJ+hYFsarDU1od5YvmI1P2Msw4O1nRYIsnK1aTRwaWZNUi8v3h5ZrJ8uRZPW2bpZMRtuzQLJMr4NT\ hkrWVNVsWgeyAklW78kq9Rr0nI5m4XWVekP2N6iIPGqirDdV6hhZFmBnmo+Eg2uaKCvsRNZbGY9p/iYf\ IJcKWWQQbydZR8rfk3KIZO9t78hOKwLD1eRkf777+QNRv+6p2MoqI8M9fH2on7Y85BOIZprzkqyjRa9J\ Iaxl+dB7RMVug56T3sMGcqrKBtfhcdZ06M1wrQ0tFGXX2jvOmgnAvAdYx//ndM8q0KVi2YPWDXHWbFrU\ 1dVX4hstc2bNmFuaNx8tFvSVSjMWtkaN+LdgVvOEmugrQGNRnLWYz6Kt+jFgfrwJN6u5IL7ZJYcMyxlk\ 0Gc8N3aOs5YIssJiU1VsKXk7KLFbtgyxYijIWh5n7WHOCj3yJy47yR0k93qBS/5DLzRnrYizVmqzyAbS\ fDbclrmJRvoDplaBdvGsHcmzh2b1O0gsdVOryZgJ2DhagIRTM2WtibPWmrJ6HL5Dvywrq0F/LaCPZNGT\ 9SeMN7HsiW9ijfU75KmhzdqSnbXyIV9mQz6ckzXknZD834s95iH/bpz1njnLLacTRJg1QQTAoNbQSVLn\ uuasneKsO0H4QUh3+ZOucCkGD+TAGfzy0T8fzTc7UQ8aFRCL46z3wTmVgD98/EZQWz0HLRYsC4KGjxZz\ ljaCZT5dRIVVmB4+H0ArSn+yucgtvYX9RWgNF7zYeBZfbCrkUZZxbPAhMjTyLXz4parI8Kh+g5L9XGXk\ VBYtz49WAz5ChrqVnRH5scPIJGutbEejamux35B9dfNxvqsROU5DliRZM+W/vZWsKjKcn2R9ggyRlZlL\ fhryqUqsk81cyCUQZa2nR+eE/ayi8Duzq2RZXgf2Tj9TqcMxVHaacZvgmLrzWZ+rZncPlayVqtkXHcia\ K8k6VrVYNzQOV77cS7X4SnI5v+1ZX6tW31wiuNwoO1l1aB3IvyfrSFYAnW/Vhr5rd5bHswyf7J6+Hhqh\ naxI8Pb9vRrkB/N8E7T5EOMANdiPve3N8s2vWz8p4m5wo+y8cDWM099Yxfx8NCjfynzqlY0vIjMVtcZ4\ zlnuxsYp/JJWhdolD7fJUcJvIZfl+jawof/WgLvC9BIeC9rwJSV+VTovvgDGt5vlgLn0N6W1C6i6zaxR\ oC5TGc4CE1nMqoF6/mCV4aJLwPjWsvodULuoTHuAqlrKCjRVpymD80B5gYWsegXcfr8L/nkBFzXCPFlh\ sMx39PuSRkdCqxhVR40aVYkc2PWHEpiEv9qDZ4BcozAAwO+1zffatpndkq0p7UPTv+U929qz7bHlt5mx\ tscP55z4PIwlhgAH3jJkKj4OOKkcR5bsgSP5R2SnHDhTeCArncBDEzJyCnhpQSY+/QR+viIDr4G3KKTu\ bgrw14WUnQRBwpVIkUcXCPRZhdSoroBg6lGkJEkDInhrkYr/gyCO8ziSl68DsY70IWH6BiDg57FiJOm/\ AcgIvOCBpOibXwIxNUYkw2QGkl40WVA8qwZIm4q+jeLE+74ACmw3plG4mUc2oERXNovCOGUCVaHaD8jX\ h7yjQJ2uSqJE7vzOZ+qAjbcNX+eQC0/JPxswNT8R9BS38vF35+cB2AnZC76TQY64zu1beTeuwk67VnNl\ 8V7M0tkzp0+dPHF8+f4KHDoEq3MUjwHy2w4OAAAAAElFTkSuQmCC\ '; // https://github.com/swagger-api/swagger-ui/blob/v2.1.3/dist/images/logo_small.png local.templateSwaggerUiLogoSmallBase64 = '\ iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFn\ ZVJlYWR5ccllPAAAAqRJREFUeNrEVz1s00AUfnGXii5maMXoEUEHVwIpEkPNgkBdMnQoU5ytiKHJwpp2\ Q2JIO8DCUDOxIJFIVOoWZyJSh3pp1Q2PVVlcCVBH3ufeVZZ9Zye1Ay86nXV+ue/9fO/lheg/Se02X1rv\ ksmbnTiKvuxQMBNgBnN4a/LCbmnUAP6JV58NCUsBC8CuAJxGPF47OgNqBaA93tolUhnx6jC4NxGwyOEw\ lccyAs+3kwdzKq0HDn2vEBTi8J2XpyMaywNDE157BhXUE3zJhlq8GKq+Zd2zaWHepPA8oN9XkfLmRdOi\ JV4XUUg/IyWncLjCYY/SHndV2u7zHr3bPKZtdxgboJOnthvrfGj/oMf3G0r7JVmNlLfKklmrt2MvvcNO\ 7LFOhoFHfuAJI5o6ta10jpt5CQLgwXhXG2YIwvu+34qf78ybOjWTnWwkgR36d7JqJOrW0hHmNrKg9xhi\ S4+1jFmrxymh03B0w+6kURIAu3yHtOD5oaUNojMnGgbcctNvwdAnyxvxRR+/vaJnjzbpzcZX+nN1SdGv\ 85i9eH8w3qPO+mdm/y4dnQ1iI8Fq6Nf4cxL6GWSjiFDSs0VRnxC5g0xSB2cgHpaseTxfqOv5uoHkNQ6H\ a/N1Yz9mNMppEkEkYKj79q6uCq4bCHcSX3fJ0Vk/k9siASjCm1N6gZH6Ec9IXt2WkFES2K/ixoIyktJP\ Au/ptOA1SgO5zqtr6KASJPF0nMV8dgMsRhRPOcMwqQAOoi0VAIMLAEWJ6YYC1c8ibj1GP51RqwzYwZVM\ HQuvOzMCBUtb2tGHx5NAdLKqp5AX7Ng4d+Zi8AGDI9z1ijx9yaCH04y3GCP2S+QcvaGl+pcxyUBvinFl\ awoDQjHSelX8hQEoIrAq8p/mgC88HOS1YCl/BRgAmiD/1gn6Nu8AAAAASUVORK5CYII=\ '; // https://github.com/swagger-api/swagger-ui/blob/v2.1.3/src/main/template/main.handlebars local.templateUiMain = '\ <!-- <div class="swggUiContainer"> -->\n\ <h2 class="eventDelegateSubmit hXxx thead" data-onevent="onEventUiReload">\n\ <a class="td td1" href="https://github.com/kaizhu256/node-swgg" target="_blank">swgg</a>\n\ <input\n\ class="td td2"\n\ placeholder="http://petstore.swagger.io/v2/swagger.json"\n\ type="text"\n\ value="{{urlSwaggerJson}}"\n\ >\n\ <input\n\ class="td td3"\n\ id="swggApiKeyInput1"\n\ placeholder="api-key"\n\ type="text"\n\ value="{{apiKeyValue}}"\n\ >\n\ <button class="button eventDelegateClick td td4" data-onevent="onEventUiReload">explore</button>\n\ <button\n\ class="button eventDelegateClick td td5" data-onevent="onEventUiReload"\n\ id="buttonSwggApiKeyClear1"\n\ >\n\ clear api-keys\n\ </button>\n\ </h2>\n\ <div\n\ class="colorError"\n\ id="swggUiReloadErrorDiv1"\n\ style="background: none; border: 0;"\n\ ></div>\n\ <div class="eventDelegateClick info reset">\n\ {{#if info}}\n\ {{#if info.x-swgg-homepage}}\n\ <h2 class="hXxx">\n\ <a href="{{info.x-swgg-homepage}}" target="_blank">{{info.title}} ({{info.version}})</a>\n\ </h2>\n\ {{#unless info.x-swgg-homepage}}\n\ <h2 class="hXxx">{{info.title}} ({{info.version}})</h2>\n\ {{/if info.x-swgg-homepage}}\n\ {{#if info.x-swgg-description}}\n\ <div class="markdown">{{info.x-swgg-description markdownToHtml}}</div>\n\ {{/if info.x-swgg-description}}\n\ {{#if info.description}}\n\ <div class="description markdown">{{info.description markdownToHtml}}</div>\n\ {{/if info.description}}\n\ {{#if x-swgg-downloadStandaloneApp}}\n\ <a class="button" download href="{{x-swgg-downloadStandaloneApp notHtmlSafe}}">\n\ download standalone app\n\ </a><br>\n\ {{/if x-swgg-downloadStandaloneApp}}\n\ {{#if x-swgg-onEventDomDb}}\n\ <button class="button" data-onevent="onEventDomDb" data-onevent-db="dbReset">reset database</button><br>\n\ <button class="button" data-onevent="onEventDomDb" data-onevent-db="dbExport">export database -> file</button><br>\n\ <button class="button" data-onevent="onEventDomDb" data-onevent-db="dbImport">import database <- file</button><br>\n\ {{/if x-swgg-onEventDomDb}}\n\ <ul>\n\ {{#if externalDocs.url}}\n\ <li>\n\ <a href="{{externalDocs.url}}" target="_blank">\n\ {{#if externalDocs.description}}\n\ {{externalDocs.description}}\n\ {{#unless externalDocs.description}}\n\ external url\n\ {{/if externalDocs.description}}\n\ </a>\n\ </li>\n\ {{/if externalDocs.url}}\n\ {{#if info.termsOfService}}\n\ <li><a target="_blank" href="{{info.termsOfService}}">terms of service</a></li>\n\ {{/if info.termsOfService}}\n\ {{#if info.contact.name}}\n\ <li>created by {{info.contact.name}}</li>\n\ {{/if info.contact.name}}\n\ {{#if info.contact.url}}\n\ <li>see more at <a href="{{info.contact.url}}">{{info.contact.url}}</a></li>\n\ {{/if info.contact.url}}\n\ {{#if info.contact.email}}\n\ <li>\n\ <a\n\ target="_parent"\n\ href="mailto:{{info.contact.email}}?subject={{info.title}}"\n\ >\n\ contact the developer\n\ </a>\n\ </li>\n\ {{/if info.contact.email}}\n\ {{#if info.license}}\n\ <li><a target="_blank" href="{{info.license.url}}">{{info.license.name}}</a></li>\n\ {{/if info.license}}\n\ </ul>\n\ {{/if info}}\n\ </div>\n\ {{#if urlSwaggerJson}}\n\ <h4 class="label">nodejs initialization</h4>\n\ <pre id="swggAjaxProgressPre1" tabIndex="0">\n\ /*\n\ * initialize nodejs swgg-client\n\ * 1. download currently-loaded apis to file swagger.json:\n\ * $ curl -L -o swagger.json "{{urlSwaggerJson}}"\n\ * 2. npm install swgg\n\ * $ npm install swgg\n\ * 3. run code below to initialize nodejs swgg-client\n\ * 4. (optional) edit file swagger.json to suit your needs\n\ */\n\ let swgg;\n\ swgg = require("swgg");\n\ swgg.apiUpdate(require("./swagger.json"));\n\ console.log("printing currently loaded apis ...");\n\ Object.keys(swgg.apiDict).sort().forEach(function (key) {\n\ console.log("swgg.apiDict[" + JSON.stringify(key) + "].ajax");\n\ });\n\ console.log("initialized nodejs swgg-client");\n\ </pre>\n\ <div class="color777 reset">[ <span>base url</span>: {{basePath}} ]</div>\n\ {{/if urlSwaggerJson}}\n\ <div id="swggAjaxProgressDiv1" style="text-align: center;">\n\ <span>{{ajaxProgressText}}</span>\n\ <div class="uiAnimateSpin" style="animation: uiAnimateSpin 2s linear infinite; border: 5px solid #999; border-radius: 50%; border-top: 5px solid #7d7; display: inline-block; height: 25px; vertical-align: middle; width: 25px;"></div>\n\ </div>\n\ <ol class="reset resourceList" style="list-style-type: upper-roman;"></ol>\n\ <div style="text-align: center;">\n\ [\n\ this document was created with\n\ <a\n\ href="https://github.com/kaizhu256/node-swgg" target="_blank"\n\ >swgg</a>\n\ ]\n\ </div>\n\ <!-- </div> -->\n\ '; // https://github.com/swagger-api/swagger-ui/blob/v2.1.3/src/main/template/operation.handlebars local.templateUiOperation = '\ <div class="operation" data-_method-path="{{_methodPath}}" id="{{id}}">\n\ <div class="thead" data-onevent="onEventOperationDisplayShow" tabindex="0">\n\ <span class="td td1"></span>\n\ <span class="method{{_method}} td td2">{{_method}}</span>\n\ <span\n\ class="td td3"\n\ {{#if deprecated}}style="text-decoration: line-through;"{{/if deprecated}}\n\ >\n\ {{_path}}\n\ </span>\n\ <span class="color777 td td4 textOverflowEllipsis">{{summary}}</span>\n\ </div>\n\ <form accept-charset="UTF-8"\n\ class="onEventInputValidateAndAjax uiAnimateSlide"\n\ style="border-bottom: 0; border-top: 0; margin-bottom: 0; margin-top: 0; max-height: 0; padding-bottom: 0; padding-top: 0;"\n\ >\n\ {{#if deprecated}}\n\ <h4 class="colorError label">(warning: deprecated)</h4><br>\n\ {{/if deprecated}}\n\ <h4 class="label">description</h4>\n\ <div class="description markdown">\n\ {{description markdownToHtml}}\n\ </div>\n\ {{#if parameters.length}}\n\ <h4 class="label">parameters</h4>\n\ <div class="borderBottom1Px color777 schemaP thead">\n\ <span class="td td1">name and description</span>\n\ <span class="td td2">data type</span>\n\ <span class="td td3">value</span>\n\ <span class="td td4">schema</span>\n\ </div>\n\ {{#each parameters}}\n\ {{innerHTML notHtmlSafe}}\n\ {{/each parameters}}\n\ {{/if parameters.length}}\n\ <h4 class="label">response messages</h4>\n\ <div class="borderBottom1Px color777 schemaResponse thead">\n\ <span class="td td1">http status code</span>\n\ <span class="td td2">reason</span>\n\ </div>\n\ {{#each responseList}}\n\ <div class="schemaResponse tr">\n\ <span class="td td1">{{key}}</span>\n\ <span class="markdown td td2">{{value.description markdownToHtml}}</span>\n\ </div>\n\ {{/each responseList}}\n\ <button class="button" data-onevent="onEventOperationAjax">try it out!</button>\n\ <h4 class="label">nodejs request</h4>\n\ <pre class="reqJs" tabIndex="0"></pre>\n\ <h4 class="label">curl request</h4>\n\ <pre class="reqCurl" tabIndex="0"></pre>\n\ <h4 class="label">response status code</h4>\n\ <pre class="resStatusCode" tabindex="0"></pre>\n\ <h4 class="label">response headers</h4>\n\ <pre class="resHeaders" tabIndex="0"></pre>\n\ <h4 class="label">response body</h4>\n\ <pre class="resBody" tabIndex="0"></pre>\n\ <div class="resMedia"></div>\n\ </form>\n\ </div>\n\ '; // https://github.com/swagger-api/swagger-ui/blob/v2.1.3/src/main/template/param.handlebars local.templateUiParameter = '\ <div class="schemaP tr" id="{{id}}" data-name="{{name}}">\n\ <span class="td td1">\n\ {{name}}\n\ {{#if required}}<br><span style="font-weight: bold;">(required)</span>{{/if required}}\n\ {{#if description}}\n\ <br>\n\ <span class="color777 markdown">{{description markdownToHtml}}</span>\n\ {{/if description}}\n\ </span>\n\ <span class="td td2">{{type2}}{{#if format2}}<br>({{format2}}){{/if format2}}</span>\n\ <span class="td td3" data-onevent="onEventInputValidateAndAjax">\n\ {{#if isTextarea}}\n\ <div class="multilinePlaceholderContainer">\n\ <pre class="multilinePlaceholderPre">{{placeholder}}</pre>\n\ <textarea\n\ class="input multilinePlaceholderTextarea textarea" data-onevent="onEventInputTextareaChange"\n\ data-value-text="{{valueText encodeURIComponent notHtmlSafe}}"\n\ ></textarea>\n\ </div>\n\ {{/if isTextarea}}\n\ {{#if isFile}}<input class="input" type="file">{{/if isFile}}\n\ {{#if enum2}}\n\ <select class="input" {{#if isSelectMultiple}}multiple{{/if isSelectMultiple}}>\n\ {{#each selectOptionList}}\n\ <option\n\ data-value-select-option=\n\ "{{valueSelectOption jsonStringify encodeURIComponent notHtmlSafe}}"\n\ id="{{id}}"\n\ {{selected}}\n\ >{{placeholder}}</option>\n\ {{/each selectOptionList}}\n\ </select>\n\ {{/if enum2}}\n\ {{#if isInputNumber}}\n\ <input\n\ class="input"\n\ data-value-text="{{valueText encodeURIComponent notHtmlSafe}}"\n\ placeholder="{{placeholder}}"\n\ type="number"\n\ >\n\ {{/if isInputNumber}}\n\ {{#if isInputText}}\n\ <input\n\ class="input"\n\ data-value-text="{{valueText encodeURIComponent notHtmlSafe}}"\n\ placeholder="{{placeholder}}"\n\ type="text"\n\ >\n\ {{/if isInputText}}\n\ <div class="colorError"></div>\n\ </span>\n\ <span class="td td4">\n\ {{#if schemaText}}<pre tabIndex="0">{{schemaText}}</pre>{{/if schemaText}}\n\ </span>\n\ </div>\n\ '; local.templateUiReqJs = '\ /*\n\ * reproduce api-call {{opt.api._methodPath jsonStringify}}\n\ * 1. initialize nodejs swgg-client from previous step\n\ * 2. run code below to reproduce api-call\n\ */\n\ swgg.apiDict[{{opt.api._methodPath jsonStringify}}].ajax({{optionJson}}, \ function (err, data) {\n\ if (err) {\n\ console.error(err);\n\ return;\n\ }\n\ console.log(data.responseJson || data.responseText);\n\ }\ );\n\ '; // https://github.com/swagger-api/swagger-ui/blob/v2.1.3/src/main/template/resource.handlebars local.templateUiResource = '\ <li\n\ class="eventDelegateChange eventDelegateClick eventDelegateKeyup eventDelegateSubmit resource"\n\ data-name="{{name}}"\n\ id="{{id}}"\n\ >\n\ <h3 class="thead">\n\ <span class="td td1 textOverflowEllipsis" data-onevent="onEventResourceDisplayAction" tabindex="0">\n\ {{name}}: {{summary}}\n\ </span>\n\ <span class="td td2" data-onevent="onEventResourceDisplayAction" tabindex="0">\n\ expand / collapse operations\n\ </span>\n\ </h3>\n\ <ol\n\ class="operationList uiAnimateSlide"\n\ style="border-bottom: 0; border-top: 0; margin-bottom: 0; margin-top: 0; max-height: 0; padding-bottom: 0; padding-top: 0;"\n\ >\n\ <div class="description markdown">{{description markdownToHtml}}</div>\n\ </ol>\n\ </li>\n\ '; local.templateUiTitle = '\ {{#if info.title}}\n\ {{#if info.version}}\n\ {{info.title}} ({{info.version}})\n\ {{#unless info.version}}\n\ {{info.title}}\n\ {{/if info.version}}\n\ {{#unless info.title}}\n\ swgg\n\ {{/if info.title}}\n\ '; /* validateLineSortedReset */ local.assetsDict["/assets.swgg.html"] = local.assetsDict["/assets.utility2.template.html"] .replace("assets.utility2.template.html", "") .replace((/<title>.*?<\/title>/), "<title>swgg</title>") .replace("\n<!-- utility2-comment\n", "\n") .replace("\n</style>\n", '\ \n\ </style>\n\ <style>\n\ /* jslint utility2:true */\n\ /*csslint\n\ */\n\ /* csslint ignore:start */\n\ .swggUiContainer,\n\ .swggUiContainer * {\n\ border: 0;\n\ border-radius: 0;\n\ margin: 0;\n\ max-width: 100%;\n\ padding: 0;\n\ }\n\ .swggUiContainer pre,\n\ .swggUiContainer .operation > .thead:focus,\n\ .swggUiContainer .resource > .thead > .td:focus {\n\ outline: none;\n\ }\n\ .swggUiContainer .description > * {\n\ margin-top: 20px;\n\ }\n\ .swggUiContainer .description > *:first-child {\n\ margin-top: 0;\n\ }\n\ /* csslint ignore:end */\n\ /* validateLineSortedReset */\n\ /* general */\n\ .swggUiContainer code,\n\ .swggUiContainer pre,\n\ .swggUiContainer textarea {\n\ line-height: 1.25rem;\n\ max-height: 50rem;\n\ overflow: auto;\n\ }\n\ .swggUiContainer input,\n\ .swggUiContainer pre,\n\ .swggUiContainer textarea {\n\ min-height: 1.5rem;\n\ }\n\ .swggUiContainer pre {\n\ white-space: pre;\n\ }\n\ .swggUiContainer .button,\n\ .swggUiContainer .operation > .thead,\n\ .swggUiContainer .resource > .thead {\n\ cursor: pointer;\n\ }\n\ .swggUiContainer .button,\n\ .swggUiContainer .operation > .thead > .td3,\n\ .swggUiContainer .resource > .thead > .td {\n\ font-weight: bold;\n\ text-decoration: underline;\n\ }\n\ .swggUiContainer .markdown pre {\n\ max-height: none;\n\ }\n\ .swggUiContainer .multilinePlaceholderContainer {\n\ min-height: 10rem;\n\ position: relative;\n\ }\n\ .swggUiContainer .multilinePlaceholderPre {\n\ position: absolute;\n\ white-space: pre;\n\ }\n\ .swggUiContainer .multilinePlaceholderTextarea {\n\ position: absolute;\n\ }\n\ .swggUiContainer .operation > .thead > .td1 {\n\ text-align: left;\n\ width: 2rem;\n\ }\n\ .swggUiContainer .operation > .thead > .td2 {\n\ text-align: center;\n\ width: 5rem;\n\ }\n\ .swggUiContainer .resBody,\n\ .swggUiContainer .resHeaders,\n\ .swggUiContainer .resStatusCode {\n\ font-weight: bold;\n\ }\n\ .swggUiContainer .schemaP pre,\n\ .swggUiContainer .schemaP select[multiple],\n\ .swggUiContainer .schemaP textarea,\n\ .swggUiContainer .schemaP .multilinePlaceholderContainer {\n\ height: 10rem;\n\ }\n\ .swggUiContainer .schemaP > .td3 {\n\ overflow: visible;\n\ }\n\ .swggUiContainer .td {\n\ overflow: auto;\n\ overflow-wrap: break-word;\n\ }\n\ .swggUiContainer .td input,\n\ .swggUiContainer .td pre,\n\ .swggUiContainer .td select,\n\ .swggUiContainer .td textarea {\n\ width: 100%;\n\ }\n\ .swggUiContainer .zeroPixel {\n\ border: 0;\n\ height: 0;\n\ margin: 0;\n\ padding: 0;\n\ width: 0;\n\ }\n\ /* validateLineSortedReset */\n\ /* background */\n\ .swggUiContainer code,\n\ .swggUiContainer pre {\n\ background: #ddd;\n\ }\n\ .swggUiContainer .button {\n\ background: #ddf;\n\ }\n\ .swggUiContainer .description {\n\ background: #bdb;\n\ }\n\ .swggUiContainer .methodDELETE {\n\ background: #b07;\n\ }\n\ .swggUiContainer .methodGET {\n\ background: #373;\n\ }\n\ .swggUiContainer .methodHEAD {\n\ background: #7b7;\n\ }\n\ .swggUiContainer .methodOPTIONS {\n\ background: #777;\n\ }\n\ .swggUiContainer .methodPATCH {\n\ background: #99f;\n\ }\n\ .swggUiContainer .methodPOST {\n\ background: #33d;\n\ }\n\ .swggUiContainer .methodPUT {\n\ background: #77d;\n\ }\n\ .swggUiContainer .multilinePlaceholderPre {\n\ background: #fff;\n\ }\n\ .swggUiContainer .operation {\n\ background: #dfd;\n\ }\n\ .swggUiContainer .resource > .thead,\n\ .swggUiContainer > .thead {\n\ background: #7b7;\n\ }\n\ .swggUiContainer > .info > .button {\n\ width: 20rem;\n\ }\n\ .swggUiContainer > .thead > .td1 {\n\ background: transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAqRJREFUeNrEVz1s00AUfnGXii5maMXoEUEHVwIpEkPNgkBdMnQoU5ytiKHJwpp2Q2JIO8DCUDOxIJFIVOoWZyJSh3pp1Q2PVVlcCVBH3ufeVZZ9Zye1Ay86nXV+ue/9fO/lheg/Se02X1rvksmbnTiKvuxQMBNgBnN4a/LCbmnUAP6JV58NCUsBC8CuAJxGPF47OgNqBaA93tolUhnx6jC4NxGwyOEwlccyAs+3kwdzKq0HDn2vEBTi8J2XpyMaywNDE157BhXUE3zJhlq8GKq+Zd2zaWHepPA8oN9XkfLmRdOiJV4XUUg/IyWncLjCYY/SHndV2u7zHr3bPKZtdxgboJOnthvrfGj/oMf3G0r7JVmNlLfKklmrt2MvvcNO7LFOhoFHfuAJI5o6ta10jpt5CQLgwXhXG2YIwvu+34qf78ybOjWTnWwkgR36d7JqJOrW0hHmNrKg9xhiS4+1jFmrxymh03B0w+6kURIAu3yHtOD5oaUNojMnGgbcctNvwdAnyxvxRR+/vaJnjzbpzcZX+nN1SdGv85i9eH8w3qPO+mdm/y4dnQ1iI8Fq6Nf4cxL6GWSjiFDSs0VRnxC5g0xSB2cgHpaseTxfqOv5uoHkNQ6Ha/N1Yz9mNMppEkEkYKj79q6uCq4bCHcSX3fJ0Vk/k9siASjCm1N6gZH6Ec9IXt2WkFES2K/ixoIyktJPAu/ptOA1SgO5zqtr6KASJPF0nMV8dgMsRhRPOcMwqQAOoi0VAIMLAEWJ6YYC1c8ibj1GP51RqwzYwZVMHQuvOzMCBUtb2tGHx5NAdLKqp5AX7Ng4d+Zi8AGDI9z1ijx9yaCH04y3GCP2S+QcvaGl+pcxyUBvinFlawoDQjHSelX8hQEoIrAq8p/mgC88HOS1YCl/BRgAmiD/1gn6Nu8AAAAASUVORK5CYII=) no-repeat left center;\n\ }\n\ /* validateLineSortedReset */\n\ /* border */\n\ .swggUiContainer input,\n\ .swggUiContainer pre,\n\ .swggUiContainer select,\n\ .swggUiContainer textarea {\n\ border: 1px solid #999;\n\ }\n\ .swggUiContainer .borderBottom1Px {\n\ border-bottom: 1px solid #777;\n\ }\n\ .swggUiContainer .button {\n\ border: 1px solid #35b;\n\ border-radius: 5px;\n\ }\n\ .swggUiContainer .resource > .thead > .td2 {\n\ border-left: 1px solid #333;\n\ }\n\ /* validateLineSortedReset */\n\ /* color */\n\ .swggUiContainer a,\n\ .swggUiContainer .button,\n\ .swggUiContainer .operation > .thead,\n\ .swggUiContainer .resource > .thead {\n\ color: #35b;\n\ }\n\ .swggUiContainer code {\n\ color: #333;\n\ }\n\ .swggUiContainer .color777 {\n\ color: #777;\n\ }\n\ .swggUiContainer .label {\n\ color: #373;\n\ }\n\ .swggUiContainer .multilinePlaceholderPre {\n\ color: #999;\n\ }\n\ .swggUiContainer .operation > .thead > .td2,\n\ .swggUiContainer .resource > .thead,\n\ .swggUiContainer > .thead > .td1 {\n\ color: #fff;\n\ }\n\ .swggUiContainer .thead,\n\ .swggUiContainer .tr {\n\ display: flex;\n\ }\n\ /* validateLineSortedReset */\n\ /* flex */\n\ .swggUiContainer .operation > .thead > .td3 {\n\ flex: 1;\n\ }\n\ .swggUiContainer .operation > .thead > .td4 {\n\ flex: 1;\n\ }\n\ .swggUiContainer .resource > .thead > .td1 {\n\ flex: 1;\n\ }\n\ .swggUiContainer .schemaP > .td1 {\n\ flex: 2;\n\ }\n\ .swggUiContainer .schemaP > .td2 {\n\ flex: 1;\n\ }\n\ .swggUiContainer .schemaP > .td3 {\n\ flex: 4;\n\ }\n\ .swggUiContainer .schemaP > .td4 {\n\ flex: 3;\n\ }\n\ .swggUiContainer .schemaResponse > .td1 {\n\ flex: 1;\n\ }\n\ .swggUiContainer .schemaResponse > .td2 {\n\ flex: 4;\n\ }\n\ .swggUiContainer > .thead > .td2 {\n\ flex: 4;\n\ }\n\ .swggUiContainer > .thead > .td3 {\n\ flex: 1;\n\ }\n\ /* validateLineSortedReset */\n\ /* margin */\n\ .swggUiContainer li {\n\ margin-top: 10px;\n\ }\n\ .swggUiContainer ol,\n\ .swggUiContainer ul,\n\ .swggUiContainer .td {\n\ margin-left: 20px;\n\ }\n\ .swggUiContainer .description,\n\ .swggUiContainer .label,\n\ .swggUiContainer .operation,\n\ .swggUiContainer .operation > form > div,\n\ .swggUiContainer .operation > form > pre,\n\ .swggUiContainer .resource,\n\ .swggUiContainer > div,\n\ .swggUiContainer > ol,\n\ .swggUiContainer > pre,\n\ .swggUiContainer > .info > div,\n\ .swggUiContainer > .info > ul,\n\ .swggUiContainer > .info > .button,\n\ .swggUiContainer > .info > .hXxx {\n\ margin-top: 20px;\n\ }\n\ .swggUiContainer .label {\n\ margin-bottom: -19px;\n\ }\n\ .swggUiContainer .operation > form > .button {\n\ margin: 40px 0 20px 0;\n\ }\n\ .swggUiContainer .resource > ol,\n\ .swggUiContainer .resource > .thead > .td,\n\ .swggUiContainer .td:first-child,\n\ .swggUiContainer > ol {\n\ margin-left: 0;\n\ }\n\ .swggUiContainer .resource > ol > .description {\n\ margin-top: 0;\n\ }\n\ /* validateLineSortedReset */\n\ /* padding */\n\ .swggUiContainer code {\n\ padding: 2px;\n\ }\n\ .swggUiContainer input {\n\ padding: 0 5px;\n\ }\n\ .swggUiContainer pre,\n\ .swggUiContainer textarea {\n\ padding: 5px;\n\ }\n\ .swggUiContainer .button,\n\ .swggUiContainer .resource > .thead > .td,\n\ .swggUiContainer > .thead {\n\ padding: 10px 20px;\n\ }\n\ .swggUiContainer .description {\n\ padding: 20px;\n\ }\n\ .swggUiContainer .operation > form {\n\ padding: 0 20px;\n\ }\n\ .swggUiContainer .operation > form .td1 {\n\ padding-left: 0;\n\ }\n\ .swggUiContainer .operation > .thead {\n\ padding: 0 20px;\n\ }\n\ .swggUiContainer .operation > .thead > .td {\n\ padding: 10px 0;\n\ }\n\ .swggUiContainer > .thead > .td1 {\n\ padding-left: 40px;\n\ padding-top: 4px;\n\ }\n\ /* validateLineSortedReset */\n\ /* .textOverflowEllipsis */\n\ .swggUiContainer .textOverflowEllipsis {\n\ overflow: hidden;\n\ text-overflow: ellipsis;\n\ white-space: nowrap;\n\ }\n\ /* validateLineSortedReset */\n\ /* @media */\n\ @media screen and (max-width: 640px) {\n\ .swggUiContainer .operation {\n\ font-size: small;\n\ }\n\ .swggUiContainer .resource > .thead > .td {\n\ flex: 1;\n\ }\n\ .swggUiContainer > .thead {\n\ display: block;\n\ padding: 0;\n\ }\n\ .swggUiContainer > .thead > .td {\n\ display: block;\n\ margin: 0;\n\ width: 100%;\n\ }\n\ }\n\ /* validateLineSortedReset */\n\ /* hover */\n\ .swggUiContainer a:hover,\n\ .swggUiContainer .resource > .thead > .td:hover,\n\ .swggUiContainer > .thead > .td1:hover {\n\ color: #037;\n\ }\n\ .swggUiContainer .button:hover,\n\ .swggUiContainer .operation > .thead:hover {\n\ background: #bbf;\n\ }\n\ /* validateLineSortedReset */\n\ /* err */\n\ .swggUiContainer button.hasError,\n\ .swggUiContainer pre.hasError,\n\ .swggUiContainer textarea.hasError {\n\ background: #fbb;\n\ }\n\ .swggUiContainer input.hasError,\n\ .swggUiContainer select.hasError {\n\ border: 5px solid #d00;\n\ }\n\ </style>\n\ ').replace(( /\n<\/script>\n[\S\s]*\n<\/html>\n/ ), '\ \n\ </script>\n\ <div class="swggUiContainer" style="margin: 0 auto; max-width: 1200px;">\n\ ' + local.templateRender(local.templateUiMain, { ajaxProgressText: "loading script", apiKeyValue: "", urlSwaggerJson: "" }) + '\ </div>\n\ <script>\n\ /* jslint utility2:true */\n\ // init domOnEventMediaHotkeys\n\ (function () {\n\ /*\n\ * this function will add media-hotkeys to elements\n\ * with class=".domOnEventMediaHotkeysInit"\n\ */\n\ "use strict";\n\ let currentTarget;\n\ let identity;\n\ let input;\n\ let onEvent;\n\ if (window.domOnEventMediaHotkeys) {\n\ return;\n\ }\n\ identity = function (value) {\n\ /*\n\ * this function will return <value>\n\ */\n\ return value;\n\ };\n\ window.domOnEventMediaHotkeys = function (evt) {\n\ let media;\n\ if (evt === "init") {\n\ document.querySelectorAll(\n\ ".domOnEventMediaHotkeysInit"\n\ ).forEach(function (media) {\n\ media.classList.remove("domOnEventMediaHotkeysInit");\n\ media.classList.add("domOnEventMediaHotkeys");\n\ [\n\ "play", "pause", "seeking"\n\ ].forEach(function (evt) {\n\ media.addEventListener(evt, onEvent);\n\ });\n\ });\n\ return;\n\ }\n\ if (evt.currentTarget.classList.contains("domOnEventMediaHotkeys")) {\n\ currentTarget = evt.currentTarget;\n\ input.focus();\n\ return;\n\ }\n\ media = currentTarget;\n\ try {\n\ switch (evt.key || evt.type) {\n\ case ",":\n\ case ".":\n\ media.currentTime += (\n\ evt.key === "," && identity(-0.03125)\n\ ) || 0.03125;\n\ break;\n\ case "<":\n\ case ">":\n\ media.playbackRate *= (\n\ evt.key === "<" && identity(0.5)\n\ ) || 2;\n\ break;\n\ case "ArrowDown":\n\ case "ArrowUp":\n\ media.volume += (\n\ evt.key === "ArrowDown" && identity(-0.05)\n\ ) || 0.05;\n\ break;\n\ case "ArrowLeft":\n\ case "ArrowRight":\n\ media.currentTime += (\n\ evt.key === "ArrowLeft" && identity(-5)\n\ ) || 5;\n\ break;\n\ case "j":\n\ case "l":\n\ media.currentTime += (evt.key === "j" && identity(-10)) || 10;\n\ break;\n\ case "k":\n\ case " ":\n\ if (media.paused) {\n\ media.play();\n\ } else {\n\ media.pause();\n\ }\n\ break;\n\ case "m":\n\ media.muted = !media.muted;\n\ break;\n\ default:\n\ if (evt.key >= 0) {\n\ media.currentTime = 0.1 * evt.key * media.duration;\n\ break;\n\ }\n\ return;\n\ }\n\ } catch (ignore) {}\n\ evt.preventDefault();\n\ };\n\ onEvent = window.domOnEventMediaHotkeys;\n\ input = document.createElement("button");\n\ input.style = (\n\ "border:0;height:0;margin:0;padding:0;position:fixed;width:0;"\n\ + "z-index:-1;"\n\ );\n\ input.addEventListener("click", onEvent);\n\ input.addEventListener("keydown", onEvent);\n\ document.body.appendChild(input);\n\ onEvent("init");\n\ }());\n\ \n\ \n\ \n\ document.querySelector(\n\ ".swggUiContainer > .thead > .td2"\n\ ).value = ((\n\ /\\bmodeSwaggerJsonUrl=([^&]+)|$/gm\n\ ).exec(location.search)[1] || "assets.swgg.swagger.json");\n\ </script>\n\ <script src="assets.utility2.rollup.js"></script>\n\ <script>\n\ /* jslint utility2:true */\n\ window.local = window.local || window.swgg;\n\ window.swgg.uiEventListenerDict.onEventUiReload({\n\ swggInit: true\n\ });\n\ </script>\n\ <!-- swgg-script-extra-begin -->\n\ <!-- swgg-script-extra-end -->\n\ </body>\n\ </html>\n\ '); /* jslint ignore:end */ local.assetsDict[ "/assets.swgg.swagger.schema.json" ] = local.jsonStringifyOrdered( local.objectSetOverride( JSON.parse(local.assetsDict["/assets.swgg.json-schema.json"].replace(( /"\$ref":".*?#/g ), "\"$ref\":\"http://json-schema.org/draft-04/schema#")), JSON.parse(local.assetsDict["/assets.swgg.schema.json"].replace(( /"\$ref":".*?#/g ), "\"$ref\":\"http://json-schema.org/draft-04/schema#")), 2 ) ); local.swaggerSchemaJson = JSON.parse( local.assetsDict["/assets.swgg.swagger.schema.json"] ); }()); // run shared js-env code - function (function () { local.apiAjax = function (that, opt, onError) { /* * this function will send a swagger-api ajax-req with the operation that */ let tmp; local.objectSetDefault(opt, { data: "", operation: that, paramDict: {}, url: "" }); if (opt.modeDefault) { local.normalizeSwaggerParamDict(opt); } // try to validate paramDict opt.err = local.swaggerValidateDataParameters({ // normalize paramDict data: local.normalizeSwaggerParamDict({ modeNoDefault: opt.modeNoDefault, operation: that, paramDict: local.jsonCopy(opt.paramDict) }).paramDict, dataReadonlyRemove: opt.paramDict, prefix: [ "operation", that._methodPath ], parameters: that.parameters, swaggerJson: local.swaggerJson })[0]; // init default local.objectSetDefault(opt, { inForm: ( that._consumes0 === "multipart/form-data" ? new local.FormData() : "" ), inHeader: {}, inPath: that._path.replace(( /#.*?$/ ), ""), inQuery: "", headers: {}, method: that._method, responseType: ( that._consumes0.indexOf("application/octet-stream") === 0 ? "arraybuffer" : "" ) }); // init paramDict that.parameters.forEach(function (schemaP) { tmp = opt.paramDict[schemaP.name]; if (local.isNullOrUndefined(tmp)) { return; } // serialize array if (Array.isArray(tmp) && schemaP.in !== "body") { switch ( schemaP.collectionFormat || schemaP["x-swgg-collectionFormat"] ) { case "json": tmp = JSON.stringify(tmp); break; case "multi": tmp.forEach(function (value) { opt[( schemaP.in === "formData" ? "inForm" : "inQuery" )] += ( "&" + encodeURIComponent(schemaP.name) + "=" + encodeURIComponent( local.schemaPItemsType(schemaP) === "string" ? value : JSON.stringify(value) ) ); }); return; case "pipes": tmp = tmp.join("|"); break; case "ssv": tmp = tmp.join(" "); break; case "tsv": tmp = tmp.join("\t"); break; // default to csv default: tmp = tmp.join(","); } } else if ( typeof tmp !== "string" && !(tmp && tmp.constructor === local.Blob) ) { tmp = JSON.stringify(tmp); } switch (schemaP.in) { case "body": opt.inBody = tmp; break; case "formData": switch (that._consumes0) { case "application/xml": // init xml header if (!opt.inForm) { opt.inForm += "<?xml version=\"1.0\"?>"; } opt.inForm += ( "\n<" + schemaP.name + ">" + "<![CDATA[" + tmp.replace(( /\]\]>/g ), "]]>") + "]]></" + schemaP.name + ">" ); break; case "multipart/form-data": opt.inForm.append(schemaP.name, tmp, tmp && tmp.name); break; default: if (opt.inForm) { opt.inForm += "&"; } opt.inForm += ( encodeURIComponent(schemaP.name) + "=" + encodeURIComponent(tmp) ); } break; case "header": opt.inHeader[encodeURIComponent(schemaP.name.toLowerCase())] = tmp; break; case "path": opt.inPath = opt.inPath.replace( "{" + schemaP.name + "}", encodeURIComponent(tmp) ); break; case "query": opt.inQuery += ( "&" + encodeURIComponent(schemaP.name) + "=" + encodeURIComponent(tmp) ); break; } }); // init data opt.data = opt.inBody || opt.inForm; // init headers local.objectSetOverride(opt.headers, opt.inHeader); // init headers - Content-Type opt.headers["Content-Type"] = that._consumes0; // init headers - Authorization opt.jwtEncrypted = opt.jwtEncrypted || local.userJwtEncrypted; if (opt.jwtEncrypted) { opt.headers.Authorization = ( opt.headers.Authorization || "Bearer " + opt.jwtEncrypted ); } // init url opt.url = ""; opt.url += ( local.value( that["x-swgg-schemes"] || local.swaggerJson.schemes || [] )[0] || local.urlParse("").protocol.slice(0, -1) ); opt.url += "://"; opt.url += ( that["x-swgg-host"] || local.swaggerJson.host || local.urlParse("").host ); opt.url += local.swaggerJsonBasePath; opt.url += opt.inPath + "?" + opt.inQuery.slice(1); opt.url = opt.url.replace(( /\?$/ ), ""); if (opt.modeAjax === "validate" || (opt.err && opt.modeAjax !== "ajax")) { onError(opt.err); return; } opt.err = null; // send ajax-req return local.ajax(opt, function (err, xhr) { // try to init responseJson local.tryCatchOnError(function () { xhr.responseJson = JSON.parse(xhr.responseText); }, local.nop); // init userJwtEncrypted local.userJwtEncrypted = ( xhr.resHeaders["swgg-jwt-encrypted"] || local.userJwtEncrypted ); onError(err, xhr); }); }; local.apiUpdate = function (swaggerJson) { /* * this function will update the swagger-api dict of api-calls */ let pathDict; let tmp; swaggerJson = swaggerJson || {}; // normalize swaggerJson swaggerJson = local.normalizeSwaggerJson(swaggerJson, { objectSetDescription: function (dict) { if (typeof dict === "object" && dict && !dict.$ref) { if (Array.isArray(dict["x-swgg-descriptionLineList"])) { dict.description = ( dict["x-swgg-descriptionLineList"].join("\n") ); } if (!( dict === swaggerJson.externalDocs || dict === swaggerJson.info )) { dict.description = dict.description || "no description"; } } } }); // init apiDict local.apiDict = local.apiDict || {}; // init swaggerJson local.swaggerJson = local.swaggerJson || { "basePath": "/api/v0", "definitions": { "BuiltinFile": { "properties": { "_id": { "readOnly": true, "type": "string" }, "_timeCreated": { "format": "date-time", "readOnly": true, "type": "string" }, "_timeUpdated": { "format": "date-time", "readOnly": true, "type": "string" }, "fileBlob": { "format": "byte", "type": "string" }, "fileContentType": { "type": "string" }, "fileDescription": { "type": "string" }, "fileFilename": { "type": "string" }, "fileInputName": { "type": "string" }, "fileSize": { "minimum": 0, "type": "integer" }, "fileUrl": { "type": "string" }, "id": { "type": "string" } } }, "BuiltinJsonapiResponse": { "properties": { "data": { "items": { "type": "object" }, "type": "array" }, "errors": { "items": { "type": "object" }, "type": "array" }, "meta": { "type": "object" } } }, "BuiltinUser": { "properties": { "_id": { "readOnly": true, "type": "string" }, "_timeCreated": { "format": "date-time", "readOnly": true, "type": "string" }, "_timeUpdated": { "format": "date-time", "readOnly": true, "type": "string" }, "id": { "type": "string" }, "jwtEncrypted": { "type": "string" }, "password": { "format": "password", "type": "string" }, "username": { "type": "string" } } } }, "info": { "title": "swgg api", "version": "0.0.1" }, "paths": {}, "securityDefinitions": {}, "swagger": "2.0", "tags": [] }; // save tags tmp = {}; [ local.swaggerJson.tags, swaggerJson.tags ].forEach(function (tagList) { tagList.forEach(function (tag) { tmp[tag.name] = local.objectSetOverride(tmp[tag.name], tag); }); }); local.swaggerJson["x-swgg-tagNameList"] = Object.keys(tmp).sort(); tmp = local.swaggerJson["x-swgg-tagNameList"].map(function (key) { return tmp[key]; }); // merge swaggerJson into local.swaggerJson swaggerJson = local.objectSetOverride(local.swaggerJson, swaggerJson, 10); // restore tags local.swaggerJson.tags = tmp; // init swaggerJsonBasePath local.swaggerJsonBasePath = ( local.swaggerJson.basePath === "/" ? "" : local.swaggerJson.basePath ); Object.keys(swaggerJson.definitions).forEach(function (schemaName) { swaggerJson.definitions[schemaName] = local.jsonCopy( local.swaggerValidateDataSchema({ // dereference definition modeDereference: true, prefix: [ "swaggerJson", "definitions", schemaName ], schema: swaggerJson.definitions[schemaName], swaggerJson: local.swaggerJson }) ); tmp = swaggerJson.definitions[schemaName]; local.valueOrEmptyList(tmp.allOf).forEach(function (element) { local.objectSetDefault( tmp, local.jsonCopy(local.swaggerValidateDataSchema({ // dereference definition.allOf modeDereference: true, prefix: [ "swaggerJson", "definitions", schemaName, "allOf" ], schema: element, swaggerJson: local.swaggerJson })), 2 ); }); delete tmp.allOf; }); // init apiDict from paths Object.keys(swaggerJson.paths).forEach(function (path) { Object.keys(swaggerJson.paths[path]).forEach(function (method) { let that; that = local.jsonCopy(swaggerJson.paths[path][method]); that._method = method.toUpperCase(); that._path = path; tmp = "operationId." + that.operationId; local.apiDict[tmp] = local.objectSetOverride( local.apiDict[tmp], that ); }); }); // init apiDict from x-swgg-apiDict Object.keys(swaggerJson["x-swgg-apiDict"] || {}).forEach(function (key) { local.apiDict[key] = local.objectSetOverride( local.apiDict[key], local.jsonCopy(swaggerJson["x-swgg-apiDict"][key]) ); }); // init apiDict Object.keys(local.apiDict).forEach(function (key) { let that; if (key.indexOf("operationId.") !== 0) { return; } key = key.split("."); that = local.apiDict[key.join(".")]; // init operationId that.operationId = that.operationId || key.slice(1).join("."); // init _crudType that._crudType = that._crudType || key.slice(2); that._crudType[0] = that._crudType[0] || that.operationId; // init _fileUploadNumber that._fileUploadNumber = Number( that._crudType[0] === "fileUploadManyByForm" && that._crudType[1] ) || 1; // init _idBackend and _idName tmp = local.idNameInit({ crudType: that._crudType }); that._idBackend = tmp.idBackend; that._idName = tmp.idName; // init tags that.tags = that.tags || []; that.tags[0] = that.tags[0] || key[1]; // init templateApiDict if (local.templateApiDict[that._crudType[0]]) { local.objectSetDefault( that, JSON.parse(local.templateApiDict[that._crudType[0]].replace(( /\{\{_fileUploadNumber\}\}/g ), that._fileUploadNumber).replace(( /\{\{_idBackend\}\}/g ), that._idBackend).replace(( /\{\{_idName\}\}/g ), that._idName).replace(( /\{\{_operationId\}\}/g ), that.operationId).replace(( /\{\{_schemaName\}\}/g ), that._schemaName).replace(( /\{\{_tags0\}\}/g ), that.tags[0])) ); } // init default local.objectSetDefault(that, { _schemaPDict: {}, consumes: [], parameters: [], responses: { "200": { description: ( "ok - http://jsonapi.org/format/#document-top-level" ), schema: { $ref: "#/definitions/BuiltinJsonapiResponse" } } }, tags: [] }); // init _consumes0 tmp = that["x-swgg-consumes0"] || (that.consumes && that.consumes[0]); that.parameters.some(function (schemaP) { tmp = tmp || ( schemaP.in === "body" && schemaP.schema.type === "string" && local.value("text/plain") ); return tmp; }); that._consumes0 = tmp || "application/json"; // init _methodPath that._methodPath = that._method + " " + that._path.replace(( /\{.*?\}/g ), "{}"); that.parameters.forEach(function (schemaP) { // dereference schemaP String(schemaP["x-swgg-$ref"] || schemaP.$ref).replace(( /#\/parameters\/(.+?$)/m ), function (ignore, match1) { local.objectSetDefault( schemaP, local.jsonCopy(swaggerJson.parameters[match1]) ); delete schemaP.$ref; }); // init _idName.format and _idName.type if (that._schemaName && schemaP.name === that._idName) { schemaP.format = swaggerJson.definitions[ that._schemaName ].properties[that._idBackend].format; schemaP.type = local.schemaPType( swaggerJson.definitions[ that._schemaName ].properties[that._idBackend] ); } // init _schemaPDict that._schemaPDict[schemaP.name] = schemaP; }); // init required [ that["x-swgg-notRequired"], that["x-swgg-required"] ].forEach(function (element, ii) { local.valueOrEmptyList(element).forEach(function (name) { that._schemaPDict[name].required = Boolean(ii); }); }); switch (that._crudType[0]) { // add extra file-upload forms case "fileUploadManyByForm": tmp = 1; while (tmp <= that._fileUploadNumber) { that.parameters[tmp] = local.jsonCopy(that.parameters[1]); that.parameters[tmp].name = "file" + tmp; tmp += 1; } break; } // update apiDict that = local.jsonCopy(that); local.apiDict[key.join(".")] = that; local.apiDict[that._methodPath] = that; // init ajax that.ajax = function (swaggerJson, onError) { return local.apiAjax(that, swaggerJson, onError); }; that._ajaxToString = that.ajax.toString().replace("{", String( "{\n" + "/*\n" + " * this function will run the api-call " + JSON.stringify(that._methodPath) + "\n" + " * example usage:" + String( "\n" + "swgg.apiDict[" + JSON.stringify(key.join(".")) + "].ajax(" + JSON.stringify(local.normalizeSwaggerParamDict({ modeDefault: true, operation: that, paramDict: {} }).paramDict, null, 4) + ", function (err, data) {\n" + " if (err) {\n" + " console.error(err);\n" + " return;\n" + " }\n" + " console.log(data.responseJson" + " || data.responseText);\n" + "});" ).replace(( /\n/g ), "\n ") + "\n */" ).replace(( /\n/g ), "\n ")); that.ajax.toString = function () { return that._ajaxToString; }; // remove underscored keys from that tmp = local.jsonCopy(that); Object.keys(tmp).forEach(function (key) { if (key[0] === "_") { tmp[key] = undefined; } }); // update paths pathDict = {}; pathDict[that._path] = {}; pathDict[that._path][that._method.toLowerCase()] = tmp; local.objectSetOverride(swaggerJson, { paths: pathDict }, 3); }); // normalize swaggerJson local.swaggerJson = JSON.parse(local.jsonStringifyOrdered(swaggerJson)); // try to validate swaggerJson local.tryCatchOnError(function () { local.swaggerValidate(local.swaggerJson); }, local.onErrorDefault); // init corsForwardProxyHost local.corsForwardProxyHost = ( local.corsForwardProxyHost || local.swaggerJson["x-swgg-corsForwardProxyHost"] ); // init assets.swgg.swagger.server.json local.assetsDict["/assets.swgg.swagger.server.json"] = JSON.stringify( local.swaggerJson ); }; local.dbFieldRandomCreate = function (opt) { /* * this function will create a random dbField from <opt>.schemaP */ let depth; let ii; let max; let min; let schemaP; let value; depth = ( Number.isFinite(opt.depth) ? opt.depth : 3 ); schemaP = opt.schemaP; schemaP = schemaP.schema || schemaP; if (schemaP.readOnly) { return; } // init default if (opt.modeNotRandom && !local.isNullOrUndefined(schemaP.default)) { return local.jsonCopy(schemaP.default); } // init enum-value if (schemaP.enum) { value = ( opt.modeNotRandom ? schemaP.enum[0] : local.listGetElementRandom(schemaP.enum) ); return ( local.schemaPType(schemaP) === "array" ? [ value ] : value ); } // init default value = null; switch (local.schemaPType(schemaP)) { // 5.3. Validation keywords for arrays case "array": if (depth <= 0) { break; } value = []; ii = 0; while (ii < Math.min( // 5.3.2. maxItems schemaP.maxItems || 2, // 5.3.3. minItems schemaP.minItems || 2, // 5.3.4. uniqueItems schemaP.uniqueItems ? 2 : 1 )) { // recurse dbFieldRandomCreate value.push(local.dbFieldRandomCreate({ depth: depth - 1, modeNotRandom: opt.modeNotRandom, schemaP: local.schemaPItems(schemaP) })); ii += 1; } break; case "boolean": value = ( opt.modeNotRandom ? false : Boolean(Math.random() > 0.5) ); break; // 5.1. Validation keywords for numeric instances (number and integer) case "integer": case "number": max = schemaP.maximum; min = schemaP.minimum; if (opt.modeNotRandom) { value = ( !(0 < min || max < 0) ? 0 : min || max ); } else { if (!(Number.isFinite(max) && Number.isFinite(min))) { if (!Number.isFinite(max) && !Number.isFinite(min)) { max = 1000; min = 0; } else if (Number.isFinite(max)) { min = max - 1000; } else { max = min + 1000; } } // exclusiveMaximum and exclusiveMinimum for float value = ( min + (max - min) * Math.max(Math.random(), min * 0.000000000000001) ); if (local.schemaPType(schemaP) === "integer") { value = Math.round(value); } } max = schemaP.maximum; min = schemaP.minimum; // exclusiveMaximum for integer if (schemaP.exclusiveMaximum && value === max) { value -= 1; } // exclusiveMinimum for integer if (schemaP.exclusiveMaximum && value === min) { value += 1; } // multipleOf if (schemaP.multipleOf > 0) { value = schemaP.multipleOf * Math.floor(value / schemaP.multipleOf); if (value < min || (schemaP.exclusiveMinimum && value <= min)) { value += schemaP.multipleOf; } } break; // 5.2. Validation keywords for strings case "string": value = ( opt.modeNotRandom ? "abcd1234" : Number( (1 + Math.random()) * 0x10000000000000 ).toString(36).slice(1) ); switch (schemaP.format) { case "byte": value = local.base64FromBuffer(value); break; case "date": case "date-time": value = new Date().toISOString(); break; case "email": value = value + "@example.com"; break; case "json": value = JSON.stringify({ foo: value }); break; case "phone": value = ( opt.modeNotRandom ? "+123 (1234) 1234-1234" : "+" + Math.random().toString().slice(-3) + " (" + Math.random().toString().slice(-4) + ") " + Math.random().toString().slice(-4) + "-" + Math.random().toString().slice(-4) ); break; } while (value.length < schemaP.minLength) { value += value; } value = value.slice(0, schemaP.maxLength || Infinity); break; // 5.4. Validation keywords for objects default: if (depth <= 0) { break; } // recurse dbRowRandomCreate value = local.dbRowRandomCreate({ depth: depth - 1, modeNotRandom: opt.modeNotRandom, prefix: [ "schema<" + JSON.stringify(schemaP) + ">" ], schema: schemaP }); } return value; }; local.dbRowListRandomCreate = function (opt) { /* * this function will create a dbRowList of <opt>.length random dbRow's */ let ii; ii = 0; while (ii < opt.length) { opt.dbRowList.push(local.dbRowRandomCreate(opt)); ii += 1; } return opt.dbRowList; }; local.dbRowRandomCreate = function (opt) { /* * this function will create a random dbRow from opt.properties */ let dbRow; let ii; let properties; dbRow = {}; opt = local.objectSetDefault(opt, { override: local.nop, prefix: [ "dbRow" ] }); properties = local.swaggerValidateDataSchema({ // dereference property modeDereference: true, prefix: opt.prefix, schema: opt.schema, swaggerJson: local.swaggerJson }); properties = local.jsonCopy((properties && properties.properties) || {}); ii = Object.keys(properties).length; while (ii < (opt.schema && opt.schema.minProperties)) { properties["property" + ii] = { type: "string" }; ii += 1; } Object.keys(properties).forEach(function (key) { dbRow[key] = local.dbFieldRandomCreate({ depth: opt.depth, modeNotRandom: opt.modeNotRandom, schemaP: local.swaggerValidateDataSchema({ // dereference property modeDereference: true, prefix: opt.prefix.concat([ key ]), schema: properties[key], swaggerJson: local.swaggerJson }) }); }); dbRow = local.jsonCopy(local.objectSetOverride(dbRow, opt.override(opt))); // try to validate data local.tryCatchOnError(function () { local.swaggerValidateDataSchema({ data: dbRow, prefix: opt.prefix, schema: opt.schema, swaggerJson: local.swaggerJson }); }, local.onErrorDefault); return dbRow; }; local.idDomElementCreate = function (seed) { /* * this function will create a deterministic and unique dom-element id * from <seed> that is both dom-selector and url friendly */ local.idDomElementDict[seed] = (local.idDomElementDict[seed] || 0) + 1; return encodeURIComponent( seed + "_" + local.idDomElementDict[seed] ).replace(( /\W/g ), "_"); }; local.idNameInit = function (opt) { /* * this function will init <opt>.idBackend, <opt>.idName, and <opt>.queryById */ let idBackend; let idName; // init idName idName = opt.crudType[1] || "id"; opt.idName = idName; // init idBackend idBackend = opt.crudType[2] || opt.idName; opt.idBackend = idBackend; // invert queryById if (opt.modeQueryByIdInvert) { idBackend = opt.idName; idName = opt.idBackend; } // init queryById opt.idValue = (opt.data && opt.data[idBackend]) || opt.idValue; opt.queryById = {}; opt.queryById[idName] = opt.idValue; return opt; }; local.middlewareBodyParse = function (req, res, next) { /* * this function will run middleware to parse <req>.bodyRaw */ let boundary; let crlf; let data; let headerParse; let ii; let jj; let name; // if req is already parsed, then goto next if (!req.swgg.operation || !local.isNullOrUndefined(req.swgg.bodyParsed)) { next(); return; } headerParse = function () { local.bufferToUtf8(req.bodyRaw.slice(ii, ii + 1024)).replace(( /^content-disposition:\u0020?form-data;(.+?)\r\n(?:content-type:\u0020?(.*?)$)?/im ), function (ignore, match1, match2) { data = { contentType: match2, name: "" }; match1.replace(( /(\w+)="([^"]+)/g ), function (ignore, match1, match2) { data[match1.toLowerCase()] = match2; }); name = data.name; req.swgg.bodyMeta[name] = data; }); }; switch (req.swgg.operation._consumes0) { // parse application/x-www-form-urlencoded, e.g. // aa=hello%20world&bb=bye%20world case "application/x-www-form-urlencoded": req.swgg.bodyParsed = local.bufferToUtf8(req.bodyRaw); req.swgg.bodyParsed = local.urlParse( "?" + req.swgg.bodyParsed, true ).query; break; case "application/xml": req.swgg.bodyParsed = {}; local.bufferToUtf8(req.bodyRaw).replace(( /<(.+?)><!\[CDATA\[([\S\s]+?)\]\]>/g ), function (name, match1, value) { name = match1; name = decodeURIComponent(name); req.swgg.bodyParsed[name] = ( local.schemaPType( req.swgg.operation._schemaPDict[name] ) === "string" ? value : JSON.parse(value) ); }); break; /* * parse multipart/form-data, e.g. * --Boundary\r\n * Content-Disposition: form-data; name="key"\r\n * \r\n * value\r\n * --Boundary\r\n * Content-Disposition: form-data; name="input1"; filename="file1.png"\r\n * Content-Type: image/jpeg\r\n * \r\n * <data1>\r\n * --Boundary\r\n * Content-Disposition: form-data; name="input2"; filename="file2.png"\r\n * Content-Type: image/jpeg\r\n * \r\n * <data2>\r\n * --Boundary--\r\n * https://tools.ietf.org/html/rfc7578 */ case "multipart/form-data": req.swgg.bodyParsed = {}; req.swgg.bodyMeta = {}; crlf = new Uint8Array([ 0x0d, 0x0a ]); // init boundary ii = 0; jj = local.bufferIndexOfSubBuffer(req.bodyRaw, crlf, ii); if (jj <= 0) { break; } boundary = local.bufferConcat([ crlf, req.bodyRaw.slice(ii, jj) ]); ii = jj + 2; while (true) { jj = local.bufferIndexOfSubBuffer( req.bodyRaw, boundary, ii ); if (jj < 0) { break; } headerParse(); ii = local.bufferIndexOfSubBuffer( req.bodyRaw, [ 0x0d, 0x0a, 0x0d, 0x0a ], ii + 2 ) + 4; data = req.bodyRaw.slice(ii, jj); req.swgg.bodyParsed[name] = data; ii = jj + boundary.length + 2; } break; default: req.swgg.bodyParsed = local.bufferToUtf8(req.bodyRaw); // try to JSON.parse the string local.tryCatchOnError(function () { req.swgg.bodyParsed = JSON.parse(req.swgg.bodyParsed); }, local.nop); } next(null, req, res); }; local.middlewareCrudBuiltin = function (req, res, next) { /* * this function will run middleware to * run the builtin crud-operations backed by db-lite */ let crud; let onParallel; let opt; let tmp; let user; opt = {}; local.gotoNext(opt, function (err, data, meta) { switch (opt.gotoState) { case 1: crud = req.swgg.crud; user = req.swgg.user; switch (crud.crudType[0]) { case "crudCountManyByQuery": crud.dbTable.crudCountManyByQuery( crud.queryWhere, opt.gotoNext ); break; case "crudSetManyById": crud.dbTable.crudSetManyById(crud.body, opt.gotoNext); break; case "crudSetOneById": // replace idName with idBackend in body delete crud.body.id; delete crud.body[crud.idName]; crud.body[crud.idBackend] = crud.data[crud.idName]; crud.dbTable.crudSetOneById(crud.body, opt.gotoNext); break; case "crudUpdateOneById": // replace idName with idBackend in body delete crud.body.id; delete crud.body[crud.idName]; crud.body[crud.idBackend] = crud.data[crud.idName]; crud.dbTable.crudUpdateOneById(crud.body, opt.gotoNext); break; // hack-istanbul - test err handling-behavior case "crudErrorDelete": case "crudErrorGet": case "crudErrorHead": case "crudErrorOptions": case "crudErrorPatch": case "crudErrorPost": case "crudErrorPut": opt.gotoNext(local.errDefault); break; case "crudGetManyByQuery": onParallel = local.onParallel(opt.gotoNext); onParallel.counter += 1; crud.dbTable.crudGetManyByQuery({ fieldList: crud.queryFields, limit: crud.queryLimit, query: crud.queryWhere, skip: crud.querySkip, sort: crud.querySort }, function (err, data) { crud.queryData = data; onParallel(err); }); onParallel.counter += 1; crud.dbTable.crudCountAll(function (err, data) { crud.paginationCountTotal = data; onParallel(err); }); break; case "crudGetOneById": crud.dbTable.crudGetOneById(crud.queryById, opt.gotoNext); break; case "crudGetOneByQuery": crud.dbTable.crudGetOneByQuery({ query: crud.queryWhere }, opt.gotoNext); break; case "crudNullDelete": case "crudNullGet": case "crudNullHead": case "crudNullOptions": case "crudNullPatch": case "crudNullPost": case "crudNullPut": opt.gotoNext(); break; case "crudRemoveManyByQuery": crud.dbTable.crudRemoveManyByQuery( crud.queryWhere, opt.gotoNext ); break; case "crudRemoveOneById": crud.dbTable.crudRemoveOneById(crud.queryById, opt.gotoNext); break; case "fileGetOneById": local.dbTableFile = local.db.dbTableCreateOne({ name: "File" }); crud.dbTable.crudGetOneById(crud.queryById, opt.gotoNext); break; case "fileUploadManyByForm": local.dbTableFile = local.db.dbTableCreateOne({ name: "File" }); req.swgg.paramDict = {}; Object.keys(req.swgg.bodyMeta).forEach(function (key) { if (typeof req.swgg.bodyMeta[key].filename !== "string") { req.swgg.paramDict[key] = local.bufferToUtf8( req.swgg.bodyParsed[key] ); } }); crud.body = Object.keys(req.swgg.bodyMeta).filter(function ( key ) { return typeof req.swgg.bodyMeta[key].filename === "string"; }).map(function (key) { tmp = local.jsonCopy(req.swgg.paramDict); tmp.id = tmp.id || Number( (1 + Math.random()) * 0x10000000000000 ).toString(36).slice(1); local.objectSetOverride(tmp, { fileBlob: local.base64FromBuffer( req.swgg.bodyParsed[key] ), fileContentType: req.swgg.bodyMeta[key].contentType, fileFilename: req.swgg.bodyMeta[key].filename, fileInputName: req.swgg.bodyMeta[key].name, fileSize: req.swgg.bodyParsed[key].length, fileUrl: ( local.swaggerJsonBasePath + "/" + req.swgg.operation.tags[0] + "/fileGetOneById/" + tmp.id ) }); return tmp; }); local.dbTableFile.crudSetManyById(crud.body, opt.gotoNext); break; case "userLoginByPassword": case "userLogout": // respond with 401 Unauthorized if (!user.isAuthenticated) { local.serverRespondHeadSet(req, res, 401, {}); req.swgg.crud.endArgList = [ req, res ]; opt.gotoState = Infinity; opt.gotoNext(); return; } opt.gotoNext(); break; default: opt.gotoState = Infinity; opt.gotoNext(); } break; case 2: switch (crud.crudType[0]) { case "crudSetOneById": case "crudUpdateOneById": opt.gotoNext(null, data); break; case "crudGetManyByQuery": opt.gotoNext(null, crud.queryData, { paginationCountTotal: crud.paginationCountTotal }); break; case "fileUploadManyByForm": opt.gotoNext(null, data.map(function (element) { delete element.fileBlob; return element; })); break; case "userLoginByPassword": opt.gotoNext(null, { jwtEncrypted: user.jwtEncrypted }); break; case "userLogout": crud.dbTable.crudUpdateOneById({ jwtEncrypted: null, username: user.username }, opt.gotoNext); break; default: opt.gotoNext(null, data, meta); } break; case 3: switch (crud.crudType[0]) { case "fileGetOneById": if (!data) { local.serverRespondDefault(req, res, 404); return; } local.serverRespondHeadSet(req, res, null, { "Content-Type": data.fileContentType }); res.end(local.base64ToBuffer(data.fileBlob)); break; case "userLogout": opt.gotoNext(); break; default: opt.gotoNext(null, data, meta); } break; case 4: req.swgg.crud.endArgList = [ req, res, null, data, meta ]; opt.gotoNext(); break; default: next(err); } }); opt.gotoState = 0; opt.gotoNext(); }; local.middlewareCrudEnd = function (req, res, next) { /* * this function will run middleware to end builtin crud-operations */ if (req.swgg.crud.endArgList) { local.serverRespondJsonapi.apply(null, req.swgg.crud.endArgList); return; } next(null, req, res); }; local.middlewareRouter = function (req, res, next) { /* * this function will run middleware to * map the req's method-path to swagger's tags[0]-crudType */ let tmp; // init swgg object local.objectSetDefault(req, { swgg: { crud: { crudType: [] }, user: {} } }, 3); // if req.url is not prefixed with swaggerJsonBasePath, // then default to next if (req.urlParsed.pathname.indexOf(local.swaggerJsonBasePath) !== 0) { next(); return; } // init methodPath req.swgg.methodPath = ( req.method + " " + req.urlParsed.pathname.replace(local.swaggerJsonBasePath, "") ); // init operation while (req.swgg.methodPath !== tmp) { req.swgg.operation = ( local.apiDict[req.swgg.methodPath] // handle /foo/{id}/bar case || local.apiDict[req.swgg.methodPath.replace(( /\/[^\/]+\/([^\/]*?)$/ ), "/{}/$1")] ); // if operation exists, then break if (req.swgg.operation) { req.swgg.operation = local.jsonCopy(req.swgg.operation); // init crud.crudType req.swgg.crud.crudType = req.swgg.operation._crudType; break; } tmp = req.swgg.methodPath; // handle /foo/{id} case req.swgg.methodPath = req.swgg.methodPath.replace(( /\/[^\/]+?(\/*?)$/ ), "/$1{}"); } next(null, req, res); }; local.middlewareUserLogin = function (req, res, next) { /* * this function will run middleware to handle user login */ let crud; let opt; let user; opt = {}; local.gotoNext(opt, function (err, data) { switch (opt.gotoState) { case 1: local.dbTableUser = local.db.dbTableCreateOne({ name: "User" }); crud = req.swgg.crud; user = {}; req.swgg.user = user; user.jwtEncrypted = ( req.headers.authorization && req.headers.authorization.replace("Bearer ", "") ); user.jwtDecrypted = local.jwtAes256GcmDecrypt(user.jwtEncrypted); switch (crud.crudType[0]) { // hack-istanbul - test err handling-behavior case "crudErrorLogin": opt.gotoNext(local.errDefault); return; case "userLoginByPassword": user.password = req.urlParsed.query.password; user.username = req.urlParsed.query.username; if (user.password && user.username) { local.dbTableUser.crudGetOneById({ username: user.username }, opt.gotoNext); return; } break; default: if (user.jwtDecrypted.sub) { // init username user.username = user.jwtDecrypted.sub; local.dbTableUser.crudGetOneById({ username: user.username }, opt.gotoNext); return; } } opt.gotoState = Infinity; opt.gotoNext(); break; case 2: switch (crud.crudType[0]) { case "userLoginByPassword": user.data = data; if (!local.sjclHashScryptValidate( user.password, user.data && user.data.password )) { opt.gotoState = Infinity; opt.gotoNext(); return; } // init isAuthenticated user.isAuthenticated = true; // create JSON Web Token (JWT) // https://tools.ietf.org/html/rfc7519 user.jwtDecrypted = {}; user.jwtDecrypted.sub = user.data.username; // update jwtEncrypted in client user.jwtEncrypted = local.jwtAes256GcmEncrypt( user.jwtDecrypted ); local.serverRespondHeadSet(req, res, null, { "swgg-jwt-encrypted": user.jwtEncrypted }); // update jwtEncrypted in dbTableUser local.dbTableUser.crudUpdateOneById({ jwtEncrypted: user.jwtEncrypted, username: user.jwtDecrypted.sub }, opt.gotoNext); return; default: data = data || {}; user.data = data; if (data.jwtEncrypted) { // init isAuthenticated user.isAuthenticated = true; // update jwtEncrypted in client if (data.jwtEncrypted !== user.jwtEncrypted) { user.jwtEncrypted = data.jwtEncrypted; user.jwtDecrypted = local.jwtAes256GcmDecrypt( user.jwtEncrypted ); local.serverRespondHeadSet(req, res, null, { "swgg-jwt-encrypted": user.jwtEncrypted }); } } } opt.gotoNext(); break; default: next(err); } }); opt.gotoState = 0; opt.gotoNext(); }; local.middlewareValidate = function (req, res, next) { /* * this function will run middleware to validate the swagger-<req> */ let crud; let opt; let tmp; opt = {}; local.gotoNext(opt, function (err) { switch (opt.gotoState) { case 1: if (!req.swgg.operation) { opt.gotoState = Infinity; opt.gotoNext(); return; } // init paramDict req.swgg.paramDict = {}; // parse path param tmp = req.urlParsed.pathname.replace( local.swaggerJsonBasePath, "" ).split("/"); req.swgg.operation._path.split("/").forEach(function (key, ii) { if (( /^\{\S*?\}$/ ).test(key)) { req.swgg.paramDict[key.slice(1, -1)] = ( decodeURIComponent(tmp[ii]) ); } }); req.swgg.operation.parameters.forEach(function (schemaP) { switch (schemaP.in) { // parse body param case "body": req.swgg.paramDict[schemaP.name] = ( req.swgg.bodyParsed || undefined ); break; // parse formData param case "formData": switch (req.swgg.operation._consumes0) { case "application/x-www-form-urlencoded": case "application/xml": req.swgg.paramDict[schemaP.name] = ( req.swgg.bodyParsed[schemaP.name] ); break; } break; // parse header param case "header": req.swgg.paramDict[schemaP.name] = ( req.headers[schemaP.name.toLowerCase()] ); break; // parse query param case "query": req.swgg.paramDict[schemaP.name] = ( req.urlParsed.query[schemaP.name] ); break; } // parse array-multi tmp = req.swgg.paramDict[schemaP.name]; if ( tmp && local.schemaPType(schemaP) === "array" && schemaP.collectionFormat === "multi" ) { req.swgg.paramDict[schemaP.name] = ( encodeURIComponent(schemaP.name) + "=" + ( Array.isArray(tmp) ? tmp : [ tmp ] ).join("&" + encodeURIComponent(schemaP.name) + "=") ); } // init default if ( local.isNullOrUndefined(req.swgg.paramDict[schemaP.name]) && schemaP.default !== undefined ) { req.swgg.paramDict[schemaP.name] = local.jsonCopy( schemaP.default ); } }); // normalize paramDict local.normalizeSwaggerParamDict(req.swgg); // validate paramDict err = local.swaggerValidateDataParameters({ data: req.swgg.paramDict, prefix: [ "operation", req.swgg.methodPath ], parameters: req.swgg.operation.parameters, swaggerJson: local.swaggerJson })[0]; opt.gotoNext(err); break; case 2: // init crud crud = req.swgg.crud; // init crud.dbTable crud.dbTable = ( req.swgg.operation && req.swgg.operation._schemaName && local.db.dbTableCreateOne({ name: req.swgg.operation._schemaName }) ); if (!crud.dbTable) { next(); return; } // init crud.body if (req.swgg.operation._consumes0 !== "multipart/form-data") { crud.body = local.jsonCopy(req.swgg.bodyParsed); } // init crud.data crud.data = local.jsonCopy(req.swgg.paramDict); req.swgg.operation.parameters.forEach(function (schemaP) { // JSON.parse json-string if ( schemaP.format === "json" && local.schemaPType(schemaP) === "string" && crud.data[schemaP.name] ) { crud.data[schemaP.name] = JSON.parse( crud.data[schemaP.name] ); } }); // init crud.query* [ { key: "queryFields", value: {} }, { key: "queryLimit", value: 100 }, { key: "querySkip", value: 0 }, { key: "querySort", value: [ { fieldName: "id" }, { fieldName: "_timeUpdated", isDescending: true } ] }, { key: "queryWhere", value: {} } ].forEach(function (element) { crud[element.key] = crud.data["_" + element.key] || JSON.parse( local.templateRender( req.swgg.operation["_" + element.key] || "null", req.swgg.paramDict, { notHtmlSafe: true } ) ) || element.value; }); // init-before crud.idName crud.modeQueryByIdInvert = true; local.idNameInit(crud); // init crud.data.id switch (crud.crudType[0]) { case "crudSetOneById": case "crudUpdateOneById": if (!local.isNullOrUndefined(crud.data[crud.idName])) { break; } crud.data[crud.idName] = ( crud.body && crud.body[crud.idBackend] ); break; } // init-after crud.idName crud.modeQueryByIdInvert = true; local.idNameInit(crud); next(); break; default: next(err, req, res); } }); opt.gotoState = 0; opt.gotoNext(); }; local.normalizeSwaggerJson = function (swaggerJson, opt) { /* * this function will normalize swaggerJson and filter $npm_package_swggTags0 */ let pathDict; let tmp; opt = local.objectSetDefault(opt, { objectSetDescription: function (dict) { if ( dict && dict.description && Array.isArray(dict["x-swgg-descriptionLineList"]) ) { delete dict.description; } } }); local.objectSetDefault(swaggerJson, { paths: {}, tags: [] }); // fix err - semanticPaths2 pathDict = {}; Object.keys(swaggerJson.paths).forEach(function (path) { tmp = path.replace(( /\{.*?\}/g ), "{}"); pathDict[tmp] = pathDict[tmp] || {}; pathDict[tmp][path] = true; }); Object.keys(pathDict).forEach(function (key) { Object.keys(pathDict[key]).sort().forEach(function (path, ii) { // fix err.semanticUniquePath if (ii && swaggerJson["x-swgg-fixErrorSemanticUniquePath"]) { swaggerJson.paths[path + "#" + ii] = swaggerJson.paths[path]; delete swaggerJson.paths[path]; } }); }); Object.keys(swaggerJson.paths).forEach(function (path) { Object.keys(swaggerJson.paths[path]).forEach(function (method) { tmp = swaggerJson.paths[path][method]; // auto-create operationId from path if ( swaggerJson["x-swgg-operationIdFromPath"] || tmp["x-swgg-operationIdFromPath"] || !tmp.operationId ) { tmp.operationId = local.operationIdFromAjax({ method, url: path }); } // normalize parameter.required local.valueOrEmptyList( tmp.parameters ).forEach(function (schemaP) { if (schemaP.required === false) { delete schemaP.required; } }); }); }); // override tag.description with x-swgg-tags0-override if (swaggerJson["x-swgg-tags0-override"]) { swaggerJson.tags.forEach(function (tag) { tmp = local.objectSetDefault( swaggerJson["x-swgg-tags0-override"][tag.name], { description: tag.description, "x-swgg-descriptionLineList": ( tag["x-swgg-descriptionLineList"] ) } ); tag.description = tmp.description; tag["x-swgg-descriptionLineList"] = ( tmp["x-swgg-descriptionLineList"] ); // objectSetDescription opt.objectSetDescription(tmp); opt.objectSetDescription(tag); }); } // apply opt.objectSetDescription ([ swaggerJson.externalDocs, swaggerJson.info ]).forEach(opt.objectSetDescription); ([ swaggerJson.definitions, swaggerJson.parameters, swaggerJson.responses ]).forEach(function (dict) { Object.keys(dict || {}).forEach(function (key) { tmp = dict[key]; if (dict === swaggerJson.definitions) { tmp = tmp.properties || {}; Object.keys(tmp).forEach(function (key) { opt.objectSetDescription(tmp[key]); }); return; } opt.objectSetDescription(tmp); }); }); Object.keys(swaggerJson.paths).forEach(function (path) { Object.keys(swaggerJson.paths[path]).forEach(function (method) { tmp = swaggerJson.paths[path][method]; opt.objectSetDescription(tmp); local.valueOrEmptyList( tmp.parameters ).forEach(opt.objectSetDescription); Object.keys(tmp.responses || {}).forEach(function (key) { opt.objectSetDescription(tmp.responses[key]); }); }); }); if ( !local.env.npm_package_swggTags0 || ( /-all$/ ).test(local.env.npm_package_swggTags0) ) { return swaggerJson; } // override swaggerJson with x-swgg-tags0-override local.objectSetOverride( swaggerJson, ( swaggerJson["x-swgg-tags0-override"] && swaggerJson["x-swgg-tags0-override"][ local.env.npm_package_swggTags0 ] ), 10 ); // filter $npm_package_swggTags0 - definitions and parameters [ "definitions", "parameters", "responses" ].forEach(function (schema) { schema = swaggerJson[schema] || {}; Object.keys(schema).forEach(function (key) { tmp = schema[key]["x-swgg-tags0"]; if ( tmp && tmp !== "all" && tmp !== local.env.npm_package_swggTags0 ) { delete schema[key]; } }); }); // filter $npm_package_swggTags0 - paths Object.keys(swaggerJson.paths).forEach(function (path) { Object.keys(swaggerJson.paths[path]).forEach(function (method) { tmp = swaggerJson.paths[path][method]["x-swgg-tags0"]; if ( tmp && tmp !== "all" && tmp !== local.env.npm_package_swggTags0 ) { delete swaggerJson.paths[path][method]; return; } }); if (!Object.keys(swaggerJson.paths[path]).length) { delete swaggerJson.paths[path]; } }); // filter $npm_package_swggTags0 - tags swaggerJson.tags = swaggerJson.tags.filter(function (tag) { return ( !tag["x-swgg-tags0"] || tmp["x-swgg-tags0"] === "all" || tag["x-swgg-tags0"] === local.env.npm_package_swggTags0 ); }); return swaggerJson; }; local.normalizeSwaggerParamDict = function (opt) { /* * this function will parse the <opt> according to <opt>.operation.parameters */ let tmp; opt.operation.parameters.forEach(function (schemaP) { tmp = opt.paramDict[schemaP.name]; // init default if ( !opt.modeNoDefault && (opt.modeDefault || schemaP.required) && local.isNullOrUndefined(tmp) ) { tmp = local.jsonCopy(schemaP.default); } if (opt.modeDefault && local.isNullOrUndefined(tmp)) { tmp = local.dbFieldRandomCreate({ modeNotRandom: true, schemaP }); } // parse array if (local.schemaPType(schemaP) === "array" && schemaP.in !== "body") { if (typeof tmp === "string") { switch ( schemaP.collectionFormat || schemaP["x-swgg-collectionFormat"] ) { case "json": local.tryCatchOnError(function () { tmp = JSON.parse(tmp); }, local.nop); opt.paramDict[schemaP.name] = tmp; return; case "multi": tmp = local.urlParse("?" + tmp, true).query[schemaP.name]; Iif (!Array.isArray(tmp)) { tmp = [ tmp ]; } break; case "pipes": tmp = tmp.split("|"); break; case "ssv": tmp = tmp.split(" "); break; case "tsv": tmp = tmp.split("\t"); break; // default to csv default: tmp = tmp.split(","); } if (local.schemaPItemsType(schemaP) !== "string") { // try to JSON.parse the string local.tryCatchOnError(function () { tmp = tmp.map(function (element) { return JSON.parse(element); }); }, local.nop); } } // JSON.parse paramDict } else if ( local.schemaPType(schemaP) !== "file" && local.schemaPType(schemaP) !== "string" && ( typeof tmp === "string" || Object.prototype.toString.call(tmp) === "[object Uint8Array]" ) ) { // try to JSON.parse the string local.tryCatchOnError(function () { tmp = JSON.parse(local.bufferToUtf8(tmp)); }, local.nop); } opt.paramDict[schemaP.name] = tmp; }); return opt; }; local.onErrorJsonapi = function (onError) { /* * this function will normalize err and data to jsonapi format, * and pass them to onError * http://jsonapi.org/format/#errors * http://jsonapi.org/format/#document-structure-resource-objects */ return function (err, data, meta) { data = [ err, data ].map(function (data, ii) { // if no err occurred, then return if ( (ii === 0 && !data) // if data is already normalized, then return it || (data && data.meta && data.meta.isJsonapiResponse) ) { return data; } // normalize data-list if (!Array.isArray(data)) { data = [ data ]; } // normalize errList to contain non-null objects if (!ii) { data = data.errList || data; // normalize errList to be non-empty if (!data.length) { data.push(null); } data = data.map(function (element) { if (!(typeof element === "object" && element)) { element = { message: String(element) }; } // normalize errObj to plain json-object return { message: element.message, name: element.name, stack: element.stack, statusCode: Number(element.statusCode) || 500 }; }); err = local.jsonCopy(data[0]); err.errors = data; return err; } return { data }; }); // init data.meta data.forEach(function (data, ii) { if (!data) { return; } data.meta = local.jsonCopy(meta || {}); data.meta.isJsonapiResponse = true; if (ii) { data.meta.dataLength = data.data.length; } else { data.meta.errorsLength = data.errors.length; } data.meta.statusCode = ( Number(data.meta.statusCode) || Number(data.statusCode) || 0 ); }); onError(data[0], data[1]); }; }; local.operationIdFromAjax = function (opt) { /* * this function will create a sortable operationId * from given ajax-<opt> */ let urlParsed; urlParsed = local.urlParseWithBraket(opt.url); return encodeURIComponent( urlParsed.pathname + urlParsed.hash + " " + opt.method.toUpperCase() ).replace(( /[^\w\-.]/g ), "_"); }; local.schemaPItems = function (schemaP) { /* * this function will return schemaP.items */ return schemaP["x-swgg-items"] || schemaP.items; }; local.schemaPItemsType = function (schemaP) { /* * this function will return schemaP.items.type */ return local.schemaPType(local.schemaPItems(schemaP) || {}); }; local.schemaPType = function (schemaP) { /* * this function will return schemaP.type */ return schemaP && (schemaP["x-swgg-type"] || schemaP.type); }; local.serverRespondJsonapi = function (req, res, err, data, meta) { /* * this function will respond in jsonapi format * http://jsonapi.org/format/#errors * http://jsonapi.org/format/#document-structure-resource-objects */ local.onErrorJsonapi(function (err, data) { local.serverRespondHeadSet(req, res, err && err.statusCode, { "Content-Type": "application/json" }); if (err) { // debug statusCode / method / url local.errorMessagePrepend( err, res.statusCode + " " + req.method + " " + req.url + "\n" ); // print err.stack to stderr local.onErrorDefault(err); } data = err || data; res.statusCode = data.meta.statusCode || res.statusCode; data.meta.statusCode = res.statusCode; res.end(JSON.stringify(data)); })(err, data, meta); }; local.swaggerJsonFromAjax = function (swaggerJson, opt) { /* * this function will update swaggerJson * with definitions and paths created from given ajax-<opt> */ let data; let isArray; let operation; let pathDict; let type; let upsertSchemaP; let urlParsed; upsertSchemaP = function (schemaP) { if (!operation.parameters.some(function (element) { if (element.in === schemaP.in && element.name === schemaP.name) { [ "default", "items", "schema" ].forEach(function (key) { if (!local.isNullOrUndefined(schemaP[key])) { element[key] = schemaP[key]; } }); return true; } })) { operation.parameters.push(schemaP); } }; // init swaggerJson swaggerJson = local.objectSetDefault(swaggerJson, { basePath: "/", definitions: {}, info: { title: "", version: "" }, paths: {}, swagger: "2.0" }); // init opt opt = local.objectSetDefault(opt, { headers: {}, method: "GET" }); // init urlParsed urlParsed = local.urlParseWithBraket(opt.url); // init operation operation = { operationId: opt.operationId || local.operationIdFromAjax(opt), parameters: [], responses: { default: { description: "default response" } }, tags: opt.tags || [ "undefined" ], "x-swgg-tags0": opt["x-swgg-tags0"] }; if (( /^(?:http|https):\/\// ).test(opt.url)) { operation["x-swgg-host"] = urlParsed.host; operation["x-swgg-schemes"] = [ urlParsed.protocol.slice(0, -1) ]; } pathDict = {}; pathDict[urlParsed.pathname + urlParsed.hash] = {}; pathDict[urlParsed.pathname + urlParsed.hash][ opt.method.toLowerCase() ] = operation; local.objectSetDefault(swaggerJson, { paths: pathDict }, 3); // init param in header Object.keys(opt.headers).forEach(function (key) { upsertSchemaP({ default: opt.headers[key], in: "header", name: key, type: "string" }); }); // init param in path urlParsed.pathname.replace(( /\{[^}]+?\}/g ), function (match0) { match0 = match0.slice(1, -1); upsertSchemaP({ default: match0, in: "path", name: match0, required: true, type: "string" }); }); // init param in query Object.keys(urlParsed.query).forEach(function (key) { upsertSchemaP({ default: urlParsed.query[key], in: "query", name: key, type: "string" }); }); data = opt.data; if (!data) { return swaggerJson; } // init param in body - text-data upsertSchemaP({ in: "body", name: "body", schema: { type: "string" } }); local.tryCatchOnError(function () { data = JSON.parse(data); }, local.nop); if (typeof data !== "object") { return swaggerJson; } // init param in body - json-data isArray = Array.isArray(data); type = local.swaggerJsonFromPostBody(swaggerJson, { data: ( isArray ? data[0] : data ), depth: 2, key: "body", prefix: operation.operationId, "x-swgg-tags0": opt["x-swgg-tags0"] }); upsertSchemaP({ in: "body", name: "body", schema: ( isArray ? { items: type, type: "array" } : type ) }); return swaggerJson; }; local.swaggerJsonFromCurl = function (swaggerJson, text) { /* * this function will update swaggerJson * with definitions and paths created from given curl-command-text */ let arg; let argList; let doubleBackslash; let opt; let quote; arg = ""; argList = []; doubleBackslash = local.stringUniqueKey(text); // parse doubleBackslash text = text.replace(( /\\\\/g ), doubleBackslash); // parse line-continuation text = text.replace(( /\\\n/g ), ""); // parse quotes text.replace(( /(\s*?)(\S+)/g ), function (match0, line, word) { line = match0; word.replace(( /^(["']?).*?(?:\\")?(["']?)$/ ), function (quote1, match1, quote2) { quote1 = match1; if (quote) { arg += line; } else { arg = word; quote = quote1; } if (!quote || quote === quote2) { switch (quote) { // parse escapes in single-quotes case "'": arg = arg.replace(( /'"'"'/g ), "'"); arg = arg.slice(1, -1); break; // parse escapes in double-quotes // https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html case "\"": arg = arg.replace(( /\\([$`"\n])/g ), "$1"); arg = arg.slice(1, -1); break; } argList.push(arg); arg = ""; quote = ""; } }); }); // un-parse doubleBackslash argList = argList.map(function (arg) { return arg.replace(new RegExp(doubleBackslash, "g"), "\\\\"); }); argList.push("curl"); argList.forEach(function (arg, ii) { switch (argList[ii - 1]) { case "--data": case "--data-ascii": case "--data-binary": case "--data-raw": case "-d": opt.data = arg; return; case "--header": case "-H": arg = arg.split(":"); arg[1] = arg.slice(1).join(":").trim(); opt.headers[arg[0].toLowerCase()] = arg[1]; return; case "--request": case "-X": opt.method = arg; return; } if (arg === "curl") { if (opt) { opt.url = opt.url || argList[ii - 1]; swaggerJson = local.swaggerJsonFromAjax(swaggerJson, opt); } opt = { headers: {}, method: "GET" }; } if (( /^(?:http|https):\/\// ).test(arg)) { opt.url = arg; } }); return swaggerJson; }; local.swaggerJsonFromPostBody = function (swaggerJson, opt) { /* * this function will update swaggerJson * with definitions created from the post-body-data */ let definition; let isArray; let prefix; let schemaP; let type; let value; prefix = opt.prefix + "." + encodeURIComponent(opt.key); definition = { properties: {}, "x-swgg-tags0": opt["x-swgg-tags0"] }; swaggerJson.definitions[prefix] = definition; Object.keys(opt.data).forEach(function (key) { value = opt.data[key]; isArray = Array.isArray(value); if (isArray) { value = value[0]; } type = ( local.isNullOrUndefined(value) ? "string" : typeof value ); schemaP = ( isArray ? { default: opt.data[key], items: { type }, type: "array" } : { default: value, type } ); definition.properties[key] = schemaP; if (!(type === "object" && opt.depth > 1)) { return; } // recurse type = local.swaggerJsonFromPostBody(swaggerJson, { data: value, depth: opt.depth - 1, key, prefix, "x-swgg-tags0": opt["x-swgg-tags0"] }); if (isArray) { schemaP.items = type; } else { definition.properties[key] = type; } }); return { $ref: "#/definitions/" + prefix }; }; local.swaggerValidate = function (swaggerJson) { /* * this function will validate the json-object swaggerJson */ let operation; let operationIdDict; let pathDict; let prefix; let test; let tmp; operationIdDict = {}; swaggerJson = swaggerJson || {}; local.swaggerValidateDataSchema({ data: swaggerJson, modeSchema: true, prefix: [ "swaggerJson" ], schema: local.swaggerSchemaJson, swaggerJson }); pathDict = {}; Object.keys(swaggerJson.paths).forEach(function (path) { prefix = [ "swaggerJson", "paths", path ]; // validate semanticPaths1 test = path.indexOf("?") < 0; local.throwSwaggerError(!test && { errorType: "semanticPaths1", prefix }); tmp = path.replace(( /\{.*?\}/g ), "{}"); // validate semanticPaths2 test = !pathDict[tmp]; local.throwSwaggerError(!test && { errorType: "semanticPaths2", pathList: [ pathDict[tmp], path ], prefix }); pathDict[tmp] = path; // validate semanticPaths3 tmp = {}; path.replace(( /\{.*?\}/g ), function (match0) { test = !tmp[match0]; local.throwSwaggerError(!test && { errorType: "semanticPaths3", name: match0, prefix }); tmp[match0] = true; }); // validate semanticPaths5 test = path.indexOf("{}") < 0; local.throwSwaggerError(!test && { errorType: "semanticPaths5", prefix }); }); // validate swaggerJson.definitions[key].properties[ii].default Object.keys(swaggerJson.definitions || {}).forEach(function (schemaName) { tmp = local.swaggerValidateDataSchema({ // dereference definition modeDereference: true, prefix: [ "swaggerJson", "definitions", schemaName ], schema: swaggerJson.definitions[schemaName], swaggerJson }); Object.keys(tmp.properties || {}).forEach(function (key) { local.swaggerValidateDataSchema({ modeDefault: true, prefix: [ "swaggerJson", "definitions", schemaName, "properties", key ], schema: tmp.properties[key], swaggerJson }); }); }); // validate swaggerJson.parameters[key].default Object.keys(swaggerJson.parameters || []).forEach(function (key) { local.swaggerValidateDataSchema({ modeDefault: true, prefix: [ "swaggerJson", "parameters", key ], schema: swaggerJson.parameters[key], swaggerJson }); }); // validate swaggerJson.paths[key][key].parameters[ii].default Object.keys(swaggerJson.paths).forEach(function (path) { Object.keys(swaggerJson.paths[path]).forEach(function (method) { prefix = [ "swaggerJson", "paths", path, method ]; operation = local.swaggerValidateDataSchema({ // dereference operation modeDereference: true, prefix, schema: swaggerJson.paths[path][method], swaggerJson }); // validate semanticOperationIds1 test = !operationIdDict[operation.operationId]; local.throwSwaggerError(!test && { data: operation.operationId, errorType: "semanticOperationIds1", prefix: prefix.concat([ "operationId" ]) }); operationIdDict[operation.operationId] = true; tmp = { in: {}, name: {}, path: {}, type: {} }; path.replace(( /\{.*?\}/g ), function (match0) { match0 = match0.slice(1, -1); tmp.path[match0] = tmp.path[match0] || []; tmp.path[match0][0] = true; }); local.valueOrEmptyList( operation.parameters ).forEach(function (schemaP, ii) { // dereference schemaP String(schemaP["x-swgg-$ref"] || schemaP.$ref).replace(( /#\/parameters\/(.+?$)/m ), function (ignore, match1) { schemaP = local.objectSetDefault( local.jsonCopy(schemaP), local.jsonCopy(swaggerJson.parameters[match1]) ); delete schemaP.$ref; }); // validate semanticOperations2 test = !(tmp.in.body && schemaP.in === "body"); local.throwSwaggerError(!test && { data: operation, errorType: "semanticOperations2", prefix, schema: operation }); // validate semanticOperations3 test = ( schemaP.name === undefined || schemaP.in === undefined || !tmp.name[schemaP.name + " " + schemaP.in] ); local.throwSwaggerError(!test && { data: operation.parameters, errorType: "semanticOperations3", prefix: prefix.concat([ "parameters" ]) }); tmp.in[schemaP.in] = true; tmp.name[schemaP.name + " " + schemaP.in] = true; tmp.type[schemaP.type] = true; // validate semanticOperations1 test = !(tmp.in.body && tmp.in.formData); local.throwSwaggerError(!test && { data: operation, errorType: "semanticOperations1", prefix }); // validate schemaP local.swaggerValidateDataSchema({ modeDefault: true, prefix: prefix.concat([ "parameters", schemaP.name ]), schema: schemaP, swaggerJson }); if (schemaP.in === "path") { tmp.path[schemaP.name] = tmp.path[schemaP.name] || []; tmp.path[schemaP.name][1] = true; // validate semanticPaths7 test = tmp.path[schemaP.name][0]; local.throwSwaggerError(!test && { data: schemaP, errorType: "semanticPaths7", prefix: prefix.concat([ "parameters", ii ]) }); } }); Object.keys(tmp.path).forEach(function (name) { // validate semanticPaths6 test = tmp.path[name][1]; local.throwSwaggerError(!test && { errorType: "semanticPaths6", name, prefix: prefix.concat([ "parameters", "ii" ]) }); }); // validate semanticFormData4 test = ( !tmp.type.file || local.valueOrEmptyList(operation.consumes).indexOf( "multipart/form-data" ) >= 0 ); local.throwSwaggerError(!test && { data: operation, errorType: "semanticFormData4", prefix }); // validate semanticFormData5 test = ( !tmp.in.formData || local.valueOrEmptyList(operation.consumes).indexOf( "application/x-www-form-urlencoded" ) >= 0 || local.valueOrEmptyList(operation.consumes).indexOf( "multipart/form-data" ) >= 0 ); local.throwSwaggerError(!test && { data: operation, errorType: "semanticFormData5", prefix, schema: operation }); }); }); }; local.swaggerValidateDataParameters = function (opt) { /* * this function will validate the items in <opt>.paramDict * against the schemaP's in <opt>.parameters */ let errList; errList = []; opt.parameters.forEach(function (schemaP) { local.tryCatchOnError(function () { local.swaggerValidateDataSchema({ data: opt.data[schemaP.name], dataReadonlyRemove: [ opt.dataReadonlyRemove || {}, schemaP.name, opt.dataReadonlyRemove && opt.dataReadonlyRemove[schemaP.name] ], prefix: opt.prefix.concat([ schemaP.name ]), schema: schemaP, swaggerJson: local.swaggerJson }); }, function (errCaught) { console.error(errCaught.message); errList.push(errCaught); errCaught.errList = errList; }); }); return errList; }; local.swaggerValidateDataSchema = function (opt) { /* * this function will validate <opt>.data against the swagger <opt>.schema * http://json-schema.org/draft-04/json-schema-validation.html#rfc.section.5 */ let $ref; let circularSet; let data; let dataReadonlyRemove2; let ii; let list; let oneOf; let schema; let test; let tmp; if (!opt.schema) { return; } data = opt.data; opt.dataReadonlyRemove = opt.dataReadonlyRemove || [ {}, "", null ]; dataReadonlyRemove2 = opt.dataReadonlyRemove[2] || {}; schema = opt.schema; circularSet = new Set(); while (true) { // dereference schema.schema while (schema.schema) { schema = schema.schema; } // dereference schema.oneOf oneOf = (data && schema.oneOf) || []; ii = 0; while (ii < oneOf.length) { tmp = String(oneOf[ii] && oneOf[ii].$ref).replace( "http://json-schema.org/draft-04/schema#", "#" ); switch ( tmp + " " + (!local.isNullOrUndefined(data.$ref) || data.in) ) { case "#/definitions/bodyParameter body": case "#/definitions/formDataParameterSubSchema formData": case "#/definitions/headerParameterSubSchema header": case "#/definitions/jsonReference true": case "#/definitions/pathParameterSubSchema path": case "#/definitions/queryParameterSubSchema query": schema = local.swaggerSchemaJson.definitions[tmp.split("/")[2]]; break; default: switch (tmp) { case "#/definitions/bodyParameter": case "#/definitions/jsonReference": schema = oneOf[ii ^ 1]; break; } } if (!schema.oneOf) { break; } ii += 1; } // dereference schema.$ref $ref = schema && schema.$ref; if (!$ref) { break; } test = !circularSet.has($ref); local.throwSwaggerError(!test && { data, errorType: "schemaDereferenceCircular", prefix: opt.prefix, schema }); circularSet.add($ref); // validate semanticWalker6 test = ( $ref.indexOf("#/") === 0 || $ref.indexOf("http://json-schema.org/draft-04/schema#/") === 0 ); local.throwSwaggerError(!test && { data: $ref, errorType: "semanticWalker6", prefix: opt.prefix.concat([ "$ref" ]) }); switch (opt.modeSchema && $ref) { case "http://json-schema.org/draft-04/schema#/definitions/parameter": // validate semanticFormData1 test = data.in !== "formdata"; local.throwSwaggerError(!test && { data: data.in, errorType: "semanticFormData1", prefix: opt.prefix.concat([ "in" ]) }); // validate semanticFormData3 test = data.type !== "file" || data.in === "formData"; local.throwSwaggerError(!test && { data, errorType: "semanticFormData3", prefix: opt.prefix }); // validate semanticParameters2 test = data.in === "body" || !local.isNullOrUndefined(data.type); local.throwSwaggerError(!test && { data, errorType: "semanticParameters2", prefix: opt.prefix }); break; case "http://json-schema.org/draft-04/schema#/definitions/schema": list = data.required || []; ii = 0; while (ii < list.length) { tmp = list[ii]; // validate semanticSchema1 test = !( data.properties && data.properties[tmp] && data.properties[tmp].readOnly ); local.throwSwaggerError(!test && { data: data.properties[tmp], errorType: "semanticSchema1", prefix: opt.prefix.concat([ "properties", tmp ]) }); ii += 1; } // validate semanticWalker1 test = ( local.isNullOrUndefined(data.type) || typeof data.type === "string" ); local.throwSwaggerError(!test && { data: data.type, errorType: "semanticWalker1", prefix: opt.prefix.concat([ "type" ]) }); // validate semanticWalker2 test = !(data.maximum < data.minimum); local.throwSwaggerError(!test && { data, errorType: "semanticWalker2", prefix: opt.prefix }); // validate semanticWalker3 test = !(data.maxProperties < data.minProperties); local.throwSwaggerError(!test && { data, errorType: "semanticWalker3", prefix: opt.prefix }); // validate semanticWalker4 test = !(data.maxLength < data.minLength); local.throwSwaggerError(!test && { data, errorType: "semanticWalker4", prefix: opt.prefix, schema }); break; } tmp = $ref.split("/").slice(-2); schema = ( $ref.indexOf("http://json-schema.org/draft-04/schema#/") === 0 ? local.swaggerSchemaJson[tmp[0]] : opt.swaggerJson[tmp[0]] ); schema = schema && schema[tmp[1]]; test = schema; local.throwSwaggerError(!test && { data, errorType: "schemaDereference", prefix: opt.prefix, schema: opt.schema }); } if (opt.modeDereference) { if (opt.modeDereferenceDepth > 1) { schema = local.jsonCopy(schema); Object.keys(schema.properties || {}).forEach(function (key) { schema.properties[key] = local.swaggerValidateDataSchema({ // dereference property modeDereference: true, modeDereferenceDepth: opt.modeDereferenceDepth - 1, prefix: opt.prefix.concat([ "properties", key ]), schema: schema.properties[key], swaggerJson: opt.swaggerJson }); }); } return schema; } // validate schema.default if (opt.modeDefault) { data = schema.default; } // validate schema.required test = ( opt.modeDefault || !local.isNullOrUndefined(data) || schema.required !== true || schema["x-swgg-notRequired"] ); local.throwSwaggerError(!test && { data, errorType: "objectRequired", prefix: opt.prefix, schema }); if (local.isNullOrUndefined(data)) { return; } // validate semanticItemsRequiredForArrayObjects1 test = ( !opt.modeSchema || local.schemaPType(data) !== "array" || ( typeof local.schemaPItems(data) === "object" && local.schemaPItems(data) ) ); local.throwSwaggerError(!test && { errorType: "semanticItemsRequiredForArrayObjects1", prefix: opt.prefix, schema: data }); // remove readOnly property if (schema.readOnly) { delete opt.dataReadonlyRemove[0][opt.dataReadonlyRemove[1]]; } // optimization - validate schema.type first // 5.5.2. type // https://swagger.io/docs/specification/data-models/data-types/ // https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#data-types switch (local.schemaPType(schema)) { case "array": test = Array.isArray(data); break; case "boolean": test = typeof data === "boolean"; break; case "file": test = !opt.modeSchema; break; case "integer": test = Number.isInteger(data); switch (schema.format) { case "int32": break; case "int64": break; } break; case "number": test = Number.isFinite(data); switch (schema.format) { case "double": break; case "float": break; } break; case "string": test = ( typeof data === "string" || (!opt.modeSchema && schema.format === "binary") ); switch (test && !opt.modeSchema && schema.format) { // Clarify 'byte' format #50 // https://github.com/swagger-api/swagger-spec/issues/50 case "byte": test = !( /[^\n\r+\/0-9=A-Za-z]/ ).test(data); break; case "date": case "date-time": test = JSON.stringify(new Date(data)) !== "null"; break; case "email": test = local.regexpValidateEmail.test(data); break; case "json": test = local.tryCatchOnError(function () { JSON.parse(data); return true; }, local.nop); break; case "phone": test = local.regexpValidatePhone.test(data); break; } break; default: test = opt.modeSchema || typeof data === "object"; } local.throwSwaggerError(!test && { data, errorType: "itemType", prefix: opt.prefix, schema, typeof: local.value(typeof data) }); tmp = typeof data; if (tmp === "object" && Array.isArray(data)) { tmp = "array"; } switch (tmp) { // 5.3. Validation keywords for arrays case "array": // 5.3.1. additionalItems and items // swagger disallows array items data.forEach(function (element, ii) { // recurse - schema.additionalItems and schema.items local.swaggerValidateDataSchema({ data: element, dataReadonlyRemove: [ dataReadonlyRemove2, ii, dataReadonlyRemove2[ii] ], modeSchema: opt.modeSchema, prefix: opt.prefix.concat([ ii ]), schema: local.schemaPItems(schema) || schema.additionalItems, swaggerJson: opt.swaggerJson }); }); // 5.3.2. maxItems test = ( typeof schema.maxItems !== "number" || data.length <= schema.maxItems ); local.throwSwaggerError(!test && { data, errorType: "arrayMaxItems", prefix: opt.prefix, schema }); // 5.3.3. minItems test = ( typeof schema.minItems !== "number" || data.length >= schema.minItems ); local.throwSwaggerError(!test && { data, errorType: "arrayMinItems", prefix: opt.prefix, schema }); // 5.3.4. uniqueItems test = !schema.uniqueItems || data.every(function (element) { tmp = element; return data.indexOf(element) === data.lastIndexOf(element); }); local.throwSwaggerError(!test && { data, errorType: "arrayUniqueItems", prefix: opt.prefix, schema, tmp }); break; // 5.1. Validation keywords for numeric instances (number and integer) case "number": // 5.1.1. multipleOf test = ( typeof schema.multipleOf !== "number" || data % schema.multipleOf === 0 ); local.throwSwaggerError(!test && { data, errorType: "numberMultipleOf", prefix: opt.prefix, schema }); // 5.1.2. maximum and exclusiveMaximum test = typeof schema.maximum !== "number" || ( schema.exclusiveMaximum ? data < schema.maximum : data <= schema.maximum ); local.throwSwaggerError(!test && { data, errorType: ( schema.exclusiveMaximum ? "numberExclusiveMaximum" : "numberMaximum" ), prefix: opt.prefix, schema }); // 5.1.3. minimum and exclusiveMinimum test = typeof schema.minimum !== "number" || ( schema.exclusiveMinimum ? data > schema.minimum : data >= schema.minimum ); local.throwSwaggerError(!test && { data, errorType: ( schema.exclusiveMinimum ? "numberExclusiveMinimum" : "numberMinimum" ), prefix: opt.prefix, schema }); break; // 5.4. Validation keywords for objects case "object": // 5.4.1. maxProperties test = ( typeof schema.maxProperties !== "number" || Object.keys(data).length <= schema.maxProperties ); local.throwSwaggerError(!test && { data, errorType: "objectMaxProperties", prefix: opt.prefix, schema }); // 5.4.2. minProperties test = ( typeof schema.minProperties !== "number" || Object.keys(data).length >= schema.minProperties ); local.throwSwaggerError(!test && { data, errorType: "objectMinProperties", prefix: opt.prefix, schema }); // 5.4.3. required local.valueOrEmptyList(schema.required).forEach(function (key) { // validate semanticItemsRequiredForArrayObjects2 test = !local.isNullOrUndefined(data[key]); local.throwSwaggerError(!test && { data, errorType: "semanticItemsRequiredForArrayObjects2", key, prefix: opt.prefix, schema }); }); // 5.4.4. additionalProperties, properties and patternProperties Object.keys(data).forEach(function (key) { tmp = null; if (schema.properties && schema.properties[key]) { tmp = true; // recurse - schema.properties local.swaggerValidateDataSchema({ data: data[key], dataReadonlyRemove: [ dataReadonlyRemove2, key, dataReadonlyRemove2[key] ], modeSchema: opt.modeSchema, prefix: opt.prefix.concat([ key ]), schema: schema.properties[key], swaggerJson: opt.swaggerJson }); } Object.keys(schema.patternProperties || {}).forEach(function (rgx) { if (new RegExp(rgx).test(key)) { tmp = true; // recurse - schema.patternProperties local.swaggerValidateDataSchema({ data: data[key], modeSchema: opt.modeSchema, prefix: opt.prefix.concat([ key ]), schema: schema.patternProperties[rgx], swaggerJson: opt.swaggerJson }); } }); /* * validate * 5.4.4.4. If "additionalProperties" has boolean value false * * In this case, validation of the instance depends on the property set of * "properties" and "patternProperties". In this section, the property names of * "patternProperties" will be called regexes for convenience. * * The first step is to collect the following sets: * * s * The property set of the instance to validate. * p * The property set from "properties". * pp * The property set from "patternProperties". * Having collected these three sets, the process is as follows: * * remove from "s" all elements of "p", if any; * for each regex in "pp", remove all elements of "s" which this regex matches. * Validation of the instance succeeds if, after these two steps, * set "s" is empty. */ test = tmp || schema.additionalProperties !== false; local.throwSwaggerError(!test && { data, errorType: "objectAdditionalProperties", key, prefix: opt.prefix, schema }); // recurse - schema.additionalProperties local.swaggerValidateDataSchema({ data: data[key], modeSchema: opt.modeSchema, prefix: opt.prefix.concat([ key ]), schema: schema.additionalProperties, swaggerJson: opt.swaggerJson }); }); // 5.4.5. dependencies Object.keys(schema.dependencies || {}).forEach(function (key) { if (local.isNullOrUndefined(data[key])) { return; } // 5.4.5.2.1. Schema dependencies // recurse - schema.dependencies local.swaggerValidateDataSchema({ data: data[key], modeSchema: opt.modeSchema, prefix: opt.prefix.concat([ key ]), schema: schema.dependencies[key], swaggerJson: opt.swaggerJson }); // 5.4.5.2.2. Property dependencies schema.dependencies[key].every(function (key2) { test = !local.isNullOrUndefined(data[key2]); local.throwSwaggerError(!test && { data, errorType: "objectDependencies", key, key2, prefix: opt.prefix, schema }); }); }); break; // 5.2. Validation keywords for strings case "string": // 5.2.1. maxLength test = ( typeof schema.maxLength !== "number" || data.length <= schema.maxLength ); local.throwSwaggerError(!test && { data, errorType: "stringMaxLength", prefix: opt.prefix, schema }); // 5.2.2. minLength test = ( typeof schema.minLength !== "number" || data.length >= schema.minLength ); local.throwSwaggerError(!test && { data, errorType: "stringMinLength", prefix: opt.prefix, schema }); // 5.2.3. pattern test = !schema.pattern || new RegExp(schema.pattern).test(data); local.throwSwaggerError(!test && { data, errorType: "stringPattern", prefix: opt.prefix, schema }); break; } // 5.5. Validation keywords for any instance type // 5.5.1. enum tmp = schema.enum || ( !opt.modeSchema && local.valueOrEmptyList(local.schemaPItems(schema) || {}).enum ); test = !tmp || ( Array.isArray(data) ? data : [ data ] ).every(function (element) { return tmp.indexOf(element) >= 0; }); local.throwSwaggerError(!test && { data, errorType: "itemEnum", prefix: opt.prefix, schema, tmp }); // 5.5.2. type local.nop(); // 5.5.3. allOf local.valueOrEmptyList(schema.allOf).forEach(function (element) { // recurse - schema.allOf local.swaggerValidateDataSchema({ data, prefix: opt.prefix, modeSchema: opt.modeSchema, schema: element, swaggerJson: opt.swaggerJson }); }); // 5.5.4. anyOf tmp = null; test = !schema.anyOf || schema.anyOf.some(function (element) { local.tryCatchOnError(function () { // recurse - schema.anyOf local.swaggerValidateDataSchema({ data, modeSchema: opt.modeSchema, prefix: opt.prefix, schema: element, swaggerJson: opt.swaggerJson }); return true; }, local.nop); tmp = tmp || local.utility2._debugTryCatchError; return !tmp; }); local.throwSwaggerError(!test && { data, errorType: "itemOneOf", prefix: opt.prefix, schema, tmp }); // 5.5.5. oneOf tmp = ( !schema.oneOf ? 1 : 0 ); local.valueOrEmptyList(schema.oneOf).some(function (element) { local.tryCatchOnError(function () { // recurse - schema.oneOf local.swaggerValidateDataSchema({ data, modeSchema: opt.modeSchema, prefix: opt.prefix, schema: element, swaggerJson: opt.swaggerJson }); tmp += 1; }, local.nop); return tmp > 1; }); test = tmp === 1; local.throwSwaggerError(!test && { data, errorType: "itemOneOf", prefix: opt.prefix, schema, tmp }); // 5.5.6. not test = !schema.not || !local.tryCatchOnError(function () { // recurse - schema.not local.swaggerValidateDataSchema({ data, modeSchema: opt.modeSchema, prefix: opt.prefix, schema: schema.not, swaggerJson: opt.swaggerJson }); return true; }, local.nop); local.throwSwaggerError(!test && { data, errorType: "itemNot", prefix: opt.prefix, schema }); // 5.5.7. definitions local.nop(); // validate data.$ref if (schema === local.swaggerSchemaJson.definitions.jsonReference) { local.swaggerValidateDataSchema({ modeDereference: true, modeSchema: opt.modeSchema, prefix: opt.prefix, schema: data, swaggerJson: opt.swaggerJson }); } return schema; }; local.swaggerValidateFile = function (opt, onError) { /* * this function will validate the json-file <opt>.file */ local.gotoNext(opt, function (err, data) { switch (opt.gotoState) { case 1: if (typeof opt.data === "string") { opt.gotoNext(null, opt.data); return; } // fetch url if (( /^(?:http|https):\/\// ).test(opt.file)) { local.ajax({ url: opt.file }, function (err, xhr) { opt.gotoNext(err, xhr && xhr.responseText); }); return; } // read file local.fs.readFile(opt.file, "utf8", opt.gotoNext); break; case 2: // jslint local.jslint.jslintAndPrint(data, opt.file); local.assertOrThrow( !local.jslint.jslintResult.errMsg, local.jslint.jslintResult.errMsg.replace(( /\u001b\[\d*m/g ), "") ); // validate local.swgg.swaggerValidate(JSON.parse(data)); opt.gotoNext(); break; default: console.error( err ? "\u001b[31mswagger-validate - failed - " + opt.file + "\n" + err.message + "\u001b[39m" : "swagger-validate - passed - " + opt.file ); onError(err); } }); opt.gotoState = 0; opt.gotoNext(); }; local.throwSwaggerError = function (opt) { /* * this function will throw a swaggerError with given <opt>.errorType */ let err; if (!opt) { return; } [ 0, 2 ].forEach(function (ii) { opt["prefix" + ii] = opt.prefix[ii] + opt.prefix.slice( ii + 1 ).map(function (element) { return "[" + JSON.stringify(element) + "]"; }).join(""); }); opt.prefix0 += " = " + local.stringTruncate( JSON.stringify(opt.data) || "undefined", 100 ); opt.schema2 = local.stringTruncate( JSON.stringify(opt.schema) || "undefined", 500 ); opt.type2 = (opt.schema && local.schemaPType(opt.schema)) || "object"; if (opt.schema && opt.schema.format) { opt.type2 += " (" + opt.schema.format + ")"; } err = new Error("error." + opt.errorType + " - " + local.templateRender( local.swaggerErrorTypeDict[opt.errorType], opt, { notHtmlSafe: true } )); err.messageShort = local.templateRender( local.swaggerErrorTypeDict[opt.errorType].replace( "{{prefix0}}", "{{prefix2}}" ), opt, { notHtmlSafe: true } ); err.opt = opt; err.statusCode = 400; throw err; }; local.uiEventDelegate = function (evt) { // filter non-input keyup-evt evt.targetOnEvent = evt.target.closest( "[data-onevent]" ); Iif (!evt.targetOnEvent) { return; } // rate-limit keyup Iif (evt.type === "keyup") { local.uiEventDelegateKeyupEvent = evt; if (local.uiEventDelegateKeyupTimerTimeout !== 2) { local.uiEventDelegateKeyupTimerTimeout = ( local.uiEventDelegateKeyupTimerTimeout || setTimeout(function () { local.uiEventDelegateKeyupTimerTimeout = 2; local.uiEventDelegate(local.uiEventDelegateKeyupEvent); }, 100) ); return; } local.uiEventDelegateKeyupTimerTimeout = null; if (!evt.target.closest( "input, option, select, textarea" )) { return; } } switch (evt.targetOnEvent.tagName) { case "BUTTON": case "FORM": evt.preventDefault(); break; } evt.stopPropagation(); local.uiEventListenerDict[evt.targetOnEvent.dataset.onevent](evt); }; local.uiEventListenerDict = local.objectAssignDefault( globalThis.domOnEventDelegateDict ); local.uiEventListenerDict.onEventDomDb = local.db.onEventDomDb; local.uiEventListenerDict.onEventInputTextareaChange = function (evt) { /* * this function will show/hide the textarea's multiline placeholder */ let isTransparent; let value; isTransparent = evt.targetOnEvent.style.background.indexOf( "transparent" ) >= 0; value = evt.targetOnEvent.value; Iif (value && isTransparent) { evt.targetOnEvent.style.background = ""; } if (!value && !isTransparent) { evt.targetOnEvent.style.background = "transparent"; } local.uiEventListenerDict.onEventInputValidateAndAjax({ targetOnEvent: evt.targetOnEvent }); }; local.uiEventListenerDict.onEventInputValidateAndAjax = function ( opt, onError ) { /* * this function will validate the input parameters * against the schemas in <opt>.parameters */ let errorDict; let jsonParse; let tmp; jsonParse = function (text) { /* * this function will try to JSON.parse(text) */ return local.tryCatchOnError(function () { return JSON.parse(text); }, function () { return text; }); }; // hack-jslint opt.targetOnEvent = opt.targetOnEvent.closest( ".operation" ); opt.api = local.apiDict[opt.targetOnEvent.dataset._methodPath]; opt.headers = {}; opt.modeAjax = opt.modeAjax || "validate"; opt.modeNoDefault = true; opt.paramDict = {}; opt.url = ""; opt.api.parameters.forEach(function (schemaP) { tmp = opt.targetOnEvent.querySelector( ".schemaP[data-name=" + JSON.stringify(schemaP.name) + "] .input" ); switch (tmp.tagName) { case "INPUT": // parse file Iif (local.schemaPType(tmp) === "file") { tmp = tmp.files && tmp.files[0]; break; } tmp = tmp.value; if (!tmp) { return; } // parse string if (local.schemaPType(schemaP) !== "string") { tmp = jsonParse(tmp); } break; case "SELECT": tmp = Array.from(tmp.options).filter(function (element) { return element.selected; }).map(function (element) { return jsonParse(decodeURIComponent( element.dataset.valueSelectOption )); }); if (!tmp.length || tmp[0] === "$swggUndefined") { return; } if (local.schemaPType(schemaP) !== "array") { tmp = tmp[0]; } break; case "TEXTAREA": tmp = tmp.value; if (!tmp) { return; } // ignore string (json) if ( schemaP.format === "json" && local.schemaPType(schemaP) === "string" ) { break; } if ( schemaP.schema && local.schemaPType(schemaP.schema) === "string" && typeof tmp === "string" ) { break; } // parse schema if (schemaP.in === "body") { tmp = jsonParse(tmp); break; } // parse array tmp = tmp.split("\n").map(function (element) { return ( local.schemaPItemsType(schemaP) === "string" ? element : jsonParse(element) ); }); break; } opt.paramDict[schemaP.name] = tmp; }); opt.api.ajax(opt, onError || local.nop); // init errorDict errorDict = {}; local.valueOrEmptyList(opt.err && opt.err.errList).forEach(function (err) { errorDict[err.opt.prefix[2]] = err; }); // shake input on err Array.from(opt.targetOnEvent.querySelectorAll( ".schemaP[data-name]" )).forEach(function (element) { tmp = errorDict[element.dataset.name]; local.uiAnimateShakeIfError(tmp, element.querySelector( ".input" )); element.querySelector( ".colorError" ).textContent = ( tmp ? tmp.messageShort : "" ); }); // shake submit-button on err local.uiAnimateShakeIfError( opt.err, opt.targetOnEvent.querySelector( ".onEventOperationAjax" ) ); // init reqCurl tmp = opt.data; local.tryCatchOnError(function () { tmp = JSON.stringify(JSON.parse(opt.data), null, 4); }, local.nop); tmp = ( "curl \\\n" + "--request " + opt.api._method + " \\\n" + Object.keys(opt.headers).map(function (key) { return "--header '" + key + ": " + opt.headers[key] + "' \\\n"; }).join("") + "--data-binary " + ( typeof tmp === "string" ? "'" + tmp.replace(( /'/g ), "'\"'\"'") + "'" : "<blob>" ) + " \\\n\"" + opt.url.replace(( /&/g ), "&\\\n") + "\"" ); opt.targetOnEvent.querySelector( ".reqCurl" ).textContent = tmp; // init reqJs opt.targetOnEvent.querySelector( ".reqJs" ).textContent = local.templateRender( local.templateUiReqJs, { opt, optionJson: JSON.stringify({ paramDict: opt.paramDict }, null, 4) }, { notHtmlSafe: true } ); }; local.uiEventListenerDict.onEventOperationAjax = function (opt) { /* * this function will submit the operation to the backend */ // ensure opt is stateless opt = { targetOnEvent: opt.targetOnEvent.closest(".operation") }; local.gotoNext(opt, function (err, data) { switch (opt.gotoState) { case 1: // force ajax opt.modeAjax = "ajax"; // validate input local.uiEventListenerDict.onEventInputValidateAndAjax( opt, opt.gotoNext ); // reset res output Array.from(opt.targetOnEvent.querySelectorAll( ".resBody, .resHeaders, .resStatusCode" )).forEach(function (element) { element.classList.remove("hasError"); element.textContent = "loading ..."; }); opt.targetOnEvent.querySelector( ".resMedia" ).innerHTML = ""; // scrollTo res opt.targetOnEvent.querySelector( ".resStatusCode" ).focus(); break; default: local.onErrorDefault(err); data = local.objectSetDefault(data, { contentType: "undefined", statusCode: "undefined" }); // init resStatusCode opt.targetOnEvent.querySelector( ".resStatusCode" ).textContent = ( data.statusCode ); // init resHeaders opt.targetOnEvent.querySelector( ".resHeaders" ).textContent = Object.keys(data.resHeaders).map(function (key) { return key + ": " + data.resHeaders[key] + "\r\n"; }).join(""); // init resBody opt.targetOnEvent.querySelector( ".resHeaders" ).textContent.replace(( /^content-type:(.*?)$/im ), function (ignore, match1) { data.contentType = match1.trim(); }); data.mediaType = data.contentType.split("/")[0].replace( "image", "img" ); switch (data.mediaType) { case "audio": case "img": case "video": opt.targetOnEvent.querySelector( ".resBody" ).textContent = ( data.contentType ); opt.targetOnEvent.querySelector( ".resMedia" ).innerHTML = ( "<" + data.mediaType + " class=\"domOnEventMediaHotkeysInit\"" + " controls src=\"data:" + data.contentType + ";base64," + local.base64FromBuffer(data.resBuffer) + "\"></" + data.mediaType + ">" ); globalThis.domOnEventMediaHotkeys("init"); break; default: opt.targetOnEvent.querySelector( ".resBody" ).textContent = ( data.responseJson ? JSON.stringify(data.responseJson, null, 4) : data.response ); } // shake res on err Array.from(opt.targetOnEvent.querySelectorAll( ".resBody, .resHeaders, .resStatusCode" )).forEach(function (element) { local.uiAnimateShakeIfError(data.statusCode >= 400, element); }); } }); opt.gotoState = 0; opt.gotoNext(); }; local.uiEventListenerDict.onEventOperationDisplayShow = function ( evt, onError ) { /* * this function will toggle the display of the operation */ let element; element = evt.targetOnEvent; element = element.querySelector( ".operation" ) || element.closest( ".operation" ); location.hash = "!" + element.id; element.closest( ".resource" ).classList.remove("expanded"); // show parent resource local.uiAnimateSlideDown(element.closest( ".resource" ).querySelector( ".operationList" )); // show the operation, but hide all other operations local.uiAnimateSlideAccordian( element.querySelector( ".operation > form" ), Array.from(element.closest( ".operationList" ).querySelectorAll( ".operation > form" )), function () { // scrollTo operation element.querySelector( "[tabIndex]" ).blur(); element.querySelector( "[tabIndex]" ).focus(); // validate input local.uiEventListenerDict.onEventInputValidateAndAjax({ targetOnEvent: element }); local.setTimeoutOnError(onError, 0, null, element); } ); }; local.uiEventListenerDict.onEventResourceDisplayAction = function (evt) { /* * this function will toggle the display of the resource */ location.hash = "!" + evt.currentTarget.id; evt.targetOnEvent.className.split(" ").some(function (className) { switch (className) { case "td1": // show the resource, but hide all other resources local.uiAnimateSlideAccordian( evt.currentTarget.querySelector( ".operationList" ), Array.from(document.querySelectorAll( ".swggUiContainer .operationList" )) ); // show at least one operation in the resource local.uiEventListenerDict.onEventOperationDisplayShow({ targetOnEvent: evt.currentTarget.querySelector( ".operation .uiAnimateSlide[style*=\"max-height: 100%\"]" ) || evt.currentTarget.querySelector( ".operation" ) }); return true; case "td2": // show the resource, but hide all other resources local.uiAnimateSlideAccordian( evt.currentTarget.querySelector( ".operationList" ), Array.from(document.querySelectorAll( ".swggUiContainer .operationList" )) ); // collapse all operations in the resource if (evt.currentTarget.classList.contains("expanded")) { evt.currentTarget.classList.remove("expanded"); Array.from(evt.currentTarget.querySelectorAll( ".operation > form" )).forEach(function (element) { local.uiAnimateSlideUp(element); }); // expand all operations in the resource } else { evt.currentTarget.classList.add("expanded"); Array.from(evt.currentTarget.querySelectorAll( ".operation > form" )).forEach(function (element) { local.uiAnimateSlideDown(element); // validate input local.uiEventListenerDict.onEventInputValidateAndAjax({ targetOnEvent: element }); }); } return true; } }); }; local.uiEventListenerDict.onEventUiReload = function (opt, onError) { /* * this function will reload the ui */ let resource; let swaggerJson; opt = opt || {}; swaggerJson = opt; local.gotoNext(opt, function (err, data) { switch (opt.gotoState) { case 1: Iif ( opt && opt.targetOnEvent && opt.targetOnEvent.classList && !opt.targetOnEvent.classList.contains( "eventDelegate" + opt.type[0].toUpperCase() + opt.type.slice(1) ) ) { return; } opt.inputUrl = document.querySelector( ".swggUiContainer > .thead > .td2" ); // clear all apiKeyValue's from localStorage Iif ( opt.targetOnEvent && opt.targetOnEvent.id === "buttonSwggApiKeyClear1" ) { local.apiKeyValue = ""; Object.keys(localStorage).forEach(function (key) { if (key.indexOf("utility2_swgg_apiKeyKey_") === 0) { localStorage.removeItem(key); } }); // restore apiKeyValue } else if (opt.swggInit) { local.apiKeyKey = ( "utility2_swgg_apiKeyKey_" + encodeURIComponent( local.urlParse(opt.inputUrl.value.replace(( /^\// ), "")).href ) ); local.apiKeyValue = localStorage.getItem(local.apiKeyKey) || ""; // save apiKeyValue } else { local.apiKeyValue = document.querySelector( "#swggApiKeyInput1" ).value; local.localStorageSetItemOrClear( local.apiKeyKey, local.apiKeyValue ); } // if keyup-evt is not return-key, then return if ( (opt.type === "keyup" && opt.code !== "Enter") // do not reload ui during test || globalThis.utility2_modeTest >= 4 ) { opt.gotoState = Infinity; opt.gotoNext(); return; } // reset ui document.querySelector( "#swggUiReloadErrorDiv1" ).textContent = ""; document.querySelectorAll( ".swggUiContainer > .reset" ).forEach(function (element) { element.remove(); }); // normalize swaggerJsonUrl opt.inputUrl.value = local.urlParse( opt.inputUrl.value.replace(( /^\// ), "") ).href; document.querySelector( "#swggAjaxProgressDiv1 span" ).innerHTML = ( "loading swagger.json" ); opt.gotoNext(); break; case 2: // fetch swagger.json file local.ajax({ url: opt.inputUrl.value }, opt.gotoNext); break; case 3: // JSON.parse swagger.json string local.tryCatchOnError(function () { opt.gotoNext(null, JSON.parse(data.responseText)); }, opt.gotoNext); break; case 4: // reset state local.apiDict = null; local.swaggerJson = null; // apiUpdate swagger.json object local.apiUpdate(data); swaggerJson = local.jsonCopy(local.swaggerJson); local.uiState = swaggerJson; // init ajaxProgressText swaggerJson.ajaxProgressText = "rendering swagger.json"; // init apiKeyValue swaggerJson.apiKeyValue = local.apiKeyValue; // templateRender title document.querySelector( "head > title" ).textContent = local.templateRender( local.templateUiTitle, swaggerJson ).trim(); // init urlSwaggerJson swaggerJson.urlSwaggerJson = opt.inputUrl.value; // templateRender main document.querySelector( ".swggUiContainer" ).innerHTML = local.templateRender( local.templateUiMain, swaggerJson ); setTimeout(function () { // recurse - render .resourceList local.uiEventListenerDict.onEventUiReload( swaggerJson, opt.gotoNext ); }, 100); break; default: local.onErrorDefault(err); // debug err local._debugOnEventUiReload = err || local._debugOnEventUiReload; document.querySelector( "#swggUiReloadErrorDiv1" ).textContent = local.value(err || { message: "" }).message; local.setTimeoutOnError(onError, 0, err); } }); // optimization - render .swggUiContainer first if (!swaggerJson.swagger) { opt.gotoState = 0; opt.gotoNext(); return; } // optimization - render .resourceList in separate evt-loop // reset state local.idDomElementDict = {}; local.objectSetDefault(swaggerJson, { resourceDict: {}, operationDict: {}, tagDict: {} }); // init tagDict swaggerJson.tags.forEach(function (tag) { swaggerJson.tagDict[tag.name] = tag; }); // init operationDict Object.keys(local.apiDict).sort().forEach(function (operation) { // init operation operation = local.jsonCopy(local.apiDict[operation]); operation.tags.forEach(function (tag) { swaggerJson.operationDict[operation._methodPath] = operation; // init resource swaggerJson.resourceDict[tag] = local.objectSetDefault( swaggerJson.resourceDict[tag] || swaggerJson.tagDict[tag], { description: "no description", name: tag } ); resource = swaggerJson.resourceDict[tag]; resource.id = resource.id || local.idDomElementCreate( "swgg_id_" + tag ); resource.summary = resource.summary || String( resource.description ).replace(( /\bhttps?:\/\/[^\s<]+[^<.,:;"')\]\s]/g ), ""); }); }); // init uiFragment swaggerJson.uiFragment = document.createDocumentFragment(); // init resourceDict Object.keys(swaggerJson.resourceDict).sort().forEach(function (key) { // templateRender resource swaggerJson.uiFragment.appendChild( local.domFragmentRender( local.templateUiResource, swaggerJson.resourceDict[key] ) ); }); Object.keys(swaggerJson.operationDict).sort(function (aa, bb) { aa = swaggerJson.operationDict[aa]; aa = aa["x-swgg-sortValue"] || (aa._path + " " + aa._method); bb = swaggerJson.operationDict[bb]; bb = bb["x-swgg-sortValue"] || (bb._path + " " + bb._method); return ( aa < bb ? -1 : 1 ); }).forEach(function (operation) { operation = swaggerJson.operationDict[operation]; operation.id = local.idDomElementCreate( "swgg_id_" + operation.operationId ); operation.tags.forEach(function (tag) { // create new operation for each tag operation = local.jsonCopy(operation); resource = swaggerJson.resourceDict[tag]; local.objectSetDefault(operation, { description: "no description", responseList: Object.keys( operation.responses ).sort().map(function (key) { return { key, value: operation.responses[key] }; }) }); operation.summary = operation.summary || operation.description; operation.summary = operation.summary.replace(( /\bhttps?:\/\/[^\s<]+[^<.,:;"')\]\s]/g ), ""); operation.parameters.forEach(local.uiRenderSchemaP); // templateRender operation swaggerJson.uiFragment.querySelector( "#" + resource.id + " .operationList" ).appendChild( local.domFragmentRender(local.templateUiOperation, operation) ); }); }); // emulate <ol></ol> for operations Array.from(swaggerJson.uiFragment.querySelectorAll( ".operationList" )).forEach(function (element) { Array.from(element.querySelectorAll( ".operation > .thead > .td1" )).forEach(function (element, ii) { element.textContent = ii + 1 + "."; }); }); // append uiFragment to swggUiContainer document.querySelector( "#swggAjaxProgressDiv1" ).style.display = "none"; document.querySelector( ".swggUiContainer .resourceList" ).appendChild( swaggerJson.uiFragment ); document.querySelectorAll( ".swggUiContainer [data-value-text]" ).forEach(function (element) { // render valueText element.value = decodeURIComponent(element.dataset.valueText); delete element.dataset.valueText; // init textarea's multiline placeholder if (element.tagName === "TEXTAREA") { local.uiEventListenerDict.onEventInputTextareaChange({ targetOnEvent: element }); } }); // init evt-handling [ "Change", "Click", "Keyup", "Submit" ].forEach(function (eventType) { document.querySelectorAll( ".eventDelegate" + eventType ).forEach(function (element) { element.addEventListener( eventType.toLowerCase(), local.uiEventDelegate ); }); }); // scrollTo location.hash local.uiEventListenerDict.onEventOperationDisplayShow({ targetOnEvent: ( document.querySelector( "#" + (location.hash.slice(2) || "undefined") ) || document.querySelector( ".swggUiContainer .operation" ) ) }); local.setTimeoutOnError(onError); }; local.uiRenderSchemaP = function (schemaP) { /* * this function will render schemaP */ // init schemaP.id schemaP.id = local.idDomElementCreate("swgg_id_" + schemaP.name); // init enum schemaP.enum2 = ( schemaP.enum || local.valueOrEmptyObject(local.schemaPItems(schemaP)).enum || (local.schemaPType(schemaP) === "boolean" && [ false, true ]) ); // init input - file if (local.schemaPType(schemaP) === "file") { schemaP.isFile = true; // init input - textarea } else if (schemaP.in === "body") { schemaP.isTextarea = true; // init input - select } else if (schemaP.enum2) { // init enumDefault schemaP.enumDefault = []; if (schemaP.required && schemaP.default !== undefined) { schemaP.enumDefault = ( local.schemaPType(schemaP) === "array" ? schemaP.default : [ schemaP.default ] ); } schemaP.isSelectMultiple = local.schemaPType(schemaP) === "array"; schemaP.selectOptionList = schemaP.enum2.map(function (element) { // init hasDefault schemaP.hasDefault = ( schemaP.hasDefault || schemaP.enumDefault.indexOf(element) >= 0 ); return { id: local.idDomElementCreate("swgg_id_" + schemaP.name), selected: ( schemaP.enumDefault.indexOf(element) >= 0 ? "selected" : "" ), type: ( local.schemaPItemsType(schemaP) || local.schemaPType(schemaP) ), placeholder: ( typeof element === "string" ? element : JSON.stringify(element) ), valueSelectOption: element }; }); // init 'undefined' value if (!schemaP.required && !schemaP.hasDefault) { schemaP.selectOptionList.unshift({ id: local.idDomElementCreate("swgg_id_" + schemaP.name), selected: "selected", type: local.schemaPType(schemaP), placeholder: "<none>", valueSelectOption: "$swggUndefined" }); } // select at least one value schemaP.selectOptionList.some(function (element, ii) { if (ii === 0 || element.selected) { element.selected = "selected"; if (ii !== 0) { schemaP.selectOptionList[0].selected = ""; return true; } } }); // init input - textarea } else if (local.schemaPType(schemaP) === "array" || ( schemaP.format === "json" && local.schemaPType(schemaP) === "string" )) { schemaP.isTextarea = true; // init input - number } else if (schemaP.type === "integer" || schemaP.type === "number") { schemaP.isInputNumber = true; // init input - text } else { schemaP.isInputText = true; } // init format2 / type2 Array.from([ schemaP, schemaP.schema || {} ]).some(function (element) { local.objectSetDefault(schemaP, { format2: local.schemaPItemsType(element) || element.format, type2: local.schemaPType(element) }); return schemaP.type2; }); schemaP.type2 = schemaP.type2 || "object"; // init schema2 Array.from([ schemaP, local.schemaPItems(schemaP), schemaP.schema, schemaP.schema && local.schemaPItems(schemaP.schema) ]).some(function (element) { schemaP.schema2 = (local.swaggerValidateDataSchema({ // dereference schemaP modeDereference: true, modeDereferenceDepth: 2, prefix: [ "parameters", schemaP.name ], schema: element, swaggerJson: local.swaggerJson }) || {}); return schemaP.schema2.properties; }); if (schemaP.schema2.properties) { schemaP.schemaText = JSON.stringify(( schemaP.type2 === "array" ? [ schemaP.schema2.properties ] : schemaP.schema2.properties ), null, 4); } // init placeholder schemaP.placeholder = ( !local.isNullOrUndefined(schemaP.default) ? schemaP.default : local.dbFieldRandomCreate({ modeNotRandom: true, schemaP }) ); if (typeof schemaP.placeholder !== "string") { if (schemaP.in === "body") { schemaP.placeholder = JSON.stringify(schemaP.placeholder, null, 4); } else if (Array.isArray(schemaP.placeholder)) { schemaP.placeholder = schemaP.placeholder.map(function (element) { return ( typeof element === "string" ? element : JSON.stringify(element) ); }).join("\n"); } else { schemaP.placeholder = JSON.stringify(schemaP.placeholder); } } else if (schemaP.format === "json") { schemaP.placeholder = JSON.stringify( JSON.parse(schemaP.placeholder), null, 4 ); } // init valueText schemaP.valueText = ( schemaP["x-swgg-apiKey"] ? local.apiKeyValue : schemaP.default === null ? "" : (schemaP.required || schemaP.isTextarea) ? schemaP.placeholder : "" ); // templateRender schemaP schemaP.innerHTML = local.templateRender( local.templateUiParameter, schemaP ); }; local.urlParseWithBraket = function (url) { /* * this function will urlParse the url with curly-brackets preserved */ let tmp; tmp = local.stringUniqueKey(url); return JSON.parse(JSON.stringify( local.urlParse(url.replace(( /\{/g ), tmp + 1).replace(( /\}/g ), tmp + 2)) ).replace( new RegExp(tmp + 1, "g"), "{" ).replace( new RegExp(tmp + 2, "g"), "}" )); }; local.userLoginByPassword = function (opt, onError) { /* * this function will send a login-by-password req */ local.apiDict["GET /user/userLoginByPassword"].ajax({ paramDict: { password: opt.password, username: opt.username } }, onError); }; local.userLogout = function (opt, onError) { /* * this function will send a logout req */ local.apiDict["GET /user/userLogout"].ajax(opt, onError); }; }()); // run node js-env code - init-after /* istanbul ignore next */ (function () { if (local.isBrowser) { return; } local.assetsDict["/assets.swagger-ui.logo.medium.png"] = Buffer.from( local.templateSwaggerUiLogoMediumBase64, "base64" ); local.assetsDict["/assets.swagger-ui.logo.small.png"] = Buffer.from( local.templateSwaggerUiLogoSmallBase64, "base64" ); local.swgg.apiUpdate(local.fsReadFileOrEmptyStringSync( local.__dirname + "/assets.swgg.swagger.json", "json" )); }()); }()); |