forked from loafle/openapi-generator-original
Compare commits
1663 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c00f4ba805 | ||
|
|
dd3b253e15 | ||
|
|
3969a9f294 | ||
|
|
78f8eaa687 | ||
|
|
fe676c83c0 | ||
|
|
18370b9076 | ||
|
|
70d987666e | ||
|
|
6247dd0cde | ||
|
|
ea7ef990b9 | ||
|
|
83afaffd92 | ||
|
|
d2faa63ebc | ||
|
|
dcec2e7b5d | ||
|
|
940e76f45f | ||
|
|
fecbc3c45d | ||
|
|
a6e4203cd5 | ||
|
|
dd34d75f00 | ||
|
|
1eed1917b9 | ||
|
|
91afec43a6 | ||
|
|
adeff7855c | ||
|
|
e289b858a9 | ||
|
|
7170f7fa01 | ||
|
|
6253a592d9 | ||
|
|
9f842a1295 | ||
|
|
723cf9b823 | ||
|
|
bbb59f93db | ||
|
|
2fcb705826 | ||
|
|
4723f51c63 | ||
|
|
485186e6b6 | ||
|
|
1ac6842b5a | ||
|
|
57e3ea3e9c | ||
|
|
0f75b053c8 | ||
|
|
eee69f1e05 | ||
|
|
9b8a633435 | ||
|
|
dcc47a92b5 | ||
|
|
e9aaa6da36 | ||
|
|
568a7be994 | ||
|
|
214e0186e8 | ||
|
|
7f5cdba606 | ||
|
|
295af57c9a | ||
|
|
bade71c6ba | ||
|
|
9adb077a7b | ||
|
|
10a9c62e2b | ||
|
|
a6bd0773f7 | ||
|
|
b2506ab598 | ||
|
|
a21f08118e | ||
|
|
96380bbc83 | ||
|
|
abe4980449 | ||
|
|
e3151c57a0 | ||
|
|
d2dc333699 | ||
|
|
b41a40f9be | ||
|
|
2f3a2413c7 | ||
|
|
19ea3ecf66 | ||
|
|
5c29562926 | ||
|
|
b827d06077 | ||
|
|
539496d735 | ||
|
|
6b7059d23f | ||
|
|
bff8f96b99 | ||
|
|
5e69d929a0 | ||
|
|
e1ee7065d5 | ||
|
|
aaf1df1971 | ||
|
|
555fd54fbb | ||
|
|
905a7746e7 | ||
|
|
eeaf4071f9 | ||
|
|
84b7302f12 | ||
|
|
1b0963ebe0 | ||
|
|
b054cd3cc6 | ||
|
|
4ea797d0e8 | ||
|
|
002feb3e7c | ||
|
|
89dc4d29ab | ||
|
|
3cf1f1a56a | ||
|
|
b83db8e535 | ||
|
|
eb1e0b5034 | ||
|
|
d7b4f58994 | ||
|
|
e8fbdaabe3 | ||
|
|
b82333aea4 | ||
|
|
7bbb883a00 | ||
|
|
6477a27579 | ||
|
|
ad1626ad2d | ||
|
|
bfa4303e6e | ||
|
|
9508579eed | ||
|
|
9ac980298f | ||
|
|
a2fda604f8 | ||
|
|
8339e4b092 | ||
|
|
90eab19305 | ||
|
|
8a2c34ba7a | ||
|
|
8c5991b793 | ||
|
|
3debd08a32 | ||
|
|
92d1e8a1d9 | ||
|
|
71c5160739 | ||
|
|
3dd0b04fb9 | ||
|
|
04369ddfce | ||
|
|
084e7f7199 | ||
|
|
ab026fdde3 | ||
|
|
e0dfc1b43d | ||
|
|
d5e2aea723 | ||
|
|
d2df310290 | ||
|
|
7db67aa192 | ||
|
|
a1fa0b0834 | ||
|
|
02a9fe2618 | ||
|
|
97a5a8922f | ||
|
|
0802f94d94 | ||
|
|
21eb406140 | ||
|
|
84928abd8d | ||
|
|
1c21730607 | ||
|
|
5a76a1b155 | ||
|
|
bc5a610567 | ||
|
|
860b551e9b | ||
|
|
22218cb132 | ||
|
|
300a0dc82c | ||
|
|
3a66c0c710 | ||
|
|
a94384ca7f | ||
|
|
6d50ce6a77 | ||
|
|
583493f5ca | ||
|
|
6cc17d8508 | ||
|
|
265b4b5945 | ||
|
|
65e63a8c52 | ||
|
|
e4e77d03f5 | ||
|
|
638bbfaf43 | ||
|
|
0b4b5e8839 | ||
|
|
c7b08bc112 | ||
|
|
f1b0cf839a | ||
|
|
988de07c17 | ||
|
|
f603efc419 | ||
|
|
4e7d893a8e | ||
|
|
1ef51e5ad7 | ||
|
|
17545e959a | ||
|
|
5ed52b3e1d | ||
|
|
6ce09ee779 | ||
|
|
7b1799f874 | ||
|
|
43b3acf550 | ||
|
|
d162d48fa3 | ||
|
|
e562b0ae34 | ||
|
|
748460488a | ||
|
|
1fb2a97497 | ||
|
|
15f5eae2a8 | ||
|
|
6fd54d5285 | ||
|
|
00517a1ad3 | ||
|
|
5cd01af350 | ||
|
|
9ecb2e92ae | ||
|
|
6cc5a32d40 | ||
|
|
64fd94262f | ||
|
|
5144c54895 | ||
|
|
9311dcaccb | ||
|
|
a5a6ae72c3 | ||
|
|
c31ed5a30d | ||
|
|
aa0fbada07 | ||
|
|
ab34dc5697 | ||
|
|
edf2642e73 | ||
|
|
d95660aca1 | ||
|
|
297f9e961c | ||
|
|
42b716207f | ||
|
|
7d69107696 | ||
|
|
4d2fb1cc9a | ||
|
|
503ffd06d0 | ||
|
|
725df15dd5 | ||
|
|
8e9e3a6171 | ||
|
|
6ee42bebe6 | ||
|
|
69a346cb57 | ||
|
|
d451d4efb8 | ||
|
|
b7b8b527db | ||
|
|
3bd4502bbf | ||
|
|
733e19c113 | ||
|
|
735cae7b49 | ||
|
|
3b36bbe97d | ||
|
|
228e039046 | ||
|
|
b27663e1ad | ||
|
|
eaddebe220 | ||
|
|
f8485f26d3 | ||
|
|
d9117480f8 | ||
|
|
7b79abef63 | ||
|
|
dbd89092f0 | ||
|
|
6ed7663466 | ||
|
|
d882e9fe0a | ||
|
|
ea1c2809f7 | ||
|
|
3c78e29a12 | ||
|
|
6cb4473526 | ||
|
|
65a9c78544 | ||
|
|
69911a1974 | ||
|
|
761029241e | ||
|
|
1018ca634d | ||
|
|
ff0b0c15a8 | ||
|
|
727c32f2a2 | ||
|
|
3c0eab65f3 | ||
|
|
a72ac99c91 | ||
|
|
4b62a94350 | ||
|
|
12d8f97aee | ||
|
|
acaf1b1cd0 | ||
|
|
c1c3439b86 | ||
|
|
5744bb4053 | ||
|
|
2711e375cc | ||
|
|
25abc15233 | ||
|
|
984b645ea1 | ||
|
|
253c46a0d5 | ||
|
|
7c431a8e11 | ||
|
|
3c98e32765 | ||
|
|
f483f934d8 | ||
|
|
053af7a749 | ||
|
|
d2d6ff661a | ||
|
|
17bdd73891 | ||
|
|
d9bfb884da | ||
|
|
19d8766363 | ||
|
|
e270fdcfd9 | ||
|
|
a2f47672e7 | ||
|
|
90dc0a7bd8 | ||
|
|
2a679f798a | ||
|
|
dbecb9e562 | ||
|
|
4db86003f5 | ||
|
|
d5cf2b6cfe | ||
|
|
6a3108a6bf | ||
|
|
2ea3816e65 | ||
|
|
baca3027f4 | ||
|
|
0e9e2046e7 | ||
|
|
e301020acc | ||
|
|
cf1f113852 | ||
|
|
c26a387d9a | ||
|
|
c70ca9d572 | ||
|
|
6bdfb8810c | ||
|
|
2a5ab78056 | ||
|
|
e5a4ef3ba0 | ||
|
|
9b148be57e | ||
|
|
0380fc5a35 | ||
|
|
597282742b | ||
|
|
5e805c2be6 | ||
|
|
b080abeb01 | ||
|
|
2943f41cdd | ||
|
|
84e0df6115 | ||
|
|
a49826e4d7 | ||
|
|
b8792b6a71 | ||
|
|
5ee86b9816 | ||
|
|
e32272aedb | ||
|
|
ee7f447f77 | ||
|
|
a5fb689615 | ||
|
|
a26cf60a22 | ||
|
|
ed13d7b1b8 | ||
|
|
c59e2b88b1 | ||
|
|
e8d40a146c | ||
|
|
4ef69794a3 | ||
|
|
30fbdd4d05 | ||
|
|
13c079342e | ||
|
|
a284bb7a51 | ||
|
|
44bbe301cb | ||
|
|
69f8274287 | ||
|
|
770ea9d12e | ||
|
|
d09d8bb495 | ||
|
|
85f99934c8 | ||
|
|
66dee928d2 | ||
|
|
d4a94fbf52 | ||
|
|
844cae75b7 | ||
|
|
4e4e9e7893 | ||
|
|
61690d625f | ||
|
|
1cd8141645 | ||
|
|
98ff2d231f | ||
|
|
09add2d871 | ||
|
|
9cbf2d3707 | ||
|
|
0622838947 | ||
|
|
a6df340cdc | ||
|
|
bcbf9c54c7 | ||
|
|
6dcaa890cf | ||
|
|
2b06a81a52 | ||
|
|
956624f1a4 | ||
|
|
b1728aed7c | ||
|
|
8733be9ac9 | ||
|
|
c203854254 | ||
|
|
3dc3af8d18 | ||
|
|
cbc2fb237d | ||
|
|
b7d64d1352 | ||
|
|
047b06ac84 | ||
|
|
f29f5d6f13 | ||
|
|
1863aca0fa | ||
|
|
cf300c09da | ||
|
|
27ab9c2e57 | ||
|
|
c83c564a19 | ||
|
|
8978a0a906 | ||
|
|
6d21422bad | ||
|
|
65cfa735d5 | ||
|
|
e2ce427fb1 | ||
|
|
781458b0d1 | ||
|
|
65f86dbb0f | ||
|
|
cc1c495ea5 | ||
|
|
261ae79528 | ||
|
|
fb14585adf | ||
|
|
27e434d786 | ||
|
|
2a37c48e12 | ||
|
|
85df7c8ed7 | ||
|
|
b3ca9cdbe0 | ||
|
|
477d5c40d9 | ||
|
|
460c8caa8a | ||
|
|
53e13aee19 | ||
|
|
ec05dc4414 | ||
|
|
7eec769654 | ||
|
|
f483b8dfa8 | ||
|
|
2ac41ff080 | ||
|
|
ade61c0701 | ||
|
|
bd63c1d9d9 | ||
|
|
5d1e70544c | ||
|
|
349702adf9 | ||
|
|
88410635b3 | ||
|
|
0262d3c8d2 | ||
|
|
96f4a3ab71 | ||
|
|
b0063d9e9f | ||
|
|
48bd888483 | ||
|
|
1358e33bf6 | ||
|
|
c8edacb25c | ||
|
|
47dc4d7642 | ||
|
|
1ecb8a74c1 | ||
|
|
967c574f5b | ||
|
|
8bb8a7a79a | ||
|
|
1268b0627f | ||
|
|
761f172c2f | ||
|
|
1321d5f9a5 | ||
|
|
35f462f571 | ||
|
|
f21fa08cd6 | ||
|
|
16afd4ee9b | ||
|
|
46f78f2180 | ||
|
|
2e402bba97 | ||
|
|
34f196a144 | ||
|
|
def3f5b3fb | ||
|
|
60e5a34534 | ||
|
|
1eed90f34e | ||
|
|
e34063f0f2 | ||
|
|
dbdcf34044 | ||
|
|
43d71ed10c | ||
|
|
b3db24ead6 | ||
|
|
d21c6f2b45 | ||
|
|
3c3762fd92 | ||
|
|
0edbfeff15 | ||
|
|
4b539a9d6e | ||
|
|
71a3218bb3 | ||
|
|
d37cf6595a | ||
|
|
1bac705876 | ||
|
|
3385082e2c | ||
|
|
2b1a63a7de | ||
|
|
93847d8dc7 | ||
|
|
3514bf14b3 | ||
|
|
e215a1c87f | ||
|
|
5bcd8fb207 | ||
|
|
a8f7708789 | ||
|
|
26c0bfef7d | ||
|
|
12190e0900 | ||
|
|
f340a389e9 | ||
|
|
8b96cdb7d7 | ||
|
|
90307cafc6 | ||
|
|
58c5ecf13c | ||
|
|
e72a53448e | ||
|
|
90b89c6189 | ||
|
|
ee1febcd95 | ||
|
|
6c079e95d9 | ||
|
|
d22398eb73 | ||
|
|
30228dcca5 | ||
|
|
2e30a3af27 | ||
|
|
212d240316 | ||
|
|
ba701be2f2 | ||
|
|
f6d624be2a | ||
|
|
f705e03fc4 | ||
|
|
75bb59572a | ||
|
|
f067b86fa0 | ||
|
|
2822e9ea38 | ||
|
|
435ce7b9d5 | ||
|
|
ab6118afe4 | ||
|
|
8ce06fc898 | ||
|
|
9e8e5db7b3 | ||
|
|
44b5c22cd4 | ||
|
|
6d7557971b | ||
|
|
9af16c0d79 | ||
|
|
027e4c5a20 | ||
|
|
c56d807a15 | ||
|
|
7d4ba27e01 | ||
|
|
c8ed2b0d50 | ||
|
|
1520ec536e | ||
|
|
e434380eae | ||
|
|
5940f46f56 | ||
|
|
7c60e2097f | ||
|
|
fc7cffbab7 | ||
|
|
b099d1e7a2 | ||
|
|
31e8aca357 | ||
|
|
d746894ecb | ||
|
|
2c64e0893b | ||
|
|
3c79a692aa | ||
|
|
72255286b3 | ||
|
|
3112e4ad06 | ||
|
|
38b1e1aad7 | ||
|
|
dfb87abe3a | ||
|
|
b96fdb6766 | ||
|
|
369ceb634d | ||
|
|
92f9b33eb6 | ||
|
|
5b12379a07 | ||
|
|
39b4034958 | ||
|
|
28030cba19 | ||
|
|
e0679c0b14 | ||
|
|
2fd8b8ff16 | ||
|
|
e35be1bd40 | ||
|
|
39ac64d24a | ||
|
|
b846fa5c3e | ||
|
|
3c84847adb | ||
|
|
2b48ec072c | ||
|
|
8114c416b9 | ||
|
|
adee62da7d | ||
|
|
a207251b29 | ||
|
|
265de9654b | ||
|
|
177436e69c | ||
|
|
1331484a0f | ||
|
|
4477009ef8 | ||
|
|
930c5191e0 | ||
|
|
5f811f3ba7 | ||
|
|
74bffbaadb | ||
|
|
cdd104d3fb | ||
|
|
be84f03d14 | ||
|
|
28579cee03 | ||
|
|
32ffab4519 | ||
|
|
e3c6cc3220 | ||
|
|
84346c0ba6 | ||
|
|
acbf3d3cc5 | ||
|
|
5c74146879 | ||
|
|
a59c128f90 | ||
|
|
810bf58c3a | ||
|
|
724683fab0 | ||
|
|
074ba1ea54 | ||
|
|
9e5de7da5e | ||
|
|
50f6067831 | ||
|
|
9453967815 | ||
|
|
fc4fce3731 | ||
|
|
d31013d977 | ||
|
|
ccf0cc8375 | ||
|
|
99ed012fc6 | ||
|
|
8ba4a6d7ad | ||
|
|
60fddcf378 | ||
|
|
cf5982d2c4 | ||
|
|
1378976d37 | ||
|
|
e5811ebdc7 | ||
|
|
d434b7c440 | ||
|
|
8de9e23814 | ||
|
|
b35a7b696e | ||
|
|
587028efd1 | ||
|
|
af8d61cc02 | ||
|
|
1996aa9244 | ||
|
|
f79f8895c5 | ||
|
|
b3d28f07f1 | ||
|
|
570a595ffb | ||
|
|
568b7a4fcd | ||
|
|
1b2f491b0e | ||
|
|
eb21963fa5 | ||
|
|
ab5483cd04 | ||
|
|
392e5172b5 | ||
|
|
52dc7e210c | ||
|
|
15e336b90a | ||
|
|
698ed970dc | ||
|
|
a43d2163a0 | ||
|
|
564dffa7e8 | ||
|
|
68f61d9a37 | ||
|
|
a7c08e680c | ||
|
|
2251a2f892 | ||
|
|
b0c776bbea | ||
|
|
3d89399b58 | ||
|
|
0261121d78 | ||
|
|
c177cf75d2 | ||
|
|
d4b4fe4b47 | ||
|
|
e956495665 | ||
|
|
8408a97aef | ||
|
|
b3afbe73b9 | ||
|
|
85aabbe810 | ||
|
|
3f8dbf416d | ||
|
|
0e0bfde3a8 | ||
|
|
29a2eedc1e | ||
|
|
0d5c066605 | ||
|
|
6820179903 | ||
|
|
617fa43a89 | ||
|
|
dd67287d63 | ||
|
|
6aa66897aa | ||
|
|
9b0ddd3a7f | ||
|
|
ee05366d0b | ||
|
|
d048a68438 | ||
|
|
9cc7615b71 | ||
|
|
dfb9d26c75 | ||
|
|
715c0af41f | ||
|
|
65829e5b6e | ||
|
|
a3c7e22d55 | ||
|
|
d8ceb8c648 | ||
|
|
87f1ef4dc2 | ||
|
|
7c2310a13f | ||
|
|
6dcb8da2d8 | ||
|
|
a83f01ad60 | ||
|
|
6c1f7243bf | ||
|
|
164ed99812 | ||
|
|
355cc88e0d | ||
|
|
35ed412d1e | ||
|
|
a5190266b6 | ||
|
|
d51fe80138 | ||
|
|
ec9cdca7cb | ||
|
|
8a9f43b142 | ||
|
|
0fc5702e4d | ||
|
|
3390fae15b | ||
|
|
e19b883c89 | ||
|
|
9531e1ae59 | ||
|
|
3d38c41b0e | ||
|
|
718e1ff68a | ||
|
|
a6a9d743be | ||
|
|
414de00894 | ||
|
|
cc7366787f | ||
|
|
3486eecdfc | ||
|
|
66e6d4fb8a | ||
|
|
f7dc066dec | ||
|
|
3160913433 | ||
|
|
e253fdea33 | ||
|
|
ac49d0dcdc | ||
|
|
b956d47a9d | ||
|
|
f662699fd0 | ||
|
|
1c1571cc3a | ||
|
|
e13374e1df | ||
|
|
f2df26f6e6 | ||
|
|
569082743f | ||
|
|
595c01c537 | ||
|
|
dc423cc11d | ||
|
|
4f25a0e6c5 | ||
|
|
0af29cc5cf | ||
|
|
44b4af0374 | ||
|
|
b68beefa69 | ||
|
|
07162811a7 | ||
|
|
4023460f2e | ||
|
|
83bea6a0c5 | ||
|
|
d03f680c64 | ||
|
|
4189d0765b | ||
|
|
6218ad139f | ||
|
|
b7cd38d38b | ||
|
|
2b61305582 | ||
|
|
2057d0e144 | ||
|
|
af2ec4cf85 | ||
|
|
9a239ad2a4 | ||
|
|
a610fb5ac3 | ||
|
|
fb4c62cc28 | ||
|
|
6d58d44542 | ||
|
|
0e2e7838ae | ||
|
|
2e3f94c2a5 | ||
|
|
e02a9f1797 | ||
|
|
0d399d3f6a | ||
|
|
030e45982c | ||
|
|
894d571ea5 | ||
|
|
dc1992ad45 | ||
|
|
7be6e971fa | ||
|
|
c62fca8c54 | ||
|
|
828f8694c8 | ||
|
|
31d948fc16 | ||
|
|
a481db7486 | ||
|
|
5d52952ebd | ||
|
|
c1fbf6bb1c | ||
|
|
10cd672529 | ||
|
|
52918d325e | ||
|
|
8cff8fc55a | ||
|
|
90d5ce228a | ||
|
|
d4ff25f0b3 | ||
|
|
4163f07911 | ||
|
|
560fd5718d | ||
|
|
97580a8c45 | ||
|
|
aee72d97c3 | ||
|
|
49ad008d7c | ||
|
|
7a2c0a076a | ||
|
|
365f4bc0c0 | ||
|
|
3478e053e1 | ||
|
|
75536868f2 | ||
|
|
84e8ef489c | ||
|
|
cffba0299a | ||
|
|
a6c07a8364 | ||
|
|
b14edffc79 | ||
|
|
b971aa7433 | ||
|
|
bb4311b7a2 | ||
|
|
1c0eb60c71 | ||
|
|
a0eeb90a97 | ||
|
|
38fccbd73d | ||
|
|
6fbb8ab1e0 | ||
|
|
6044f0586e | ||
|
|
84ff5cfc87 | ||
|
|
96be2b196b | ||
|
|
d93b404b23 | ||
|
|
be63776162 | ||
|
|
ae4b4979a7 | ||
|
|
0a8fb1e532 | ||
|
|
e78844cb54 | ||
|
|
2eb0c8cea6 | ||
|
|
2aaad03ab6 | ||
|
|
cb181e3480 | ||
|
|
b686b53259 | ||
|
|
f27eb7e0de | ||
|
|
36b7fb20b2 | ||
|
|
f2ef21e756 | ||
|
|
e57f1de21f | ||
|
|
a41361c959 | ||
|
|
167e95bb3a | ||
|
|
732a9eb64d | ||
|
|
c7f595fc91 | ||
|
|
29e8a8f573 | ||
|
|
d5b959d8cd | ||
|
|
7a92f53b55 | ||
|
|
4ac8a93022 | ||
|
|
cad2f961bd | ||
|
|
5328c00e8f | ||
|
|
1b31a01b76 | ||
|
|
c67a6582fc | ||
|
|
dc76887820 | ||
|
|
4321339d4f | ||
|
|
07f10a8abc | ||
|
|
4ba521a5c0 | ||
|
|
d88ec847ae | ||
|
|
7c16dfcf13 | ||
|
|
aff21e5e6b | ||
|
|
befacc41bd | ||
|
|
edebbcb802 | ||
|
|
bfb4629ab7 | ||
|
|
1007534575 | ||
|
|
97d24a7119 | ||
|
|
13038d2a12 | ||
|
|
c5dc070685 | ||
|
|
a30b66beb1 | ||
|
|
aff766b785 | ||
|
|
112a7ec8c1 | ||
|
|
55be0330e3 | ||
|
|
fe83d18a09 | ||
|
|
a6f8f9e4ff | ||
|
|
79c988616c | ||
|
|
dc62f688d9 | ||
|
|
db10bd764b | ||
|
|
92208b4ec2 | ||
|
|
0ef4702aa8 | ||
|
|
cc358cf9ce | ||
|
|
a1e6908b65 | ||
|
|
2d4c07a474 | ||
|
|
05f00013f1 | ||
|
|
bc528ef928 | ||
|
|
318a239976 | ||
|
|
189962208e | ||
|
|
bd28271b0b | ||
|
|
14b808a910 | ||
|
|
d345f8fae3 | ||
|
|
26336356cf | ||
|
|
9c3fad3040 | ||
|
|
d396a0a0e4 | ||
|
|
dc7c2a4bab | ||
|
|
0b85ad464a | ||
|
|
c5d02fe98e | ||
|
|
a81e5096f5 | ||
|
|
52971e6aa9 | ||
|
|
b2e0d83f2e | ||
|
|
2be3414357 | ||
|
|
ea901bf1ce | ||
|
|
8bd282acd6 | ||
|
|
b51ef77401 | ||
|
|
3265ec0f72 | ||
|
|
732e645042 | ||
|
|
cc45ff17cb | ||
|
|
b843b55339 | ||
|
|
75711f954b | ||
|
|
d0b5af31a5 | ||
|
|
c01c06b198 | ||
|
|
586f4c14e1 | ||
|
|
fe0e43f963 | ||
|
|
47abfe7079 | ||
|
|
d0a3def441 | ||
|
|
7af5db3565 | ||
|
|
47c8597d36 | ||
|
|
64f2e85608 | ||
|
|
09ccf12a3b | ||
|
|
fde5c60cb0 | ||
|
|
b18cc5e0de | ||
|
|
6d8dea5dfc | ||
|
|
a8f580032f | ||
|
|
d0baa48fcd | ||
|
|
31200acc1a | ||
|
|
5bfae7b78c | ||
|
|
3b9b3e82f9 | ||
|
|
783a4c0572 | ||
|
|
9ce824d720 | ||
|
|
dee828622a | ||
|
|
5c0ae7babe | ||
|
|
02da80e837 | ||
|
|
e41a475335 | ||
|
|
fea8e680df | ||
|
|
b0f6b49595 | ||
|
|
b56da43953 | ||
|
|
979a704310 | ||
|
|
5dcdadb751 | ||
|
|
f98974190e | ||
|
|
6719a6cc74 | ||
|
|
3f9b2a9678 | ||
|
|
bbf0ce8c80 | ||
|
|
9fc8c770d3 | ||
|
|
8f2c99f0af | ||
|
|
81f5cc47e7 | ||
|
|
db37c02ebd | ||
|
|
fc71b23464 | ||
|
|
e924cec595 | ||
|
|
90f152da75 | ||
|
|
713ae4a957 | ||
|
|
50736458d0 | ||
|
|
34b341874c | ||
|
|
7a1f3dbf9e | ||
|
|
3723a9ba2d | ||
|
|
bc8eae838c | ||
|
|
88ed496b44 | ||
|
|
646da19c7d | ||
|
|
80b5363202 | ||
|
|
071fc2ded6 | ||
|
|
992b0c7e5e | ||
|
|
037f59d0df | ||
|
|
5a235c642a | ||
|
|
08ea05f7a1 | ||
|
|
e301d9d00e | ||
|
|
8a399ee1cb | ||
|
|
4e5b9e4af3 | ||
|
|
37c79525f7 | ||
|
|
f9ad16e7aa | ||
|
|
cde8d7ba4c | ||
|
|
a75b05b952 | ||
|
|
bd6fa6a2e4 | ||
|
|
609d915541 | ||
|
|
948cdb3a75 | ||
|
|
b9287cf417 | ||
|
|
df93ca80f7 | ||
|
|
0247f0774d | ||
|
|
37dbd6e4cd | ||
|
|
34db9814d8 | ||
|
|
4ecc757bea | ||
|
|
cf7082c2e6 | ||
|
|
6b4f810fec | ||
|
|
f7a07f72b8 | ||
|
|
a6012ecf41 | ||
|
|
0b7b57bf4d | ||
|
|
498a400d4e | ||
|
|
405e5a7a35 | ||
|
|
3de42afed3 | ||
|
|
f1304022b0 | ||
|
|
fc7f2a92d0 | ||
|
|
27113cf326 | ||
|
|
7179c15158 | ||
|
|
ba72e7344a | ||
|
|
596bde2ef6 | ||
|
|
a863e538a8 | ||
|
|
a134b5ca76 | ||
|
|
1f7664f81e | ||
|
|
68820e5a80 | ||
|
|
195c71da37 | ||
|
|
ddfa713f55 | ||
|
|
c9889c5baf | ||
|
|
60d6cd744a | ||
|
|
1072c9d017 | ||
|
|
4bc4a8aed1 | ||
|
|
0ad7005547 | ||
|
|
3993ef3dc8 | ||
|
|
8746f1544b | ||
|
|
f0e09ae33a | ||
|
|
e879268043 | ||
|
|
33561fa159 | ||
|
|
78760907a5 | ||
|
|
30eb1f1075 | ||
|
|
5c9afbafb2 | ||
|
|
0092d8a63b | ||
|
|
3c6f07cbe3 | ||
|
|
95cb5f73a3 | ||
|
|
02f6c805af | ||
|
|
13d74f01a2 | ||
|
|
8877be82f0 | ||
|
|
a25d3f2543 | ||
|
|
3f017af464 | ||
|
|
0e56d0d1c6 | ||
|
|
f48a7f20e6 | ||
|
|
9a15ced211 | ||
|
|
e244d20152 | ||
|
|
412b6b3839 | ||
|
|
0a652a3d13 | ||
|
|
4d302683f3 | ||
|
|
517717958d | ||
|
|
b42ead3c0f | ||
|
|
8a3c64aa41 | ||
|
|
d97b0984cb | ||
|
|
0e8cf70dc4 | ||
|
|
88e5860d9b | ||
|
|
157b07e552 | ||
|
|
1f097ee1a1 | ||
|
|
7a5fd24785 | ||
|
|
59258be3dd | ||
|
|
e5bdb3a0c1 | ||
|
|
dd35c672f0 | ||
|
|
18ea21087f | ||
|
|
746a55be73 | ||
|
|
7242a664e3 | ||
|
|
9f76acbbd7 | ||
|
|
af67353022 | ||
|
|
ecf4082d68 | ||
|
|
5821e41185 | ||
|
|
822e640e0a | ||
|
|
30925b7800 | ||
|
|
bb570d7efa | ||
|
|
c88c85a317 | ||
|
|
23dfac0194 | ||
|
|
b99f006861 | ||
|
|
80d1deb2dd | ||
|
|
2912ee8ae1 | ||
|
|
6df6c079ee | ||
|
|
f4226474e2 | ||
|
|
b70a0bf0c6 | ||
|
|
7dca394eca | ||
|
|
80303b524d | ||
|
|
6e7c70f247 | ||
|
|
715c56afcc | ||
|
|
aad05c4dee | ||
|
|
3f9d1607b6 | ||
|
|
879c1b921c | ||
|
|
fb0b7d622f | ||
|
|
f154e407d2 | ||
|
|
44705b566d | ||
|
|
71a22141bf | ||
|
|
38149173ff | ||
|
|
2258a4632d | ||
|
|
259b31ccd4 | ||
|
|
7f31da734d | ||
|
|
fcd0b31d7d | ||
|
|
4c2df94ec7 | ||
|
|
38760d2aa1 | ||
|
|
f6174051cb | ||
|
|
68915eeb8f | ||
|
|
1434691927 | ||
|
|
b46efd839d | ||
|
|
c7f8f0171b | ||
|
|
045a3b44c1 | ||
|
|
6c85fc285a | ||
|
|
7cc9581f04 | ||
|
|
9283249963 | ||
|
|
461f556289 | ||
|
|
e3d3641b96 | ||
|
|
7e8f8e85d7 | ||
|
|
abc7100a17 | ||
|
|
661b9d6315 | ||
|
|
a21c2be877 | ||
|
|
5c29cbf33d | ||
|
|
d3bc347e31 | ||
|
|
1f35f58841 | ||
|
|
a51d71e728 | ||
|
|
b8c06505f6 | ||
|
|
80731633b4 | ||
|
|
4c16366f45 | ||
|
|
4133cae2bc | ||
|
|
f6a1af2831 | ||
|
|
a24fee00cb | ||
|
|
f42f329ace | ||
|
|
6fd2ccabee | ||
|
|
20c7932df4 | ||
|
|
e49fe7a12f | ||
|
|
b1b0e28f59 | ||
|
|
dfd8d5ef64 | ||
|
|
94768d44b5 | ||
|
|
3b1999af4b | ||
|
|
7e4a82bcfb | ||
|
|
f823c0e26a | ||
|
|
bf32777b67 | ||
|
|
987a61640b | ||
|
|
66d16cfeaf | ||
|
|
0bf4163389 | ||
|
|
b61a400d91 | ||
|
|
55827fe516 | ||
|
|
5c888ad039 | ||
|
|
d7d6ba957e | ||
|
|
57b54d8ad7 | ||
|
|
4b896c759c | ||
|
|
aba755d3de | ||
|
|
fe35675168 | ||
|
|
d825b96720 | ||
|
|
422da698f6 | ||
|
|
488e604207 | ||
|
|
846d282ba0 | ||
|
|
6f1dd5ce35 | ||
|
|
108b2241c0 | ||
|
|
4d6dbf7d92 | ||
|
|
eca827613d | ||
|
|
2e76b56f30 | ||
|
|
f290de95dd | ||
|
|
59987a54a9 | ||
|
|
2d59c5d190 | ||
|
|
9726ada8d1 | ||
|
|
76ece5a4eb | ||
|
|
91af76cf41 | ||
|
|
65af735d6c | ||
|
|
30bc58f6ff | ||
|
|
3eca940e7d | ||
|
|
38d62d768a | ||
|
|
1de6952279 | ||
|
|
54d6a7e19c | ||
|
|
fafddbf040 | ||
|
|
d8b0cb739f | ||
|
|
2d3d35cfd7 | ||
|
|
8c10e4f2b0 | ||
|
|
0ac1ef266f | ||
|
|
327128dbba | ||
|
|
16e80c65d7 | ||
|
|
40c9f05536 | ||
|
|
091e76703c | ||
|
|
6a24b328e3 | ||
|
|
4143e28637 | ||
|
|
31efefe0b9 | ||
|
|
e60bd564cb | ||
|
|
69b75bb1af | ||
|
|
1fb796f14d | ||
|
|
e996498a24 | ||
|
|
c3d1367e7c | ||
|
|
69eae7d35b | ||
|
|
162d1d1f98 | ||
|
|
07d5365c5c | ||
|
|
f1239aba6c | ||
|
|
37620518e7 | ||
|
|
9d739a44cd | ||
|
|
18ac6e8aae | ||
|
|
8cce7ac053 | ||
|
|
e6e1db2064 | ||
|
|
ceafbcc97f | ||
|
|
f3a0f464f7 | ||
|
|
1af23fb751 | ||
|
|
ea76f34de5 | ||
|
|
8ce3823698 | ||
|
|
644231b915 | ||
|
|
621e3e7b1a | ||
|
|
6aac24398a | ||
|
|
545fb52b7d | ||
|
|
8e6c0f96fb | ||
|
|
1b1f860c82 | ||
|
|
50dd196d42 | ||
|
|
ce6ec20fef | ||
|
|
11e56f5c9c | ||
|
|
efd5b806be | ||
|
|
1b4c71c280 | ||
|
|
d83036ccdf | ||
|
|
d18426c69a | ||
|
|
351833a923 | ||
|
|
2979d93829 | ||
|
|
2fce2e4109 | ||
|
|
13d350be2e | ||
|
|
550493ba84 | ||
|
|
c45af23946 | ||
|
|
19ee56592e | ||
|
|
aec4af1b88 | ||
|
|
46869df631 | ||
|
|
c91a1b963b | ||
|
|
2fced0f634 | ||
|
|
60b0ffeb0e | ||
|
|
6623e120cd | ||
|
|
46ec934a9c | ||
|
|
5a9e9550ca | ||
|
|
8e0142338e | ||
|
|
61e368ce87 | ||
|
|
c93b0dd3b8 | ||
|
|
79e31a5761 | ||
|
|
fa3a9a9d61 | ||
|
|
febaa340e3 | ||
|
|
bcab55e3ef | ||
|
|
24465d2df4 | ||
|
|
8540ac71c8 | ||
|
|
9e47042122 | ||
|
|
e0109afc60 | ||
|
|
ff88f7175d | ||
|
|
c9a9b0ad2b | ||
|
|
db01ec801f | ||
|
|
495e528eec | ||
|
|
a7c91d610f | ||
|
|
d08acf7298 | ||
|
|
7be35bb02e | ||
|
|
b4d6fd3ba3 | ||
|
|
d5d1483656 | ||
|
|
02c41ac574 | ||
|
|
3a6f431f62 | ||
|
|
4fe979a8c0 | ||
|
|
3b6a3b4a38 | ||
|
|
da14c9e692 | ||
|
|
b8b003bc83 | ||
|
|
229ea93627 | ||
|
|
24296eacea | ||
|
|
6958db3d3d | ||
|
|
32b50e7c8e | ||
|
|
b803895750 | ||
|
|
d1153dfeb4 | ||
|
|
385fab225e | ||
|
|
89a5abb217 | ||
|
|
79a5614be9 | ||
|
|
a1b56c9b83 | ||
|
|
ecddfb7ccf | ||
|
|
bd5eb7ace3 | ||
|
|
8e15bd6a85 | ||
|
|
5ef50f9f4b | ||
|
|
a6331244e1 | ||
|
|
01d7776fc1 | ||
|
|
109b7eeaec | ||
|
|
5de99bafa7 | ||
|
|
a664abcf51 | ||
|
|
6f11092a57 | ||
|
|
e598384d97 | ||
|
|
53bddae904 | ||
|
|
1519912a1a | ||
|
|
b3a3bdd2e0 | ||
|
|
04be474f56 | ||
|
|
99e963709b | ||
|
|
b9ca19168a | ||
|
|
acf09da578 | ||
|
|
1d59937150 | ||
|
|
caa1b7f411 | ||
|
|
7a9a41fe01 | ||
|
|
acdc5328fe | ||
|
|
3252dd0d18 | ||
|
|
5c409884b9 | ||
|
|
f9f58596b8 | ||
|
|
bb11322919 | ||
|
|
4495774fd5 | ||
|
|
1aeb50feef | ||
|
|
b74050dd7b | ||
|
|
2ac7384abf | ||
|
|
eed45a41a3 | ||
|
|
69c2f6f945 | ||
|
|
5119299e8a | ||
|
|
719a0b732e | ||
|
|
8ed690cad0 | ||
|
|
f957471509 | ||
|
|
0b0325b8af | ||
|
|
d178d5e7d8 | ||
|
|
4ef34680cd | ||
|
|
6ab7be4058 | ||
|
|
df72188bc0 | ||
|
|
8d18aee2f2 | ||
|
|
449ba4f644 | ||
|
|
194c8ff71d | ||
|
|
62f4c252f2 | ||
|
|
5d19ef6146 | ||
|
|
a32335dfbc | ||
|
|
6b6480a026 | ||
|
|
a4df33d040 | ||
|
|
8b15416be5 | ||
|
|
bc92465bf7 | ||
|
|
a6bdc35d59 | ||
|
|
c50c8b724d | ||
|
|
0da3e58fff | ||
|
|
edcb71ad22 | ||
|
|
d6d707543d | ||
|
|
8858e7d7e3 | ||
|
|
64b46c2e15 | ||
|
|
82baa7ce4b | ||
|
|
d7315b56dc | ||
|
|
10e07eaf74 | ||
|
|
e7d4a438dd | ||
|
|
9e8631b75f | ||
|
|
e39ec927a2 | ||
|
|
6ad3a717fe | ||
|
|
f66b5cf65b | ||
|
|
d8c337185f | ||
|
|
5ade64b3e1 | ||
|
|
e65a079f0e | ||
|
|
378ffffdc7 | ||
|
|
dd356b54c0 | ||
|
|
f56388845c | ||
|
|
436db1f8e7 | ||
|
|
ba4b88ef86 | ||
|
|
b39d44db03 | ||
|
|
9c4e5ed596 | ||
|
|
ce40da0f71 | ||
|
|
7f4586a47f | ||
|
|
24a2de7389 | ||
|
|
5f1df9e093 | ||
|
|
5435777c65 | ||
|
|
7c355030f4 | ||
|
|
7b5b874fdc | ||
|
|
f87bb12ebb | ||
|
|
d2d5cf0d57 | ||
|
|
6348f67b18 | ||
|
|
eaf5a371ff | ||
|
|
dee0948e3e | ||
|
|
a59d4ba346 | ||
|
|
ec8e5179cb | ||
|
|
9d5928551b | ||
|
|
456e17430b | ||
|
|
839f0971f0 | ||
|
|
e9c1dd7842 | ||
|
|
24b110be9d | ||
|
|
7a560865a0 | ||
|
|
718a9a79ed | ||
|
|
ff9623fb5c | ||
|
|
80616b4c2b | ||
|
|
36f0ed6d0c | ||
|
|
4c8c6c3880 | ||
|
|
e38fc2c3da | ||
|
|
2fdae91cbc | ||
|
|
7aab1eaffb | ||
|
|
a0c55693dc | ||
|
|
9aca2868b9 | ||
|
|
4982784d7c | ||
|
|
e2d441e862 | ||
|
|
303dbe7730 | ||
|
|
d7b10a17c1 | ||
|
|
3f194d3288 | ||
|
|
672fcd5a14 | ||
|
|
3768932ba2 | ||
|
|
eafcc43295 | ||
|
|
1315e2d72c | ||
|
|
44780e6e1b | ||
|
|
570383d5d5 | ||
|
|
3d2f09a693 | ||
|
|
33c2b1b623 | ||
|
|
207776cec6 | ||
|
|
3b3738e587 | ||
|
|
680078dc58 | ||
|
|
a593271de1 | ||
|
|
7fd996bc86 | ||
|
|
d155ddd026 | ||
|
|
fc38b9bb79 | ||
|
|
29c41adddf | ||
|
|
180d48e89d | ||
|
|
900f39686d | ||
|
|
46c5b776ed | ||
|
|
7b6480f7f8 | ||
|
|
f610958209 | ||
|
|
ab9daaacd6 | ||
|
|
a8f6044c9b | ||
|
|
6efef51036 | ||
|
|
6617af5209 | ||
|
|
410144ea1c | ||
|
|
d8060f47a8 | ||
|
|
f2ee63da3b | ||
|
|
b636d2a2c9 | ||
|
|
7d6fdf96c0 | ||
|
|
b1f5c0314e | ||
|
|
eede02a6ab | ||
|
|
eee8685847 | ||
|
|
6253bbff3d | ||
|
|
263b4080ee | ||
|
|
50ae9659ad | ||
|
|
2e12ac5957 | ||
|
|
5f6622c70d | ||
|
|
d5cbbae182 | ||
|
|
0dd8670724 | ||
|
|
d2a82d56aa | ||
|
|
915ad77d03 | ||
|
|
f025dda4e2 | ||
|
|
1644956a9c | ||
|
|
b1cea25237 | ||
|
|
c1ddb84839 | ||
|
|
445d0f7928 | ||
|
|
637ee77d66 | ||
|
|
fb989fcd0e | ||
|
|
64ea3f8177 | ||
|
|
aaa0603e29 | ||
|
|
450edae160 | ||
|
|
4f0198dd13 | ||
|
|
56714e6c07 | ||
|
|
aa0586c666 | ||
|
|
8ee8eddcff | ||
|
|
1c2d0656b0 | ||
|
|
22d7db2cb4 | ||
|
|
96107193e9 | ||
|
|
1a39678206 | ||
|
|
6c57810128 | ||
|
|
8c340d52a4 | ||
|
|
1df3ed4487 | ||
|
|
0c1657d744 | ||
|
|
44af46c9b3 | ||
|
|
18eb3cde97 | ||
|
|
776508759d | ||
|
|
6a7fa67581 | ||
|
|
3f97d63886 | ||
|
|
c3d2a581c9 | ||
|
|
d345283ab5 | ||
|
|
ddbef8b25d | ||
|
|
d2cb05f14f | ||
|
|
3fe2169ffa | ||
|
|
ab5b2da21a | ||
|
|
b4f153c202 | ||
|
|
0d09d43257 | ||
|
|
98c303042e | ||
|
|
d0f9345c5a | ||
|
|
fffc5d7c35 | ||
|
|
e737964f66 | ||
|
|
8f2e84d263 | ||
|
|
947935f3d9 | ||
|
|
277287a341 | ||
|
|
5a75eba42b | ||
|
|
31c6a0a9da | ||
|
|
a1f156ca19 | ||
|
|
eb90b907e7 | ||
|
|
61a7d848f7 | ||
|
|
d70742119b | ||
|
|
622b5c179a | ||
|
|
ddc5293e6a | ||
|
|
a30f537f5f | ||
|
|
813c0119aa | ||
|
|
8ef4c4401e | ||
|
|
5fbda0e206 | ||
|
|
fbe327ac2f | ||
|
|
ab6f327f35 | ||
|
|
51887c64b5 | ||
|
|
654a73c5a8 | ||
|
|
eac884d85b | ||
|
|
d7aaaea0df | ||
|
|
b09250ed33 | ||
|
|
0ca97e4b68 | ||
|
|
59ca8bd986 | ||
|
|
e1393d1912 | ||
|
|
ddb3bd5477 | ||
|
|
2ec18a1397 | ||
|
|
34072faccd | ||
|
|
26d9215e43 | ||
|
|
496e06a373 | ||
|
|
513bd17610 | ||
|
|
d9fcb777c1 | ||
|
|
05700a6799 | ||
|
|
29bd743391 | ||
|
|
13e14652e3 | ||
|
|
b41e88e83a | ||
|
|
cbc4da58ab | ||
|
|
aecb4adf4a | ||
|
|
ba227b7e72 | ||
|
|
0423e0a2df | ||
|
|
afe816efb6 | ||
|
|
58feda7c8e | ||
|
|
217765998d | ||
|
|
0ffe53933d | ||
|
|
cf4b4de970 | ||
|
|
2e285ed562 | ||
|
|
9b919c54dd | ||
|
|
9618960558 | ||
|
|
fceaed34e4 | ||
|
|
eb4973237b | ||
|
|
9c747e3e37 | ||
|
|
3d16d8b2b6 | ||
|
|
1a75489b42 | ||
|
|
24c29acc09 | ||
|
|
2662167372 | ||
|
|
e98320862c | ||
|
|
2d6a7092e3 | ||
|
|
7080983521 | ||
|
|
19540ed7f0 | ||
|
|
699df0029b | ||
|
|
86971ee752 | ||
|
|
d258a6c1c2 | ||
|
|
3e0913a813 | ||
|
|
762a3279ea | ||
|
|
f357f4c9d7 | ||
|
|
8d708c2442 | ||
|
|
83d069d053 | ||
|
|
b5429d9e8e | ||
|
|
0996901e72 | ||
|
|
ec08d31031 | ||
|
|
ca46405850 | ||
|
|
7d7ed15fdc | ||
|
|
34315f7338 | ||
|
|
26a22a30a1 | ||
|
|
41e4fc79ae | ||
|
|
049299f07f | ||
|
|
5f36ad3b75 | ||
|
|
18cf6bcfa6 | ||
|
|
a8c526efd5 | ||
|
|
62c8f9e1e2 | ||
|
|
ac134c0afa | ||
|
|
a29c3abeb8 | ||
|
|
623a1278cf | ||
|
|
e52694cde0 | ||
|
|
95813714a5 | ||
|
|
6a6473ede3 | ||
|
|
e10e1f5249 | ||
|
|
6eb1a89205 | ||
|
|
4d25d264c4 | ||
|
|
ba7025d54b | ||
|
|
1f360961e0 | ||
|
|
08647b337f | ||
|
|
c5a7800ec6 | ||
|
|
26a2290078 | ||
|
|
2edcd82094 | ||
|
|
165efdbdbb | ||
|
|
412fcf11f9 | ||
|
|
e993d08563 | ||
|
|
61bc652229 | ||
|
|
699f6fff44 | ||
|
|
1a868abdfa | ||
|
|
c9c58cbe4c | ||
|
|
c3055c7cc4 | ||
|
|
2cca1a8c2c | ||
|
|
a9e767cbd8 | ||
|
|
1657f2e5f7 | ||
|
|
e93a377982 | ||
|
|
2c12312b97 | ||
|
|
866b546cfd | ||
|
|
74f5c769f9 | ||
|
|
1e09f5149e | ||
|
|
e08a5a9d83 | ||
|
|
d7dec5a43d | ||
|
|
33436d62c3 | ||
|
|
9f1504062a | ||
|
|
f8cafaaee7 | ||
|
|
4d1d163a73 | ||
|
|
171bf969c7 | ||
|
|
ca145297e9 | ||
|
|
c2c43bba37 | ||
|
|
951b7a9075 | ||
|
|
f807e34b2b | ||
|
|
aa03be7f76 | ||
|
|
ed14c515bf | ||
|
|
2d545c7f0b | ||
|
|
3beeb6125e | ||
|
|
19a8ac4841 | ||
|
|
85d0e08a80 | ||
|
|
fff8972a77 | ||
|
|
92dd5cab93 | ||
|
|
141b580c8c | ||
|
|
095771d345 | ||
|
|
5d581c3b03 | ||
|
|
087c28dae4 | ||
|
|
85c37fbe27 | ||
|
|
ad9b790712 | ||
|
|
82436c5b44 | ||
|
|
156afa7795 | ||
|
|
74dc05bbf5 | ||
|
|
b6d206aff7 | ||
|
|
e3c116312b | ||
|
|
5527932a8e | ||
|
|
3cb9d094d3 | ||
|
|
d83a275b6e | ||
|
|
98d5dd727b | ||
|
|
565f054b79 | ||
|
|
f4aee62fb4 | ||
|
|
864f0f5a3a | ||
|
|
d447c423b5 | ||
|
|
f9ed8a9a08 | ||
|
|
3638d79291 | ||
|
|
2514f3aa08 | ||
|
|
3d3cbe115e | ||
|
|
691838c47d | ||
|
|
612abf134b | ||
|
|
87a730b5a2 | ||
|
|
8d0efd812c | ||
|
|
245ce642ce | ||
|
|
df4b952312 | ||
|
|
43cfc7d401 | ||
|
|
16ba2a54ea | ||
|
|
bc9abceef3 | ||
|
|
8a311d693b | ||
|
|
52807c0724 | ||
|
|
fa15f58506 | ||
|
|
f616605e7e | ||
|
|
3d4b5a10c9 | ||
|
|
2b7bbd9513 | ||
|
|
89e3bcc4bb | ||
|
|
a590239df9 | ||
|
|
0c3f7a54cd | ||
|
|
99a11636da | ||
|
|
3a2f258517 | ||
|
|
3629a190ae | ||
|
|
715a9b8678 | ||
|
|
4187be2dc3 | ||
|
|
dd70a13c02 | ||
|
|
c8a56add5d | ||
|
|
01ebdb6122 | ||
|
|
e66f9d7fce | ||
|
|
35f63b3f6a | ||
|
|
9bf9b3edb7 | ||
|
|
92b1a13438 | ||
|
|
515f5440a1 | ||
|
|
632480787d | ||
|
|
e4faa82cfa | ||
|
|
779915a51f | ||
|
|
c509bbcb99 | ||
|
|
8231e7e36a | ||
|
|
ee145aebe7 | ||
|
|
11dd7784f8 | ||
|
|
6fe6a6daa7 | ||
|
|
e921b7cbdc | ||
|
|
fd928a3d16 | ||
|
|
5a4d3317c2 | ||
|
|
ab23cccab4 | ||
|
|
7d4cc82077 | ||
|
|
e58f8db9aa | ||
|
|
b059910a01 | ||
|
|
19de558f4a | ||
|
|
2d9772e7a9 | ||
|
|
0c1bdc0fd6 | ||
|
|
e592d1b46b | ||
|
|
8dbb1aa8e9 | ||
|
|
ef5cb5021b | ||
|
|
ff81789b37 | ||
|
|
e6efcdb6af | ||
|
|
9cf4c66331 | ||
|
|
956a3c024c | ||
|
|
efb40e149f | ||
|
|
a6876b8028 | ||
|
|
713e7a6584 | ||
|
|
778ce0b9f6 | ||
|
|
05268c2742 | ||
|
|
17d8d14cc8 | ||
|
|
4f310cd7b1 | ||
|
|
9ff0d90853 | ||
|
|
6e13403a37 | ||
|
|
8bf84aabe5 | ||
|
|
50a767ef03 | ||
|
|
4702285184 | ||
|
|
dde73d592d | ||
|
|
9a1dedbe76 | ||
|
|
20439e646f | ||
|
|
06c7a6a109 | ||
|
|
278a653154 | ||
|
|
3a8b149f09 | ||
|
|
deca6a0329 | ||
|
|
7205407818 | ||
|
|
2f6b975669 | ||
|
|
16a4b60526 | ||
|
|
9cf1835230 | ||
|
|
3623a0dd56 | ||
|
|
e0c0d2a72a | ||
|
|
dbfc46658f | ||
|
|
bb3ec04ed1 | ||
|
|
be7fccce68 | ||
|
|
f21d8503d5 | ||
|
|
063e6d062d | ||
|
|
0b7d758077 | ||
|
|
5dfa753f5c | ||
|
|
23d714f2f1 | ||
|
|
f627c81399 | ||
|
|
0fb1918196 | ||
|
|
312f1c6f25 | ||
|
|
792059f195 | ||
|
|
70c74d282f | ||
|
|
ab4975b7f1 | ||
|
|
6eaaa5cc69 | ||
|
|
f766614b4d | ||
|
|
fcf1327c1f | ||
|
|
b140f1f152 | ||
|
|
87904e8b69 | ||
|
|
194e9e6f05 | ||
|
|
8dd7d3aacd | ||
|
|
104bcc1f89 | ||
|
|
a55c03013d | ||
|
|
b783363c56 | ||
|
|
f0e4ea1780 | ||
|
|
6a336f2e1e | ||
|
|
312637c94b | ||
|
|
e717f74a0a | ||
|
|
3dde19bb59 | ||
|
|
a0abea4b72 | ||
|
|
5744bd0138 | ||
|
|
db9ca1a485 | ||
|
|
af260cba41 | ||
|
|
a77ae51318 | ||
|
|
5aad44e628 | ||
|
|
41e178e268 | ||
|
|
e068ad4494 | ||
|
|
7fc2f74851 | ||
|
|
abbea5ec4c | ||
|
|
72a4d2df2f | ||
|
|
05ac516ffa | ||
|
|
01423d4a6b | ||
|
|
3de9b4bfc8 | ||
|
|
92a2011207 | ||
|
|
8710fbfde7 | ||
|
|
0c94b89e42 | ||
|
|
9e382ecf9a | ||
|
|
0e0e265a2a | ||
|
|
d6ac7c5ecf | ||
|
|
8501ffe240 | ||
|
|
919bab0765 | ||
|
|
3e719d087f | ||
|
|
472e2afd8e | ||
|
|
68b0259c47 | ||
|
|
9809ce1d18 | ||
|
|
7a5db5e665 | ||
|
|
6ec7cf5a9d | ||
|
|
f4cbd88e2c | ||
|
|
9904c0e09f | ||
|
|
e4f5243e54 | ||
|
|
33138c139f | ||
|
|
a2d2deeb0c | ||
|
|
b4674d6fc5 | ||
|
|
1f6a19b684 | ||
|
|
c06cb38d64 | ||
|
|
3bc319d534 | ||
|
|
30496ffdc3 | ||
|
|
3544136ab1 | ||
|
|
6826a1d7df | ||
|
|
d798b943f5 | ||
|
|
4466b6e15e | ||
|
|
0248d6fd9f | ||
|
|
bc66894553 | ||
|
|
c12673a407 | ||
|
|
86e48ceef8 | ||
|
|
adcd0f4bb8 | ||
|
|
75b39e812e | ||
|
|
622d883344 | ||
|
|
8519480f2c | ||
|
|
f9db729e75 | ||
|
|
0b2eced6a3 | ||
|
|
dae01b5043 | ||
|
|
1912973d36 | ||
|
|
037a00720f | ||
|
|
c2ee64e669 | ||
|
|
e703fc7982 | ||
|
|
5a1fa6ee65 | ||
|
|
d6016757cb | ||
|
|
08184aab1d | ||
|
|
e33fbc67ad | ||
|
|
f80238ae2d | ||
|
|
75ff9089af | ||
|
|
2f5f2b367b | ||
|
|
66dea18b61 | ||
|
|
bae40ded74 | ||
|
|
fc43828c20 | ||
|
|
063a1ffd36 | ||
|
|
1d4735f76d | ||
|
|
c03250132d | ||
|
|
48844442fc | ||
|
|
f69fb40c71 | ||
|
|
0a34793f5a | ||
|
|
07cd23edac | ||
|
|
a7ef1262e5 | ||
|
|
c5fcf3ba2c | ||
|
|
d206035e0f | ||
|
|
2eeb96116d | ||
|
|
2edfb96c36 | ||
|
|
c7e22b7a3b | ||
|
|
20ced771ba | ||
|
|
01b7385a5e | ||
|
|
070a6203e0 | ||
|
|
902c56f09b | ||
|
|
129086eea7 | ||
|
|
157da246c0 | ||
|
|
321dfb7311 | ||
|
|
65097a4908 | ||
|
|
df2cbfd0e9 | ||
|
|
df95114a93 | ||
|
|
f7d30c847f | ||
|
|
b94eb443ea | ||
|
|
b70f5bc98b | ||
|
|
9876e792f1 | ||
|
|
e3f09ae4cc | ||
|
|
cd2e030dc1 | ||
|
|
6be2c06ed3 | ||
|
|
2e85871a4b | ||
|
|
47a8ef3031 | ||
|
|
93e4ef0eec | ||
|
|
303378c5eb | ||
|
|
5082f69631 | ||
|
|
abe072c83d | ||
|
|
5fbd0afdc5 | ||
|
|
4725dfb121 | ||
|
|
14c2d14fc2 | ||
|
|
119a981701 | ||
|
|
fb3088b765 | ||
|
|
e7b170bf3c | ||
|
|
96d837274e | ||
|
|
8818c209df | ||
|
|
5c057e1306 | ||
|
|
6c23a21312 | ||
|
|
2f8e0bb09c | ||
|
|
b6495a9fc2 | ||
|
|
8952759eda | ||
|
|
c96f5f6fa8 | ||
|
|
b0d2d1116b | ||
|
|
4a55223a8f | ||
|
|
3aa9982b23 | ||
|
|
7d706f6a00 | ||
|
|
161aeb393b | ||
|
|
f9195a8a0e | ||
|
|
9a36174685 | ||
|
|
4f5f6a9e8f | ||
|
|
78072f753c | ||
|
|
d5a3cc7300 | ||
|
|
fc0be6d503 | ||
|
|
699973dcfe | ||
|
|
465266e219 | ||
|
|
5c935a4c29 | ||
|
|
95ff0b9313 | ||
|
|
eed04560c0 | ||
|
|
2c0e8f6079 | ||
|
|
152eabbd6a | ||
|
|
60ab624b23 | ||
|
|
4dd793c0ac | ||
|
|
7f4916f333 | ||
|
|
bf4d0a5466 | ||
|
|
d053d464dd | ||
|
|
5465708a42 | ||
|
|
3622cfd169 | ||
|
|
ae389a8993 | ||
|
|
1d175c1c7d | ||
|
|
7e37f3294a | ||
|
|
1e273640b4 | ||
|
|
cbbe29cf70 | ||
|
|
c87579e1f7 | ||
|
|
c30ed059fe | ||
|
|
676c4d0835 | ||
|
|
4c717829b3 | ||
|
|
8512259d02 | ||
|
|
e45b04ef32 | ||
|
|
de21088619 | ||
|
|
61bf7f49cc | ||
|
|
a819e4d523 | ||
|
|
57ca71fcc9 | ||
|
|
a03574e119 | ||
|
|
19d7dad33c | ||
|
|
2cd8ba9875 | ||
|
|
dc11c94514 | ||
|
|
037fe442dc | ||
|
|
0525d66b86 | ||
|
|
a168c4bf06 | ||
|
|
a465edd890 | ||
|
|
164a01ed12 | ||
|
|
39602c4b2b | ||
|
|
33dfcd247d | ||
|
|
1617b76e27 | ||
|
|
0a9df88e53 | ||
|
|
989641892e | ||
|
|
21fcbc7acb | ||
|
|
dfa17d2291 | ||
|
|
f4a2eff4b7 | ||
|
|
f9fd511eb0 | ||
|
|
ff71a2cc60 | ||
|
|
41371bd901 | ||
|
|
7db7b146be | ||
|
|
de25d63838 | ||
|
|
42829ffb13 | ||
|
|
444666a365 | ||
|
|
41db8798af | ||
|
|
33bd614a42 | ||
|
|
10ad0b48dc | ||
|
|
4a0314849e | ||
|
|
10a9d298d7 | ||
|
|
13d513f02b | ||
|
|
7f84deaf30 | ||
|
|
765a5c6aa1 | ||
|
|
f7c195a7ac | ||
|
|
252cb18aeb | ||
|
|
54a5ecb101 | ||
|
|
63ca000482 | ||
|
|
00aa844964 | ||
|
|
e6bf58a707 | ||
|
|
ccc0653923 | ||
|
|
70c14092f9 | ||
|
|
a1e62ea4b1 | ||
|
|
22f72e2b23 | ||
|
|
a0756bf6f2 | ||
|
|
78e1fb231e | ||
|
|
5cbe5d60aa | ||
|
|
e9c5c1434b | ||
|
|
817a74d4df | ||
|
|
02fa04aec8 | ||
|
|
7cd8d0a1ac | ||
|
|
7dcdaca288 | ||
|
|
3259a1d814 | ||
|
|
806c26d54f | ||
|
|
f2ecc271b5 | ||
|
|
a05251da51 | ||
|
|
555ef7677d | ||
|
|
eb2ec92b66 | ||
|
|
e1a3540caf | ||
|
|
9de22c8146 | ||
|
|
eb0fccd1d2 | ||
|
|
cb2f5d3e25 | ||
|
|
73665a2b67 | ||
|
|
24d5dc093f | ||
|
|
18476114b9 | ||
|
|
bd07425b25 | ||
|
|
49ad6f47a5 | ||
|
|
65b6d210bc | ||
|
|
6c4765fd00 | ||
|
|
ef3811390f | ||
|
|
2ce55115a6 | ||
|
|
0811e0bce3 | ||
|
|
62d4516fe7 | ||
|
|
970facaa8a | ||
|
|
fe92889b10 |
47
.dockerignore
Normal file
47
.dockerignore
Normal file
@@ -0,0 +1,47 @@
|
||||
*.iml
|
||||
out/
|
||||
*.ipr
|
||||
*.iws
|
||||
classpath.txt
|
||||
version.properties
|
||||
.project
|
||||
.classpath
|
||||
lib/*
|
||||
build/*
|
||||
generated-files/*
|
||||
generated-sources/*
|
||||
generated-code/*
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
/target
|
||||
/generated-files
|
||||
/nbactions.xml
|
||||
*.pyc
|
||||
__pycache__
|
||||
samples/server-generator/scalatra/output
|
||||
samples/server-generator/node/output/node_modules
|
||||
samples/server-generator/scalatra/target
|
||||
samples/server-generator/scalatra/output/.history
|
||||
samples/client/petstore/qt5cpp/PetStore/moc_*
|
||||
samples/client/petstore/qt5cpp/PetStore/*.o
|
||||
samples/client/petstore/objc/PetstoreClient.xcworkspace/xcuserdata
|
||||
samples/client/petstore/qt5cpp/build-*
|
||||
samples/client/petstore/qt5cpp/PetStore/PetStore
|
||||
samples/client/petstore/qt5cpp/PetStore/Makefile
|
||||
samples/client/petstore/java/hello.txt
|
||||
samples/client/petstore/android-java/hello.txt
|
||||
samples/client/petstore/objc/Build
|
||||
samples/client/petstore/objc/Pods
|
||||
samples/server/petstore/nodejs/node_modules
|
||||
target
|
||||
.idea
|
||||
.lib
|
||||
atlassian-ide-plugin.xml
|
||||
.DS_Store
|
||||
|
||||
samples/client/petstore/php/SwaggerClient-php/composer.lock
|
||||
samples/client/petstore/php/SwaggerClient-php/vendor/
|
||||
|
||||
samples/client/petstore/silex/SwaggerServer/composer.lock
|
||||
samples/client/petstore/silex/SwaggerServer/venodr/
|
||||
29
.gitignore
vendored
29
.gitignore
vendored
@@ -9,6 +9,7 @@ version.properties
|
||||
lib/*
|
||||
build/*
|
||||
generated-files/*
|
||||
generated-sources/*
|
||||
generated-code/*
|
||||
*.swp
|
||||
*.swo
|
||||
@@ -22,9 +23,35 @@ samples/server-generator/scalatra/output
|
||||
samples/server-generator/node/output/node_modules
|
||||
samples/server-generator/scalatra/target
|
||||
samples/server-generator/scalatra/output/.history
|
||||
|
||||
samples/client/petstore/qt5cpp/PetStore/moc_*
|
||||
samples/client/petstore/qt5cpp/PetStore/*.o
|
||||
samples/client/petstore/objc/PetstoreClient.xcworkspace/xcuserdata
|
||||
samples/client/petstore/qt5cpp/build-*
|
||||
samples/client/petstore/qt5cpp/PetStore/PetStore
|
||||
samples/client/petstore/qt5cpp/PetStore/Makefile
|
||||
samples/client/petstore/java/hello.txt
|
||||
samples/client/petstore/android-java/hello.txt
|
||||
samples/client/petstore/objc/SwaggerClientTests/Build
|
||||
samples/client/petstore/objc/SwaggerClientTests/Pods
|
||||
samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcworkspace
|
||||
samples/client/petstore/objc/SwaggerClientTests/Podfile.lock
|
||||
samples/server/petstore/nodejs/node_modules
|
||||
target
|
||||
.idea
|
||||
.lib
|
||||
atlassian-ide-plugin.xml
|
||||
.DS_Store
|
||||
packages/
|
||||
.pub
|
||||
.packages
|
||||
|
||||
samples/client/petstore/php/SwaggerClient-php/composer.lock
|
||||
samples/client/petstore/php/SwaggerClient-php/vendor/
|
||||
|
||||
samples/client/petstore/silex/SwaggerServer/composer.lock
|
||||
samples/client/petstore/silex/SwaggerServer/venodr/
|
||||
|
||||
samples/client/petstore/python/.projectile
|
||||
samples/client/petstore/python/.venv/
|
||||
|
||||
*/.settings
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
sudo: false
|
||||
language: java
|
||||
script: mvn verify
|
||||
script: mvn verify -Psamples
|
||||
jdk:
|
||||
- oraclejdk7
|
||||
|
||||
13
Dockerfile
Normal file
13
Dockerfile
Normal file
@@ -0,0 +1,13 @@
|
||||
FROM maven:3.3-jdk-7
|
||||
|
||||
WORKDIR /src
|
||||
VOLUME /src
|
||||
VOLUME /root/.m2/repository
|
||||
|
||||
ADD . /opt/swagger-codegen
|
||||
|
||||
RUN cd /opt/swagger-codegen && mvn package
|
||||
|
||||
ENTRYPOINT ["java", "-jar", "/opt/swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"]
|
||||
|
||||
CMD ["help"]
|
||||
11
LICENSE
Normal file
11
LICENSE
Normal file
@@ -0,0 +1,11 @@
|
||||
Copyright 2015 SmartBear Software
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
223
README.md
223
README.md
@@ -1,26 +1,73 @@
|
||||
# Swagger Code Generator
|
||||
|
||||
[](https://travis-ci.org/swagger-api/swagger-codegen)
|
||||
[](https://maven-badges.herokuapp.com/maven-central/io.swagger/swagger-codegen-project)
|
||||
|
||||
## Overview
|
||||
This is the swagger codegen project, which allows generation of client libraries automatically from a Swagger-compliant server.
|
||||
|
||||
## What's Swagger?
|
||||
|
||||
The goal of Swagger™ is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined via Swagger, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interfaces have done for lower-level programming, Swagger removes the guesswork in calling the service.
|
||||
|
||||
|
||||
Check out [Swagger-Spec](https://github.com/swagger-api/swagger-spec) for additional information about the Swagger project, including additional libraries with support for other languages and more.
|
||||
|
||||
# Table of contents
|
||||
|
||||
## Compatability
|
||||
- [Swagger Code Generator](#swagger-code-generator)
|
||||
- [Overview](#overview)
|
||||
- [Table of Contents](#table-of-contents)
|
||||
- Installation
|
||||
- [Build and run using docker](#build-and-run-using-docker)
|
||||
- [Build a nodejs server stub](#build-a-nodejs-server-stub)
|
||||
- [Compatibility](#compatibility)
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [OS X Users](#os-x-users)
|
||||
- [Building](#building)
|
||||
- Generators
|
||||
- [To generate a sample client library](#to-generate-a-sample-client-library)
|
||||
- [Generating libraries from your server](#generating-libraries-from-your-server)
|
||||
- [Modifying the client library format](#modifying-the-client-library-format)
|
||||
- [Making your own codegen modules](#making-your-own-codegen-modules)
|
||||
- [Where is Javascript???](#where-is-javascript)
|
||||
- [Generating a client from local files](#generating-a-client-from-local-files)
|
||||
- [Customizing the generator](#customizing-the-generator)
|
||||
- [Validating your swagger spec](#validating-your-swagger-spec)
|
||||
- [Generating dynamic html api documentation](#generating-dynamic-html-api-documentation)
|
||||
- [Generating static html api documentation](#generating-static-html-api-documentation)
|
||||
- [To build a server stub](#to-build-a-server-stub)
|
||||
- [node.js](#nodejs)
|
||||
- [rails-grape](#rails-grape)
|
||||
- [scala scalatra](#scala-scalatra)
|
||||
- [java jax-rs](#java-jax-rs)
|
||||
- [java spring-mvc](#java-spring-mvc)
|
||||
- [To build the codegen library](#to-build-the-codegen-library)
|
||||
- [License](#license)
|
||||
|
||||
## Build and run using docker
|
||||
|
||||
```
|
||||
git clone https://github.com/swagger-api/swagger-codegen
|
||||
|
||||
cd swagger-codegen
|
||||
|
||||
./run-in-docker.sh mvn package
|
||||
```
|
||||
|
||||
## Build a nodejs server stub
|
||||
|
||||
```
|
||||
./run-in-docker.sh generate \
|
||||
-i http://petstore.swagger.io/v2/swagger.json \
|
||||
-l nodejs \
|
||||
-o samples/server/petstore/nodejs
|
||||
```
|
||||
|
||||
## Compatibility
|
||||
The Swagger Specification has undergone 3 revisions since initial creation in 2010. The swagger-codegen project has the following compatibilies with the swagger specification:
|
||||
|
||||
Swagger Codegen Version | Release Date | Swagger Spec compatibility | Notes
|
||||
----------------------- | ------------ | -------------------------- | -----
|
||||
2.1.0-M2 | 2015-04-06 | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen)
|
||||
2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/v2.0.17)
|
||||
1.0.4 | 2012-04-12 | 1.0, 1.1 | [tag v1.0.4](https://github.com/swagger-api/swagger-codegen/tree/swagger-codegen_2.9.1-1.1)
|
||||
Swagger Codegen Version | Release Date | Swagger Spec compatibility | Notes
|
||||
-------------------------- | ------------ | -------------------------- | -----
|
||||
2.1.5-SNAPSHOT | | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen)
|
||||
2.1.4 (**current stable**) | 2015-10-25 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.4](https://github.com/swagger-api/swagger-codegen/tree/v2.1.3)
|
||||
2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/v2.0.17)
|
||||
1.0.4 | 2012-04-12 | 1.0, 1.1 | [tag v1.0.4](https://github.com/swagger-api/swagger-codegen/tree/swagger-codegen_2.9.1-1.1)
|
||||
|
||||
|
||||
### Prerequisites
|
||||
@@ -29,6 +76,17 @@ You need the following installed and available in your $PATH:
|
||||
* [Java 7](http://java.oracle.com)
|
||||
|
||||
* [Apache maven 3.0.3 or greater](http://maven.apache.org/)
|
||||
|
||||
#### OS X Users
|
||||
Don't forget to install Java 7. You probably have 1.6 or 1.8.
|
||||
|
||||
Export JAVA_HOME in order to user proper Java version:
|
||||
```
|
||||
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
|
||||
export PATH=${JAVA_HOME}/bin:$PATH
|
||||
```
|
||||
|
||||
#### Building
|
||||
|
||||
After cloning the project, you can build it from source with this command:
|
||||
|
||||
@@ -60,11 +118,14 @@ NAME
|
||||
|
||||
SYNOPSIS
|
||||
swagger generate [(-a <authorization> | --auth <authorization>)]
|
||||
[(-c <configuration file> | --config <configuration file>)]
|
||||
[-D <system properties>]
|
||||
(-i <spec file> | --input-spec <spec file>)
|
||||
(-l <language> | --lang <language>)
|
||||
[(-o <output directory> | --output <output directory>)]
|
||||
[(-t <template directory> | --template-dir <template directory>)]
|
||||
[(-v | --verbose)]
|
||||
[(-s | --skip-overwrite)]
|
||||
|
||||
OPTIONS
|
||||
-a <authorization>, --auth <authorization>
|
||||
@@ -72,6 +133,16 @@ OPTIONS
|
||||
remotely. Pass in a URL-encoded string of name:header with a comma
|
||||
separating multiple values
|
||||
|
||||
-c <configuration file>, --config <configuration file>
|
||||
Path to json configuration file. File content should be in a json
|
||||
format {"optionKey":"optionValue", "optionKey1":"optionValue1"...}
|
||||
Supported options can be different for each language. Run
|
||||
config-help -l {lang} command for language specific config options.
|
||||
|
||||
-D <system properties>
|
||||
sets specified system properties in the format of
|
||||
name=value,name=value
|
||||
|
||||
-i <spec file>, --input-spec <spec file>
|
||||
location of the swagger spec, as URL or file (required)
|
||||
|
||||
@@ -87,7 +158,11 @@ OPTIONS
|
||||
|
||||
-v, --verbose
|
||||
verbose mode
|
||||
```
|
||||
|
||||
-s , --skip-overwrite
|
||||
specifies if the existing files should be overwritten during
|
||||
the generation
|
||||
```
|
||||
|
||||
You can then compile and run the client, as well as unit tests against it:
|
||||
|
||||
@@ -127,7 +202,7 @@ static code generation.
|
||||
There is a third-party component called [swagger-js-codegen](https://github.com/wcandillon/swagger-js-codegen) that can generate angularjs or nodejs source code from a swagger specification.
|
||||
|
||||
|
||||
#### Generating a client from flat files (i.e. no remote server calls)
|
||||
#### Generating a client from local files
|
||||
If you don't want to call your server, you can save the swagger spec files into a directory and pass an argument
|
||||
to the code generator like this:
|
||||
|
||||
@@ -137,40 +212,151 @@ to the code generator like this:
|
||||
|
||||
Great for creating libraries on your ci server, from the [Swagger Editor](http://editor.swagger.io)... or while coding on an airplane.
|
||||
|
||||
### Selective generation
|
||||
You may not want to generate *all* models in your project. Likewise you may want just one or two apis to be written. If that's the case, you can use system properties to control the output:
|
||||
|
||||
The default is generate *everything* supported by the specific library. Once you enable a feature, it will restrict the contents generated:
|
||||
|
||||
```
|
||||
# generate only models
|
||||
java -Dmodels {opts}
|
||||
|
||||
# generate only apis
|
||||
java -Dapis {opts}
|
||||
|
||||
# generate only supporting files
|
||||
java -DsupportingFiles
|
||||
|
||||
# generate models and supporting files
|
||||
java -Dmodels -DsupportingFiles
|
||||
```
|
||||
|
||||
To control the specific files being generated, you can pass a CSV list of what you want:
|
||||
```
|
||||
# generate the User and Pet models only
|
||||
-Dmodels=User,Pet
|
||||
|
||||
# generate the User model and the supportingFile `StringUtil.java`:
|
||||
-Dmodels=User -DsupportingFiles=StringUtil.java
|
||||
```
|
||||
|
||||
When using selective generation, _only_ the templates needed for the specific generation will be used.
|
||||
|
||||
### Customizing the generator
|
||||
|
||||
There are different aspects of customizing the code generator beyond just creating or modifying templates. Each language has a supporting configuration file to handle different type mappings, etc:
|
||||
|
||||
```
|
||||
$ ls -1 modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/
|
||||
$ ls -1 modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/
|
||||
AbstractTypeScriptClientCodegen.java
|
||||
AkkaScalaClientCodegen.java
|
||||
AndroidClientCodegen.java
|
||||
AsyncScalaClientCodegen.java
|
||||
CSharpClientCodegen.java
|
||||
CsharpDotNet2ClientCodegen.java
|
||||
DartClientCodegen.java
|
||||
FlashClientCodegen.java
|
||||
JavaClientCodegen.java
|
||||
JavaInflectorServerCodegen.java
|
||||
JaxRSServerCodegen.java
|
||||
NodeJSServerCodegen.java
|
||||
ObjcClientCodegen.java
|
||||
PerlClientCodegen.java
|
||||
PhpClientCodegen.java
|
||||
PythonClientCodegen.java
|
||||
Qt5CPPGenerator.java
|
||||
RubyClientCodegen.java
|
||||
ScalaClientCodegen.java
|
||||
ScalatraServerCodegen.java
|
||||
SilexServerCodegen.java
|
||||
SinatraServerCodegen.java
|
||||
SpringMVCServerCodegen.java
|
||||
StaticDocCodegen.java
|
||||
StaticHtmlGenerator.java
|
||||
SwaggerGenerator.java
|
||||
SwaggerYamlGenerator.java
|
||||
SwiftCodegen.java
|
||||
TizenClientCodegen.java
|
||||
TypeScriptAngularClientCodegen.java
|
||||
TypeScriptNodeClientCodegen.java
|
||||
```
|
||||
|
||||
Each of these files creates reasonable defaults so you can get running quickly. But if you want to configure package names, prefixes, model folders, etc., you may want to extend these.
|
||||
Each of these files creates reasonable defaults so you can get running quickly. But if you want to configure package names, prefixes, model folders, etc. you can use a json config file to pass the values.
|
||||
|
||||
```
|
||||
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
|
||||
-i http://petstore.swagger.io/v2/swagger.json \
|
||||
-l java \
|
||||
-o samples/client/petstore/java \
|
||||
-c path/to/config.json
|
||||
```
|
||||
Supported config options can be different per language. Running `config-help -l {lang}` will show available options.
|
||||
|
||||
```
|
||||
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar config-help -l java
|
||||
```
|
||||
|
||||
Output
|
||||
|
||||
```
|
||||
CONFIG OPTIONS
|
||||
modelPackage
|
||||
package for generated models
|
||||
|
||||
apiPackage
|
||||
package for generated api classes
|
||||
|
||||
sortParamsByRequiredFlag
|
||||
Sort method arguments to place required parameters before optional parameters. Default: true
|
||||
|
||||
invokerPackage
|
||||
root package for generated code
|
||||
|
||||
groupId
|
||||
groupId in generated pom.xml
|
||||
|
||||
artifactId
|
||||
artifactId in generated pom.xml
|
||||
|
||||
artifactVersion
|
||||
artifact version in generated pom.xml
|
||||
|
||||
sourceFolder
|
||||
source folder for generated code
|
||||
|
||||
localVariablePrefix
|
||||
prefix for generated code members and local variables
|
||||
|
||||
serializableModel
|
||||
boolean - toggle "implements Serializable" for generated models
|
||||
|
||||
library
|
||||
library template (sub-template) to use:
|
||||
<default> - HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2
|
||||
jersey2 - HTTP client: Jersey client 2.6
|
||||
okhttp-gson - HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1
|
||||
retrofit - HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1 (Retrofit 1.9.0)
|
||||
```
|
||||
|
||||
Your config file for java can look like
|
||||
|
||||
```
|
||||
{
|
||||
"groupId":"com.my.company",
|
||||
"artifactId":"MyClent",
|
||||
"artifactVersion":"1.2.0"
|
||||
}
|
||||
```
|
||||
|
||||
For all the unspecified options default values will be used.
|
||||
|
||||
Another way to override default options is to extend config class for specific language.
|
||||
To change, for example, the prefix for the Objective-C generated files, simply subclass the ObjcClientCodegen.java:
|
||||
|
||||
```
|
||||
package com.mycompany.swagger.codegen;
|
||||
|
||||
import com.wordnik.swagger.codegen.languages.*;
|
||||
import io.swagger.codegen.languages.*;
|
||||
|
||||
public class MyObjcCodegen extends ObjcClientCodegen {
|
||||
static {
|
||||
@@ -221,6 +407,7 @@ open index.html
|
||||
You can also use the codegen to generate a server for a couple different frameworks. Take a look here:
|
||||
|
||||
### node.js
|
||||
|
||||
```
|
||||
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
|
||||
-i http://petstore.swagger.io/v2/swagger.json \
|
||||
@@ -229,8 +416,8 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
|
||||
```
|
||||
|
||||
### rails-grape
|
||||
#### Not yet migrated to this branch
|
||||
|
||||
*Not yet migrated to this branch*
|
||||
|
||||
### scala scalatra
|
||||
```
|
||||
@@ -270,7 +457,7 @@ Note! The templates are included in the library generated. If you want to modi
|
||||
License
|
||||
-------
|
||||
|
||||
Copyright 2015 Reverb Technologies, Inc.
|
||||
Copyright 2015 SmartBear Software
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
||||
31
bin/akka-scala-petstore.sh
Executable file
31
bin/akka-scala-petstore.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/akka-scala -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l akka-scala -o samples/client/petstore/akka-scala"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -18,16 +18,29 @@ if [ ! -d "${APP_DIR}" ]; then
|
||||
fi
|
||||
|
||||
cd $APP_DIR
|
||||
./bin/akka-scala-petstore.sh
|
||||
./bin/android-java-petstore.sh
|
||||
./bin/csharp-petstore.sh
|
||||
./bin/dynamic-html.sh
|
||||
./bin/html-petstore.sh
|
||||
./bin/jaxrs-petstore-server.sh
|
||||
./bin/java-petstore.sh
|
||||
./bin/java-petstore-jersey2.sh
|
||||
./bin/java-petstore-okhttp-gson.sh
|
||||
./bin/java-petstore-retrofit.sh
|
||||
./bin/jaxrs-petstore-server.sh
|
||||
./bin/nodejs-petstore-server.sh
|
||||
./bin/objc-petstore.sh
|
||||
./bin/perl-petstore.sh
|
||||
./bin/php-petstore.sh
|
||||
./bin/python-petstore.sh
|
||||
./bin/qt5-petstore.sh
|
||||
./bin/ruby-petstore.sh
|
||||
./bin/objc-petstore.sh
|
||||
./bin/scala-async-petstore.sh
|
||||
./bin/scala-petstore.sh
|
||||
./bin/scalatra-petstore-server.sh
|
||||
./bin/silex-petstore-server.sh
|
||||
./bin/spring-mvc-petstore-server.sh
|
||||
./bin/swift-petstore.sh
|
||||
./bin/tizen-petstore.sh
|
||||
./bin/typescript-angular-petstore.sh
|
||||
./bin/typescript-node-petstore.sh
|
||||
|
||||
31
bin/csharp-dotnet2-petstore.sh
Executable file
31
bin/csharp-dotnet2-petstore.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l CsharpDotNet2 -o samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -26,6 +26,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l csharp -o samples/client/petstore/csharp"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l csharp -o samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
31
bin/dart-petstore.sh
Executable file
31
bin/dart-petstore.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l dart -o samples/client/petstore/dart"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
31
bin/flash-petstore.sh
Executable file
31
bin/flash-petstore.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/flash -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l flash -o samples/client/petstore/flash"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
31
bin/java-inflector-petstore-server.sh
Executable file
31
bin/java-inflector-petstore-server.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaInflector -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l inflector -o samples/server/petstore/java-inflector"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
4
bin/java-petstore-jersey2.json
Normal file
4
bin/java-petstore-jersey2.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"library": "jersey2",
|
||||
"artifactId": "swagger-petstore-jersey2"
|
||||
}
|
||||
31
bin/java-petstore-jersey2.sh
Executable file
31
bin/java-petstore-jersey2.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-jersey2.json -o samples/client/petstore/java/jersey2"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
4
bin/java-petstore-okhttp-gson.json
Normal file
4
bin/java-petstore-okhttp-gson.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"library": "okhttp-gson",
|
||||
"artifactId": "swagger-petstore-okhttp-gson"
|
||||
}
|
||||
31
bin/java-petstore-okhttp-gson.sh
Executable file
31
bin/java-petstore-okhttp-gson.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-okhttp-gson.json -o samples/client/petstore/java/okhttp-gson"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
4
bin/java-petstore-retrofit.json
Normal file
4
bin/java-petstore-retrofit.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"library": "retrofit",
|
||||
"artifactId": "swagger-petstore-retrofit"
|
||||
}
|
||||
31
bin/java-petstore-retrofit.sh
Executable file
31
bin/java-petstore-retrofit.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-retrofit.json -o samples/client/petstore/java/retrofit"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -26,6 +26,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -o samples/client/petstore/java"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -o samples/client/petstore/java/default"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
@@ -26,6 +26,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l jaxrs -o samples/server/petstore/jaxrs"
|
||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l jaxrs -o samples/server/petstore/jaxrs -Dswagger.codegen.jaxrs.impl.source=src/main/java"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
31
bin/perl-petstore.sh
Executable file
31
bin/perl-petstore.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l perl -o samples/client/petstore/perl"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
31
bin/qt5-petstore.sh
Executable file
31
bin/qt5-petstore.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/qt5cpp -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l qt5cpp -o samples/client/petstore/qt5cpp"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
5
bin/ruby-petstore.json
Normal file
5
bin/ruby-petstore.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"gemName": "petstore",
|
||||
"moduleName": "Petstore",
|
||||
"gemVersion": "1.0.0"
|
||||
}
|
||||
@@ -26,6 +26,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/ruby -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l ruby -o samples/client/petstore/ruby"
|
||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/ruby -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
31
bin/silex-petstore-server.sh
Executable file
31
bin/silex-petstore-server.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/silex -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l silex -o samples/server/petstore/silex"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
31
bin/sinatra-petstore-server.sh
Executable file
31
bin/sinatra-petstore-server.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/sinatra -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l sinatra -o samples/server/petstore/sinatra"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
4
bin/swift-petstore.json
Normal file
4
bin/swift-petstore.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"projectName": "PetstoreClient",
|
||||
"responseAs": "PromiseKit"
|
||||
}
|
||||
31
bin/swift-petstore.sh
Executable file
31
bin/swift-petstore.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l swift -c ./bin/swift-petstore.json -o samples/client/petstore/swift"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
31
bin/typescript-angular-petstore.sh
Executable file
31
bin/typescript-angular-petstore.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-angular -o samples/client/petstore/typescript-angular"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
31
bin/typescript-node-petstore.sh
Executable file
31
bin/typescript-node-petstore.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-node -o samples/client/petstore/typescript-node"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -1,9 +1,9 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>com.wordnik</groupId>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-codegen-project</artifactId>
|
||||
<version>2.1.0-M2</version>
|
||||
<version>2.1.4</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@@ -15,6 +15,14 @@
|
||||
|
||||
<build>
|
||||
<finalName>swagger-codegen-cli</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<excludes>
|
||||
<exclude>logback.xml</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@@ -22,7 +30,7 @@
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>com.wordnik.swagger.codegen.SwaggerCodegen</mainClass>
|
||||
<mainClass>io.swagger.codegen.SwaggerCodegen</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
@@ -33,7 +41,7 @@
|
||||
<version>2.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>reduced-pom</id>
|
||||
<id>process-resources</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
@@ -44,17 +52,9 @@
|
||||
<dependencyReducedPomLocation>
|
||||
${java.io.tmpdir}/dependency-reduced-pom.xml
|
||||
</dependencyReducedPomLocation>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>process-resources</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
|
||||
<transformer
|
||||
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
|
||||
</transformers>
|
||||
</configuration>
|
||||
</execution>
|
||||
@@ -66,30 +66,38 @@
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.wordnik</groupId>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-codegen</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--https://github.com/airlift/airline-->
|
||||
<dependency>
|
||||
<groupId>io.airlift</groupId>
|
||||
<artifactId>airline</artifactId>
|
||||
<version>0.7</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.googlecode.lambdaj</groupId>
|
||||
<artifactId>lambdaj</artifactId>
|
||||
<version>2.3.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>${slf4j-version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>${testng-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jmockit</groupId>
|
||||
<artifactId>jmockit</artifactId>
|
||||
<version>${jmockit-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -1,120 +0,0 @@
|
||||
package com.wordnik.swagger.codegen.cmd;
|
||||
|
||||
import com.wordnik.swagger.codegen.ClientOptInput;
|
||||
import com.wordnik.swagger.codegen.ClientOpts;
|
||||
import com.wordnik.swagger.codegen.CodegenConfig;
|
||||
import com.wordnik.swagger.codegen.DefaultGenerator;
|
||||
import com.wordnik.swagger.models.Swagger;
|
||||
import io.airlift.airline.Command;
|
||||
import io.airlift.airline.Option;
|
||||
import io.swagger.parser.SwaggerParser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import static java.util.ServiceLoader.load;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||
|
||||
/**
|
||||
* User: lanwen
|
||||
* Date: 24.03.15
|
||||
* Time: 20:22
|
||||
*/
|
||||
|
||||
@Command(name = "generate", description = "Generate code with chosen lang")
|
||||
public class Generate implements Runnable {
|
||||
|
||||
public static final Logger LOG = LoggerFactory.getLogger(Generate.class);
|
||||
|
||||
public static final String TEMPLATE_DIR_PARAM = "templateDir";
|
||||
|
||||
@Option(name = {"-v", "--verbose"}, description = "verbose mode")
|
||||
private boolean verbose;
|
||||
|
||||
@Option(name = {"-l", "--lang"}, title = "language", required = true,
|
||||
description = "client language to generate (maybe class name in classpath, required)")
|
||||
private String lang;
|
||||
|
||||
@Option(name = {"-o", "--output"}, title = "output directory",
|
||||
description = "where to write the generated files (current dir by default)")
|
||||
private String output = "";
|
||||
|
||||
@Option(name = {"-i", "--input-spec"}, title = "spec file", required = true,
|
||||
description = "location of the swagger spec, as URL or file (required)")
|
||||
private String spec;
|
||||
|
||||
@Option(name = {"-t", "--template-dir"}, title = "template directory",
|
||||
description = "folder containing the template files")
|
||||
private String templateDir;
|
||||
|
||||
@Option(name = {"-a", "--auth"}, title = "authorization",
|
||||
description = "adds authorization headers when fetching the swagger definitions remotely. " +
|
||||
"Pass in a URL-encoded string of name:header with a comma separating multiple values")
|
||||
private String auth;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
verbosed(verbose);
|
||||
|
||||
ClientOptInput input = new ClientOptInput();
|
||||
|
||||
if (isNotEmpty(auth)) {
|
||||
input.setAuth(auth);
|
||||
}
|
||||
|
||||
CodegenConfig config = forName(lang);
|
||||
config.setOutputDir(new File(output).getAbsolutePath());
|
||||
|
||||
if (null != templateDir) {
|
||||
config.additionalProperties().put(TEMPLATE_DIR_PARAM, new File(templateDir).getAbsolutePath());
|
||||
}
|
||||
|
||||
input.setConfig(config);
|
||||
|
||||
Swagger swagger = new SwaggerParser().read(spec, input.getAuthorizationValues(), true);
|
||||
new DefaultGenerator().opts(input.opts(new ClientOpts()).swagger(swagger)).generate();
|
||||
}
|
||||
|
||||
/**
|
||||
* If true parameter, adds system properties which enables debug mode in generator
|
||||
* @param verbose - if true, enables debug mode
|
||||
*/
|
||||
private void verbosed(boolean verbose) {
|
||||
if (!verbose) {
|
||||
return;
|
||||
}
|
||||
LOG.info("\nVERBOSE MODE: ON. Additional debug options are injected" +
|
||||
"\n - [debugSwagger] prints the swagger specification as interpreted by the codegen" +
|
||||
"\n - [debugModels] prints models passed to the template engine" +
|
||||
"\n - [debugOperations] prints operations passed to the template engine" +
|
||||
"\n - [debugSupportingFiles] prints additional data passed to the template engine");
|
||||
|
||||
System.setProperty("debugSwagger", "");
|
||||
System.setProperty("debugModels", "");
|
||||
System.setProperty("debugOperations", "");
|
||||
System.setProperty("debugSupportingFiles", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to load config class with SPI first, then with class name directly from classpath
|
||||
* @param name name of config, or full qualified class name in classpath
|
||||
* @return config class
|
||||
*/
|
||||
private static CodegenConfig forName(String name) {
|
||||
ServiceLoader<CodegenConfig> loader = load(CodegenConfig.class);
|
||||
for (CodegenConfig config : loader) {
|
||||
if (config.getName().equals(name)) {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
||||
// else try to load directly
|
||||
try {
|
||||
return (CodegenConfig) Class.forName(name).newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Can't load config class with name ".concat(name), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,17 @@
|
||||
package com.wordnik.swagger.codegen;
|
||||
package io.swagger.codegen;
|
||||
|
||||
import com.wordnik.swagger.codegen.cmd.Generate;
|
||||
import com.wordnik.swagger.codegen.cmd.Langs;
|
||||
import com.wordnik.swagger.codegen.cmd.Meta;
|
||||
import io.airlift.airline.Cli;
|
||||
import io.airlift.airline.Help;
|
||||
import io.swagger.codegen.cmd.ConfigHelp;
|
||||
import io.swagger.codegen.cmd.Generate;
|
||||
import io.swagger.codegen.cmd.Langs;
|
||||
import io.swagger.codegen.cmd.Meta;
|
||||
|
||||
/**
|
||||
* User: lanwen
|
||||
* Date: 24.03.15
|
||||
* Time: 17:56
|
||||
*
|
||||
* <p>
|
||||
* Command line interface for swagger codegen
|
||||
* use `swagger-codegen-cli.jar help` for more info
|
||||
*
|
||||
@@ -27,7 +28,8 @@ public class SwaggerCodegen {
|
||||
Generate.class,
|
||||
Meta.class,
|
||||
Langs.class,
|
||||
Help.class
|
||||
Help.class,
|
||||
ConfigHelp.class
|
||||
);
|
||||
|
||||
builder.build().parse(args).run();
|
||||
@@ -0,0 +1,27 @@
|
||||
package io.swagger.codegen.cmd;
|
||||
|
||||
import io.airlift.airline.Command;
|
||||
import io.airlift.airline.Option;
|
||||
import io.swagger.codegen.CliOption;
|
||||
import io.swagger.codegen.CodegenConfig;
|
||||
import io.swagger.codegen.CodegenConfigLoader;
|
||||
|
||||
@Command(name = "config-help", description = "Config help for chosen lang")
|
||||
public class ConfigHelp implements Runnable {
|
||||
|
||||
@Option(name = {"-l", "--lang"}, title = "language", required = true,
|
||||
description = "language to get config help for")
|
||||
private String lang;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println();
|
||||
CodegenConfig config = CodegenConfigLoader.forName(lang);
|
||||
System.out.println("CONFIG OPTIONS");
|
||||
for (CliOption langCliOption : config.cliOptions()) {
|
||||
System.out.println("\t" + langCliOption.getOpt());
|
||||
System.out.println("\t " + langCliOption.getDescription().replaceAll("\n", "\n\t "));
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
package io.swagger.codegen.cmd;
|
||||
|
||||
import io.airlift.airline.Command;
|
||||
import io.airlift.airline.Option;
|
||||
import io.swagger.codegen.ClientOptInput;
|
||||
import io.swagger.codegen.CodegenConstants;
|
||||
import io.swagger.codegen.DefaultGenerator;
|
||||
import io.swagger.codegen.cmd.utils.OptionUtils;
|
||||
import io.swagger.codegen.config.CodegenConfigurator;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||
|
||||
/**
|
||||
* User: lanwen
|
||||
* Date: 24.03.15
|
||||
* Time: 20:22
|
||||
*/
|
||||
|
||||
@Command(name = "generate", description = "Generate code with chosen lang")
|
||||
public class Generate implements Runnable {
|
||||
|
||||
public static final Logger LOG = LoggerFactory.getLogger(Generate.class);
|
||||
|
||||
@Option(name = {"-v", "--verbose"}, description = "verbose mode")
|
||||
private Boolean verbose;
|
||||
|
||||
@Option(name = {"-l", "--lang"}, title = "language", required = true,
|
||||
description = "client language to generate (maybe class name in classpath, required)")
|
||||
private String lang;
|
||||
|
||||
@Option(name = {"-o", "--output"}, title = "output directory",
|
||||
description = "where to write the generated files (current dir by default)")
|
||||
private String output = "";
|
||||
|
||||
@Option(name = {"-i", "--input-spec"}, title = "spec file", required = true,
|
||||
description = "location of the swagger spec, as URL or file (required)")
|
||||
private String spec;
|
||||
|
||||
@Option(name = {"-t", "--template-dir"}, title = "template directory",
|
||||
description = "folder containing the template files")
|
||||
private String templateDir;
|
||||
|
||||
@Option(name = {"-a", "--auth"}, title = "authorization",
|
||||
description = "adds authorization headers when fetching the swagger definitions remotely. " +
|
||||
"Pass in a URL-encoded string of name:header with a comma separating multiple values")
|
||||
private String auth;
|
||||
|
||||
@Option(name = {"-D"}, title = "system properties", description = "sets specified system properties in " +
|
||||
"the format of name=value,name=value")
|
||||
private String systemProperties;
|
||||
|
||||
@Option(name = {"-c", "--config"}, title = "configuration file", description = "Path to json configuration file. " +
|
||||
"File content should be in a json format {\"optionKey\":\"optionValue\", \"optionKey1\":\"optionValue1\"...} " +
|
||||
"Supported options can be different for each language. Run config-help -l {lang} command for language specific config options.")
|
||||
private String configFile;
|
||||
|
||||
@Option(name = {"-s", "--skip-overwrite"}, title = "skip overwrite", description = "specifies if the existing files should be " +
|
||||
"overwritten during the generation.")
|
||||
private Boolean skipOverwrite;
|
||||
|
||||
@Option(name = {"--api-package"}, title = "api package", description = CodegenConstants.API_PACKAGE_DESC)
|
||||
private String apiPackage;
|
||||
|
||||
@Option(name = {"--model-package"}, title = "model package", description = CodegenConstants.MODEL_PACKAGE_DESC)
|
||||
private String modelPackage;
|
||||
|
||||
@Option(name = {"--instantiation-types"}, title = "instantiation types", description = "sets instantiation type mappings in the format of type=instantiatedType,type=instantiatedType." +
|
||||
"For example (in Java): array=ArrayList,map=HashMap. In other words array types will get instantiated as ArrayList in generated code.")
|
||||
private String instantiationTypes;
|
||||
|
||||
@Option(name = {"--type-mappings"}, title = "type mappings", description = "sets mappings between swagger spec types and generated code types " +
|
||||
"in the format of swaggerType=generatedType,swaggerType=generatedType. For example: array=List,map=Map,string=String")
|
||||
private String typeMappings;
|
||||
|
||||
@Option(name = {"--additional-properties"}, title = "additional properties", description = "sets additional properties that can be referenced by the mustache templates in the format of name=value,name=value")
|
||||
private String additionalProperties;
|
||||
|
||||
@Option(name = {"--language-specific-primitives"}, title = "language specific primitives",
|
||||
description = "specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: String,boolean,Boolean,Double")
|
||||
private String languageSpecificPrimitives;
|
||||
|
||||
@Option(name = {"--import-mappings"}, title = "import mappings",
|
||||
description = "specifies mappings between a given class and the import that should be used for that class in the format of type=import,type=import")
|
||||
private String importMappings;
|
||||
|
||||
@Option(name = {"--invoker-package"}, title = "invoker package", description = CodegenConstants.INVOKER_PACKAGE_DESC)
|
||||
private String invokerPackage;
|
||||
|
||||
@Option(name = {"--group-id"}, title = "group id", description = CodegenConstants.GROUP_ID_DESC)
|
||||
private String groupId;
|
||||
|
||||
@Option(name = {"--artifact-id"}, title = "artifact id", description = CodegenConstants.ARTIFACT_ID_DESC)
|
||||
private String artifactId;
|
||||
|
||||
@Option(name = {"--artifact-version"}, title = "artifact version", description = CodegenConstants.ARTIFACT_VERSION_DESC)
|
||||
private String artifactVersion;
|
||||
|
||||
@Option(name = {"--library"}, title = "library", description = CodegenConstants.LIBRARY_DESC)
|
||||
private String library;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
//attempt to read from config file
|
||||
CodegenConfigurator configurator = CodegenConfigurator.fromFile(configFile);
|
||||
|
||||
//if a config file wasn't specified or we were unable to read it
|
||||
if(configurator == null) {
|
||||
//createa a fresh configurator
|
||||
configurator = new CodegenConfigurator();
|
||||
}
|
||||
|
||||
//now override with any specified parameters
|
||||
if (verbose != null) {
|
||||
configurator.setVerbose(verbose);
|
||||
}
|
||||
|
||||
if(skipOverwrite != null) {
|
||||
configurator.setSkipOverwrite(skipOverwrite);
|
||||
}
|
||||
|
||||
if(isNotEmpty(spec)) {
|
||||
configurator.setInputSpec(spec);
|
||||
}
|
||||
|
||||
if(isNotEmpty(lang)) {
|
||||
configurator.setLang(lang);
|
||||
}
|
||||
|
||||
if(isNotEmpty(output)) {
|
||||
configurator.setOutputDir(output);
|
||||
}
|
||||
|
||||
if(isNotEmpty(auth)) {
|
||||
configurator.setAuth(auth);
|
||||
}
|
||||
|
||||
if(isNotEmpty(templateDir)) {
|
||||
configurator.setTemplateDir(templateDir);
|
||||
}
|
||||
|
||||
if(isNotEmpty(apiPackage)) {
|
||||
configurator.setApiPackage(apiPackage);
|
||||
}
|
||||
|
||||
if(isNotEmpty(modelPackage)) {
|
||||
configurator.setModelPackage(modelPackage);
|
||||
}
|
||||
|
||||
if(isNotEmpty(invokerPackage)) {
|
||||
configurator.setInvokerPackage(invokerPackage);
|
||||
}
|
||||
|
||||
if(isNotEmpty(groupId)) {
|
||||
configurator.setGroupId(groupId);
|
||||
}
|
||||
|
||||
if(isNotEmpty(artifactId)) {
|
||||
configurator.setArtifactId(artifactId);
|
||||
}
|
||||
|
||||
if(isNotEmpty(artifactVersion)) {
|
||||
configurator.setArtifactVersion(artifactVersion);
|
||||
}
|
||||
|
||||
if(isNotEmpty(library)) {
|
||||
configurator.setLibrary(library);
|
||||
}
|
||||
|
||||
setSystemProperties(configurator);
|
||||
setInstantiationTypes(configurator);
|
||||
setImportMappings(configurator);
|
||||
setTypeMappings(configurator);
|
||||
setAdditionalProperties(configurator);
|
||||
setLanguageSpecificPrimitives(configurator);
|
||||
|
||||
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||
|
||||
new DefaultGenerator().opts(clientOptInput).generate();
|
||||
}
|
||||
|
||||
private void setSystemProperties(CodegenConfigurator configurator) {
|
||||
final Map<String, String> map = createMapFromKeyValuePairs(systemProperties);
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
configurator.addSystemProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private void setInstantiationTypes(CodegenConfigurator configurator) {
|
||||
final Map<String, String> map = createMapFromKeyValuePairs(instantiationTypes);
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
configurator.addInstantiationType(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private void setImportMappings(CodegenConfigurator configurator) {
|
||||
final Map<String, String> map = createMapFromKeyValuePairs(importMappings);
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
configurator.addImportMapping(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private void setTypeMappings(CodegenConfigurator configurator) {
|
||||
final Map<String, String> map = createMapFromKeyValuePairs(typeMappings);
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
configurator.addTypeMapping(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private void setAdditionalProperties(CodegenConfigurator configurator) {
|
||||
final Map<String, String> map = createMapFromKeyValuePairs(additionalProperties);
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
configurator.addAdditionalProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private void setLanguageSpecificPrimitives(CodegenConfigurator configurator) {
|
||||
final Set<String> set = createSetFromCsvList(languageSpecificPrimitives);
|
||||
for (String item : set) {
|
||||
configurator.addLanguageSpecificPrimitive(item);
|
||||
}
|
||||
}
|
||||
|
||||
private Set<String> createSetFromCsvList(String csvProperty) {
|
||||
final List<String> values = OptionUtils.splitCommaSeparatedList(csvProperty);
|
||||
return new HashSet<String>(values);
|
||||
}
|
||||
|
||||
private Map createMapFromKeyValuePairs(String commaSeparatedKVPairs) {
|
||||
final List<Pair<String, String>> pairs = OptionUtils.parseCommaSeparatedTuples(commaSeparatedKVPairs);
|
||||
|
||||
Map result = new HashMap();
|
||||
|
||||
for (Pair<String, String> pair : pairs) {
|
||||
result.put(pair.getLeft(), pair.getRight());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.wordnik.swagger.codegen.cmd;
|
||||
package io.swagger.codegen.cmd;
|
||||
|
||||
import ch.lambdaj.collection.LambdaIterable;
|
||||
import com.wordnik.swagger.codegen.CodegenConfig;
|
||||
import io.airlift.airline.Command;
|
||||
import io.swagger.codegen.CodegenConfig;
|
||||
|
||||
import static ch.lambdaj.Lambda.on;
|
||||
import static ch.lambdaj.collection.LambdaCollections.with;
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.wordnik.swagger.codegen.cmd;
|
||||
package io.swagger.codegen.cmd;
|
||||
|
||||
import ch.lambdaj.function.convert.Converter;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import com.wordnik.swagger.codegen.DefaultGenerator;
|
||||
import com.wordnik.swagger.codegen.SupportingFile;
|
||||
import io.airlift.airline.Command;
|
||||
import io.airlift.airline.Option;
|
||||
import io.swagger.codegen.DefaultGenerator;
|
||||
import io.swagger.codegen.SupportingFile;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -47,8 +47,8 @@ public class Meta implements Runnable {
|
||||
private String name = "default";
|
||||
|
||||
@Option(name = {"-p", "--package"}, title = "package",
|
||||
description = "the package to put the main class into (defaults to com.wordnik.swagger.codegen)")
|
||||
private String targetPackage = "com.wordnik.swagger.codegen";
|
||||
description = "the package to put the main class into (defaults to io.swagger.codegen)")
|
||||
private String targetPackage = "io.swagger.codegen";
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -65,7 +65,7 @@ public class Meta implements Runnable {
|
||||
new SupportingFile("api.template", "src/main/resources" + File.separator + name, "api.mustache"),
|
||||
new SupportingFile("model.template", "src/main/resources" + File.separator + name, "model.mustache"),
|
||||
new SupportingFile("services.mustache",
|
||||
"src/main/resources/META-INF/services", "com.wordnik.swagger.codegen.CodegenConfig")
|
||||
"src/main/resources/META-INF/services", "io.swagger.codegen.CodegenConfig")
|
||||
);
|
||||
|
||||
Map<String, Object> data = new ImmutableMap.Builder<String, Object>()
|
||||
@@ -81,8 +81,9 @@ public class Meta implements Runnable {
|
||||
/**
|
||||
* Converter method to process supporting files: execute with mustache,
|
||||
* or simply copy to destination directory
|
||||
*
|
||||
* @param targetDir - destination directory
|
||||
* @param data - map with additional params needed to process templates
|
||||
* @param data - map with additional params needed to process templates
|
||||
* @return converter object to pass to lambdaj
|
||||
*/
|
||||
private Converter<SupportingFile, File> processFiles(final File targetDir, final Map<String, Object> data) {
|
||||
@@ -121,6 +122,7 @@ public class Meta implements Runnable {
|
||||
|
||||
/**
|
||||
* Creates mustache loader for template using classpath loader
|
||||
*
|
||||
* @param generator - class with reader getter
|
||||
* @return loader for template
|
||||
*/
|
||||
@@ -135,6 +137,7 @@ public class Meta implements Runnable {
|
||||
|
||||
/**
|
||||
* Converts package name to path on file system
|
||||
*
|
||||
* @param packageName - package name to convert
|
||||
* @return relative path
|
||||
*/
|
||||
@@ -0,0 +1,43 @@
|
||||
package io.swagger.codegen.cmd.utils;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||
|
||||
public class OptionUtils {
|
||||
|
||||
public static List<Pair<String, String>> parseCommaSeparatedTuples(String input) {
|
||||
|
||||
List<Pair<String, String>> results = new ArrayList<Pair<String, String>>();
|
||||
|
||||
final List<String> tuples = splitCommaSeparatedList(input);
|
||||
|
||||
for (String tuple : tuples) {
|
||||
int ix = tuple.indexOf('=');
|
||||
if (ix > 0 && ix < tuple.length() - 1) {
|
||||
final Pair<String, String> pair = Pair.of(tuple.substring(0, ix), tuple.substring(ix + 1));
|
||||
results.add(pair);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
public static List<String> splitCommaSeparatedList(String input) {
|
||||
|
||||
List<String> results = new ArrayList<String>();
|
||||
|
||||
if(input != null && !input.isEmpty()) {
|
||||
for (String value : input.split(",")) {
|
||||
if(isNotEmpty(value))
|
||||
results.add(value);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
<logger name="com.wordnik" level="debug"/>
|
||||
<root level="error">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
<logger name="io.swagger" level="debug"/>
|
||||
<root level="error">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
</configuration>
|
||||
|
||||
@@ -0,0 +1,357 @@
|
||||
package io.swagger.codegen.cmd;
|
||||
|
||||
import io.swagger.codegen.ClientOptInput;
|
||||
import io.swagger.codegen.DefaultGenerator;
|
||||
import io.swagger.codegen.SwaggerCodegen;
|
||||
import io.swagger.codegen.config.CodegenConfigurator;
|
||||
import mockit.Expectations;
|
||||
import mockit.FullVerifications;
|
||||
import mockit.Injectable;
|
||||
import mockit.Mocked;
|
||||
import mockit.Verifications;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class GenerateTest {
|
||||
|
||||
@Mocked
|
||||
CodegenConfigurator configurator;
|
||||
|
||||
@Injectable
|
||||
ClientOptInput clientOptInput;
|
||||
|
||||
@Mocked
|
||||
DefaultGenerator generator;
|
||||
|
||||
@Test
|
||||
public void testVerbose() throws Exception {
|
||||
setupAndRunGenericTest("-v");
|
||||
|
||||
new FullVerifications() {{
|
||||
configurator.setVerbose(true);
|
||||
times = 1;
|
||||
}};
|
||||
|
||||
setupAndRunGenericTest("--verbose");
|
||||
|
||||
new FullVerifications() {{
|
||||
configurator.setVerbose(true);
|
||||
times = 1;
|
||||
}};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequiredArgs_ShortArgs() throws Exception {
|
||||
setupAndRunTest("-i", "swagger.yaml", "-l", "java", "-o", "src/main/java", false, null);
|
||||
new FullVerifications() {{
|
||||
}};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequiredArgs_LongArgs() throws Exception {
|
||||
setupAndRunTest("--input-spec", "swagger.yaml", "--lang", "java", "--output", "src/main/java", false, null);
|
||||
new FullVerifications() {{
|
||||
}};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTemplateDir() throws Exception {
|
||||
|
||||
final String templateDir = "src/main/resources/customTemplates";
|
||||
|
||||
setupAndRunGenericTest("--template-dir", templateDir);
|
||||
|
||||
new FullVerifications() {{
|
||||
configurator.setTemplateDir(templateDir);
|
||||
times = 1;
|
||||
}};
|
||||
|
||||
setupAndRunGenericTest("-t", templateDir);
|
||||
|
||||
new FullVerifications() {{
|
||||
configurator.setTemplateDir(templateDir);
|
||||
times = 1;
|
||||
}};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAuth() throws Exception {
|
||||
|
||||
final String auth = "hello:world";
|
||||
|
||||
setupAndRunGenericTest("--auth", auth);
|
||||
|
||||
new FullVerifications() {{
|
||||
configurator.setAuth(auth);
|
||||
times = 1;
|
||||
}};
|
||||
|
||||
setupAndRunGenericTest("-a", auth);
|
||||
|
||||
new FullVerifications() {{
|
||||
configurator.setAuth(auth);
|
||||
times = 1;
|
||||
}};
|
||||
|
||||
setupAndRunGenericTest();
|
||||
|
||||
new FullVerifications() {{
|
||||
configurator.setAuth(anyString);
|
||||
times = 0;
|
||||
}};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSystemProperties() throws Exception {
|
||||
|
||||
setupAndRunGenericTest("-D", "hello=world,foo=bar");
|
||||
|
||||
new FullVerifications() {{
|
||||
configurator.addSystemProperty("hello", "world");
|
||||
times = 1;
|
||||
configurator.addSystemProperty("foo", "bar");
|
||||
times = 1;
|
||||
}};
|
||||
|
||||
setupAndRunGenericTest("-D", "hello=world,key=,foo=bar");
|
||||
|
||||
new FullVerifications() {{
|
||||
configurator.addSystemProperty("hello", "world");
|
||||
times = 1;
|
||||
configurator.addSystemProperty("foo", "bar");
|
||||
times = 1;
|
||||
configurator.addSystemProperty("key", anyString);
|
||||
times = 0;
|
||||
}};
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testConfig() throws Exception {
|
||||
|
||||
setupAndRunTest("-i", "swagger.yaml", "-l", "java", "-o", "src/main/java", true, "config.json", "-c", "config.json");
|
||||
|
||||
new FullVerifications(){{}};
|
||||
|
||||
setupAndRunTest("-i", "swagger.yaml", "-l", "java", "-o", "src/main/java", true, "config.json", "--config", "config.json");
|
||||
|
||||
new FullVerifications(){{}};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSkipOverwrite() throws Exception {
|
||||
|
||||
setupAndRunGenericTest("-s");
|
||||
new FullVerifications(){{
|
||||
configurator.setSkipOverwrite(true); times=1;
|
||||
}};
|
||||
|
||||
setupAndRunGenericTest("--skip-overwrite");
|
||||
new FullVerifications(){{
|
||||
configurator.setSkipOverwrite(true); times=1;
|
||||
}};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApiPackage() throws Exception {
|
||||
final String value = "io.foo.bar.api";
|
||||
setupAndRunGenericTest("--api-package", value);
|
||||
|
||||
new FullVerifications(){{
|
||||
configurator.setApiPackage(value); times=1;
|
||||
}};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelPackage() throws Exception {
|
||||
final String value = "io.foo.bar.api";
|
||||
setupAndRunGenericTest("--model-package", value);
|
||||
|
||||
new FullVerifications(){{
|
||||
configurator.setModelPackage(value); times=1;
|
||||
}};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInstantiationTypes() throws Exception {
|
||||
|
||||
setupAndRunGenericTest("--instantiation-types", "hello=world,key=,foo=bar");
|
||||
|
||||
new FullVerifications() {{
|
||||
configurator.addInstantiationType("hello", "world");
|
||||
times = 1;
|
||||
configurator.addInstantiationType("foo", "bar");
|
||||
times = 1;
|
||||
configurator.addInstantiationType("key", anyString);
|
||||
times = 0;
|
||||
}};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTypeMappings() throws Exception {
|
||||
setupAndRunGenericTest("--type-mappings", "hello=world,key=,foo=bar");
|
||||
|
||||
new FullVerifications() {{
|
||||
configurator.addTypeMapping("hello", "world");
|
||||
times = 1;
|
||||
configurator.addTypeMapping("foo", "bar");
|
||||
times = 1;
|
||||
configurator.addTypeMapping("key", anyString);
|
||||
times = 0;
|
||||
}};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAdditionalProperties() throws Exception {
|
||||
setupAndRunGenericTest("--additional-properties", "hello=world,key=,foo=bar");
|
||||
|
||||
new FullVerifications() {{
|
||||
configurator.addAdditionalProperty("hello", "world");
|
||||
times = 1;
|
||||
configurator.addAdditionalProperty("foo", "bar");
|
||||
times = 1;
|
||||
configurator.addAdditionalProperty("key", anyString);
|
||||
times = 0;
|
||||
}};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLanguageSpecificPrimitives() throws Exception {
|
||||
setupAndRunGenericTest("--language-specific-primitives", "foo,bar,,hello,world");
|
||||
|
||||
new FullVerifications() {{
|
||||
configurator.addLanguageSpecificPrimitive("foo");
|
||||
times = 1;
|
||||
configurator.addLanguageSpecificPrimitive("bar");
|
||||
times = 1;
|
||||
configurator.addLanguageSpecificPrimitive("hello");
|
||||
times = 1;
|
||||
configurator.addLanguageSpecificPrimitive("world");
|
||||
times = 1;
|
||||
}};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImportMappings() throws Exception {
|
||||
setupAndRunGenericTest("--import-mappings", "hello=world,key=,foo=bar");
|
||||
|
||||
new FullVerifications() {{
|
||||
configurator.addImportMapping("hello", "world");
|
||||
times = 1;
|
||||
configurator.addImportMapping("foo", "bar");
|
||||
times = 1;
|
||||
configurator.addImportMapping("key", anyString);
|
||||
times = 0;
|
||||
}};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvokerPackage() throws Exception {
|
||||
final String value = "io.foo.bar.api";
|
||||
setupAndRunGenericTest("--invoker-package", value);
|
||||
|
||||
new FullVerifications(){{
|
||||
configurator.setInvokerPackage(value); times=1;
|
||||
}};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGroupId() throws Exception {
|
||||
final String value = "io.foo.bar.api";
|
||||
setupAndRunGenericTest("--group-id", value);
|
||||
|
||||
new FullVerifications(){{
|
||||
configurator.setGroupId(value); times=1;
|
||||
}};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArtifactId() throws Exception {
|
||||
final String value = "awesome-api";
|
||||
setupAndRunGenericTest("--artifact-id", value);
|
||||
|
||||
new FullVerifications(){{
|
||||
configurator.setArtifactId(value); times=1;
|
||||
}};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArtifactVersion() throws Exception {
|
||||
final String value = "1.2.3";
|
||||
setupAndRunGenericTest("--artifact-version", value);
|
||||
|
||||
new FullVerifications(){{
|
||||
configurator.setArtifactVersion(value); times=1;
|
||||
}};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLibrary() throws Exception {
|
||||
final String value = "library1";
|
||||
setupAndRunGenericTest("--library", value);
|
||||
|
||||
new FullVerifications(){{
|
||||
configurator.setLibrary(value); times=1;
|
||||
}};
|
||||
}
|
||||
|
||||
private void setupAndRunTest(String specFlag, final String spec, String langFlag, final String lang,
|
||||
String outputDirFlag, final String outputDir, boolean configuratorFromFile,
|
||||
final String configFile, String... additionalParameters) {
|
||||
final String[] commonArgs = {"generate", langFlag, lang, outputDirFlag, outputDir, specFlag, spec};
|
||||
|
||||
String[] argsToUse = ArrayUtils.addAll(commonArgs, additionalParameters);
|
||||
|
||||
if (configuratorFromFile) {
|
||||
|
||||
new Expectations(){{
|
||||
CodegenConfigurator.fromFile(configFile);
|
||||
times = 1;
|
||||
result = configurator;
|
||||
}};
|
||||
|
||||
} else {
|
||||
new Expectations() {{
|
||||
CodegenConfigurator.fromFile(anyString);
|
||||
result = null;
|
||||
|
||||
new CodegenConfigurator();
|
||||
times = 1;
|
||||
result = configurator;
|
||||
}};
|
||||
}
|
||||
|
||||
new Expectations() {{
|
||||
|
||||
configurator.toClientOptInput();
|
||||
times = 1;
|
||||
result = clientOptInput;
|
||||
|
||||
new DefaultGenerator();
|
||||
times = 1;
|
||||
result = generator;
|
||||
|
||||
generator.opts(clientOptInput);
|
||||
times = 1;
|
||||
result = generator;
|
||||
|
||||
generator.generate();
|
||||
times = 1;
|
||||
|
||||
}};
|
||||
|
||||
SwaggerCodegen.main(argsToUse);
|
||||
|
||||
new Verifications() {{
|
||||
configurator.setLang(lang);
|
||||
times = 1;
|
||||
configurator.setInputSpec(spec);
|
||||
times = 1;
|
||||
configurator.setOutputDir(outputDir);
|
||||
}};
|
||||
}
|
||||
|
||||
private void setupAndRunGenericTest(String... additionalParameters) {
|
||||
setupAndRunTest("-i", "swagger.yaml", "-l", "java", "-o", "src/main/java", false, null, additionalParameters);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package io.swagger.codegen.cmd.utils;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
public class OptionUtilsTest {
|
||||
|
||||
@Test
|
||||
public void splitCommaSeparatedList() throws Exception {
|
||||
doCommaSeparatedListTest("a,b,c", Arrays.asList("a", "b", "c"));
|
||||
doCommaSeparatedListTest("a,,c", Arrays.asList("a", "c"));
|
||||
doCommaSeparatedListTest("", new ArrayList<String>());
|
||||
doCommaSeparatedListTest(null, new ArrayList<String>());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseCommaSeparatedTuples() throws Exception {
|
||||
doTupleListTest("a=1,b=2,c=3", Arrays.asList(Pair.of("a", "1"), Pair.of("b", "2"), Pair.of("c", "3")));
|
||||
doTupleListTest("a=1,,c=3", Arrays.asList(Pair.of("a", "1"), Pair.of("c", "3")));
|
||||
doTupleListTest("a=1,xyz,c=3", Arrays.asList(Pair.of("a", "1"), Pair.of("c", "3")));
|
||||
doTupleListTest("a=1,=,c=3", Arrays.asList(Pair.of("a", "1"), Pair.of("c", "3")));
|
||||
doTupleListTest("", new ArrayList<Pair<String, String>>());
|
||||
doTupleListTest(null, new ArrayList<Pair<String, String>>());
|
||||
}
|
||||
|
||||
private void doTupleListTest(String input, List<Pair<String, String>> expectedResults) {
|
||||
final List<Pair<String, String>> result = OptionUtils.parseCommaSeparatedTuples(input);
|
||||
assertNotNull(result);
|
||||
assertEquals(result.size(), expectedResults.size());
|
||||
for (int i = 0; i < expectedResults.size(); i++) {
|
||||
final Pair<String, String> actualPair = result.get(i);
|
||||
final Pair<String, String> expected = expectedResults.get(i);
|
||||
assertEquals(actualPair, expected);
|
||||
}
|
||||
}
|
||||
|
||||
private void doCommaSeparatedListTest(String csvStr, List<String> expectedResults) {
|
||||
final List<String> result = OptionUtils.splitCommaSeparatedList(csvStr);
|
||||
assertNotNull(result);
|
||||
assertEquals(result.size(), expectedResults.size());
|
||||
for (int i = 0; i < expectedResults.size(); i++) {
|
||||
assertEquals(result.get(i), expectedResults.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
55
modules/swagger-codegen-maven-plugin/README.md
Normal file
55
modules/swagger-codegen-maven-plugin/README.md
Normal file
@@ -0,0 +1,55 @@
|
||||
swagger-codegen-maven-plugin
|
||||
============================
|
||||
|
||||
A Maven plugin to support the [swagger](http://swagger.io) code generation project
|
||||
|
||||
Usage
|
||||
============================
|
||||
|
||||
Add to your `build->plugins` section (default phase is `generate-sources` phase)
|
||||
```xml
|
||||
<plugin>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-codegen-maven-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<inputSpec>src/main/resources/api.yaml</inputSpec>
|
||||
<language>java</language>
|
||||
<configOptions>
|
||||
<sourceFolder>src/gen/java/main</sourceFolder>
|
||||
</configOptions>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
```
|
||||
|
||||
Followed by:
|
||||
|
||||
```
|
||||
mvn clean compile
|
||||
```
|
||||
|
||||
### General Configuration parameters
|
||||
|
||||
- `inputSpec` - swagger spec file path
|
||||
- `language` - target generation language
|
||||
- `output` - target output path (default is `${project.build.directory}/generated-sources/swagger`)
|
||||
- `templateDirectory` - directory with mustache templates
|
||||
- `addCompileSourceRoot` - add the output directory to the project as a source root (`true` by default)
|
||||
- `modelPackage` - the package to use for generated model objects/classes
|
||||
- `apiPackage` - the package to use for generated api objects/classes
|
||||
- `invokerPackage` - the package to use for the generated invoker objects
|
||||
- `configOptions` - a map of language-specific parameters (see below)
|
||||
|
||||
### Java-specific parameters (under configOptions)
|
||||
|
||||
- `sourceFolder` - the folder to use for generated sources under the output folder
|
||||
- `groupId` - groupId in generated pom.xml
|
||||
- `artifactId` - artifactId in generated pom.xml
|
||||
- `artifactVersion` - artifact version in generated pom.xml
|
||||
87
modules/swagger-codegen-maven-plugin/pom.xml
Normal file
87
modules/swagger-codegen-maven-plugin/pom.xml
Normal file
@@ -0,0 +1,87 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-codegen-project</artifactId>
|
||||
<version>2.1.4</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<artifactId>swagger-codegen-maven-plugin</artifactId>
|
||||
<name>swagger-codegen (maven-plugin)</name>
|
||||
<packaging>maven-plugin</packaging>
|
||||
<description>maven plugin to build modules from swagger codegen</description>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-core</artifactId>
|
||||
<version>3.2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-artifact</artifactId>
|
||||
<version>3.2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-compat</artifactId>
|
||||
<version>3.2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
<version>3.2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.plugin-tools</groupId>
|
||||
<artifactId>maven-plugin-annotations</artifactId>
|
||||
<version>3.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-codegen</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-plugin-plugin</artifactId>
|
||||
<version>3.4</version>
|
||||
<configuration>
|
||||
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>mojo-descriptor</id>
|
||||
<phase>process-classes</phase>
|
||||
<goals>
|
||||
<goal>descriptor</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>help-goal</id>
|
||||
<goals>
|
||||
<goal>helpmojo</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,16 @@
|
||||
package io.swagger.codegen.plugin;
|
||||
|
||||
/**
|
||||
* User: lanwen
|
||||
* Date: 24.03.15
|
||||
* Time: 14:47
|
||||
*/
|
||||
public final class AdditionalParams {
|
||||
public static final String TEMPLATE_DIR_PARAM = "templateDir";
|
||||
public static final String MODEL_PACKAGE_PARAM = "modelPackage";
|
||||
public static final String API_PACKAGE_PARAM = "apiPackage";
|
||||
public static final String INVOKER_PACKAGE_PARAM = "invokerPackage";
|
||||
|
||||
private AdditionalParams() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
package io.swagger.codegen.plugin;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import io.swagger.codegen.CliOption;
|
||||
import io.swagger.codegen.ClientOptInput;
|
||||
import io.swagger.codegen.ClientOpts;
|
||||
import io.swagger.codegen.CodegenConfig;
|
||||
import io.swagger.codegen.CodegenConfigLoader;
|
||||
import io.swagger.codegen.DefaultGenerator;
|
||||
import io.swagger.models.Swagger;
|
||||
import io.swagger.parser.SwaggerParser;
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
import org.apache.maven.plugins.annotations.Parameter;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
import config.Config;
|
||||
import config.ConfigParser;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import static io.swagger.codegen.plugin.AdditionalParams.API_PACKAGE_PARAM;
|
||||
import static io.swagger.codegen.plugin.AdditionalParams.INVOKER_PACKAGE_PARAM;
|
||||
import static io.swagger.codegen.plugin.AdditionalParams.MODEL_PACKAGE_PARAM;
|
||||
import static io.swagger.codegen.plugin.AdditionalParams.TEMPLATE_DIR_PARAM;
|
||||
|
||||
/**
|
||||
* Goal which generates client/server code from a swagger json/yaml definition.
|
||||
*/
|
||||
@Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
|
||||
public class CodeGenMojo extends AbstractMojo {
|
||||
/**
|
||||
* Location of the output directory.
|
||||
*/
|
||||
@Parameter(name = "output",
|
||||
property = "swagger.codegen.maven.plugin.output",
|
||||
defaultValue = "${project.build.directory}/generated-sources/swagger")
|
||||
private File output;
|
||||
|
||||
/**
|
||||
* Location of the swagger spec, as URL or file.
|
||||
*/
|
||||
@Parameter(name = "inputSpec", required = true)
|
||||
private String inputSpec;
|
||||
|
||||
/**
|
||||
* Folder containing the template files.
|
||||
*/
|
||||
@Parameter(name = "templateDirectory")
|
||||
private File templateDirectory;
|
||||
|
||||
/**
|
||||
* The package to use for generated model objects/classes
|
||||
*/
|
||||
@Parameter(name = "modelPackage")
|
||||
private String modelPackage;
|
||||
|
||||
/**
|
||||
* The package to use for generated api objects/classes
|
||||
*/
|
||||
@Parameter(name = "apiPackage")
|
||||
private String apiPackage;
|
||||
|
||||
/**
|
||||
* The package to use for the generated invoker objects
|
||||
*/
|
||||
@Parameter(name = "invokerPackage")
|
||||
private String invokerPackage;
|
||||
|
||||
/**
|
||||
* Client language to generate.
|
||||
*/
|
||||
@Parameter(name = "language", required = true)
|
||||
private String language;
|
||||
|
||||
/**
|
||||
* Path to separate json configuration file.
|
||||
*/
|
||||
@Parameter(name = "configurationFile", required = false)
|
||||
private String configurationFile;
|
||||
|
||||
/**
|
||||
* A map of language-specific parameters as passed with the -c option to the command line
|
||||
*/
|
||||
@Parameter(name = "configOptions")
|
||||
private Map configOptions;
|
||||
|
||||
/**
|
||||
* Add the output directory to the project as a source root, so that the
|
||||
* generated java types are compiled and included in the project artifact.
|
||||
*/
|
||||
@Parameter(defaultValue = "true")
|
||||
private boolean addCompileSourceRoot = true;
|
||||
|
||||
@Parameter
|
||||
protected Map<String, String> environmentVariables = new HashMap<String, String>();
|
||||
|
||||
/**
|
||||
* The project being built.
|
||||
*/
|
||||
@Parameter(readonly = true, required = true, defaultValue = "${project}")
|
||||
private MavenProject project;
|
||||
|
||||
@Override
|
||||
public void execute() throws MojoExecutionException {
|
||||
Swagger swagger = new SwaggerParser().read(inputSpec);
|
||||
|
||||
CodegenConfig config = CodegenConfigLoader.forName(language);
|
||||
config.setOutputDir(output.getAbsolutePath());
|
||||
|
||||
if (environmentVariables != null) {
|
||||
for(String key : environmentVariables.keySet()) {
|
||||
String value = environmentVariables.get(key);
|
||||
if(value == null) {
|
||||
// don't put null values
|
||||
value = "";
|
||||
}
|
||||
System.setProperty(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
if (null != templateDirectory) {
|
||||
config.additionalProperties().put(TEMPLATE_DIR_PARAM, templateDirectory.getAbsolutePath());
|
||||
}
|
||||
if (null != modelPackage) {
|
||||
config.additionalProperties().put(MODEL_PACKAGE_PARAM, modelPackage);
|
||||
}
|
||||
if (null != apiPackage) {
|
||||
config.additionalProperties().put(API_PACKAGE_PARAM, apiPackage);
|
||||
}
|
||||
if (null != invokerPackage) {
|
||||
config.additionalProperties().put(INVOKER_PACKAGE_PARAM, invokerPackage);
|
||||
}
|
||||
|
||||
if (configOptions != null) {
|
||||
for (CliOption langCliOption : config.cliOptions()) {
|
||||
if (configOptions.containsKey(langCliOption.getOpt())) {
|
||||
config.additionalProperties().put(langCliOption.getOpt(),
|
||||
configOptions.get(langCliOption.getOpt()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (null != configurationFile) {
|
||||
Config genConfig = ConfigParser.read(configurationFile);
|
||||
if (null != genConfig) {
|
||||
for (CliOption langCliOption : config.cliOptions()) {
|
||||
if (genConfig.hasOption(langCliOption.getOpt())) {
|
||||
config.additionalProperties().put(langCliOption.getOpt(), genConfig.getOption(langCliOption.getOpt()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("Unable to read configuration file");
|
||||
}
|
||||
}
|
||||
|
||||
ClientOptInput input = new ClientOptInput().opts(new ClientOpts()).swagger(swagger);
|
||||
input.setConfig(config);
|
||||
|
||||
try {
|
||||
new DefaultGenerator().opts(input).generate();
|
||||
} catch (Exception e) {
|
||||
// Maven logs exceptions thrown by plugins only if invoked with -e
|
||||
// I find it annoying to jump through hoops to get basic diagnostic information,
|
||||
// so let's log it in any case:
|
||||
getLog().error(e);
|
||||
throw new MojoExecutionException("Code generation failed. See above for the full exception.");
|
||||
}
|
||||
|
||||
if (addCompileSourceRoot) {
|
||||
project.addCompileSourceRoot(output.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,341 +1,271 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>com.wordnik</groupId>
|
||||
<artifactId>swagger-codegen-project</artifactId>
|
||||
<version>2.1.0-M2</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.wordnik</groupId>
|
||||
<artifactId>swagger-codegen</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>swagger-codegen (core library)</name>
|
||||
<version>2.1.0-M2</version>
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.jvnet.wagon-svn</groupId>
|
||||
<artifactId>wagon-svn</artifactId>
|
||||
<version>1.8</version>
|
||||
</extension>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ssh-external</artifactId>
|
||||
<version>1.0-alpha-6</version>
|
||||
</extension>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-webdav</artifactId>
|
||||
<version>1.0-beta-1</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
<directory>target</directory>
|
||||
<finalName>${project.artifactId}-${project.version}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>java</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<mainClass>com.wordnik.swagger.codegen.Codegen</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/lib</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>net.alchim31.maven</groupId>
|
||||
<artifactId>scala-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
<goal>compile</goal>
|
||||
<goal>testCompile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<configuration>
|
||||
<recompileMode>incremental</recompileMode>
|
||||
</configuration>
|
||||
<jvmArgs>
|
||||
<jvmArg>-Xmx384m</jvmArg>
|
||||
</jvmArgs>
|
||||
<args>
|
||||
<arg>-target:jvm-1.6</arg>
|
||||
<arg>-deprecation</arg>
|
||||
</args>
|
||||
<launchers>
|
||||
<launcher>
|
||||
<id>run-scalatest</id>
|
||||
<mainClass>org.scalatest.tools.Runner</mainClass>
|
||||
<args>
|
||||
<arg>-p</arg>
|
||||
<arg>${project.build.testOutputDirectory}</arg>
|
||||
</args>
|
||||
<jvmArgs>
|
||||
<jvmArg>-Xmx512m</jvmArg>
|
||||
</jvmArgs>
|
||||
</launcher>
|
||||
</launchers>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.0</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<mode>development</mode>
|
||||
<url>${project.url}</url>
|
||||
<implementation-version>${project.version}</implementation-version>
|
||||
<package>com.wordnik</package>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>2.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.1</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>net.alchim31.maven</groupId>
|
||||
<artifactId>scala-maven-plugin</artifactId>
|
||||
<version>${scala-maven-plugin-version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<configuration>
|
||||
<releaseProfiles>release</releaseProfiles>
|
||||
<goals>sign</goals>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>release-profile</id>
|
||||
<properties>
|
||||
<skipTests>true</skipTests>
|
||||
</properties>
|
||||
<build>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-codegen-project</artifactId>
|
||||
<version>2.1.4</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>swagger-codegen</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>swagger-codegen (core library)</name>
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<excludes>
|
||||
<exclude>logback.xml</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.jvnet.wagon-svn</groupId>
|
||||
<artifactId>wagon-svn</artifactId>
|
||||
<version>1.8</version>
|
||||
</extension>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ssh-external</artifactId>
|
||||
<version>1.0-alpha-6</version>
|
||||
</extension>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-webdav</artifactId>
|
||||
<version>1.0-beta-1</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
<directory>target</directory>
|
||||
<finalName>${project.artifactId}-${project.version}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>net.alchim31.maven</groupId>
|
||||
<artifactId>scala-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
<goal>testCompile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration />
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-source</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>java</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>src/main/scala</source>
|
||||
</sources>
|
||||
<mainClass>io.swagger.codegen.Codegen</mainClass>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/lib</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.0</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<mode>development</mode>
|
||||
<url>${project.url}</url>
|
||||
<implementation-version>${project.version}</implementation-version>
|
||||
<package>io.swagger</package>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>2.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.1</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>release-sign-artifacts</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>performRelease</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>release-profile</id>
|
||||
<properties>
|
||||
<skipTests>true</skipTests>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>release-sign-artifacts</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>performRelease</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
<reporting>
|
||||
<outputDirectory>target/site</outputDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.9</version>
|
||||
<configuration>
|
||||
<aggregate>true</aggregate>
|
||||
<debug>true</debug>
|
||||
<links>
|
||||
<link>http://java.sun.com/javaee/5/docs/api</link>
|
||||
<link>http://java.sun.com/j2se/1.5.0/docs/api</link>
|
||||
</links>
|
||||
<excludePackageNames/>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jxr-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<configuration>
|
||||
<aggregate>true</aggregate>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
<report>project-team</report>
|
||||
</reports>
|
||||
</reportSet>
|
||||
</reportSets>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
<reporting>
|
||||
<outputDirectory>target/site</outputDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.9</version>
|
||||
<configuration>
|
||||
<aggregate>true</aggregate>
|
||||
<debug>true</debug>
|
||||
<links>
|
||||
<link>http://java.sun.com/javaee/5/docs/api</link>
|
||||
<link>http://java.sun.com/j2se/1.5.0/docs/api</link>
|
||||
</links>
|
||||
<excludePackageNames />
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>net.alchim31.maven</groupId>
|
||||
<artifactId>scala-maven-plugin</artifactId>
|
||||
<version>${scala-maven-plugin-version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jxr-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<configuration>
|
||||
<aggregate>true</aggregate>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
<report>project-team</report>
|
||||
</reports>
|
||||
</reportSet>
|
||||
</reportSets>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-parser</artifactId>
|
||||
<version>${swagger-parser-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-compat-spec-parser</artifactId>
|
||||
<version>${swagger-parser-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>swagger-core</artifactId>
|
||||
<version>${swagger-core-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.samskivert</groupId>
|
||||
<artifactId>jmustache</artifactId>
|
||||
<version>${jmustache-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons-io-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-tools-api</artifactId>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>${felix-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-ext</artifactId>
|
||||
<version>${slf4j-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${slf4j-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>${commons-lang-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
<version>${commons-cli-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.scalatest</groupId>
|
||||
<artifactId>scalatest_2.11</artifactId>
|
||||
<version>${scala-test-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>sonatype-snapshots</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
</reporting>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-parser</artifactId>
|
||||
<version>${swagger-parser-version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-compat-spec-parser</artifactId>
|
||||
<version>${swagger-parser-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>swagger-core</artifactId>
|
||||
<version>${swagger-core-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.samskivert</groupId>
|
||||
<artifactId>jmustache</artifactId>
|
||||
<version>${jmustache-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons-io-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-tools-api</artifactId>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>${felix-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-ext</artifactId>
|
||||
<version>${slf4j-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${slf4j-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>${slf4j-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>${commons-lang-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
<version>${commons-cli-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>${testng-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>${reflections-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jmockit</groupId>
|
||||
<artifactId>jmockit</artifactId>
|
||||
<version>${jmockit-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>sonatype-snapshots</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
package com.wordnik.swagger.codegen;
|
||||
|
||||
import com.samskivert.mustache.*;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
import java.io.*;
|
||||
|
||||
public abstract class AbstractGenerator {
|
||||
|
||||
public File writeToFile(String filename, String contents) throws IOException {
|
||||
System.out.println("writing file " + filename);
|
||||
File output = new File(filename);
|
||||
|
||||
if(output.getParent() != null && !new File(output.getParent()).exists()) {
|
||||
File parent = new File(output.getParent());
|
||||
parent.mkdirs();
|
||||
}
|
||||
Writer out = new BufferedWriter(new OutputStreamWriter(
|
||||
new FileOutputStream(output), "UTF-8"));
|
||||
|
||||
out.write(contents);
|
||||
out.close();
|
||||
return output;
|
||||
}
|
||||
|
||||
public String readTemplate(String name) {
|
||||
try{
|
||||
Reader reader = getTemplateReader(name);
|
||||
if(reader == null)
|
||||
throw new RuntimeException("no file found");
|
||||
java.util.Scanner s = new java.util.Scanner(reader).useDelimiter("\\A");
|
||||
return s.hasNext() ? s.next() : "";
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
throw new RuntimeException("can't load template " + name);
|
||||
}
|
||||
|
||||
public Reader getTemplateReader(String name) {
|
||||
try{
|
||||
InputStream is = this.getClass().getClassLoader().getResourceAsStream(getCPResourcePath(name));
|
||||
if(is == null)
|
||||
is = new FileInputStream(new File(name));
|
||||
if(is == null)
|
||||
throw new RuntimeException("no file found");
|
||||
return new InputStreamReader(is);
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
throw new RuntimeException("can't load template " + name);
|
||||
}
|
||||
|
||||
private String getCPResourcePath(String name) {
|
||||
if (!"/".equals(File.separator))
|
||||
return name.replaceAll(Pattern.quote(File.separator), "/");
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
/**
|
||||
* Copyright 2015 Reverb, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wordnik.swagger.codegen;
|
||||
|
||||
import com.wordnik.swagger.codegen.ClientOpts;
|
||||
import com.wordnik.swagger.annotations.*;
|
||||
import com.wordnik.swagger.models.Swagger;
|
||||
import com.wordnik.swagger.models.auth.AuthorizationValue;
|
||||
|
||||
import java.util.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.net.URLDecoder;
|
||||
|
||||
public class ClientOptInput {
|
||||
private ClientOpts opts;
|
||||
private Swagger swagger;
|
||||
private List<AuthorizationValue> auths;
|
||||
protected CodegenConfig config;
|
||||
|
||||
public ClientOptInput swagger(Swagger swagger) {
|
||||
this.setSwagger(swagger);
|
||||
return this;
|
||||
}
|
||||
public ClientOptInput opts(ClientOpts opts) {
|
||||
this.setOpts(opts);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setAuth(String urlEncodedAuthString) {
|
||||
List<AuthorizationValue> auths = new ArrayList<AuthorizationValue>();
|
||||
if(urlEncodedAuthString != null && !"".equals(urlEncodedAuthString)) {
|
||||
String[] parts = urlEncodedAuthString.split(",");
|
||||
for(String part : parts) {
|
||||
String[] kvPair = part.split(":");
|
||||
if(kvPair.length == 2) {
|
||||
auths.add(new AuthorizationValue(URLDecoder.decode(kvPair[0]), URLDecoder.decode(kvPair[1]), "header"));
|
||||
}
|
||||
}
|
||||
}
|
||||
this.auths = auths;
|
||||
}
|
||||
public String getAuth() {
|
||||
if(auths != null) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
for(AuthorizationValue v : auths) {
|
||||
try {
|
||||
if(b.toString().length() > 0)
|
||||
b.append(",");
|
||||
b.append(URLEncoder.encode(v.getKeyName(), "UTF-8"))
|
||||
.append(":")
|
||||
.append(URLEncoder.encode(v.getValue(), "UTF-8"));
|
||||
}
|
||||
catch (Exception e) {
|
||||
// continue
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
public List<AuthorizationValue> getAuthorizationValues() {
|
||||
return auths;
|
||||
}
|
||||
|
||||
public CodegenConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
public void setConfig(CodegenConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public void setOpts(ClientOpts opts) {
|
||||
this.opts = opts;
|
||||
}
|
||||
|
||||
public ClientOpts getOpts() {
|
||||
return opts;
|
||||
}
|
||||
|
||||
public void setSwagger(Swagger swagger) {
|
||||
this.swagger = swagger;
|
||||
}
|
||||
|
||||
@ApiModelProperty(dataType="Object")
|
||||
public Swagger getSwagger() {
|
||||
return swagger;
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.wordnik.swagger.codegen;
|
||||
|
||||
import com.wordnik.swagger.codegen.auth.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ClientOpts {
|
||||
protected String uri;
|
||||
protected String target;
|
||||
protected AuthMethod auth;
|
||||
protected Map<String, String> properties = new HashMap<String, String>();
|
||||
protected String outputDirectory;
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public String getTarget() {
|
||||
return target;
|
||||
}
|
||||
public void setTarget(String target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public Map<String, String> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
public void setProperties(Map<String, String> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public String getOutputDirectory() {
|
||||
return outputDirectory;
|
||||
}
|
||||
public void setOutputDirectory(String outputDirectory) {
|
||||
this.outputDirectory = outputDirectory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("ClientOpts: {\n");
|
||||
sb.append(" uri: ").append(uri).append(",");
|
||||
sb.append(" auth: ").append(auth).append(",");
|
||||
sb.append(properties);
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
package com.wordnik.swagger.codegen;
|
||||
|
||||
import com.wordnik.swagger.codegen.languages.*;
|
||||
import com.wordnik.swagger.models.Swagger;
|
||||
import com.wordnik.swagger.models.auth.AuthorizationValue;
|
||||
import com.wordnik.swagger.util.*;
|
||||
|
||||
import io.swagger.parser.SwaggerParser;
|
||||
|
||||
import org.apache.commons.cli.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @deprecated use instead {@link com.wordnik.swagger.codegen.DefaultGenerator}
|
||||
* or cli interface from https://github.com/swagger-api/swagger-codegen/pull/547
|
||||
*/
|
||||
@Deprecated
|
||||
public class Codegen extends DefaultGenerator {
|
||||
static Map<String, CodegenConfig> configs = new HashMap<String, CodegenConfig>();
|
||||
static String configString;
|
||||
static {
|
||||
List<CodegenConfig> extensions = getExtensions();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for(CodegenConfig config : extensions) {
|
||||
if(sb.toString().length() != 0)
|
||||
sb.append(", ");
|
||||
sb.append(config.getName());
|
||||
configs.put(config.getName(), config);
|
||||
configString = sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static String debugInfoOptions = "\nThe following additional debug options are available for all codegen targets:" +
|
||||
"\n -DdebugSwagger prints the swagger specification as interpreted by the codegen" +
|
||||
"\n -DdebugModels prints models passed to the template engine" +
|
||||
"\n -DdebugOperations prints operations passed to the template engine" +
|
||||
"\n -DdebugSupportingFiles prints additional data passed to the template engine";
|
||||
public static void main(String[] args) {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
Options options = new Options();
|
||||
options.addOption("h", "help", false, "shows this message");
|
||||
options.addOption("l", "lang", true, "client language to generate.\nAvailable languages include:\n\t[" + configString + "]");
|
||||
options.addOption("o", "output", true, "where to write the generated files");
|
||||
options.addOption("i", "input-spec", true, "location of the swagger spec, as URL or file");
|
||||
options.addOption("t", "template-dir", true, "folder containing the template files");
|
||||
options.addOption("d", "debug-info", false, "prints additional info for debugging");
|
||||
options.addOption("a", "auth", true, "adds authorization headers when fetching the swagger definitions remotely. Pass in a URL-encoded string of name:header with a comma separating multiple values");
|
||||
|
||||
ClientOptInput clientOptInput = new ClientOptInput();
|
||||
ClientOpts clientOpts = new ClientOpts();
|
||||
Swagger swagger = null;
|
||||
|
||||
CommandLine cmd = null;
|
||||
try {
|
||||
CommandLineParser parser = new BasicParser();
|
||||
CodegenConfig config = null;
|
||||
|
||||
cmd = parser.parse(options, args);
|
||||
if (cmd.hasOption("d")) {
|
||||
usage(options);
|
||||
System.out.println(debugInfoOptions);
|
||||
return;
|
||||
}
|
||||
if (cmd.hasOption("a"))
|
||||
clientOptInput.setAuth(cmd.getOptionValue("a"));
|
||||
if (cmd.hasOption("l"))
|
||||
clientOptInput.setConfig(getConfig(cmd.getOptionValue("l")));
|
||||
else {
|
||||
usage(options);
|
||||
return;
|
||||
}
|
||||
if (cmd.hasOption("o"))
|
||||
clientOptInput.getConfig().setOutputDir(cmd.getOptionValue("o"));
|
||||
if (cmd.hasOption("h")) {
|
||||
if(cmd.hasOption("l")) {
|
||||
config = getConfig(String.valueOf(cmd.getOptionValue("l")));
|
||||
if(config != null) {
|
||||
options.addOption("h", "help", true, config.getHelp());
|
||||
usage(options);
|
||||
return;
|
||||
}
|
||||
}
|
||||
usage(options);
|
||||
return;
|
||||
}
|
||||
if (cmd.hasOption("i"))
|
||||
swagger = new SwaggerParser().read(cmd.getOptionValue("i"), clientOptInput.getAuthorizationValues(), true);
|
||||
if (cmd.hasOption("t"))
|
||||
clientOpts.getProperties().put("templateDir", String.valueOf(cmd.getOptionValue("t")));
|
||||
}
|
||||
catch (Exception e) {
|
||||
usage(options);
|
||||
return;
|
||||
}
|
||||
try{
|
||||
clientOptInput
|
||||
.opts(clientOpts)
|
||||
.swagger(swagger);
|
||||
new Codegen().opts(clientOptInput).generate();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<CodegenConfig> getExtensions() {
|
||||
ServiceLoader<CodegenConfig> loader = ServiceLoader.load(CodegenConfig.class);
|
||||
List<CodegenConfig> output = new ArrayList<CodegenConfig>();
|
||||
Iterator<CodegenConfig> itr = loader.iterator();
|
||||
while(itr.hasNext()) {
|
||||
output.add(itr.next());
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
static void usage(Options options) {
|
||||
HelpFormatter formatter = new HelpFormatter();
|
||||
formatter.printHelp( "Codegen", options );
|
||||
}
|
||||
|
||||
public static CodegenConfig getConfig(String name) {
|
||||
if(configs.containsKey(name)) {
|
||||
return configs.get(name);
|
||||
}
|
||||
else {
|
||||
// see if it's a class
|
||||
try {
|
||||
System.out.println("loading class " + name);
|
||||
Class customClass = Class.forName(name);
|
||||
System.out.println("loaded");
|
||||
return (CodegenConfig)customClass.newInstance();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException("can't load class " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.wordnik.swagger.codegen;
|
||||
|
||||
import com.wordnik.swagger.models.*;
|
||||
import com.wordnik.swagger.models.auth.SecuritySchemeDefinition;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public interface CodegenConfig {
|
||||
CodegenType getTag();
|
||||
String getName();
|
||||
String getHelp();
|
||||
Map<String, Object> additionalProperties();
|
||||
String apiPackage();
|
||||
String apiFileFolder();
|
||||
String fileSuffix();
|
||||
String outputFolder();
|
||||
String templateDir();
|
||||
String modelFileFolder();
|
||||
String modelPackage();
|
||||
String toApiName(String name);
|
||||
String toApiVarName(String name);
|
||||
String toModelName(String name);
|
||||
String toParamName(String name);
|
||||
String escapeText(String text);
|
||||
String escapeReservedWord(String name);
|
||||
String getTypeDeclaration(Property p);
|
||||
String getTypeDeclaration(String name);
|
||||
void processOpts();
|
||||
String generateExamplePath(String path, Operation operation);
|
||||
|
||||
Set<String> reservedWords();
|
||||
|
||||
List<SupportingFile> supportingFiles();
|
||||
|
||||
void setOutputDir(String dir);
|
||||
String getOutputDir();
|
||||
|
||||
CodegenModel fromModel(String name, Model model);
|
||||
CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, Map<String, Model> definitions);
|
||||
List<CodegenSecurity> fromSecurity(Map<String, SecuritySchemeDefinition> schemes);
|
||||
|
||||
Set<String> defaultIncludes();
|
||||
Map<String, String> typeMapping();
|
||||
Map<String, String> instantiationTypes();
|
||||
Map<String, String> importMapping();
|
||||
Map<String, String> apiTemplateFiles();
|
||||
Map<String, String> modelTemplateFiles();
|
||||
void processSwagger(Swagger swagger);
|
||||
|
||||
String toApiFilename(String name);
|
||||
String toModelFilename(String name);
|
||||
String toModelImport(String name);
|
||||
String toApiImport(String name);
|
||||
void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations);
|
||||
Map<String, Object> postProcessModels(Map<String, Object> objs);
|
||||
Map<String, Object> postProcessOperations(Map<String, Object> objs);
|
||||
Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.wordnik.swagger.codegen;
|
||||
|
||||
import com.wordnik.swagger.models.*;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CodegenModel {
|
||||
public String parent;
|
||||
public String name, classname, description, classVarName, modelJson;
|
||||
public String defaultValue;
|
||||
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>();
|
||||
public Set<String> imports = new HashSet<String>();
|
||||
public Boolean hasVars, emptyVars, hasMoreModels;
|
||||
public ExternalDocs externalDocs;
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.wordnik.swagger.codegen;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class CodegenModelFactory {
|
||||
|
||||
private static final Map<CodegenModelType, Class<?>> typeMapping = new HashMap<CodegenModelType, Class<?>>();
|
||||
|
||||
/**
|
||||
* Configure a different implementation class.
|
||||
* @param type the type that shall be replaced
|
||||
* @param implementation the implementation class must extend the default class and must provide a public no-arg constructor
|
||||
*/
|
||||
public static void setTypeMapping(CodegenModelType type, Class<?> implementation) {
|
||||
if (!type.getDefaultImplementation().isAssignableFrom(implementation)) {
|
||||
throw new IllegalArgumentException(implementation.getSimpleName() + " doesn't extend " + type.getDefaultImplementation().getSimpleName());
|
||||
}
|
||||
try {
|
||||
implementation.newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
typeMapping.put(type, implementation);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T newInstance(CodegenModelType type) {
|
||||
Class<?> classType = typeMapping.get(type);
|
||||
try {
|
||||
return (T) (classType != null ? classType : type.getDefaultImplementation()).newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.wordnik.swagger.codegen;
|
||||
|
||||
public enum CodegenModelType {
|
||||
|
||||
MODEL(CodegenModel.class),
|
||||
OPERATION(CodegenOperation.class),
|
||||
PARAMETER(CodegenParameter.class),
|
||||
PROPERTY(CodegenProperty.class),
|
||||
RESPONSE(CodegenResponse.class),
|
||||
SECURITY(CodegenSecurity.class);
|
||||
|
||||
private final Class<?> defaultImplementation;
|
||||
|
||||
private CodegenModelType(Class<?> defaultImplementation) {
|
||||
this.defaultImplementation = defaultImplementation;
|
||||
}
|
||||
|
||||
public Class<?> getDefaultImplementation() {
|
||||
return defaultImplementation;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.wordnik.swagger.codegen;
|
||||
|
||||
import com.wordnik.swagger.models.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CodegenOperation {
|
||||
public Boolean hasConsumes, hasProduces, hasParams, returnTypeIsPrimitive,
|
||||
returnSimpleType, subresourceOperation, isMapContainer, isListContainer,
|
||||
hasMore = Boolean.TRUE;
|
||||
public String path, operationId, returnType, httpMethod, returnBaseType,
|
||||
returnContainer, summary, notes, baseName, defaultResponse;
|
||||
|
||||
public List<Map<String, String>> consumes, produces;
|
||||
public CodegenParameter bodyParam;
|
||||
public List<CodegenParameter> allParams = new ArrayList<CodegenParameter>();
|
||||
public List<CodegenParameter> bodyParams = new ArrayList<CodegenParameter>();
|
||||
public List<CodegenParameter> pathParams = new ArrayList<CodegenParameter>();
|
||||
public List<CodegenParameter> queryParams = new ArrayList<CodegenParameter>();
|
||||
public List<CodegenParameter> headerParams = new ArrayList<CodegenParameter>();
|
||||
public List<CodegenParameter> formParams = new ArrayList<CodegenParameter>();
|
||||
public List<CodegenSecurity> authMethods;
|
||||
public List<String> tags;
|
||||
public List<CodegenResponse> responses = new ArrayList<CodegenResponse>();
|
||||
public final List<CodegenProperty> responseHeaders = new ArrayList<CodegenProperty>();
|
||||
public Set<String> imports = new HashSet<String>();
|
||||
public List<Map<String, String>> examples;
|
||||
public ExternalDocs externalDocs;
|
||||
|
||||
// legacy support
|
||||
public String nickname;
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.wordnik.swagger.codegen;
|
||||
|
||||
public class CodegenParameter {
|
||||
public Boolean isFormParam, isQueryParam, isPathParam, isHeaderParam,
|
||||
isCookieParam, isBodyParam, isFile, notFile, hasMore, isContainer, secondaryParam;
|
||||
public String baseName, paramName, dataType, collectionFormat, description, baseType;
|
||||
public String jsonSchema;
|
||||
|
||||
/**
|
||||
* Determines whether this parameter is mandatory. If the parameter is in "path",
|
||||
* this property is required and its value MUST be true. Otherwise, the property
|
||||
* MAY be included and its default value is false.
|
||||
*/
|
||||
public Boolean required;
|
||||
|
||||
public CodegenParameter copy() {
|
||||
CodegenParameter output = new CodegenParameter();
|
||||
output.isFile = this.isFile;
|
||||
output.notFile = this.notFile;
|
||||
output.hasMore = this.hasMore;
|
||||
output.isContainer = this.isContainer;
|
||||
output.secondaryParam = this.secondaryParam;
|
||||
output.baseName = this.baseName;
|
||||
output.paramName = this.paramName;
|
||||
output.dataType = this.dataType;
|
||||
output.collectionFormat = this.collectionFormat;
|
||||
output.description = this.description;
|
||||
output.baseType = this.baseType;
|
||||
output.isFormParam = this.isFormParam;
|
||||
output.isQueryParam = this.isQueryParam;
|
||||
output.isPathParam = this.isPathParam;
|
||||
output.isHeaderParam = this.isHeaderParam;
|
||||
output.isCookieParam = this.isCookieParam;
|
||||
output.isBodyParam = this.isBodyParam;
|
||||
output.required = this.required;
|
||||
output.jsonSchema = this.jsonSchema;
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.wordnik.swagger.codegen;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CodegenProperty {
|
||||
public String baseName, complexType, getter, setter, description, datatype, datatypeWithEnum,
|
||||
name, min, max, defaultValue, baseType, containerType;
|
||||
|
||||
/** maxLength validation for strings, see http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.1 */
|
||||
public Integer maxLength;
|
||||
/** minLength validation for strings, see http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.2 */
|
||||
public Integer minLength;
|
||||
/** pattern validation for strings, see http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.3 */
|
||||
public String pattern;
|
||||
/** A free-form property to include an example of an instance for this schema. */
|
||||
public String example;
|
||||
|
||||
public String jsonSchema;
|
||||
public Double minimum, maximum, exclusiveMinimum, exclusiveMaximum;
|
||||
public Boolean hasMore = null, required = null, secondaryParam = null;
|
||||
public Boolean isPrimitiveType, isContainer, isNotContainer;
|
||||
public boolean isEnum;
|
||||
public List<String> _enum;
|
||||
public Map<String, Object> allowableValues;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.wordnik.swagger.codegen;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CodegenResponse {
|
||||
public String code, message;
|
||||
public Boolean hasMore;
|
||||
public List<Map<String, String>> examples;
|
||||
public final List<CodegenProperty> headers = new ArrayList<CodegenProperty>();
|
||||
public String dataType, baseType, containerType;
|
||||
public Boolean simpleType;
|
||||
public Boolean primitiveType;
|
||||
public Boolean isMapContainer;
|
||||
public Boolean isListContainer;
|
||||
public Object schema;
|
||||
public String jsonSchema;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.wordnik.swagger.codegen;
|
||||
|
||||
public class CodegenSecurity {
|
||||
String name;
|
||||
String type;
|
||||
Boolean hasMore, isBasic, isOAuth, isApiKey;
|
||||
// ApiKey specific
|
||||
String keyParamName;
|
||||
Boolean isKeyInQuery, isKeyInHeader;
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.wordnik.swagger.codegen;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
public enum CodegenType {
|
||||
CLIENT, SERVER, DOCUMENTATION, OTHER;
|
||||
|
||||
private static Map<String, CodegenType> names = new HashMap<String, CodegenType>();
|
||||
|
||||
static {
|
||||
names.put("client", CLIENT);
|
||||
names.put("server", SERVER);
|
||||
names.put("documentation", DOCUMENTATION);
|
||||
names.put("other", OTHER);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static CodegenType forValue(String value) {
|
||||
return names.get(value.toLowerCase());
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String toValue() {
|
||||
for (Map.Entry<String, CodegenType> entry : names.entrySet()) {
|
||||
if (entry.getValue() == this)
|
||||
return entry.getKey();
|
||||
}
|
||||
|
||||
return null; // or fail
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,440 +0,0 @@
|
||||
package com.wordnik.swagger.codegen;
|
||||
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import com.samskivert.mustache.Template;
|
||||
import com.wordnik.swagger.models.Contact;
|
||||
import com.wordnik.swagger.models.Info;
|
||||
import com.wordnik.swagger.models.License;
|
||||
import com.wordnik.swagger.models.Model;
|
||||
import com.wordnik.swagger.models.Operation;
|
||||
import com.wordnik.swagger.models.Path;
|
||||
import com.wordnik.swagger.models.Swagger;
|
||||
import com.wordnik.swagger.models.auth.SecuritySchemeDefinition;
|
||||
import com.wordnik.swagger.util.Json;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Reader;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.capitalize;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||
|
||||
public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
protected CodegenConfig config;
|
||||
protected ClientOptInput opts = null;
|
||||
protected Swagger swagger = null;
|
||||
|
||||
public Generator opts(ClientOptInput opts) {
|
||||
this.opts = opts;
|
||||
|
||||
this.swagger = opts.getSwagger();
|
||||
this.config = opts.getConfig();
|
||||
this.config.additionalProperties().putAll(opts.getOpts().getProperties());
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<File> generate() {
|
||||
if (swagger == null || config == null) {
|
||||
throw new RuntimeException("missing swagger input or config!");
|
||||
}
|
||||
if (System.getProperty("debugSwagger") != null) {
|
||||
Json.prettyPrint(swagger);
|
||||
}
|
||||
List<File> files = new ArrayList<File>();
|
||||
try {
|
||||
config.processOpts();
|
||||
if (swagger.getInfo() != null) {
|
||||
Info info = swagger.getInfo();
|
||||
if (info.getTitle() != null) {
|
||||
config.additionalProperties().put("appName", info.getTitle());
|
||||
}
|
||||
if (info.getVersion() != null) {
|
||||
config.additionalProperties().put("appVersion", info.getVersion());
|
||||
}
|
||||
if (info.getDescription() != null) {
|
||||
config.additionalProperties().put("appDescription",
|
||||
config.escapeText(info.getDescription()));
|
||||
}
|
||||
if (info.getContact() != null) {
|
||||
Contact contact = info.getContact();
|
||||
config.additionalProperties().put("infoUrl", contact.getUrl());
|
||||
if (contact.getEmail() != null) {
|
||||
config.additionalProperties().put("infoEmail", contact.getEmail());
|
||||
}
|
||||
}
|
||||
if (info.getLicense() != null) {
|
||||
License license = info.getLicense();
|
||||
if (license.getName() != null) {
|
||||
config.additionalProperties().put("licenseInfo", license.getName());
|
||||
}
|
||||
if (license.getUrl() != null) {
|
||||
config.additionalProperties().put("licenseUrl", license.getUrl());
|
||||
}
|
||||
}
|
||||
if (info.getVersion() != null) {
|
||||
config.additionalProperties().put("version", info.getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder hostBuilder = new StringBuilder();
|
||||
if (swagger.getSchemes() != null && swagger.getSchemes().size() > 0) {
|
||||
hostBuilder.append(swagger.getSchemes().get(0).toValue());
|
||||
hostBuilder.append("://");
|
||||
} else {
|
||||
hostBuilder.append("https://");
|
||||
}
|
||||
if (swagger.getHost() != null) {
|
||||
hostBuilder.append(swagger.getHost());
|
||||
} else {
|
||||
hostBuilder.append("localhost");
|
||||
}
|
||||
if (swagger.getBasePath() != null) {
|
||||
hostBuilder.append(swagger.getBasePath());
|
||||
} else {
|
||||
hostBuilder.append("/");
|
||||
}
|
||||
String contextPath = swagger.getBasePath() == null ? "/" : swagger.getBasePath();
|
||||
String basePath = hostBuilder.toString();
|
||||
|
||||
|
||||
List<Object> allOperations = new ArrayList<Object>();
|
||||
List<Object> allModels = new ArrayList<Object>();
|
||||
|
||||
// models
|
||||
Map<String, Model> definitions = swagger.getDefinitions();
|
||||
if (definitions != null) {
|
||||
for (String name : definitions.keySet()) {
|
||||
Model model = definitions.get(name);
|
||||
Map<String, Model> modelMap = new HashMap<String, Model>();
|
||||
modelMap.put(name, model);
|
||||
Map<String, Object> models = processModels(config, modelMap);
|
||||
models.putAll(config.additionalProperties());
|
||||
|
||||
allModels.add(((List<Object>) models.get("models")).get(0));
|
||||
|
||||
for (String templateName : config.modelTemplateFiles().keySet()) {
|
||||
String suffix = config.modelTemplateFiles().get(templateName);
|
||||
String filename = config.modelFileFolder() + File.separator + config.toModelFilename(name) + suffix;
|
||||
String template = readTemplate(config.templateDir() + File.separator + templateName);
|
||||
Template tmpl = Mustache.compiler()
|
||||
.withLoader(new Mustache.TemplateLoader() {
|
||||
public Reader getTemplate(String name) {
|
||||
return getTemplateReader(config.templateDir() + File.separator + name + ".mustache");
|
||||
}
|
||||
})
|
||||
.defaultValue("")
|
||||
.compile(template);
|
||||
writeToFile(filename, tmpl.execute(models));
|
||||
files.add(new File(filename));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (System.getProperty("debugModels") != null) {
|
||||
System.out.println("############ Model info ############");
|
||||
Json.prettyPrint(allModels);
|
||||
}
|
||||
|
||||
// apis
|
||||
Map<String, List<CodegenOperation>> paths = processPaths(swagger.getPaths());
|
||||
for (String tag : paths.keySet()) {
|
||||
List<CodegenOperation> ops = paths.get(tag);
|
||||
Map<String, Object> operation = processOperations(config, tag, ops);
|
||||
operation.put("basePath", basePath);
|
||||
operation.put("contextPath", contextPath);
|
||||
operation.put("baseName", tag);
|
||||
operation.put("modelPackage", config.modelPackage());
|
||||
operation.putAll(config.additionalProperties());
|
||||
operation.put("classname", config.toApiName(tag));
|
||||
operation.put("classVarName", config.toApiVarName(tag));
|
||||
|
||||
allOperations.add(new HashMap<String, Object>(operation));
|
||||
for (int i = 0; i < allOperations.size(); i++) {
|
||||
Map<String, Object> oo = (Map<String, Object>) allOperations.get(i);
|
||||
if (i < (allOperations.size() - 1)) {
|
||||
oo.put("hasMore", "true");
|
||||
}
|
||||
}
|
||||
|
||||
for (String templateName : config.apiTemplateFiles().keySet()) {
|
||||
String suffix = config.apiTemplateFiles().get(templateName);
|
||||
String filename = config.apiFileFolder() +
|
||||
File.separator +
|
||||
config.toApiFilename(tag) +
|
||||
suffix;
|
||||
|
||||
String template = readTemplate(config.templateDir() + File.separator + templateName);
|
||||
Template tmpl = Mustache.compiler()
|
||||
.withLoader(new Mustache.TemplateLoader() {
|
||||
public Reader getTemplate(String name) {
|
||||
return getTemplateReader(config.templateDir() + File.separator + name + ".mustache");
|
||||
}
|
||||
})
|
||||
.defaultValue("")
|
||||
.compile(template);
|
||||
|
||||
writeToFile(filename, tmpl.execute(operation));
|
||||
files.add(new File(filename));
|
||||
}
|
||||
}
|
||||
if (System.getProperty("debugOperations") != null) {
|
||||
System.out.println("############ Operation info ############");
|
||||
Json.prettyPrint(allOperations);
|
||||
}
|
||||
|
||||
// supporting files
|
||||
Map<String, Object> bundle = new HashMap<String, Object>();
|
||||
bundle.putAll(config.additionalProperties());
|
||||
bundle.put("apiPackage", config.apiPackage());
|
||||
|
||||
Map<String, Object> apis = new HashMap<String, Object>();
|
||||
apis.put("apis", allOperations);
|
||||
if (swagger.getHost() != null) {
|
||||
bundle.put("host", swagger.getHost());
|
||||
}
|
||||
bundle.put("basePath", basePath);
|
||||
bundle.put("contextPath", contextPath);
|
||||
bundle.put("apiInfo", apis);
|
||||
bundle.put("models", allModels);
|
||||
bundle.put("apiFolder", config.apiPackage().replace('.', File.separatorChar));
|
||||
bundle.put("modelPackage", config.modelPackage());
|
||||
if (swagger.getExternalDocs() != null) {
|
||||
bundle.put("externalDocs", swagger.getExternalDocs());
|
||||
}
|
||||
for (int i = 0; i < allModels.size() - 1; i++) {
|
||||
HashMap<String, CodegenModel> cm = (HashMap<String, CodegenModel>) allModels.get(i);
|
||||
CodegenModel m = cm.get("model");
|
||||
m.hasMoreModels = true;
|
||||
}
|
||||
|
||||
config.postProcessSupportingFileData(bundle);
|
||||
|
||||
if (System.getProperty("debugSupportingFiles") != null) {
|
||||
System.out.println("############ Supporting file info ############");
|
||||
Json.prettyPrint(bundle);
|
||||
}
|
||||
|
||||
for (SupportingFile support : config.supportingFiles()) {
|
||||
String outputFolder = config.outputFolder();
|
||||
if (isNotEmpty(support.folder)) {
|
||||
outputFolder += File.separator + support.folder;
|
||||
}
|
||||
File of = new File(outputFolder);
|
||||
if (!of.isDirectory()) {
|
||||
of.mkdirs();
|
||||
}
|
||||
String outputFilename = outputFolder + File.separator + support.destinationFilename;
|
||||
|
||||
if (support.templateFile.endsWith("mustache")) {
|
||||
String template = readTemplate(config.templateDir() + File.separator + support.templateFile);
|
||||
Template tmpl = Mustache.compiler()
|
||||
.withLoader(new Mustache.TemplateLoader() {
|
||||
public Reader getTemplate(String name) {
|
||||
return getTemplateReader(config.templateDir() + File.separator + name + ".mustache");
|
||||
}
|
||||
})
|
||||
.defaultValue("")
|
||||
.compile(template);
|
||||
|
||||
writeToFile(outputFilename, tmpl.execute(bundle));
|
||||
files.add(new File(outputFilename));
|
||||
} else {
|
||||
InputStream in = null;
|
||||
|
||||
try {
|
||||
in = new FileInputStream(config.templateDir() + File.separator + support.templateFile);
|
||||
}
|
||||
catch (Exception e) {
|
||||
// continue
|
||||
}
|
||||
if(in == null) {
|
||||
in = this.getClass().getClassLoader().getResourceAsStream(config.templateDir() + File.separator + support.templateFile);
|
||||
}
|
||||
File outputFile = new File(outputFilename);
|
||||
OutputStream out = new FileOutputStream(outputFile, false);
|
||||
if(in != null && out != null)
|
||||
IOUtils.copy(in,out);
|
||||
else {
|
||||
if(in == null)
|
||||
System.out.println("can't open " + config.templateDir() + File.separator + support.templateFile + " for input");
|
||||
if(out == null)
|
||||
System.out.println("can't open " + outputFile + " for output");
|
||||
}
|
||||
|
||||
files.add(outputFile);
|
||||
}
|
||||
}
|
||||
|
||||
config.processSwagger(swagger);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
public Map<String, List<CodegenOperation>> processPaths(Map<String, Path> paths) {
|
||||
Map<String, List<CodegenOperation>> ops = new HashMap<String, List<CodegenOperation>>();
|
||||
|
||||
for (String resourcePath : paths.keySet()) {
|
||||
Path path = paths.get(resourcePath);
|
||||
processOperation(resourcePath, "get", path.getGet(), ops);
|
||||
processOperation(resourcePath, "put", path.getPut(), ops);
|
||||
processOperation(resourcePath, "post", path.getPost(), ops);
|
||||
processOperation(resourcePath, "delete", path.getDelete(), ops);
|
||||
processOperation(resourcePath, "patch", path.getPatch(), ops);
|
||||
processOperation(resourcePath, "options", path.getOptions(), ops);
|
||||
}
|
||||
return ops;
|
||||
}
|
||||
|
||||
public SecuritySchemeDefinition fromSecurity(String name) {
|
||||
Map<String, SecuritySchemeDefinition> map = swagger.getSecurityDefinitions();
|
||||
if (map == null) {
|
||||
return null;
|
||||
}
|
||||
return map.get(name);
|
||||
}
|
||||
|
||||
|
||||
public void processOperation(String resourcePath, String httpMethod, Operation operation, Map<String, List<CodegenOperation>> operations) {
|
||||
if (operation != null) {
|
||||
List<String> tags = operation.getTags();
|
||||
if (tags == null) {
|
||||
tags = new ArrayList<String>();
|
||||
tags.add("default");
|
||||
}
|
||||
|
||||
for (String tag : tags) {
|
||||
CodegenOperation co = config.fromOperation(resourcePath, httpMethod, operation, swagger.getDefinitions());
|
||||
co.tags = new ArrayList<String>();
|
||||
co.tags.add(sanitizeTag(tag));
|
||||
config.addOperationToGroup(sanitizeTag(tag), resourcePath, operation, co, operations);
|
||||
|
||||
List<Map<String, List<String>>> securities = operation.getSecurity();
|
||||
if (securities == null) {
|
||||
continue;
|
||||
}
|
||||
Map<String, SecuritySchemeDefinition> authMethods = new HashMap<String, SecuritySchemeDefinition>();
|
||||
for (Map<String, List<String>> security : securities) {
|
||||
if (security.size() != 1) {
|
||||
//Not sure what to do
|
||||
continue;
|
||||
}
|
||||
String securityName = security.keySet().iterator().next();
|
||||
SecuritySchemeDefinition securityDefinition = fromSecurity(securityName);
|
||||
if (securityDefinition != null) {
|
||||
authMethods.put(securityName, securityDefinition);
|
||||
}
|
||||
}
|
||||
if (!authMethods.isEmpty()) {
|
||||
co.authMethods = config.fromSecurity(authMethods);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String sanitizeTag(String tag) {
|
||||
// remove spaces and make strong case
|
||||
String[] parts = tag.split(" ");
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (String part : parts) {
|
||||
if (isNotEmpty(part)) {
|
||||
buf.append(capitalize(part));
|
||||
}
|
||||
}
|
||||
return buf.toString().replaceAll("[^a-zA-Z ]", "");
|
||||
}
|
||||
|
||||
public Map<String, Object> processOperations(CodegenConfig config, String tag, List<CodegenOperation> ops) {
|
||||
Map<String, Object> operations = new HashMap<String, Object>();
|
||||
Map<String, Object> objs = new HashMap<String, Object>();
|
||||
objs.put("classname", config.toApiName(tag));
|
||||
objs.put("operation", ops);
|
||||
operations.put("operations", objs);
|
||||
operations.put("package", config.apiPackage());
|
||||
|
||||
Set<String> allImports = new LinkedHashSet<String>();
|
||||
for (CodegenOperation op : ops) {
|
||||
allImports.addAll(op.imports);
|
||||
}
|
||||
|
||||
List<Map<String, String>> imports = new ArrayList<Map<String, String>>();
|
||||
for (String nextImport : allImports) {
|
||||
Map<String, String> im = new LinkedHashMap<String, String>();
|
||||
String mapping = config.importMapping().get(nextImport);
|
||||
if (mapping == null) {
|
||||
mapping = config.toModelImport(nextImport);
|
||||
}
|
||||
if (mapping != null) {
|
||||
im.put("import", mapping);
|
||||
imports.add(im);
|
||||
}
|
||||
}
|
||||
|
||||
operations.put("imports", imports);
|
||||
config.postProcessOperations(operations);
|
||||
if (objs.size() > 0) {
|
||||
List<CodegenOperation> os = (List<CodegenOperation>) objs.get("operation");
|
||||
|
||||
if (os != null && os.size() > 0) {
|
||||
CodegenOperation op = os.get(os.size() - 1);
|
||||
op.hasMore = null;
|
||||
}
|
||||
}
|
||||
return operations;
|
||||
}
|
||||
|
||||
public Map<String, Object> processModels(CodegenConfig config, Map<String, Model> definitions) {
|
||||
Map<String, Object> objs = new HashMap<String, Object>();
|
||||
objs.put("package", config.modelPackage());
|
||||
List<Object> models = new ArrayList<Object>();
|
||||
Set<String> allImports = new LinkedHashSet<String>();
|
||||
for (String key : definitions.keySet()) {
|
||||
Model mm = definitions.get(key);
|
||||
CodegenModel cm = config.fromModel(key, mm);
|
||||
Map<String, Object> mo = new HashMap<String, Object>();
|
||||
mo.put("model", cm);
|
||||
models.add(mo);
|
||||
allImports.addAll(cm.imports);
|
||||
}
|
||||
objs.put("models", models);
|
||||
|
||||
List<Map<String, String>> imports = new ArrayList<Map<String, String>>();
|
||||
for (String nextImport : allImports) {
|
||||
Map<String, String> im = new LinkedHashMap<String, String>();
|
||||
String mapping = config.importMapping().get(nextImport);
|
||||
if (mapping == null) {
|
||||
mapping = config.toModelImport(nextImport);
|
||||
}
|
||||
if (mapping != null && !config.defaultIncludes().contains(mapping)) {
|
||||
im.put("import", mapping);
|
||||
imports.add(im);
|
||||
}
|
||||
// add instantiation types
|
||||
mapping = config.instantiationTypes().get(nextImport);
|
||||
if (mapping != null && !config.defaultIncludes().contains(mapping)) {
|
||||
im.put("import", mapping);
|
||||
imports.add(im);
|
||||
}
|
||||
}
|
||||
|
||||
objs.put("imports", imports);
|
||||
config.postProcessModels(objs);
|
||||
|
||||
return objs;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.wordnik.swagger.codegen;
|
||||
|
||||
import com.wordnik.swagger.models.Swagger;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public interface Generator {
|
||||
Generator opts(ClientOptInput opts);
|
||||
List<File> generate();
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
package com.wordnik.swagger.codegen;
|
||||
|
||||
import com.wordnik.swagger.codegen.languages.*;
|
||||
import com.wordnik.swagger.models.Swagger;
|
||||
import com.wordnik.swagger.models.auth.AuthorizationValue;
|
||||
import com.wordnik.swagger.util.*;
|
||||
|
||||
import io.swagger.parser.SwaggerParser;
|
||||
|
||||
import com.samskivert.mustache.*;
|
||||
|
||||
import org.apache.commons.cli.*;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Reader;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @deprecated use instead {@link com.wordnik.swagger.codegen.DefaultGenerator}
|
||||
* or cli interface from https://github.com/swagger-api/swagger-codegen/pull/547
|
||||
*/
|
||||
@Deprecated
|
||||
public class MetaGenerator extends AbstractGenerator {
|
||||
static Map<String, CodegenConfig> configs = new HashMap<String, CodegenConfig>();
|
||||
static String configString;
|
||||
static {
|
||||
List<CodegenConfig> extensions = getExtensions();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for(CodegenConfig config : extensions) {
|
||||
if(sb.toString().length() != 0)
|
||||
sb.append(", ");
|
||||
sb.append(config.getName());
|
||||
configs.put(config.getName(), config);
|
||||
configString = sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new MetaGenerator().generate(args);
|
||||
}
|
||||
|
||||
protected void generate(String[] args) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String targetLanguage = null;
|
||||
String outputFolder = null;
|
||||
String name = null;
|
||||
String targetPackage = "com.wordnik.swagger.codegen";
|
||||
final String templateDir = "codegen";
|
||||
|
||||
Options options = new Options();
|
||||
options.addOption("h", "help", false, "shows this message");
|
||||
options.addOption("l", "lang", false, "client language to generate.\nAvailable languages include:\n\t[" + configString + "]");
|
||||
options.addOption("o", "output", true, "where to write the generated files");
|
||||
options.addOption("n", "name", true, "the human-readable name of the generator");
|
||||
options.addOption("p", "package", true, "the package to put the main class into (defaults to com.wordnik.swagger.codegen");
|
||||
|
||||
ClientOptInput clientOptInput = new ClientOptInput();
|
||||
Swagger swagger = null;
|
||||
CommandLine cmd = null;
|
||||
try {
|
||||
CommandLineParser parser = new BasicParser();
|
||||
|
||||
cmd = parser.parse(options, args);
|
||||
if (cmd.hasOption("h")) {
|
||||
usage(options);
|
||||
return;
|
||||
}
|
||||
if (cmd.hasOption("n"))
|
||||
name = cmd.getOptionValue("n");
|
||||
else {
|
||||
System.out.println("name is required");
|
||||
usage(options);
|
||||
return;
|
||||
}
|
||||
if (cmd.hasOption("l"))
|
||||
targetLanguage = cmd.getOptionValue("l");
|
||||
if (cmd.hasOption("p"))
|
||||
targetPackage = cmd.getOptionValue("p");
|
||||
if (cmd.hasOption("o"))
|
||||
outputFolder = cmd.getOptionValue("o");
|
||||
else {
|
||||
System.out.println("output folder is required");
|
||||
usage(options);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
usage(options);
|
||||
return;
|
||||
}
|
||||
System.out.println("writing to folder " + outputFolder);
|
||||
File outputFolderLocation = new File(outputFolder);
|
||||
if(!outputFolderLocation.exists())
|
||||
outputFolderLocation.mkdirs();
|
||||
File sourceFolder = new File(outputFolder + File.separator + "src/main/java/" + targetPackage.replace('.', File.separatorChar));
|
||||
if(!sourceFolder.exists())
|
||||
sourceFolder.mkdirs();
|
||||
File resourcesFolder = new File(outputFolder + File.separator + "src/main/resources/META-INF/services");
|
||||
if(!resourcesFolder.exists())
|
||||
resourcesFolder.mkdirs();
|
||||
|
||||
String mainClass = Character.toUpperCase(name.charAt(0)) + name.substring(1) + "Generator";
|
||||
|
||||
List<SupportingFile> supportingFiles = new ArrayList<SupportingFile>();
|
||||
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||
supportingFiles.add(new SupportingFile("generatorClass.mustache",
|
||||
"src/main/java/" + File.separator + targetPackage.replace('.', File.separatorChar),
|
||||
mainClass + ".java"));
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("api.template", "src/main/resources" + File.separator + name, "api.mustache"));
|
||||
supportingFiles.add(new SupportingFile("model.template", "src/main/resources" + File.separator + name, "model.mustache"));
|
||||
|
||||
supportingFiles.add(new SupportingFile("services.mustache", "src/main/resources/META-INF/services", "com.wordnik.swagger.codegen.CodegenConfig"));
|
||||
|
||||
List<File> files = new ArrayList<File>();
|
||||
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("generatorPackage", targetPackage);
|
||||
data.put("generatorClass", mainClass);
|
||||
data.put("name", name);
|
||||
data.put("fullyQualifiedGeneratorClass", targetPackage + "." + mainClass);
|
||||
|
||||
for(SupportingFile support : supportingFiles) {
|
||||
try {
|
||||
String destinationFolder = outputFolder;
|
||||
if(support.folder != null && !"".equals(support.folder))
|
||||
destinationFolder += File.separator + support.folder;
|
||||
File of = new File(destinationFolder);
|
||||
if(!of.isDirectory())
|
||||
of.mkdirs();
|
||||
String outputFilename = destinationFolder + File.separator + support.destinationFilename;
|
||||
|
||||
if(support.templateFile.endsWith("mustache")) {
|
||||
String template = readTemplate(templateDir + File.separator + support.templateFile);
|
||||
Template tmpl = Mustache.compiler()
|
||||
.withLoader(new Mustache.TemplateLoader() {
|
||||
public Reader getTemplate (String name) {
|
||||
return getTemplateReader(templateDir + File.separator + name + ".mustache");
|
||||
};
|
||||
})
|
||||
.defaultValue("")
|
||||
.compile(template);
|
||||
|
||||
writeToFile(outputFilename, tmpl.execute(data));
|
||||
files.add(new File(outputFilename));
|
||||
}
|
||||
else {
|
||||
String template = readTemplate(templateDir + File.separator + support.templateFile);
|
||||
FileUtils.writeStringToFile(new File(outputFilename), template);
|
||||
System.out.println("copying file to " + outputFilename);
|
||||
files.add(new File(outputFilename));
|
||||
}
|
||||
}
|
||||
catch (java.io.IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static List<CodegenConfig> getExtensions() {
|
||||
ServiceLoader<CodegenConfig> loader = ServiceLoader.load(CodegenConfig.class);
|
||||
List<CodegenConfig> output = new ArrayList<CodegenConfig>();
|
||||
Iterator<CodegenConfig> itr = loader.iterator();
|
||||
while(itr.hasNext()) {
|
||||
output.add(itr.next());
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
static void usage(Options options) {
|
||||
HelpFormatter formatter = new HelpFormatter();
|
||||
formatter.printHelp( "MetaGenerator. Generator for creating a new template set " +
|
||||
"and configuration for Codegen. The output will be based on the language you " +
|
||||
"specify, and includes default templates to include.", options );
|
||||
}
|
||||
|
||||
public static CodegenConfig getConfig(String name) {
|
||||
if(configs.containsKey(name)) {
|
||||
return configs.get(name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.wordnik.swagger.codegen;
|
||||
|
||||
public class SupportingFile {
|
||||
public String templateFile;
|
||||
public String folder;
|
||||
public String destinationFilename;
|
||||
|
||||
public SupportingFile(String templateFile, String folder, String destinationFilename) {
|
||||
this.templateFile = templateFile;
|
||||
this.folder = folder;
|
||||
this.destinationFilename = destinationFilename;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package com.wordnik.swagger.codegen.auth;
|
||||
|
||||
public interface AuthMethod {
|
||||
String getType();
|
||||
void setType(String type);
|
||||
}
|
||||
@@ -1,165 +0,0 @@
|
||||
package com.wordnik.swagger.codegen.examples;
|
||||
|
||||
import com.wordnik.swagger.models.*;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
import com.wordnik.swagger.util.Json;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
public class ExampleGenerator {
|
||||
protected Map<String, Model> examples;
|
||||
|
||||
public ExampleGenerator(Map<String, Model> examples) {
|
||||
this.examples = examples;
|
||||
}
|
||||
|
||||
public List<Map<String, String>> generate(Map<String, String> examples, List<String> mediaTypes, Property property) {
|
||||
List<Map<String, String>> output = new ArrayList<Map<String, String>>();
|
||||
Set<String> processedModels = new HashSet<String>();
|
||||
if(examples == null ) {
|
||||
if(mediaTypes == null) {
|
||||
// assume application/json for this
|
||||
mediaTypes = Arrays.asList("application/json");
|
||||
}
|
||||
for(String mediaType : mediaTypes) {
|
||||
Map<String, String> kv = new HashMap<String, String>();
|
||||
kv.put("contentType", mediaType);
|
||||
if(property != null && mediaType.startsWith("application/json")) {
|
||||
String example = Json.pretty(resolvePropertyToExample(mediaType, property, processedModels));
|
||||
|
||||
if(example != null) {
|
||||
example = example.replaceAll("\n", "\\\\n");
|
||||
kv.put("example", example);
|
||||
output.add(kv);
|
||||
}
|
||||
}
|
||||
else if(property != null && mediaType.startsWith("application/xml")) {
|
||||
String example = new XmlExampleGenerator(this.examples).toXml(property);
|
||||
if(example != null) {
|
||||
example = example.replaceAll("\n", "\\\\n");
|
||||
kv.put("example", example);
|
||||
output.add(kv);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(String key: examples.keySet()) {
|
||||
String value = examples.get(key);
|
||||
|
||||
Map<String, String> kv = new HashMap<String, String>();
|
||||
kv.put("contentType", key);
|
||||
kv.put("example", value);
|
||||
output.add(kv);
|
||||
}
|
||||
}
|
||||
if(output.size() == 0) {
|
||||
Map<String, String> kv = new HashMap<String, String>();
|
||||
kv.put("output", "none");
|
||||
output.add(kv);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
protected Object resolvePropertyToExample(String mediaType, Property property, Set<String> processedModels) {
|
||||
if(property.getExample() != null) {
|
||||
return property.getExample();
|
||||
}
|
||||
else if(property instanceof StringProperty) {
|
||||
return "aeiou";
|
||||
}
|
||||
else if(property instanceof BooleanProperty) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
else if(property instanceof ArrayProperty) {
|
||||
Property innerType = ((ArrayProperty)property).getItems();
|
||||
if(innerType != null) {
|
||||
Object[] output = new Object[]{
|
||||
resolvePropertyToExample(mediaType, innerType, processedModels)
|
||||
};
|
||||
return output;
|
||||
}
|
||||
}
|
||||
else if(property instanceof DateProperty) {
|
||||
return new java.util.Date(System.currentTimeMillis());
|
||||
}
|
||||
else if(property instanceof DateTimeProperty) {
|
||||
return new java.util.Date(System.currentTimeMillis());
|
||||
}
|
||||
else if(property instanceof DecimalProperty) {
|
||||
return new BigDecimal(1.3579);
|
||||
}
|
||||
else if(property instanceof DoubleProperty) {
|
||||
return new Double(3.149);
|
||||
}
|
||||
else if(property instanceof FileProperty) {
|
||||
return ""; // TODO
|
||||
}
|
||||
else if(property instanceof FloatProperty) {
|
||||
return new Float(1.23);
|
||||
}
|
||||
else if(property instanceof IntegerProperty) {
|
||||
return new Integer(123);
|
||||
}
|
||||
else if(property instanceof LongProperty) {
|
||||
return new Long(123456789);
|
||||
}
|
||||
else if(property instanceof MapProperty) {
|
||||
Map<String, Object> mp = new HashMap<String, Object>();
|
||||
if(property.getName() != null) {
|
||||
mp.put(property.getName(),
|
||||
resolvePropertyToExample(mediaType, ((MapProperty)property).getAdditionalProperties(), processedModels));
|
||||
}
|
||||
else {
|
||||
mp.put("key",
|
||||
resolvePropertyToExample(mediaType, ((MapProperty)property).getAdditionalProperties(), processedModels));
|
||||
}
|
||||
return mp;
|
||||
}
|
||||
else if(property instanceof ObjectProperty) {
|
||||
return "{}";
|
||||
}
|
||||
else if(property instanceof RefProperty) {
|
||||
String simpleName = ((RefProperty)property).getSimpleRef();
|
||||
Model model = examples.get(simpleName);
|
||||
if(model != null)
|
||||
return resolveModelToExample(simpleName, mediaType, model, processedModels);
|
||||
}
|
||||
else if(property instanceof UUIDProperty) {
|
||||
return "046b6c7f-0b8a-43b9-b35d-6489e6daee91";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public Object resolveModelToExample(String name, String mediaType, Model model, Set<String> processedModels) {
|
||||
if(processedModels.contains(name)) {
|
||||
return "";
|
||||
}
|
||||
if(model instanceof ModelImpl) {
|
||||
processedModels.add(name);
|
||||
ModelImpl impl = (ModelImpl) model;
|
||||
Map<String, Object> values = new HashMap<String, Object>();
|
||||
|
||||
if(impl != null && impl.getProperties() != null) {
|
||||
for(String propertyName : impl.getProperties().keySet()) {
|
||||
Property property = impl.getProperties().get(propertyName);
|
||||
values.put(propertyName, resolvePropertyToExample(mediaType, property, processedModels));
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -1,188 +0,0 @@
|
||||
package com.wordnik.swagger.codegen.examples;
|
||||
|
||||
|
||||
import com.wordnik.swagger.util.Json;
|
||||
import com.wordnik.swagger.models.*;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class XmlExampleGenerator {
|
||||
public static String NEWLINE = "\n";
|
||||
public static String TAG_START = "<";
|
||||
public static String CLOSE_TAG = ">";
|
||||
public static String TAG_END = "</";
|
||||
protected Map<String, Model> examples;
|
||||
protected SimpleDateFormat dtFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
||||
protected SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
||||
|
||||
public XmlExampleGenerator(Map<String, Model> examples) {
|
||||
this.examples = examples;
|
||||
if(examples == null)
|
||||
examples = new HashMap<String, Model>();
|
||||
}
|
||||
|
||||
public String toXml(Property property) {
|
||||
return toXml(null, property, 0);
|
||||
}
|
||||
|
||||
protected String toXml(Model model, int indent) {
|
||||
if(model instanceof RefModel) {
|
||||
RefModel ref = (RefModel) model;
|
||||
Model actualModel = examples.get(ref.getSimpleRef());
|
||||
if(actualModel instanceof ModelImpl)
|
||||
return modelImplToXml((ModelImpl)actualModel, indent);
|
||||
}
|
||||
else if(model instanceof ModelImpl) {
|
||||
return modelImplToXml((ModelImpl)model, indent);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String modelImplToXml(ModelImpl model, int indent) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// attributes
|
||||
Map<String, Property> attributes = new LinkedHashMap<String, Property>();
|
||||
Map<String, Property> elements = new LinkedHashMap<String, Property>();
|
||||
|
||||
String name = model.getName();
|
||||
String namespace;
|
||||
String prefix;
|
||||
Boolean wrapped;
|
||||
|
||||
Xml xml = model.getXml();
|
||||
if(xml != null) {
|
||||
if(xml.getName() != null)
|
||||
name = xml.getName();
|
||||
}
|
||||
for(String pName : model.getProperties().keySet()) {
|
||||
Property p = model.getProperties().get(pName);
|
||||
if(p != null && p.getXml() != null && p.getXml().getAttribute() != null && p.getXml().getAttribute())
|
||||
attributes.put(pName, p);
|
||||
else
|
||||
elements.put(pName, p);
|
||||
}
|
||||
sb.append(indent(indent)).append(TAG_START);
|
||||
sb.append(name);
|
||||
for(String pName : attributes.keySet()) {
|
||||
Property p = attributes.get(pName);
|
||||
sb.append(" ").append(pName).append("=").append(quote(toXml(null, p, 0)));
|
||||
}
|
||||
sb.append(CLOSE_TAG);
|
||||
sb.append(NEWLINE);
|
||||
for(String pName : elements.keySet()) {
|
||||
Property p = elements.get(pName);
|
||||
sb.append(toXml(pName, p, indent + 1));
|
||||
sb.append(NEWLINE);
|
||||
}
|
||||
sb.append(indent(indent)).append(TAG_END).append(name).append(CLOSE_TAG);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected String quote(String string) {
|
||||
return "\"" + string + "\"";
|
||||
}
|
||||
|
||||
protected String toXml(String name, Property property, int indent) {
|
||||
if(property == null) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if(property instanceof ArrayProperty) {
|
||||
ArrayProperty p = (ArrayProperty) property;
|
||||
Property inner = p.getItems();
|
||||
boolean wrapped = false;
|
||||
if(property.getXml() != null && property.getXml().getWrapped())
|
||||
wrapped = true;
|
||||
if(wrapped) {
|
||||
if(name != null) {
|
||||
sb.append(indent(indent));
|
||||
sb.append(openTag(name));
|
||||
sb.append(NEWLINE);
|
||||
}
|
||||
sb.append(toXml(name, inner, indent + 1));
|
||||
if(name != null) {
|
||||
sb.append(NEWLINE);
|
||||
sb.append(indent(indent));
|
||||
sb.append(closeTag(name));
|
||||
}
|
||||
}
|
||||
else
|
||||
sb.append(toXml(name, inner, indent));
|
||||
}
|
||||
else if(property instanceof RefProperty) {
|
||||
RefProperty ref = (RefProperty) property;
|
||||
Model actualModel = examples.get(ref.getSimpleRef());
|
||||
sb.append(toXml(actualModel, indent));
|
||||
}
|
||||
else {
|
||||
if(name != null) {
|
||||
sb.append(indent(indent));
|
||||
sb.append(openTag(name));
|
||||
}
|
||||
sb.append(getExample(property));
|
||||
if(name != null)
|
||||
sb.append(closeTag(name));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected String getExample(Property property) {
|
||||
if(property instanceof DateTimeProperty) {
|
||||
if(property.getExample() != null)
|
||||
return property.getExample();
|
||||
else
|
||||
return dtFormat.format(new Date());
|
||||
}
|
||||
else if(property instanceof StringProperty) {
|
||||
if(property.getExample() != null)
|
||||
return property.getExample();
|
||||
else
|
||||
return "string";
|
||||
}
|
||||
else if(property instanceof DateProperty) {
|
||||
if(property.getExample() != null)
|
||||
return property.getExample();
|
||||
else
|
||||
return dateFormat.format(new Date());
|
||||
}
|
||||
else if(property instanceof IntegerProperty) {
|
||||
if(property.getExample() != null)
|
||||
return property.getExample();
|
||||
else
|
||||
return "0";
|
||||
}
|
||||
else if(property instanceof BooleanProperty) {
|
||||
if(property.getExample() != null)
|
||||
return property.getExample();
|
||||
else
|
||||
return "true";
|
||||
}
|
||||
else if(property instanceof LongProperty) {
|
||||
if(property.getExample() != null)
|
||||
return property.getExample();
|
||||
else
|
||||
return "123456";
|
||||
}
|
||||
return "not implemented " + property;
|
||||
}
|
||||
|
||||
protected String openTag(String name) {
|
||||
return "<" + name + ">";
|
||||
}
|
||||
|
||||
protected String closeTag(String name) {
|
||||
return "</" + name + ">";
|
||||
}
|
||||
|
||||
protected String indent(int indent) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for(int i = 0; i < indent; i++) {
|
||||
sb.append(" ");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String invokerPackage = "io.swagger.client";
|
||||
protected String groupId = "io.swagger";
|
||||
protected String artifactId = "swagger-android-client";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
protected String sourceFolder = "src/main/java";
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "android";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates an Android client library.";
|
||||
}
|
||||
|
||||
public AndroidClientCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/android";
|
||||
modelTemplateFiles.put("model.mustache", ".java");
|
||||
apiTemplateFiles.put("api.mustache", ".java");
|
||||
templateDir = "android-java";
|
||||
apiPackage = "io.swagger.client.api";
|
||||
modelPackage = "io.swagger.client.model";
|
||||
|
||||
reservedWords = new HashSet<String> (
|
||||
Arrays.asList(
|
||||
"abstract", "continue", "for", "new", "switch", "assert",
|
||||
"default", "if", "package", "synchronized", "boolean", "do", "goto", "private",
|
||||
"this", "break", "double", "implements", "protected", "throw", "byte", "else",
|
||||
"import", "public", "throws", "case", "enum", "instanceof", "return", "transient",
|
||||
"catch", "extends", "int", "short", "try", "char", "final", "interface", "static",
|
||||
"void", "class", "finally", "long", "strictfp", "volatile", "const", "float",
|
||||
"native", "super", "while")
|
||||
);
|
||||
|
||||
additionalProperties.put("invokerPackage", invokerPackage);
|
||||
additionalProperties.put("groupId", groupId);
|
||||
additionalProperties.put("artifactId", artifactId);
|
||||
additionalProperties.put("artifactVersion", artifactVersion);
|
||||
|
||||
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||
supportingFiles.add(new SupportingFile("apiInvoker.mustache",
|
||||
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiInvoker.java"));
|
||||
supportingFiles.add(new SupportingFile("httpPatch.mustache",
|
||||
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "HttpPatch.java"));
|
||||
supportingFiles.add(new SupportingFile("jsonUtil.mustache",
|
||||
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "JsonUtil.java"));
|
||||
supportingFiles.add(new SupportingFile("apiException.mustache",
|
||||
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiException.java"));
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"String",
|
||||
"boolean",
|
||||
"Boolean",
|
||||
"Double",
|
||||
"Integer",
|
||||
"Long",
|
||||
"Float",
|
||||
"Object")
|
||||
);
|
||||
instantiationTypes.put("array", "ArrayList");
|
||||
instantiationTypes.put("map", "HashMap");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
if(p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
Property inner = ap.getItems();
|
||||
return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
else if (p instanceof MapProperty) {
|
||||
MapProperty mp = (MapProperty) p;
|
||||
Property inner = mp.getAdditionalProperties();
|
||||
|
||||
return getSwaggerType(p) + "<String, " + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwaggerType(Property p) {
|
||||
String swaggerType = super.getSwaggerType(p);
|
||||
String type = null;
|
||||
if(typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if(languageSpecificPrimitives.contains(type))
|
||||
return toModelName(type);
|
||||
}
|
||||
else
|
||||
type = swaggerType;
|
||||
return toModelName(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replaceAll("-", "_");
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$"))
|
||||
return name;
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// pet_id => petId
|
||||
name = camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if(reservedWords.contains(name) || name.matches("^\\d.*"))
|
||||
name = escapeReservedWord(name);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// should be the same as variable name
|
||||
return toVarName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if(reservedWords.contains(name))
|
||||
throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// should be the same as the model name
|
||||
return toModelName(name);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,194 +0,0 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
public class AsyncScalaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String invokerPackage = "io.swagger.client";
|
||||
protected String groupId = "com.wordnik";
|
||||
protected String artifactId = "swagger-async-scala-client";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
protected String sourceFolder = "src/main/scala";
|
||||
protected String clientName = "SwaggerClient";
|
||||
protected String authScheme = "";
|
||||
protected boolean authPreemptive = false;
|
||||
protected boolean asyncHttpClient = !authScheme.isEmpty();
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "async-scala";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates an Asynchronous Scala client library.";
|
||||
}
|
||||
|
||||
public AsyncScalaClientCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/async-scala";
|
||||
modelTemplateFiles.put("model.mustache", ".scala");
|
||||
apiTemplateFiles.put("api.mustache", ".scala");
|
||||
templateDir = "asyncscala";
|
||||
apiPackage = "io.swagger.client.api";
|
||||
modelPackage = "io.swagger.client.model";
|
||||
|
||||
reservedWords = new HashSet<String> (
|
||||
Arrays.asList(
|
||||
"abstract", "case", "catch", "class", "def", "do", "else", "extends",
|
||||
"false", "final", "finally", "for", "forSome", "if", "implicit",
|
||||
"import", "lazy", "match", "new", "null", "object", "override", "package",
|
||||
"private", "protected", "return", "sealed", "super", "this", "throw",
|
||||
"trait", "try", "true", "type", "val", "var", "while", "with", "yield")
|
||||
);
|
||||
|
||||
additionalProperties.put("invokerPackage", invokerPackage);
|
||||
additionalProperties.put("groupId", groupId);
|
||||
additionalProperties.put("artifactId", artifactId);
|
||||
additionalProperties.put("artifactVersion", artifactVersion);
|
||||
additionalProperties.put("asyncHttpClient", asyncHttpClient);
|
||||
additionalProperties.put("authScheme", authScheme);
|
||||
additionalProperties.put("authPreemptive", authPreemptive);
|
||||
additionalProperties.put("clientName", clientName);
|
||||
|
||||
supportingFiles.add(new SupportingFile("sbt.mustache", "", "build.sbt"));
|
||||
supportingFiles.add(new SupportingFile("client.mustache",
|
||||
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), clientName + ".scala"));
|
||||
|
||||
importMapping.remove("List");
|
||||
importMapping.remove("Set");
|
||||
importMapping.remove("Map");
|
||||
|
||||
importMapping.put("DateTime", "org.joda.time.DateTime");
|
||||
importMapping.put("ListBuffer", "scala.collections.mutable.ListBuffer");
|
||||
|
||||
typeMapping = new HashMap<String, String>();
|
||||
typeMapping.put("enum", "NSString");
|
||||
typeMapping.put("array", "List");
|
||||
typeMapping.put("set", "Set");
|
||||
typeMapping.put("boolean", "Boolean");
|
||||
typeMapping.put("string", "String");
|
||||
typeMapping.put("int", "Int");
|
||||
typeMapping.put("long", "Long");
|
||||
typeMapping.put("float", "Float");
|
||||
typeMapping.put("byte", "Byte");
|
||||
typeMapping.put("short", "Short");
|
||||
typeMapping.put("char", "Char");
|
||||
typeMapping.put("long", "Long");
|
||||
typeMapping.put("double", "Double");
|
||||
typeMapping.put("object", "Any");
|
||||
typeMapping.put("file", "File");
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"String",
|
||||
"boolean",
|
||||
"Boolean",
|
||||
"Double",
|
||||
"Int",
|
||||
"Long",
|
||||
"Float",
|
||||
"Object",
|
||||
"List",
|
||||
"Map")
|
||||
);
|
||||
instantiationTypes.put("array", "ListBuffer");
|
||||
instantiationTypes.put("map", "HashMap");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
if(p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
Property inner = ap.getItems();
|
||||
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
else if (p instanceof MapProperty) {
|
||||
MapProperty mp = (MapProperty) p;
|
||||
Property inner = mp.getAdditionalProperties();
|
||||
|
||||
return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwaggerType(Property p) {
|
||||
String swaggerType = super.getSwaggerType(p);
|
||||
String type = null;
|
||||
if(typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if(languageSpecificPrimitives.contains(type))
|
||||
return toModelName(type);
|
||||
}
|
||||
else
|
||||
type = swaggerType;
|
||||
return toModelName(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toInstantiationType(Property p) {
|
||||
if (p instanceof MapProperty) {
|
||||
MapProperty ap = (MapProperty) p;
|
||||
String inner = getSwaggerType(ap.getAdditionalProperties());
|
||||
return instantiationTypes.get("map") + "[String, " + inner + "]";
|
||||
}
|
||||
else if (p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
String inner = getSwaggerType(ap.getItems());
|
||||
return instantiationTypes.get("array") + "[" + inner + "]";
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public String toDefaultValue(Property p) {
|
||||
if(p instanceof StringProperty)
|
||||
return "null";
|
||||
else if (p instanceof BooleanProperty)
|
||||
return "null";
|
||||
else if(p instanceof DateProperty)
|
||||
return "null";
|
||||
else if(p instanceof DateTimeProperty)
|
||||
return "null";
|
||||
else if (p instanceof DoubleProperty)
|
||||
return "null";
|
||||
else if (p instanceof FloatProperty)
|
||||
return "null";
|
||||
else if (p instanceof IntegerProperty)
|
||||
return "null";
|
||||
else if (p instanceof LongProperty)
|
||||
return "null";
|
||||
else if (p instanceof MapProperty) {
|
||||
MapProperty ap = (MapProperty) p;
|
||||
String inner = getSwaggerType(ap.getAdditionalProperties());
|
||||
return "new HashMap[String, " + inner + "]() ";
|
||||
}
|
||||
else if (p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
String inner = getSwaggerType(ap.getItems());
|
||||
return "new ListBuffer[" + inner + "]() ";
|
||||
}
|
||||
else
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String invokerPackage = "io.swagger.client";
|
||||
protected String groupId = "io.swagger";
|
||||
protected String artifactId = "swagger-csharp-client";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
protected String sourceFolder = "src/main/csharp";
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "csharp";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates a CSharp client library.";
|
||||
}
|
||||
|
||||
public CSharpClientCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/csharp";
|
||||
modelTemplateFiles.put("model.mustache", ".cs");
|
||||
apiTemplateFiles.put("api.mustache", ".cs");
|
||||
templateDir = "csharp";
|
||||
apiPackage = "io.swagger.Api";
|
||||
modelPackage = "io.swagger.Model";
|
||||
|
||||
reservedWords = new HashSet<String> (
|
||||
Arrays.asList(
|
||||
"abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", "false", "finally", "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock", "long", "namespace", "new", "null", "object", "operator", "out", "override", "params", "private", "protected", "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while")
|
||||
);
|
||||
|
||||
additionalProperties.put("invokerPackage", invokerPackage);
|
||||
|
||||
supportingFiles.add(new SupportingFile("apiInvoker.mustache",
|
||||
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiInvoker.cs"));
|
||||
supportingFiles.add(new SupportingFile("apiException.mustache",
|
||||
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiException.cs"));
|
||||
supportingFiles.add(new SupportingFile("Newtonsoft.Json.dll", "bin", "Newtonsoft.Json.dll"));
|
||||
supportingFiles.add(new SupportingFile("compile.mustache", "", "compile.bat"));
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"String",
|
||||
"boolean",
|
||||
"Boolean",
|
||||
"Double",
|
||||
"Integer",
|
||||
"Long",
|
||||
"Float",
|
||||
"Object")
|
||||
);
|
||||
instantiationTypes.put("array", "List");
|
||||
instantiationTypes.put("map", "Dictionary");
|
||||
|
||||
typeMapping = new HashMap<String, String>();
|
||||
typeMapping.put("boolean", "bool?");
|
||||
typeMapping.put("integer", "int?");
|
||||
typeMapping.put("float", "float?");
|
||||
typeMapping.put("long", "long?");
|
||||
typeMapping.put("double", "double?");
|
||||
typeMapping.put("number", "double?");
|
||||
typeMapping.put("Date", "DateTime");
|
||||
typeMapping.put("file", "byte[]");
|
||||
typeMapping.put("array", "List");
|
||||
typeMapping.put("map", "Dictionary");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replaceAll("-", "_");
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$"))
|
||||
return name;
|
||||
|
||||
// camelize the variable name
|
||||
// pet_id => PetId
|
||||
name = camelize(name);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if(reservedWords.contains(name) || name.matches("^\\d.*"))
|
||||
name = escapeReservedWord(name);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// should be the same as variable name
|
||||
return toVarName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if(reservedWords.contains(name))
|
||||
throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// should be the same as the model name
|
||||
return toModelName(name);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
if(p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
Property inner = ap.getItems();
|
||||
return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
else if (p instanceof MapProperty) {
|
||||
MapProperty mp = (MapProperty) p;
|
||||
Property inner = mp.getAdditionalProperties();
|
||||
|
||||
return getSwaggerType(p) + "<String, " + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwaggerType(Property p) {
|
||||
String swaggerType = super.getSwaggerType(p);
|
||||
String type = null;
|
||||
if(typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if(languageSpecificPrimitives.contains(type))
|
||||
return type;
|
||||
}
|
||||
else
|
||||
type = swaggerType;
|
||||
return type;
|
||||
}
|
||||
}
|
||||
@@ -1,163 +0,0 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String invokerPackage = "io.swagger.client";
|
||||
protected String groupId = "io.swagger";
|
||||
protected String artifactId = "swagger-java-client";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
protected String sourceFolder = "src/main/java";
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "java";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates a Java client library.";
|
||||
}
|
||||
|
||||
public JavaClientCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/java";
|
||||
modelTemplateFiles.put("model.mustache", ".java");
|
||||
apiTemplateFiles.put("api.mustache", ".java");
|
||||
templateDir = "Java";
|
||||
apiPackage = "io.swagger.client.api";
|
||||
modelPackage = "io.swagger.client.model";
|
||||
|
||||
reservedWords = new HashSet<String> (
|
||||
Arrays.asList(
|
||||
"abstract", "continue", "for", "new", "switch", "assert",
|
||||
"default", "if", "package", "synchronized", "boolean", "do", "goto", "private",
|
||||
"this", "break", "double", "implements", "protected", "throw", "byte", "else",
|
||||
"import", "public", "throws", "case", "enum", "instanceof", "return", "transient",
|
||||
"catch", "extends", "int", "short", "try", "char", "final", "interface", "static",
|
||||
"void", "class", "finally", "long", "strictfp", "volatile", "const", "float",
|
||||
"native", "super", "while")
|
||||
);
|
||||
|
||||
additionalProperties.put("invokerPackage", invokerPackage);
|
||||
additionalProperties.put("groupId", groupId);
|
||||
additionalProperties.put("artifactId", artifactId);
|
||||
additionalProperties.put("artifactVersion", artifactVersion);
|
||||
|
||||
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||
supportingFiles.add(new SupportingFile("apiInvoker.mustache",
|
||||
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiInvoker.java"));
|
||||
supportingFiles.add(new SupportingFile("JsonUtil.mustache",
|
||||
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "JsonUtil.java"));
|
||||
supportingFiles.add(new SupportingFile("apiException.mustache",
|
||||
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiException.java"));
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"String",
|
||||
"boolean",
|
||||
"Boolean",
|
||||
"Double",
|
||||
"Integer",
|
||||
"Long",
|
||||
"Float",
|
||||
"Object")
|
||||
);
|
||||
instantiationTypes.put("array", "ArrayList");
|
||||
instantiationTypes.put("map", "HashMap");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replaceAll("-", "_");
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$"))
|
||||
return name;
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// pet_id => petId
|
||||
name = camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if(reservedWords.contains(name) || name.matches("^\\d.*"))
|
||||
name = escapeReservedWord(name);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// should be the same as variable name
|
||||
return toVarName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if(reservedWords.contains(name))
|
||||
throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// should be the same as the model name
|
||||
return toModelName(name);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
if(p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
Property inner = ap.getItems();
|
||||
return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
else if (p instanceof MapProperty) {
|
||||
MapProperty mp = (MapProperty) p;
|
||||
Property inner = mp.getAdditionalProperties();
|
||||
|
||||
return getSwaggerType(p) + "<String, " + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwaggerType(Property p) {
|
||||
String swaggerType = super.getSwaggerType(p);
|
||||
String type = null;
|
||||
if(typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if(languageSpecificPrimitives.contains(type))
|
||||
return toModelName(type);
|
||||
}
|
||||
else
|
||||
type = swaggerType;
|
||||
return toModelName(type);
|
||||
}
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.models.Operation;
|
||||
import com.wordnik.swagger.models.Path;
|
||||
import com.wordnik.swagger.util.Json;
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConfig {
|
||||
protected String invokerPackage = "io.swagger.api";
|
||||
protected String groupId = "io.swagger";
|
||||
protected String artifactId = "swagger-jaxrs-server";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
protected String sourceFolder = "src/main/java";
|
||||
protected String title = "Swagger Server";
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.SERVER;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "jaxrs";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates a Java JAXRS Server application.";
|
||||
}
|
||||
|
||||
public JaxRSServerCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/javaJaxRS";
|
||||
modelTemplateFiles.put("model.mustache", ".java");
|
||||
apiTemplateFiles.put("api.mustache", ".java");
|
||||
templateDir = "JavaJaxRS";
|
||||
apiPackage = "io.swagger.api";
|
||||
modelPackage = "io.swagger.model";
|
||||
|
||||
additionalProperties.put("invokerPackage", invokerPackage);
|
||||
additionalProperties.put("groupId", groupId);
|
||||
additionalProperties.put("artifactId", artifactId);
|
||||
additionalProperties.put("artifactVersion", artifactVersion);
|
||||
additionalProperties.put("title", title);
|
||||
|
||||
supportingFiles.clear();
|
||||
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("ApiException.mustache",
|
||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiException.java"));
|
||||
supportingFiles.add(new SupportingFile("ApiOriginFilter.mustache",
|
||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiOriginFilter.java"));
|
||||
supportingFiles.add(new SupportingFile("ApiResponseMessage.mustache",
|
||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiResponseMessage.java"));
|
||||
supportingFiles.add(new SupportingFile("NotFoundException.mustache",
|
||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "NotFoundException.java"));
|
||||
supportingFiles.add(new SupportingFile("web.mustache",
|
||||
("src/main/webapp/WEB-INF"), "web.xml"));
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"String",
|
||||
"boolean",
|
||||
"Boolean",
|
||||
"Double",
|
||||
"Integer",
|
||||
"Long",
|
||||
"Float")
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
if(p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
Property inner = ap.getItems();
|
||||
return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
else if (p instanceof MapProperty) {
|
||||
MapProperty mp = (MapProperty) p;
|
||||
Property inner = mp.getAdditionalProperties();
|
||||
|
||||
return getTypeDeclaration(inner);
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
|
||||
String basePath = resourcePath;
|
||||
if(basePath.startsWith("/"))
|
||||
basePath = basePath.substring(1);
|
||||
int pos = basePath.indexOf("/");
|
||||
if(pos > 0)
|
||||
basePath = basePath.substring(0, pos);
|
||||
|
||||
if(basePath == "")
|
||||
basePath = "default";
|
||||
else {
|
||||
if(co.path.startsWith("/" + basePath))
|
||||
co.path = co.path.substring(("/" + basePath).length());
|
||||
co.subresourceOperation = !co.path.isEmpty();
|
||||
}
|
||||
List<CodegenOperation> opList = operations.get(basePath);
|
||||
if(opList == null) {
|
||||
opList = new ArrayList<CodegenOperation>();
|
||||
operations.put(basePath, opList);
|
||||
}
|
||||
opList.add(co);
|
||||
co.baseName = basePath;
|
||||
}
|
||||
|
||||
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
||||
Map<String, Object> operations = (Map<String, Object>)objs.get("operations");
|
||||
if(operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
for(CodegenOperation operation : ops) {
|
||||
if(operation.returnType == null)
|
||||
operation.returnType = "Void";
|
||||
else if(operation.returnType.startsWith("List")) {
|
||||
String rt = operation.returnType;
|
||||
int end = rt.lastIndexOf(">");
|
||||
if(end > 0) {
|
||||
operation.returnType = rt.substring("List<".length(), end);
|
||||
operation.returnContainer = "List";
|
||||
}
|
||||
}
|
||||
else if(operation.returnType.startsWith("Map")) {
|
||||
String rt = operation.returnType;
|
||||
int end = rt.lastIndexOf(">");
|
||||
if(end > 0) {
|
||||
operation.returnType = rt.substring("Map<".length(), end);
|
||||
operation.returnContainer = "Map";
|
||||
}
|
||||
}
|
||||
else if(operation.returnType.startsWith("Set")) {
|
||||
String rt = operation.returnType;
|
||||
int end = rt.lastIndexOf(">");
|
||||
if(end > 0) {
|
||||
operation.returnType = rt.substring("Set<".length(), end);
|
||||
operation.returnContainer = "Set";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
}
|
||||
@@ -1,192 +0,0 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.util.Json;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String apiVersion = "1.0.0";
|
||||
protected int serverPort = 8080;
|
||||
protected String projectName = "swagger-server";
|
||||
|
||||
public String apiPackage() {
|
||||
return "controllers";
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the type of generator.
|
||||
*
|
||||
* @return the CodegenType for this generator
|
||||
* @see com.wordnik.swagger.codegen.CodegenType
|
||||
*/
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.SERVER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures a friendly name for the generator. This will be used by the generator
|
||||
* to select the library with the -l flag.
|
||||
*
|
||||
* @return the friendly name for the generator
|
||||
*/
|
||||
public String getName() {
|
||||
return "nodejs";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns human-friendly help for the generator. Provide the consumer with help
|
||||
* tips, parameters here
|
||||
*
|
||||
* @return A string value for the help message
|
||||
*/
|
||||
public String getHelp() {
|
||||
return "Generates a nodejs server library using the swagger-tools project. By default, " +
|
||||
"it will also generate service classes--which you can disable with the `-Dnoservice` environment variable.";
|
||||
}
|
||||
|
||||
public NodeJSServerCodegen() {
|
||||
super();
|
||||
|
||||
// set the output folder here
|
||||
outputFolder = "generated-code/nodejs";
|
||||
|
||||
/**
|
||||
* Models. You can write model files using the modelTemplateFiles map.
|
||||
* if you want to create one template for file, you can do so here.
|
||||
* for multiple files for model, just put another entry in the `modelTemplateFiles` with
|
||||
* a different extension
|
||||
*/
|
||||
modelTemplateFiles.clear();
|
||||
|
||||
/**
|
||||
* Api classes. You can write classes for each Api file with the apiTemplateFiles map.
|
||||
* as with models, add multiple entries with different extensions for multiple files per
|
||||
* class
|
||||
*/
|
||||
apiTemplateFiles.put(
|
||||
"controller.mustache", // the template to use
|
||||
".js"); // the extension for each file to write
|
||||
|
||||
/**
|
||||
* Template Location. This is the location which templates will be read from. The generator
|
||||
* will use the resource stream to attempt to read the templates.
|
||||
*/
|
||||
templateDir = "nodejs";
|
||||
|
||||
/**
|
||||
* Reserved words. Override this with reserved words specific to your language
|
||||
*/
|
||||
reservedWords = new HashSet<String> (
|
||||
Arrays.asList(
|
||||
"break", "case", "class", "catch", "const", "continue", "debugger",
|
||||
"default", "delete", "do", "else", "export", "extends", "finally",
|
||||
"for", "function", "if", "import", "in", "instanceof", "let", "new",
|
||||
"return", "super", "switch", "this", "throw", "try", "typeof", "var",
|
||||
"void", "while", "with", "yield")
|
||||
);
|
||||
|
||||
/**
|
||||
* Additional Properties. These values can be passed to the templates and
|
||||
* are available in models, apis, and supporting files
|
||||
*/
|
||||
additionalProperties.put("apiVersion", apiVersion);
|
||||
additionalProperties.put("serverPort", serverPort);
|
||||
|
||||
/**
|
||||
* Supporting Files. You can write single files for the generator with the
|
||||
* entire object tree available. If the input file has a suffix of `.mustache
|
||||
* it will be processed by the template engine. Otherwise, it will be copied
|
||||
*/
|
||||
// supportingFiles.add(new SupportingFile("controller.mustache",
|
||||
// "controllers",
|
||||
// "controller.js")
|
||||
// );
|
||||
supportingFiles.add(new SupportingFile("swagger.mustache",
|
||||
"api",
|
||||
"swagger.json")
|
||||
);
|
||||
supportingFiles.add(new SupportingFile("index.mustache",
|
||||
"",
|
||||
"index.js")
|
||||
);
|
||||
supportingFiles.add(new SupportingFile("package.mustache",
|
||||
"",
|
||||
"package.json")
|
||||
);
|
||||
if(System.getProperty("noservice") == null) {
|
||||
apiTemplateFiles.put(
|
||||
"service.mustache", // the template to use
|
||||
"Service.js"); // the extension for each file to write
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
if(name.length() == 0)
|
||||
return "DefaultController";
|
||||
return initialCaps(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiFilename(String name) {
|
||||
return toApiName(name);
|
||||
}
|
||||
/**
|
||||
* Escapes a reserved word as defined in the `reservedWords` array. Handle escaping
|
||||
* those terms here. This logic is only called if a variable matches the reseved words
|
||||
*
|
||||
* @return the escaped term
|
||||
*/
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name; // add an underscore to the name
|
||||
}
|
||||
|
||||
/**
|
||||
* Location to write api files. You can use the apiPackage() as defined when the class is
|
||||
* instantiated
|
||||
*/
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + File.separator + apiPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
||||
Map<String, Object> objectMap = (Map<String, Object>)objs.get("operations");
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>)objectMap.get("operation");
|
||||
for(CodegenOperation operation : operations) {
|
||||
operation.httpMethod = operation.httpMethod.toLowerCase();
|
||||
List<CodegenParameter> params = operation.allParams;
|
||||
if(params != null && params.size() == 0)
|
||||
operation.allParams = null;
|
||||
List<CodegenResponse> responses = operation.responses;
|
||||
if(responses != null) {
|
||||
for(CodegenResponse resp : responses) {
|
||||
if("0".equals(resp.code))
|
||||
resp.code = "default";
|
||||
}
|
||||
}
|
||||
if(operation.examples != null && operation.examples.size() > 0) {
|
||||
List<Map<String, String>> examples = operation.examples;
|
||||
for(int i = examples.size() - 1; i >= 0; i--) {
|
||||
Map<String, String> example = examples.get(i);
|
||||
String contentType = example.get("contentType");
|
||||
if(contentType != null && contentType.indexOf("application/json") == 0) {
|
||||
String jsonExample = example.get("example");
|
||||
if(jsonExample != null) {
|
||||
jsonExample = jsonExample.replaceAll("\\\\n", "\n");
|
||||
example.put("example", jsonExample);
|
||||
}
|
||||
}
|
||||
else
|
||||
examples.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
}
|
||||
@@ -1,273 +0,0 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.util.Json;
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected Set<String> foundationClasses = new HashSet<String>();
|
||||
protected String sourceFolder = "client";
|
||||
protected static String PREFIX = "SWG";
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "objc";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates an Objective-C client library.";
|
||||
}
|
||||
|
||||
public ObjcClientCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/objc";
|
||||
modelTemplateFiles.put("model-header.mustache", ".h");
|
||||
modelTemplateFiles.put("model-body.mustache", ".m");
|
||||
apiTemplateFiles.put("api-header.mustache", ".h");
|
||||
apiTemplateFiles.put("api-body.mustache", ".m");
|
||||
templateDir = "objc";
|
||||
modelPackage = "";
|
||||
|
||||
String appName = System.getProperty("appName");
|
||||
if(appName == null) {
|
||||
appName = "swaggerClient";
|
||||
}
|
||||
additionalProperties.put("projectName", appName);
|
||||
|
||||
defaultIncludes = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"bool",
|
||||
"int",
|
||||
"NSString",
|
||||
"NSObject",
|
||||
"NSArray",
|
||||
"NSNumber",
|
||||
"NSDate",
|
||||
"NSDictionary",
|
||||
"NSMutableArray",
|
||||
"NSMutableDictionary")
|
||||
);
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"NSNumber",
|
||||
"NSString",
|
||||
"NSObject",
|
||||
"NSDate",
|
||||
"bool")
|
||||
);
|
||||
|
||||
reservedWords = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"void", "char", "short", "int", "void", "char", "short", "int",
|
||||
"long", "float", "double", "signed", "unsigned", "id", "const",
|
||||
"volatile", "in", "out", "inout", "bycopy", "byref", "oneway",
|
||||
"self", "super", "description"
|
||||
));
|
||||
|
||||
typeMapping = new HashMap<String, String>();
|
||||
typeMapping.put("enum", "NSString");
|
||||
typeMapping.put("Date", "NSDate");
|
||||
typeMapping.put("DateTime", "NSDate");
|
||||
typeMapping.put("boolean", "NSNumber");
|
||||
typeMapping.put("string", "NSString");
|
||||
typeMapping.put("integer", "NSNumber");
|
||||
typeMapping.put("int", "NSNumber");
|
||||
typeMapping.put("float", "NSNumber");
|
||||
typeMapping.put("long", "NSNumber");
|
||||
typeMapping.put("double", "NSNumber");
|
||||
typeMapping.put("array", "NSArray");
|
||||
typeMapping.put("map", "NSDictionary");
|
||||
typeMapping.put("number", "NSNumber");
|
||||
typeMapping.put("List", "NSArray");
|
||||
typeMapping.put("object", "NSObject");
|
||||
|
||||
importMapping = new HashMap<String, String> ();
|
||||
|
||||
foundationClasses = new HashSet<String> (
|
||||
Arrays.asList(
|
||||
"NSNumber",
|
||||
"NSObject",
|
||||
"NSString",
|
||||
"NSDate",
|
||||
"NSDictionary")
|
||||
);
|
||||
|
||||
instantiationTypes.put("array", "NSMutableArray");
|
||||
instantiationTypes.put("map", "NSMutableDictionary");
|
||||
|
||||
supportingFiles.add(new SupportingFile("SWGObject.h", sourceFolder, "SWGObject.h"));
|
||||
supportingFiles.add(new SupportingFile("SWGObject.m", sourceFolder, "SWGObject.m"));
|
||||
supportingFiles.add(new SupportingFile("SWGQueryParamCollection.h", sourceFolder, "SWGQueryParamCollection.h"));
|
||||
supportingFiles.add(new SupportingFile("SWGQueryParamCollection.m", sourceFolder, "SWGQueryParamCollection.m"));
|
||||
supportingFiles.add(new SupportingFile("SWGApiClient.h", sourceFolder, "SWGApiClient.h"));
|
||||
supportingFiles.add(new SupportingFile("SWGApiClient.m", sourceFolder, "SWGApiClient.m"));
|
||||
supportingFiles.add(new SupportingFile("SWGFile.h", sourceFolder, "SWGFile.h"));
|
||||
supportingFiles.add(new SupportingFile("SWGFile.m", sourceFolder, "SWGFile.m"));
|
||||
supportingFiles.add(new SupportingFile("SWGDate.h", sourceFolder, "SWGDate.h"));
|
||||
supportingFiles.add(new SupportingFile("SWGDate.m", sourceFolder, "SWGDate.m"));
|
||||
supportingFiles.add(new SupportingFile("Podfile.mustache", "", "Podfile"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toInstantiationType(Property p) {
|
||||
if (p instanceof MapProperty) {
|
||||
MapProperty ap = (MapProperty) p;
|
||||
String inner = getSwaggerType(ap.getAdditionalProperties());
|
||||
return instantiationTypes.get("map");
|
||||
}
|
||||
else if (p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
String inner = getSwaggerType(ap.getItems());
|
||||
return instantiationTypes.get("array");
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(String name) {
|
||||
if(languageSpecificPrimitives.contains(name) && !foundationClasses.contains(name))
|
||||
return name;
|
||||
else
|
||||
return name + "*";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwaggerType(Property p) {
|
||||
String swaggerType = super.getSwaggerType(p);
|
||||
String type = null;
|
||||
if(typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if(languageSpecificPrimitives.contains(type) && !foundationClasses.contains(type))
|
||||
return toModelName(type);
|
||||
}
|
||||
else
|
||||
type = swaggerType;
|
||||
return toModelName(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
if (p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
Property inner = ap.getItems();
|
||||
String innerType = getSwaggerType(inner);
|
||||
|
||||
// In this codition, type of property p is array of primitive,
|
||||
// return container type with pointer, e.g. `NSArray*'
|
||||
if (languageSpecificPrimitives.contains(innerType))
|
||||
return getSwaggerType(p) + "*";
|
||||
|
||||
// In this codition, type of property p is array of model,
|
||||
// return container type combine inner type with pointer, e.g. `NSArray<SWGTag>*'
|
||||
String innerTypeDeclaration = getTypeDeclaration(inner);
|
||||
|
||||
if (innerTypeDeclaration.endsWith("*"))
|
||||
innerTypeDeclaration = innerTypeDeclaration.substring(0, innerTypeDeclaration.length() - 1);
|
||||
|
||||
return getSwaggerType(p) + "<" + innerTypeDeclaration + ">*";
|
||||
}
|
||||
else {
|
||||
String swaggerType = getSwaggerType(p);
|
||||
|
||||
// In this codition, type of p is objective-c primitive type, e.g. `NSSNumber',
|
||||
// return type of p with pointer, e.g. `NSNumber*'
|
||||
if (languageSpecificPrimitives.contains(swaggerType) &&
|
||||
foundationClasses.contains(swaggerType)) {
|
||||
return swaggerType + "*";
|
||||
}
|
||||
// In this codition, type of p is c primitive type, e.g. `bool',
|
||||
// return type of p, e.g. `bool'
|
||||
else if (languageSpecificPrimitives.contains(swaggerType)) {
|
||||
return swaggerType;
|
||||
}
|
||||
// In this codition, type of p is objective-c object type, e.g. `SWGPet',
|
||||
// return type of p with pointer, e.g. `'
|
||||
else {
|
||||
return swaggerType + "*";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String type) {
|
||||
if(typeMapping.keySet().contains(type) ||
|
||||
foundationClasses.contains(type) ||
|
||||
importMapping.values().contains(type) ||
|
||||
defaultIncludes.contains(type) ||
|
||||
languageSpecificPrimitives.contains(type)) {
|
||||
return Character.toUpperCase(type.charAt(0)) + type.substring(1);
|
||||
}
|
||||
else {
|
||||
return PREFIX + Character.toUpperCase(type.charAt(0)) + type.substring(1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setNonArrayMapProperty(CodegenProperty property, String type) {
|
||||
super.setNonArrayMapProperty(property, type);
|
||||
if("NSDictionary".equals(type)) {
|
||||
property.setter = "initWithDictionary";
|
||||
}
|
||||
else {
|
||||
property.setter = "initWithValues";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelImport(String name) {
|
||||
if("".equals(modelPackage()))
|
||||
return name;
|
||||
else
|
||||
return modelPackage() + "." + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toDefaultValue(Property p) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + File.separator + sourceFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + File.separator + sourceFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
return PREFIX + initialCaps(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
return PREFIX + initialCaps(name) + "Api";
|
||||
}
|
||||
|
||||
public String toApiFilename(String name) {
|
||||
return PREFIX + initialCaps(name) + "Api";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
String paramName = name.replaceAll("[^a-zA-Z0-9_]","");
|
||||
if(paramName.startsWith("new") || reservedWords.contains(paramName)) {
|
||||
return escapeReservedWord(paramName);
|
||||
}
|
||||
else
|
||||
return paramName;
|
||||
}
|
||||
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name;
|
||||
}
|
||||
}
|
||||
@@ -1,162 +0,0 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.util.Json;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String invokerPackage = "com.wordnik.client";
|
||||
protected String groupId = "com.wordnik";
|
||||
protected String artifactId = "swagger-client";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "php";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates a PHP client library.";
|
||||
}
|
||||
|
||||
public PhpClientCodegen() {
|
||||
super();
|
||||
|
||||
//TODO determine hte package name from host name
|
||||
invokerPackage = camelize("SwaggerPetstore");
|
||||
|
||||
String packagePath = invokerPackage + "-php";
|
||||
|
||||
modelPackage = packagePath + "/lib/models";
|
||||
apiPackage = packagePath + "/lib";
|
||||
outputFolder = "generated-code/php";
|
||||
modelTemplateFiles.put("model.mustache", ".php");
|
||||
apiTemplateFiles.put("api.mustache", ".php");
|
||||
templateDir = "php";
|
||||
|
||||
typeMapping.clear();
|
||||
languageSpecificPrimitives.clear();
|
||||
|
||||
reservedWords = new HashSet<String> (
|
||||
Arrays.asList(
|
||||
"__halt_compiler", "abstract", "and", "array", "as", "break", "callable", "case", "catch", "class", "clone", "const", "continue", "declare", "default", "die", "do", "echo", "else", "elseif", "empty", "enddeclare", "endfor", "endforeach", "endif", "endswitch", "endwhile", "eval", "exit", "extends", "final", "for", "foreach", "function", "global", "goto", "if", "implements", "include", "include_once", "instanceof", "insteadof", "interface", "isset", "list", "namespace", "new", "or", "print", "private", "protected", "public", "require", "require_once", "return", "static", "switch", "throw", "trait", "try", "unset", "use", "var", "while", "xor")
|
||||
);
|
||||
|
||||
additionalProperties.put("invokerPackage", invokerPackage);
|
||||
additionalProperties.put("groupId", groupId);
|
||||
additionalProperties.put("artifactId", artifactId);
|
||||
additionalProperties.put("artifactVersion", artifactVersion);
|
||||
|
||||
languageSpecificPrimitives.add("int");
|
||||
languageSpecificPrimitives.add("array");
|
||||
languageSpecificPrimitives.add("map");
|
||||
languageSpecificPrimitives.add("string");
|
||||
languageSpecificPrimitives.add("DateTime");
|
||||
|
||||
typeMapping.put("long", "int");
|
||||
typeMapping.put("integer", "int");
|
||||
typeMapping.put("Array", "array");
|
||||
typeMapping.put("String", "string");
|
||||
typeMapping.put("List", "array");
|
||||
typeMapping.put("map", "map");
|
||||
|
||||
supportingFiles.add(new SupportingFile("composer.mustache", packagePath, "composer.json"));
|
||||
supportingFiles.add(new SupportingFile("APIClient.mustache", packagePath + "/lib", "APIClient.php"));
|
||||
supportingFiles.add(new SupportingFile("APIClientException.mustache", packagePath + "/lib", "APIClientException.php"));
|
||||
supportingFiles.add(new SupportingFile("require.mustache", packagePath, invokerPackage + ".php"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + "/" + apiPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + "/" + modelPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
if(p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
Property inner = ap.getItems();
|
||||
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
else if (p instanceof MapProperty) {
|
||||
MapProperty mp = (MapProperty) p;
|
||||
Property inner = mp.getAdditionalProperties();
|
||||
return getSwaggerType(p) + "[string," + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwaggerType(Property p) {
|
||||
String swaggerType = super.getSwaggerType(p);
|
||||
String type = null;
|
||||
if(typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if(languageSpecificPrimitives.contains(type)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
else
|
||||
type = swaggerType;
|
||||
if(type == null)
|
||||
return null;
|
||||
return type;
|
||||
}
|
||||
|
||||
public String toDefaultValue(Property p) {
|
||||
return "null";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// parameter name starting with number won't compile
|
||||
// need to escape it by appending _ at the beginning
|
||||
if (name.matches("^[0-9]")) {
|
||||
name = "_" + name;
|
||||
}
|
||||
|
||||
// return the name in underscore style
|
||||
// PhoneNumber => phone_number
|
||||
return underscore(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// should be the same as variable name
|
||||
return toVarName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
// model name cannot use reserved keyword
|
||||
if(reservedWords.contains(name))
|
||||
escapeReservedWord(name); // e.g. return => _return
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// should be the same as the model name
|
||||
return toModelName(name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
String module = "client";
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "python";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates a Python client library.";
|
||||
}
|
||||
|
||||
public PythonClientCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/python";
|
||||
modelTemplateFiles.put("model.mustache", ".py");
|
||||
apiTemplateFiles.put("api.mustache", ".py");
|
||||
templateDir = "python";
|
||||
|
||||
apiPackage = module;
|
||||
modelPackage = module + ".models";
|
||||
|
||||
languageSpecificPrimitives.clear();
|
||||
languageSpecificPrimitives.add("int");
|
||||
languageSpecificPrimitives.add("float");
|
||||
languageSpecificPrimitives.add("long");
|
||||
languageSpecificPrimitives.add("list");
|
||||
languageSpecificPrimitives.add("bool");
|
||||
languageSpecificPrimitives.add("str");
|
||||
languageSpecificPrimitives.add("datetime");
|
||||
|
||||
typeMapping.clear();
|
||||
typeMapping.put("integer", "int");
|
||||
typeMapping.put("float", "float");
|
||||
typeMapping.put("long", "long");
|
||||
typeMapping.put("double", "float");
|
||||
typeMapping.put("array", "list");
|
||||
typeMapping.put("map", "map");
|
||||
typeMapping.put("boolean", "bool");
|
||||
typeMapping.put("string", "str");
|
||||
typeMapping.put("date", "datetime");
|
||||
|
||||
// from https://docs.python.org/release/2.5.4/ref/keywords.html
|
||||
reservedWords = new HashSet<String> (
|
||||
Arrays.asList(
|
||||
"and", "del", "from", "not", "while", "as", "elif", "global", "or", "with",
|
||||
"assert", "else", "if", "pass", "yield", "break", "except", "import",
|
||||
"print", "class", "exec", "in", "raise", "continue", "finally", "is",
|
||||
"return", "def", "for", "lambda", "try"));
|
||||
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("swagger.mustache", module, "swagger.py"));
|
||||
supportingFiles.add(new SupportingFile("__init__.mustache", module, "__init__.py"));
|
||||
supportingFiles.add(new SupportingFile("__init__.mustache", modelPackage.replace('.', File.separatorChar), "__init__.py"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + "/" + apiPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + "/" + modelPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
if(p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
Property inner = ap.getItems();
|
||||
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
else if (p instanceof MapProperty) {
|
||||
MapProperty mp = (MapProperty) p;
|
||||
Property inner = mp.getAdditionalProperties();
|
||||
|
||||
return getSwaggerType(p) + "(String, " + getTypeDeclaration(inner) + ")";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwaggerType(Property p) {
|
||||
String swaggerType = super.getSwaggerType(p);
|
||||
String type = null;
|
||||
if(typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if(languageSpecificPrimitives.contains(type)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
else
|
||||
type = swaggerType;
|
||||
return type;
|
||||
}
|
||||
|
||||
public String toDefaultValue(Property p) {
|
||||
// TODO: Support Python def value
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.util.Json;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String invokerPackage = "com.wordnik.client";
|
||||
protected String groupId = "com.wordnik";
|
||||
protected String artifactId = "swagger-client";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "ruby";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates a Ruby client library.";
|
||||
}
|
||||
|
||||
public RubyClientCodegen() {
|
||||
super();
|
||||
modelPackage = "models";
|
||||
apiPackage = "lib";
|
||||
outputFolder = "generated-code/ruby";
|
||||
modelTemplateFiles.put("model.mustache", ".rb");
|
||||
apiTemplateFiles.put("api.mustache", ".rb");
|
||||
templateDir = "ruby";
|
||||
|
||||
typeMapping.clear();
|
||||
languageSpecificPrimitives.clear();
|
||||
|
||||
reservedWords = new HashSet<String> (
|
||||
Arrays.asList(
|
||||
"__FILE__", "and", "def", "end", "in", "or", "self", "unless", "__LINE__",
|
||||
"begin", "defined?", "ensure", "module", "redo", "super", "until", "BEGIN",
|
||||
"break", "do", "false", "next", "rescue", "then", "when", "END", "case",
|
||||
"else", "for", "nil", "retry", "true", "while", "alias", "class", "elsif",
|
||||
"if", "not", "return", "undef", "yield")
|
||||
);
|
||||
|
||||
additionalProperties.put("invokerPackage", invokerPackage);
|
||||
additionalProperties.put("groupId", groupId);
|
||||
additionalProperties.put("artifactId", artifactId);
|
||||
additionalProperties.put("artifactVersion", artifactVersion);
|
||||
|
||||
languageSpecificPrimitives.add("int");
|
||||
languageSpecificPrimitives.add("array");
|
||||
languageSpecificPrimitives.add("map");
|
||||
languageSpecificPrimitives.add("string");
|
||||
languageSpecificPrimitives.add("DateTime");
|
||||
|
||||
typeMapping.put("long", "int");
|
||||
typeMapping.put("integer", "int");
|
||||
typeMapping.put("Array", "array");
|
||||
typeMapping.put("String", "string");
|
||||
typeMapping.put("List", "array");
|
||||
typeMapping.put("map", "map");
|
||||
|
||||
supportingFiles.add(new SupportingFile("swagger.mustache", "", "lib/swagger.rb"));
|
||||
supportingFiles.add(new SupportingFile("monkey.mustache", "", "lib/monkey.rb"));
|
||||
supportingFiles.add(new SupportingFile("swagger/request.mustache", "", "lib/swagger/request.rb"));
|
||||
supportingFiles.add(new SupportingFile("swagger/response.mustache", "", "lib/swagger/response.rb"));
|
||||
supportingFiles.add(new SupportingFile("swagger/version.mustache", "", "lib/swagger/version.rb"));
|
||||
supportingFiles.add(new SupportingFile("swagger/configuration.mustache", "", "lib/swagger/configuration.rb"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + "/" + apiPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + "/" + modelPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
if(p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
Property inner = ap.getItems();
|
||||
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
else if (p instanceof MapProperty) {
|
||||
MapProperty mp = (MapProperty) p;
|
||||
Property inner = mp.getAdditionalProperties();
|
||||
return getSwaggerType(p) + "[string," + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwaggerType(Property p) {
|
||||
String swaggerType = super.getSwaggerType(p);
|
||||
String type = null;
|
||||
if(typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if(languageSpecificPrimitives.contains(type)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
else
|
||||
type = swaggerType;
|
||||
if(type == null)
|
||||
return null;
|
||||
return type;
|
||||
}
|
||||
|
||||
public String toDefaultValue(Property p) {
|
||||
return "null";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replaceAll("-", "_");
|
||||
|
||||
// if it's all uppper case, convert to lower case
|
||||
if (name.matches("^[A-Z_]*$"))
|
||||
name = name.toLowerCase();
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// petId => pet_id
|
||||
name = underscore(name);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if(reservedWords.contains(name) || name.matches("^\\d.*"))
|
||||
name = escapeReservedWord(name);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// should be the same as variable name
|
||||
return toVarName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if(reservedWords.contains(name))
|
||||
throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if(reservedWords.contains(name))
|
||||
throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
|
||||
|
||||
// underscore the model file name
|
||||
// PhoneNumber.rb => phone_number.rb
|
||||
return underscore(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiFilename(String name) {
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replaceAll("-", "_");
|
||||
|
||||
// e.g. PhoneNumberApi.rb => phone_number_api.rb
|
||||
return underscore(name) + "_api";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
if(name.length() == 0)
|
||||
return "DefaultApi";
|
||||
// e.g. phone_number_api => PhoneNumberApi
|
||||
return camelize(name) + "Api";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,192 +0,0 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String invokerPackage = "io.swagger.client";
|
||||
protected String groupId = "com.wordnik";
|
||||
protected String artifactId = "swagger-scala-client";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
protected String sourceFolder = "src/main/scala";
|
||||
protected String authScheme = "";
|
||||
protected boolean authPreemptive = false;
|
||||
protected boolean asyncHttpClient = !authScheme.isEmpty();
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "scala";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates a Scala client library.";
|
||||
}
|
||||
|
||||
public ScalaClientCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/scala";
|
||||
modelTemplateFiles.put("model.mustache", ".scala");
|
||||
apiTemplateFiles.put("api.mustache", ".scala");
|
||||
templateDir = "scala";
|
||||
apiPackage = "io.swagger.client.api";
|
||||
modelPackage = "io.swagger.client.model";
|
||||
|
||||
reservedWords = new HashSet<String> (
|
||||
Arrays.asList(
|
||||
"abstract", "case", "catch", "class", "def", "do", "else", "extends",
|
||||
"false", "final", "finally", "for", "forSome", "if", "implicit",
|
||||
"import", "lazy", "match", "new", "null", "object", "override", "package",
|
||||
"private", "protected", "return", "sealed", "super", "this", "throw",
|
||||
"trait", "try", "true", "type", "val", "var", "while", "with", "yield")
|
||||
);
|
||||
|
||||
additionalProperties.put("invokerPackage", invokerPackage);
|
||||
additionalProperties.put("groupId", groupId);
|
||||
additionalProperties.put("artifactId", artifactId);
|
||||
additionalProperties.put("artifactVersion", artifactVersion);
|
||||
additionalProperties.put("asyncHttpClient", asyncHttpClient);
|
||||
additionalProperties.put("authScheme", authScheme);
|
||||
additionalProperties.put("authPreemptive", authPreemptive);
|
||||
|
||||
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||
supportingFiles.add(new SupportingFile("apiInvoker.mustache",
|
||||
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiInvoker.scala"));
|
||||
|
||||
importMapping.remove("List");
|
||||
importMapping.remove("Set");
|
||||
importMapping.remove("Map");
|
||||
|
||||
importMapping.put("DateTime", "org.joda.time.DateTime");
|
||||
importMapping.put("ListBuffer", "scala.collections.mutable.ListBuffer");
|
||||
|
||||
typeMapping = new HashMap<String, String>();
|
||||
typeMapping.put("enum", "NSString");
|
||||
typeMapping.put("array", "List");
|
||||
typeMapping.put("set", "Set");
|
||||
typeMapping.put("boolean", "Boolean");
|
||||
typeMapping.put("string", "String");
|
||||
typeMapping.put("int", "Int");
|
||||
typeMapping.put("long", "Long");
|
||||
typeMapping.put("float", "Float");
|
||||
typeMapping.put("byte", "Byte");
|
||||
typeMapping.put("short", "Short");
|
||||
typeMapping.put("char", "Char");
|
||||
typeMapping.put("long", "Long");
|
||||
typeMapping.put("double", "Double");
|
||||
typeMapping.put("object", "Any");
|
||||
typeMapping.put("file", "File");
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"String",
|
||||
"boolean",
|
||||
"Boolean",
|
||||
"Double",
|
||||
"Int",
|
||||
"Long",
|
||||
"Float",
|
||||
"Object",
|
||||
"List",
|
||||
"Map")
|
||||
);
|
||||
instantiationTypes.put("array", "ListBuffer");
|
||||
instantiationTypes.put("map", "HashMap");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
if(p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
Property inner = ap.getItems();
|
||||
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
else if (p instanceof MapProperty) {
|
||||
MapProperty mp = (MapProperty) p;
|
||||
Property inner = mp.getAdditionalProperties();
|
||||
|
||||
return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwaggerType(Property p) {
|
||||
String swaggerType = super.getSwaggerType(p);
|
||||
String type = null;
|
||||
if(typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if(languageSpecificPrimitives.contains(type))
|
||||
return toModelName(type);
|
||||
}
|
||||
else
|
||||
type = swaggerType;
|
||||
return toModelName(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toInstantiationType(Property p) {
|
||||
if (p instanceof MapProperty) {
|
||||
MapProperty ap = (MapProperty) p;
|
||||
String inner = getSwaggerType(ap.getAdditionalProperties());
|
||||
return instantiationTypes.get("map") + "[String, " + inner + "]";
|
||||
}
|
||||
else if (p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
String inner = getSwaggerType(ap.getItems());
|
||||
return instantiationTypes.get("array") + "[" + inner + "]";
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public String toDefaultValue(Property p) {
|
||||
if(p instanceof StringProperty)
|
||||
return "null";
|
||||
else if (p instanceof BooleanProperty)
|
||||
return "null";
|
||||
else if(p instanceof DateProperty)
|
||||
return "null";
|
||||
else if(p instanceof DateTimeProperty)
|
||||
return "null";
|
||||
else if (p instanceof DoubleProperty)
|
||||
return "null";
|
||||
else if (p instanceof FloatProperty)
|
||||
return "null";
|
||||
else if (p instanceof IntegerProperty)
|
||||
return "null";
|
||||
else if (p instanceof LongProperty)
|
||||
return "null";
|
||||
else if (p instanceof MapProperty) {
|
||||
MapProperty ap = (MapProperty) p;
|
||||
String inner = getSwaggerType(ap.getAdditionalProperties());
|
||||
return "new HashMap[String, " + inner + "]() ";
|
||||
}
|
||||
else if (p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
String inner = getSwaggerType(ap.getItems());
|
||||
return "new ListBuffer[" + inner + "]() ";
|
||||
}
|
||||
else
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
@@ -1,178 +0,0 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
import com.wordnik.swagger.util.Json;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
public class ScalatraServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String invokerPackage = "com.wordnik.client";
|
||||
protected String groupId = "com.wordnik";
|
||||
protected String artifactId = "swagger-client";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
protected String sourceFolder = "src/main/scala";
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.SERVER;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "scalatra";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates a Scala server application with Scalatra.";
|
||||
}
|
||||
|
||||
public ScalatraServerCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/scalatra";
|
||||
modelTemplateFiles.put("model.mustache", ".scala");
|
||||
apiTemplateFiles.put("api.mustache", ".scala");
|
||||
templateDir = "scalatra";
|
||||
apiPackage = "com.wordnik.client.api";
|
||||
modelPackage = "com.wordnik.client.model";
|
||||
|
||||
reservedWords = new HashSet<String> (
|
||||
Arrays.asList(
|
||||
"abstract", "continue", "for", "new", "switch", "assert",
|
||||
"default", "if", "package", "synchronized", "boolean", "do", "goto", "private",
|
||||
"this", "break", "double", "implements", "protected", "throw", "byte", "else",
|
||||
"import", "public", "throws", "case", "enum", "instanceof", "return", "transient",
|
||||
"catch", "extends", "int", "short", "try", "char", "final", "interface", "static",
|
||||
"void", "class", "finally", "long", "strictfp", "volatile", "const", "float",
|
||||
"native", "super", "while")
|
||||
);
|
||||
|
||||
defaultIncludes = new HashSet<String>(
|
||||
Arrays.asList("double",
|
||||
"Int",
|
||||
"Long",
|
||||
"Float",
|
||||
"Double",
|
||||
"char",
|
||||
"float",
|
||||
"String",
|
||||
"boolean",
|
||||
"Boolean",
|
||||
"Double",
|
||||
"Integer",
|
||||
"Long",
|
||||
"Float",
|
||||
"List",
|
||||
"Set",
|
||||
"Map")
|
||||
);
|
||||
|
||||
typeMapping.put("integer", "Int");
|
||||
typeMapping.put("long", "Long");
|
||||
|
||||
additionalProperties.put("appName", "Swagger Sample");
|
||||
additionalProperties.put("appName", "Swagger Sample");
|
||||
additionalProperties.put("appDescription", "A sample swagger server");
|
||||
additionalProperties.put("infoUrl", "http://developers.helloreverb.com");
|
||||
additionalProperties.put("infoEmail", "hello@helloreverb.com");
|
||||
additionalProperties.put("licenseInfo", "All rights reserved");
|
||||
additionalProperties.put("licenseUrl", "http://apache.org/licenses/LICENSE-2.0.html");
|
||||
additionalProperties.put("invokerPackage", invokerPackage);
|
||||
additionalProperties.put("groupId", groupId);
|
||||
additionalProperties.put("artifactId", artifactId);
|
||||
additionalProperties.put("artifactVersion", artifactVersion);
|
||||
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("build.sbt", "", "build.sbt"));
|
||||
supportingFiles.add(new SupportingFile("web.xml", "/src/main/webapp/WEB-INF", "web.xml"));
|
||||
supportingFiles.add(new SupportingFile("JettyMain.scala", sourceFolder, "JettyMain.scala"));
|
||||
supportingFiles.add(new SupportingFile("Bootstrap.mustache", sourceFolder, "ScalatraBootstrap.scala"));
|
||||
supportingFiles.add(new SupportingFile("ServletApp.mustache", sourceFolder, "ServletApp.scala"));
|
||||
supportingFiles.add(new SupportingFile("project/build.properties", "project", "build.properties"));
|
||||
supportingFiles.add(new SupportingFile("project/plugins.sbt", "project", "plugins.sbt"));
|
||||
supportingFiles.add(new SupportingFile("sbt", "", "sbt"));
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"String",
|
||||
"boolean",
|
||||
"Boolean",
|
||||
"Double",
|
||||
"Integer",
|
||||
"Long",
|
||||
"Float",
|
||||
"Object")
|
||||
);
|
||||
instantiationTypes.put("array", "ArrayList");
|
||||
instantiationTypes.put("map", "HashMap");
|
||||
|
||||
importMapping = new HashMap<String, String> ();
|
||||
importMapping.put("BigDecimal", "java.math.BigDecimal");
|
||||
importMapping.put("UUID", "java.util.UUID");
|
||||
importMapping.put("File", "java.io.File");
|
||||
importMapping.put("Date", "java.util.Date");
|
||||
importMapping.put("Timestamp", "java.sql.Timestamp");
|
||||
importMapping.put("Map", "java.util.Map");
|
||||
importMapping.put("HashMap", "java.util.HashMap");
|
||||
importMapping.put("Array", "java.util.List");
|
||||
importMapping.put("ArrayList", "java.util.ArrayList");
|
||||
importMapping.put("DateTime", "org.joda.time.DateTime");
|
||||
importMapping.put("LocalDateTime", "org.joda.time.LocalDateTime");
|
||||
importMapping.put("LocalDate", "org.joda.time.LocalDate");
|
||||
importMapping.put("LocalTime", "org.joda.time.LocalTime");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
for(CodegenOperation op: operationList) {
|
||||
op.httpMethod = op.httpMethod.toLowerCase();
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
if(p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
Property inner = ap.getItems();
|
||||
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
else if (p instanceof MapProperty) {
|
||||
MapProperty mp = (MapProperty) p;
|
||||
Property inner = mp.getAdditionalProperties();
|
||||
|
||||
return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwaggerType(Property p) {
|
||||
String swaggerType = super.getSwaggerType(p);
|
||||
String type = null;
|
||||
if(typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if(languageSpecificPrimitives.contains(type))
|
||||
return toModelName(type);
|
||||
}
|
||||
else
|
||||
type = swaggerType;
|
||||
return toModelName(type);
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
public class StaticDocCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String invokerPackage = "com.wordnik.client";
|
||||
protected String groupId = "com.wordnik";
|
||||
protected String artifactId = "swagger-client";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
protected String sourceFolder = "docs";
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.DOCUMENTATION;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "dynamic-html";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates a dynamic HTML site.";
|
||||
}
|
||||
|
||||
public StaticDocCodegen() {
|
||||
super();
|
||||
outputFolder = "docs";
|
||||
modelTemplateFiles.put("model.mustache", ".html");
|
||||
apiTemplateFiles.put("operation.mustache", ".html");
|
||||
templateDir = "swagger-static";
|
||||
|
||||
additionalProperties.put("invokerPackage", invokerPackage);
|
||||
additionalProperties.put("groupId", groupId);
|
||||
additionalProperties.put("artifactId", artifactId);
|
||||
additionalProperties.put("artifactVersion", artifactVersion);
|
||||
|
||||
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
|
||||
supportingFiles.add(new SupportingFile("main.mustache", "", "main.js"));
|
||||
supportingFiles.add(new SupportingFile("assets/css/bootstrap-responsive.css",
|
||||
outputFolder + "/assets/css", "bootstrap-responsive.css"));
|
||||
supportingFiles.add(new SupportingFile("assets/css/bootstrap.css",
|
||||
outputFolder + "/assets/css", "bootstrap.css"));
|
||||
supportingFiles.add(new SupportingFile("assets/css/style.css",
|
||||
outputFolder + "/assets/css", "style.css"));
|
||||
supportingFiles.add(new SupportingFile("assets/images/logo.png",
|
||||
outputFolder + "/assets/images", "logo.png"));
|
||||
supportingFiles.add(new SupportingFile("assets/js/bootstrap.js",
|
||||
outputFolder + "/assets/js", "bootstrap.js"));
|
||||
supportingFiles.add(new SupportingFile("assets/js/jquery-1.8.3.min.js",
|
||||
outputFolder + "/assets/js", "jquery-1.8.3.min.js"));
|
||||
supportingFiles.add(new SupportingFile("assets/js/main.js",
|
||||
outputFolder + "/assets/js", "main.js"));
|
||||
supportingFiles.add(new SupportingFile("index.mustache",
|
||||
outputFolder, "index.html"));
|
||||
|
||||
instantiationTypes.put("array", "ArrayList");
|
||||
instantiationTypes.put("map", "HashMap");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + File.separator + sourceFolder + File.separator + "operations";
|
||||
}
|
||||
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + File.separator + sourceFolder + File.separator + "models";
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
import com.wordnik.swagger.util.Json;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
public class StaticHtmlGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
protected String invokerPackage = "com.wordnik.client";
|
||||
protected String groupId = "com.wordnik";
|
||||
protected String artifactId = "swagger-client";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
protected String sourceFolder = "src/main/scala";
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.DOCUMENTATION;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "html";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates a static HTML file.";
|
||||
}
|
||||
|
||||
public StaticHtmlGenerator() {
|
||||
super();
|
||||
outputFolder = "docs";
|
||||
templateDir = "htmlDocs";
|
||||
|
||||
defaultIncludes = new HashSet<String>();
|
||||
|
||||
additionalProperties.put("appName", "Swagger Sample");
|
||||
additionalProperties.put("appDescription", "A sample swagger server");
|
||||
additionalProperties.put("infoUrl", "https://helloreverb.com");
|
||||
additionalProperties.put("infoEmail", "hello@helloreverb.com");
|
||||
additionalProperties.put("licenseInfo", "All rights reserved");
|
||||
additionalProperties.put("licenseUrl", "http://apache.org/licenses/LICENSE-2.0.html");
|
||||
additionalProperties.put("invokerPackage", invokerPackage);
|
||||
additionalProperties.put("groupId", groupId);
|
||||
additionalProperties.put("artifactId", artifactId);
|
||||
additionalProperties.put("artifactVersion", artifactVersion);
|
||||
|
||||
supportingFiles.add(new SupportingFile("index.mustache", "", "index.html"));
|
||||
reservedWords = new HashSet<String>();
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>();
|
||||
importMapping = new HashMap<String, String> ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
if(p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
Property inner = ap.getItems();
|
||||
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
else if (p instanceof MapProperty) {
|
||||
MapProperty mp = (MapProperty) p;
|
||||
Property inner = mp.getAdditionalProperties();
|
||||
|
||||
return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
for(CodegenOperation op: operationList) {
|
||||
op.httpMethod = op.httpMethod.toLowerCase();
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.util.*;
|
||||
import com.wordnik.swagger.models.Swagger;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class SwaggerGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.DOCUMENTATION;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "swagger";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Creates a static swagger.json file.";
|
||||
}
|
||||
|
||||
public SwaggerGenerator() {
|
||||
super();
|
||||
templateDir = "swagger";
|
||||
outputFolder = "generated-code/swagger";
|
||||
|
||||
supportingFiles.add(new SupportingFile("README.md", "", "README.md"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processSwagger(Swagger swagger) {
|
||||
String swaggerString = Json.pretty(swagger);
|
||||
|
||||
try{
|
||||
String outputFile = outputFolder + File.separator + "swagger.json";
|
||||
FileUtils.writeStringToFile(new File(outputFile), swaggerString);
|
||||
System.out.println("wrote file to " + outputFile);
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.util.*;
|
||||
import com.wordnik.swagger.models.Swagger;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class SwaggerYamlGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.DOCUMENTATION;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "swagger-yaml";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Creates a static swagger.yaml file.";
|
||||
}
|
||||
|
||||
public SwaggerYamlGenerator() {
|
||||
super();
|
||||
templateDir = "swagger";
|
||||
outputFolder = "generated-code/swagger";
|
||||
|
||||
supportingFiles.add(new SupportingFile("README.md", "", "README.md"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processSwagger(Swagger swagger) {
|
||||
try{
|
||||
String swaggerString = Yaml.mapper().writeValueAsString(swagger);
|
||||
String outputFile = outputFolder + File.separator + "swagger.yaml";
|
||||
FileUtils.writeStringToFile(new File(outputFile), swaggerString);
|
||||
System.out.println("wrote file to " + outputFile);
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,247 +0,0 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.util.Json;
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
public class TizenClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected Set<String> foundationClasses = new HashSet<String>();
|
||||
protected String sourceFolder = "client";
|
||||
protected static String PREFIX = "Sami";
|
||||
protected Map<String, String> namespaces = new HashMap<String, String>();
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "tizen";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates a Samsung Tizen C++ client library.";
|
||||
}
|
||||
|
||||
public TizenClientCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/tizen";
|
||||
modelTemplateFiles.put("model-header.mustache", ".h");
|
||||
modelTemplateFiles.put("model-body.mustache", ".cpp");
|
||||
apiTemplateFiles.put("api-header.mustache", ".h");
|
||||
apiTemplateFiles.put("api-body.mustache", ".cpp");
|
||||
templateDir = "tizen";
|
||||
modelPackage = "";
|
||||
|
||||
defaultIncludes = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"bool",
|
||||
"int",
|
||||
"long")
|
||||
);
|
||||
languageSpecificPrimitives = new HashSet<String>();
|
||||
|
||||
additionalProperties().put("prefix", PREFIX);
|
||||
|
||||
reservedWords = new HashSet<String>(
|
||||
// VERIFY
|
||||
Arrays.asList(
|
||||
"void", "char", "short", "int", "void", "char", "short", "int",
|
||||
"long", "float", "double", "signed", "unsigned", "id", "const",
|
||||
"volatile", "in", "out", "inout", "bycopy", "byref", "oneway",
|
||||
"self", "super"
|
||||
));
|
||||
|
||||
super.typeMapping = new HashMap<String, String>();
|
||||
|
||||
typeMapping.put("Date", "DateTime");
|
||||
typeMapping.put("DateTime", "DateTime");
|
||||
typeMapping.put("string", "String");
|
||||
typeMapping.put("integer", "Integer");
|
||||
typeMapping.put("float", "Float");
|
||||
typeMapping.put("long", "Long");
|
||||
typeMapping.put("boolean", "Boolean");
|
||||
typeMapping.put("double", "Double");
|
||||
typeMapping.put("array", "IList");
|
||||
typeMapping.put("map", "HashMap");
|
||||
typeMapping.put("number", "Long");
|
||||
typeMapping.put("object", PREFIX + "Object");
|
||||
|
||||
importMapping = new HashMap<String, String>();
|
||||
|
||||
namespaces = new HashMap<String, String> ();
|
||||
namespaces.put("DateTime", "Tizen::Base::DateTime");
|
||||
namespaces.put("Integer", "Tizen::Base::Integer");
|
||||
namespaces.put("Long", "Tizen::Base::Long");
|
||||
namespaces.put("Boolean", "Tizen::Base::Boolean");
|
||||
namespaces.put("Float", "Tizen::Base::Float");
|
||||
namespaces.put("String", "Tizen::Base::String");
|
||||
namespaces.put("Double", "Tizen::Base::Double");
|
||||
namespaces.put("IList", "Tizen::Base::Collection::IList");
|
||||
namespaces.put("HashMap", "Tizen::Base::Collection::HashMap");
|
||||
namespaces.put("ArrayList", "Tizen::Base::Collection::ArrayList");
|
||||
namespaces.put("JsonNumber", "Tizen::Web::Json");
|
||||
namespaces.put("JsonString", "Tizen::Web::Json");
|
||||
|
||||
foundationClasses = new HashSet<String> (
|
||||
Arrays.asList(
|
||||
"String",
|
||||
"Integer",
|
||||
"Float")
|
||||
);
|
||||
supportingFiles.clear();
|
||||
supportingFiles.add(new SupportingFile("modelFactory.mustache", sourceFolder, PREFIX + "ModelFactory.h"));
|
||||
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder, PREFIX + "Helpers.h"));
|
||||
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder, PREFIX + "Helpers.cpp"));
|
||||
supportingFiles.add(new SupportingFile("apiclient-header.mustache", sourceFolder, PREFIX + "ApiClient.h"));
|
||||
supportingFiles.add(new SupportingFile("apiclient-body.mustache", sourceFolder, PREFIX + "ApiClient.cpp"));
|
||||
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, PREFIX + "Object.h"));
|
||||
supportingFiles.add(new SupportingFile("error-header.mustache", sourceFolder, PREFIX + "Error.h"));
|
||||
supportingFiles.add(new SupportingFile("error-body.mustache", sourceFolder, PREFIX + "Error.cpp"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toInstantiationType(Property p) {
|
||||
if (p instanceof MapProperty) {
|
||||
MapProperty ap = (MapProperty) p;
|
||||
String inner = getSwaggerType(ap.getAdditionalProperties());
|
||||
return instantiationTypes.get("map");
|
||||
}
|
||||
else if (p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
String inner = getSwaggerType(ap.getItems());
|
||||
return instantiationTypes.get("array");
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(String name) {
|
||||
if(languageSpecificPrimitives.contains(name) && !foundationClasses.contains(name))
|
||||
return name;
|
||||
else
|
||||
return name + "*";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwaggerType(Property p) {
|
||||
String swaggerType = super.getSwaggerType(p);
|
||||
String type = null;
|
||||
if(typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if(languageSpecificPrimitives.contains(type) && !foundationClasses.contains(type))
|
||||
return toModelName(type);
|
||||
}
|
||||
else
|
||||
type = swaggerType;
|
||||
return toModelName(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
String swaggerType = getSwaggerType(p);
|
||||
if(languageSpecificPrimitives.contains(swaggerType) && !foundationClasses.contains(swaggerType))
|
||||
return toModelName(swaggerType);
|
||||
else
|
||||
return swaggerType + "*";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String type) {
|
||||
if(typeMapping.keySet().contains(type) ||
|
||||
typeMapping.values().contains(type) ||
|
||||
foundationClasses.contains(type) ||
|
||||
importMapping.values().contains(type) ||
|
||||
defaultIncludes.contains(type) ||
|
||||
languageSpecificPrimitives.contains(type)) {
|
||||
return type;
|
||||
}
|
||||
else {
|
||||
return PREFIX + Character.toUpperCase(type.charAt(0)) + type.substring(1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelImport(String name) {
|
||||
if(namespaces.containsKey(name)) {
|
||||
return "using " + namespaces.get(name) + ";";
|
||||
}
|
||||
return "#include \"" + name + ".h\"";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toDefaultValue(Property p) {
|
||||
if(p instanceof StringProperty)
|
||||
return "new String()";
|
||||
else if (p instanceof BooleanProperty)
|
||||
return "new Boolean(false)";
|
||||
else if(p instanceof DateProperty)
|
||||
return "new DateTime()";
|
||||
else if(p instanceof DateTimeProperty)
|
||||
return "new DateTime()";
|
||||
else if (p instanceof DoubleProperty)
|
||||
return "new Double()";
|
||||
else if (p instanceof FloatProperty)
|
||||
return "new Float()";
|
||||
else if (p instanceof IntegerProperty)
|
||||
return "new Integer()";
|
||||
else if (p instanceof LongProperty)
|
||||
return "new Long()";
|
||||
else if (p instanceof DecimalProperty)
|
||||
return "new Long()";
|
||||
else if (p instanceof MapProperty) {
|
||||
MapProperty ap = (MapProperty) p;
|
||||
String inner = getSwaggerType(ap.getAdditionalProperties());
|
||||
return "new HashMap()";
|
||||
}
|
||||
else if (p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
String inner = getSwaggerType(ap.getItems());
|
||||
return "new ArrayList()";
|
||||
}
|
||||
// else
|
||||
if(p instanceof RefProperty) {
|
||||
RefProperty rp = (RefProperty) p;
|
||||
return "new " + toModelName(rp.getSimpleRef()) + "()";
|
||||
}
|
||||
return "null";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + File.separator + sourceFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + File.separator + sourceFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
return PREFIX + initialCaps(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
return PREFIX + initialCaps(name) + "Api";
|
||||
}
|
||||
|
||||
public String toApiFilename(String name) {
|
||||
return PREFIX + initialCaps(name) + "Api";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
String paramName = name.replaceAll("[^a-zA-Z0-9_]","");
|
||||
paramName = Character.toUpperCase(paramName.charAt(0)) + paramName.substring(1);
|
||||
return "p" + paramName;
|
||||
}
|
||||
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name;
|
||||
}
|
||||
}
|
||||
34
modules/swagger-codegen/src/main/java/config/Config.java
Normal file
34
modules/swagger-codegen/src/main/java/config/Config.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package config;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Config {
|
||||
private Map<String, String> options;
|
||||
|
||||
public Config() {
|
||||
this.options = new HashMap<String, String>();
|
||||
}
|
||||
|
||||
public Config(Map<String, String> properties) {
|
||||
this.options = properties;
|
||||
}
|
||||
|
||||
public Map<String, String> getOptions() {
|
||||
return ImmutableMap.copyOf(options);
|
||||
}
|
||||
|
||||
public boolean hasOption(String opt) {
|
||||
return options.containsKey(opt);
|
||||
}
|
||||
|
||||
public String getOption(String opt) {
|
||||
return options.get(opt);
|
||||
}
|
||||
|
||||
public void setOption(String opt, String value) {
|
||||
options.put(opt, value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package config;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
public class ConfigParser {
|
||||
|
||||
public static Config read(String location) {
|
||||
|
||||
System.out.println("reading config from " + location);
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
Config config = new Config();
|
||||
|
||||
try {
|
||||
JsonNode rootNode = mapper.readTree(new File(location));
|
||||
Iterator<Map.Entry<String, JsonNode>> optionNodes = rootNode.fields();
|
||||
|
||||
while (optionNodes.hasNext()) {
|
||||
Map.Entry<String, JsonNode> optionNode = (Map.Entry<String, JsonNode>) optionNodes.next();
|
||||
|
||||
if (optionNode.getValue().isValueNode()) {
|
||||
config.setOption(optionNode.getKey(), optionNode.getValue().asText());
|
||||
} else {
|
||||
System.out.println("omitting non-value node " + optionNode.getKey());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package io.swagger.codegen;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public abstract class AbstractGenerator {
|
||||
|
||||
public File writeToFile(String filename, String contents) throws IOException {
|
||||
System.out.println("writing file " + filename);
|
||||
File output = new File(filename);
|
||||
|
||||
if (output.getParent() != null && !new File(output.getParent()).exists()) {
|
||||
File parent = new File(output.getParent());
|
||||
parent.mkdirs();
|
||||
}
|
||||
Writer out = new BufferedWriter(new OutputStreamWriter(
|
||||
new FileOutputStream(output), "UTF-8"));
|
||||
|
||||
out.write(contents);
|
||||
out.close();
|
||||
return output;
|
||||
}
|
||||
|
||||
public String readTemplate(String name) {
|
||||
try {
|
||||
Reader reader = getTemplateReader(name);
|
||||
if (reader == null) {
|
||||
throw new RuntimeException("no file found");
|
||||
}
|
||||
java.util.Scanner s = new java.util.Scanner(reader).useDelimiter("\\A");
|
||||
return s.hasNext() ? s.next() : "";
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
throw new RuntimeException("can't load template " + name);
|
||||
}
|
||||
|
||||
public Reader getTemplateReader(String name) {
|
||||
try {
|
||||
InputStream is = this.getClass().getClassLoader().getResourceAsStream(getCPResourcePath(name));
|
||||
if (is == null) {
|
||||
is = new FileInputStream(new File(name));
|
||||
}
|
||||
if (is == null) {
|
||||
throw new RuntimeException("no file found");
|
||||
}
|
||||
return new InputStreamReader(is);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
throw new RuntimeException("can't load template " + name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the template file path with template dir prepended, and use the
|
||||
* library template if exists.
|
||||
*/
|
||||
public String getFullTemplateFile(CodegenConfig config, String templateFile) {
|
||||
String library = config.getLibrary();
|
||||
if (library != null && !"".equals(library)) {
|
||||
String libTemplateFile = config.templateDir() + File.separator +
|
||||
"libraries" + File.separator + library + File.separator +
|
||||
templateFile;
|
||||
if (templateExists(libTemplateFile)) {
|
||||
return libTemplateFile;
|
||||
}
|
||||
}
|
||||
return config.templateDir() + File.separator + templateFile;
|
||||
}
|
||||
|
||||
public boolean templateExists(String name) {
|
||||
return this.getClass().getClassLoader().getResource(getCPResourcePath(name)) != null;
|
||||
}
|
||||
|
||||
public String getCPResourcePath(String name) {
|
||||
if (!"/".equals(File.separator)) {
|
||||
return name.replaceAll(Pattern.quote(File.separator), "/");
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package io.swagger.codegen;
|
||||
|
||||
public class CliOption {
|
||||
private final String opt;
|
||||
private String description;
|
||||
|
||||
public CliOption(String opt, String description) {
|
||||
this.opt = opt;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getOpt() {
|
||||
return opt;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package io.swagger.codegen;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.codegen.auth.AuthParser;
|
||||
import io.swagger.models.Swagger;
|
||||
import io.swagger.models.auth.AuthorizationValue;
|
||||
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||
|
||||
public class ClientOptInput {
|
||||
private CodegenConfig config;
|
||||
private ClientOpts opts;
|
||||
private Swagger swagger;
|
||||
private List<AuthorizationValue> auths;
|
||||
|
||||
public ClientOptInput swagger(Swagger swagger) {
|
||||
this.setSwagger(swagger);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ClientOptInput opts(ClientOpts opts) {
|
||||
this.setOpts(opts);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ClientOptInput config(CodegenConfig codegenConfig) {
|
||||
this.setConfig(codegenConfig);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ClientOptInput auth(String urlEncodedAuthString) {
|
||||
this.setAuth(urlEncodedAuthString);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getAuth() {
|
||||
return AuthParser.reconstruct(auths);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setAuth(String urlEncodedAuthString) {
|
||||
this.auths = AuthParser.parse(urlEncodedAuthString);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<AuthorizationValue> getAuthorizationValues() {
|
||||
return auths;
|
||||
}
|
||||
|
||||
public CodegenConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void setConfig(CodegenConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public ClientOpts getOpts() {
|
||||
return opts;
|
||||
}
|
||||
|
||||
public void setOpts(ClientOpts opts) {
|
||||
this.opts = opts;
|
||||
}
|
||||
|
||||
@ApiModelProperty(dataType = "Object")
|
||||
public Swagger getSwagger() {
|
||||
return swagger;
|
||||
}
|
||||
|
||||
public void setSwagger(Swagger swagger) {
|
||||
this.swagger = swagger;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package io.swagger.codegen;
|
||||
|
||||
import io.swagger.codegen.auth.AuthMethod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ClientOpts {
|
||||
protected String uri;
|
||||
protected String target;
|
||||
protected AuthMethod auth;
|
||||
protected Map<String, String> properties = new HashMap<String, String>();
|
||||
protected String outputDirectory;
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public String getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(String target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public Map<String, String> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(Map<String, String> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public String getOutputDirectory() {
|
||||
return outputDirectory;
|
||||
}
|
||||
|
||||
public void setOutputDirectory(String outputDirectory) {
|
||||
this.outputDirectory = outputDirectory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("ClientOpts: {\n");
|
||||
sb.append(" uri: ").append(uri).append(",");
|
||||
sb.append(" auth: ").append(auth).append(",");
|
||||
sb.append(properties);
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package io.swagger.codegen;
|
||||
|
||||
import config.Config;
|
||||
import config.ConfigParser;
|
||||
import io.swagger.models.Swagger;
|
||||
import io.swagger.parser.SwaggerParser;
|
||||
import org.apache.commons.cli.BasicParser;
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
* @deprecated use instead {@link io.swagger.codegen.DefaultGenerator}
|
||||
* or cli interface from https://github.com/swagger-api/swagger-codegen/pull/547
|
||||
*/
|
||||
@Deprecated
|
||||
public class Codegen extends DefaultGenerator {
|
||||
static Map<String, CodegenConfig> configs = new HashMap<String, CodegenConfig>();
|
||||
static String configString;
|
||||
static String debugInfoOptions = "\nThe following additional debug options are available for all codegen targets:" +
|
||||
"\n -DdebugSwagger prints the swagger specification as interpreted by the codegen" +
|
||||
"\n -DdebugModels prints models passed to the template engine" +
|
||||
"\n -DdebugOperations prints operations passed to the template engine" +
|
||||
"\n -DdebugSupportingFiles prints additional data passed to the template engine";
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
Options options = new Options();
|
||||
options.addOption("h", "help", false, "shows this message");
|
||||
options.addOption("l", "lang", true, "client language to generate.\nAvailable languages include:\n\t[" + configString + "]");
|
||||
options.addOption("o", "output", true, "where to write the generated files");
|
||||
options.addOption("i", "input-spec", true, "location of the swagger spec, as URL or file");
|
||||
options.addOption("t", "template-dir", true, "folder containing the template files");
|
||||
options.addOption("d", "debug-info", false, "prints additional info for debugging");
|
||||
options.addOption("a", "auth", true, "adds authorization headers when fetching the swagger definitions remotely. Pass in a URL-encoded string of name:header with a comma separating multiple values");
|
||||
options.addOption("c", "config", true, "location of the configuration file");
|
||||
|
||||
ClientOptInput clientOptInput = new ClientOptInput();
|
||||
ClientOpts clientOpts = new ClientOpts();
|
||||
Swagger swagger = null;
|
||||
|
||||
CommandLine cmd = null;
|
||||
try {
|
||||
CommandLineParser parser = new BasicParser();
|
||||
CodegenConfig config = null;
|
||||
|
||||
cmd = parser.parse(options, args);
|
||||
if (cmd.hasOption("d")) {
|
||||
usage(options);
|
||||
System.out.println(debugInfoOptions);
|
||||
return;
|
||||
}
|
||||
if (cmd.hasOption("a")) {
|
||||
clientOptInput.setAuth(cmd.getOptionValue("a"));
|
||||
}
|
||||
if (cmd.hasOption("l")) {
|
||||
clientOptInput.setConfig(getConfig(cmd.getOptionValue("l")));
|
||||
} else {
|
||||
usage(options);
|
||||
return;
|
||||
}
|
||||
if (cmd.hasOption("o")) {
|
||||
clientOptInput.getConfig().setOutputDir(cmd.getOptionValue("o"));
|
||||
}
|
||||
if (cmd.hasOption("h")) {
|
||||
if (cmd.hasOption("l")) {
|
||||
config = getConfig(String.valueOf(cmd.getOptionValue("l")));
|
||||
if (config != null) {
|
||||
options.addOption("h", "help", true, config.getHelp());
|
||||
usage(options);
|
||||
return;
|
||||
}
|
||||
}
|
||||
usage(options);
|
||||
return;
|
||||
}
|
||||
if (cmd.hasOption("i")) {
|
||||
swagger = new SwaggerParser().read(cmd.getOptionValue("i"), clientOptInput.getAuthorizationValues(), true);
|
||||
}
|
||||
if (cmd.hasOption("c")) {
|
||||
String configFile = cmd.getOptionValue("c");
|
||||
Config genConfig = ConfigParser.read(configFile);
|
||||
config = clientOptInput.getConfig();
|
||||
if (null != genConfig && null != config) {
|
||||
for (CliOption langCliOption : config.cliOptions()) {
|
||||
if (genConfig.hasOption(langCliOption.getOpt())) {
|
||||
config.additionalProperties().put(langCliOption.getOpt(), genConfig.getOption(langCliOption.getOpt()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cmd.hasOption("t")) {
|
||||
clientOpts.getProperties().put(CodegenConstants.TEMPLATE_DIR, String.valueOf(cmd.getOptionValue("t")));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
usage(options);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
clientOptInput
|
||||
.opts(clientOpts)
|
||||
.swagger(swagger);
|
||||
new Codegen().opts(clientOptInput).generate();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<CodegenConfig> getExtensions() {
|
||||
ServiceLoader<CodegenConfig> loader = ServiceLoader.load(CodegenConfig.class);
|
||||
List<CodegenConfig> output = new ArrayList<CodegenConfig>();
|
||||
Iterator<CodegenConfig> itr = loader.iterator();
|
||||
while (itr.hasNext()) {
|
||||
output.add(itr.next());
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
static void usage(Options options) {
|
||||
HelpFormatter formatter = new HelpFormatter();
|
||||
formatter.printHelp("Codegen", options);
|
||||
}
|
||||
|
||||
public static CodegenConfig getConfig(String name) {
|
||||
if (configs.containsKey(name)) {
|
||||
return configs.get(name);
|
||||
} else {
|
||||
// see if it's a class
|
||||
try {
|
||||
System.out.println("loading class " + name);
|
||||
Class customClass = Class.forName(name);
|
||||
System.out.println("loaded");
|
||||
return (CodegenConfig) customClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("can't load class " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
List<CodegenConfig> extensions = getExtensions();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (CodegenConfig config : extensions) {
|
||||
if (sb.toString().length() != 0) {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(config.getName());
|
||||
configs.put(config.getName(), config);
|
||||
configString = sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package io.swagger.codegen;
|
||||
|
||||
import io.swagger.models.Model;
|
||||
import io.swagger.models.Operation;
|
||||
import io.swagger.models.Swagger;
|
||||
import io.swagger.models.auth.SecuritySchemeDefinition;
|
||||
import io.swagger.models.properties.Property;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public interface CodegenConfig {
|
||||
CodegenType getTag();
|
||||
|
||||
String getName();
|
||||
|
||||
String getHelp();
|
||||
|
||||
Map<String, Object> additionalProperties();
|
||||
|
||||
String apiPackage();
|
||||
|
||||
String apiFileFolder();
|
||||
|
||||
String fileSuffix();
|
||||
|
||||
String outputFolder();
|
||||
|
||||
String templateDir();
|
||||
|
||||
String modelFileFolder();
|
||||
|
||||
String modelPackage();
|
||||
|
||||
String toApiName(String name);
|
||||
|
||||
String toApiVarName(String name);
|
||||
|
||||
String toModelName(String name);
|
||||
|
||||
String toParamName(String name);
|
||||
|
||||
String escapeText(String text);
|
||||
|
||||
String escapeReservedWord(String name);
|
||||
|
||||
String getTypeDeclaration(Property p);
|
||||
|
||||
String getTypeDeclaration(String name);
|
||||
|
||||
void processOpts();
|
||||
|
||||
List<CliOption> cliOptions();
|
||||
|
||||
String generateExamplePath(String path, Operation operation);
|
||||
|
||||
Set<String> reservedWords();
|
||||
|
||||
List<SupportingFile> supportingFiles();
|
||||
|
||||
String getOutputDir();
|
||||
|
||||
void setOutputDir(String dir);
|
||||
|
||||
CodegenModel fromModel(String name, Model model);
|
||||
|
||||
CodegenModel fromModel(String name, Model model, Map<String, Model> allDefinitions);
|
||||
|
||||
CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, Map<String, Model> definitions, Swagger swagger);
|
||||
|
||||
CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, Map<String, Model> definitions);
|
||||
|
||||
List<CodegenSecurity> fromSecurity(Map<String, SecuritySchemeDefinition> schemes);
|
||||
|
||||
Set<String> defaultIncludes();
|
||||
|
||||
Map<String, String> typeMapping();
|
||||
|
||||
Map<String, String> instantiationTypes();
|
||||
|
||||
Map<String, String> importMapping();
|
||||
|
||||
Map<String, String> apiTemplateFiles();
|
||||
|
||||
Map<String, String> modelTemplateFiles();
|
||||
|
||||
Set<String> languageSpecificPrimitives();
|
||||
|
||||
void preprocessSwagger(Swagger swagger);
|
||||
|
||||
void processSwagger(Swagger swagger);
|
||||
|
||||
String toApiFilename(String name);
|
||||
|
||||
String toModelFilename(String name);
|
||||
|
||||
String toModelImport(String name);
|
||||
|
||||
String toApiImport(String name);
|
||||
|
||||
void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations);
|
||||
|
||||
Map<String, Object> postProcessModels(Map<String, Object> objs);
|
||||
|
||||
Map<String, Object> postProcessOperations(Map<String, Object> objs);
|
||||
|
||||
Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs);
|
||||
|
||||
String apiFilename(String templateName, String tag);
|
||||
|
||||
boolean shouldOverwrite(String filename);
|
||||
|
||||
boolean isSkipOverwrite();
|
||||
|
||||
void setSkipOverwrite(boolean skipOverwrite);
|
||||
|
||||
Map<String, String> supportedLibraries();
|
||||
|
||||
void setLibrary(String library);
|
||||
|
||||
/**
|
||||
* Library template (sub-template).
|
||||
*/
|
||||
String getLibrary();
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package io.swagger.codegen;
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import static java.util.ServiceLoader.load;
|
||||
|
||||
public class CodegenConfigLoader {
|
||||
/**
|
||||
* Tries to load config class with SPI first, then with class name directly from classpath
|
||||
*
|
||||
* @param name name of config, or full qualified class name in classpath
|
||||
* @return config class
|
||||
*/
|
||||
public static CodegenConfig forName(String name) {
|
||||
ServiceLoader<CodegenConfig> loader = load(CodegenConfig.class);
|
||||
|
||||
StringBuilder availableConfigs = new StringBuilder();
|
||||
|
||||
for (CodegenConfig config : loader) {
|
||||
if (config.getName().equals(name)) {
|
||||
return config;
|
||||
}
|
||||
|
||||
availableConfigs.append(config.getName()).append("\n");
|
||||
}
|
||||
|
||||
// else try to load directly
|
||||
try {
|
||||
return (CodegenConfig) Class.forName(name).newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Can't load config class with name ".concat(name) + " Available: " + availableConfigs.toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package io.swagger.codegen;
|
||||
|
||||
/**
|
||||
* A class for storing constants that are used throughout the project.
|
||||
*/
|
||||
public class CodegenConstants {
|
||||
public static final String API_PACKAGE = "apiPackage";
|
||||
public static final String API_PACKAGE_DESC = "package for generated api classes";
|
||||
|
||||
public static final String MODEL_PACKAGE = "modelPackage";
|
||||
public static final String MODEL_PACKAGE_DESC = "package for generated models";
|
||||
|
||||
public static final String TEMPLATE_DIR = "templateDir";
|
||||
|
||||
|
||||
public static final String INVOKER_PACKAGE = "invokerPackage";
|
||||
public static final String INVOKER_PACKAGE_DESC = "root package for generated code";
|
||||
|
||||
public static final String GROUP_ID = "groupId";
|
||||
public static final String GROUP_ID_DESC = "groupId in generated pom.xml";
|
||||
|
||||
public static final String ARTIFACT_ID = "artifactId";
|
||||
public static final String ARTIFACT_ID_DESC = "artifactId in generated pom.xml";
|
||||
|
||||
public static final String ARTIFACT_VERSION = "artifactVersion";
|
||||
public static final String ARTIFACT_VERSION_DESC = "artifact version in generated pom.xml";
|
||||
|
||||
public static final String SOURCE_FOLDER = "sourceFolder";
|
||||
public static final String SOURCE_FOLDER_DESC = "source folder for generated code";
|
||||
|
||||
public static final String LOCAL_VARIABLE_PREFIX = "localVariablePrefix";
|
||||
public static final String LOCAL_VARIABLE_PREFIX_DESC = "prefix for generated code members and local variables";
|
||||
|
||||
public static final String SERIALIZABLE_MODEL = "serializableModel";
|
||||
public static final String SERIALIZABLE_MODEL_DESC = "boolean - toggle \"implements Serializable\" for generated models";
|
||||
|
||||
public static final String LIBRARY = "library";
|
||||
public static final String LIBRARY_DESC = "library template (sub-template)";
|
||||
|
||||
public static final String SORT_PARAMS_BY_REQUIRED_FLAG = "sortParamsByRequiredFlag";
|
||||
public static final String SORT_PARAMS_BY_REQUIRED_FLAG_DESC = "Sort method arguments to place required parameters before optional parameters. Default: true";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package io.swagger.codegen;
|
||||
|
||||
import io.swagger.models.ExternalDocs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class CodegenModel {
|
||||
public String parent;
|
||||
public String name, classname, description, classVarName, modelJson;
|
||||
public String unescapedDescription;
|
||||
public String defaultValue;
|
||||
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>();
|
||||
public Set<String> imports = new HashSet<String>();
|
||||
public Boolean hasVars, emptyVars, hasMoreModels, hasEnums;
|
||||
public ExternalDocs externalDocs;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package io.swagger.codegen;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class CodegenModelFactory {
|
||||
|
||||
private static final Map<CodegenModelType, Class<?>> typeMapping = new HashMap<CodegenModelType, Class<?>>();
|
||||
|
||||
/**
|
||||
* Configure a different implementation class.
|
||||
*
|
||||
* @param type the type that shall be replaced
|
||||
* @param implementation the implementation class must extend the default class and must provide a public no-arg constructor
|
||||
*/
|
||||
public static void setTypeMapping(CodegenModelType type, Class<?> implementation) {
|
||||
if (!type.getDefaultImplementation().isAssignableFrom(implementation)) {
|
||||
throw new IllegalArgumentException(implementation.getSimpleName() + " doesn't extend " + type.getDefaultImplementation().getSimpleName());
|
||||
}
|
||||
try {
|
||||
implementation.newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
typeMapping.put(type, implementation);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T newInstance(CodegenModelType type) {
|
||||
Class<?> classType = typeMapping.get(type);
|
||||
try {
|
||||
return (T) (classType != null ? classType : type.getDefaultImplementation()).newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package io.swagger.codegen;
|
||||
|
||||
public enum CodegenModelType {
|
||||
|
||||
MODEL(CodegenModel.class),
|
||||
OPERATION(CodegenOperation.class),
|
||||
PARAMETER(CodegenParameter.class),
|
||||
PROPERTY(CodegenProperty.class),
|
||||
RESPONSE(CodegenResponse.class),
|
||||
SECURITY(CodegenSecurity.class);
|
||||
|
||||
private final Class<?> defaultImplementation;
|
||||
|
||||
private CodegenModelType(Class<?> defaultImplementation) {
|
||||
this.defaultImplementation = defaultImplementation;
|
||||
}
|
||||
|
||||
public Class<?> getDefaultImplementation() {
|
||||
return defaultImplementation;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package io.swagger.codegen;
|
||||
|
||||
import io.swagger.models.ExternalDocs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class CodegenOperation {
|
||||
public final List<CodegenProperty> responseHeaders = new ArrayList<CodegenProperty>();
|
||||
public Boolean hasAuthMethods, hasConsumes, hasProduces, hasParams, returnTypeIsPrimitive,
|
||||
returnSimpleType, subresourceOperation, isMapContainer, isListContainer,
|
||||
hasMore = Boolean.TRUE, isMultipart, isResponseBinary = Boolean.FALSE;
|
||||
public String path, operationId, returnType, httpMethod, returnBaseType,
|
||||
returnContainer, summary, notes, baseName, defaultResponse;
|
||||
public List<Map<String, String>> consumes, produces;
|
||||
public CodegenParameter bodyParam;
|
||||
public List<CodegenParameter> allParams = new ArrayList<CodegenParameter>();
|
||||
public List<CodegenParameter> bodyParams = new ArrayList<CodegenParameter>();
|
||||
public List<CodegenParameter> pathParams = new ArrayList<CodegenParameter>();
|
||||
public List<CodegenParameter> queryParams = new ArrayList<CodegenParameter>();
|
||||
public List<CodegenParameter> headerParams = new ArrayList<CodegenParameter>();
|
||||
public List<CodegenParameter> formParams = new ArrayList<CodegenParameter>();
|
||||
public List<CodegenSecurity> authMethods;
|
||||
public List<String> tags;
|
||||
public List<CodegenResponse> responses = new ArrayList<CodegenResponse>();
|
||||
public Set<String> imports = new HashSet<String>();
|
||||
public List<Map<String, String>> examples;
|
||||
public ExternalDocs externalDocs;
|
||||
public Map<String, Object> vendorExtensions;
|
||||
public String nickname; // legacy support
|
||||
|
||||
/**
|
||||
* Check if there's at least one parameter
|
||||
*
|
||||
* @return true if parameter exists, false otherwise
|
||||
*/
|
||||
private boolean nonempty(List<CodegenParameter> params) {
|
||||
return params != null && params.size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there's at least one body parameter
|
||||
*
|
||||
* @return true if body parameter exists, false otherwise
|
||||
*/
|
||||
public boolean getHasBodyParam() {
|
||||
return nonempty(bodyParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there's at least one query parameter
|
||||
*
|
||||
* @return true if query parameter exists, false otherwise
|
||||
*/
|
||||
public boolean getHasQueryParams() {
|
||||
return nonempty(queryParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there's at least one header parameter
|
||||
*
|
||||
* @return true if header parameter exists, false otherwise
|
||||
*/
|
||||
public boolean getHasHeaderParams() {
|
||||
return nonempty(headerParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there's at least one path parameter
|
||||
*
|
||||
* @return true if path parameter exists, false otherwise
|
||||
*/
|
||||
public boolean getHasPathParams() {
|
||||
return nonempty(pathParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there's at least one form parameter
|
||||
*
|
||||
* @return true if any form parameter exists, false otherwise
|
||||
*/
|
||||
public boolean getHasFormParams() {
|
||||
return nonempty(formParams);
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user