Compare commits

...

977 Commits

Author SHA1 Message Date
Tony Tam
c1d51266b3 fixed version 2015-04-08 04:51:54 -06:00
Tony Tam
b85c8bbe7f rebuilt client 2015-04-06 08:08:36 -06:00
Tony Tam
e8ae9178af merged 2015-04-06 08:02:37 -06:00
Tony Tam
12d4e812a6 removed samples 2015-04-06 08:02:02 -06:00
Tony Tam
07030e1f42 Merge branch 'develop_2.0' 2015-04-06 08:01:24 -06:00
Tony Tam
c04f947a85 prepare for release 2015-04-06 08:00:16 -06:00
Tony Tam
d55aaffc48 Merge pull request #597 from wing328/php_package
Updated PHP codegen to support packaging via Composer
2015-04-06 07:44:00 -06:00
Tony Tam
b9514a40de Merge pull request #585 from wing328/ruby_fix_path_variable
Fixed Ruby path variable url-encoded twice, removed duplicated path variable replacement
2015-04-06 07:42:58 -06:00
William Cheng
ed43a38db2 Merge branch 'ruby_fix_path_variable' of https://github.com/wing328/swagger-codegen into ruby_fix_path_variable 2015-04-06 19:06:50 +08:00
William Cheng
2967cc3801 moved store spec into a separate file, update order id to 5 (as the
order with ID 2 is no longer found)
2015-04-06 19:05:19 +08:00
William Cheng
9c5153e8c8 fix test cases 2015-04-06 18:52:30 +08:00
William Cheng
0a4fc6a40f update ruby petstore sample 2015-04-06 18:52:30 +08:00
William Cheng
a717aba826 fixed path variable double uri-encoded issue 2015-04-06 18:52:30 +08:00
wing328
5c335beb60 removed description testing for Category 2015-04-06 18:28:43 +08:00
wing328
8d6d1cb329 recovered APIclient due to merge 2015-04-06 18:10:43 +08:00
wing328
6b2035e353 Merge branch 'php_package' of https://github.com/wing328/swagger-codegen into php_package
Conflicts:
	modules/swagger-codegen/src/main/resources/php/APIClient.mustache
	samples/client/petstore/php/SwaggerPetstore-php/lib/APIClient.php
	samples/client/petstore/php/SwaggerPetstore-php/lib/PetApi.php
	samples/client/petstore/php/SwaggerPetstore-php/lib/StoreApi.php
	samples/client/petstore/php/SwaggerPetstore-php/lib/UserApi.php
	samples/client/petstore/php/SwaggerPetstore-php/lib/models/Category.php
	samples/client/petstore/php/SwaggerPetstore-php/lib/models/Order.php
	samples/client/petstore/php/SwaggerPetstore-php/lib/models/Pet.php
	samples/client/petstore/php/SwaggerPetstore-php/lib/models/Tag.php
	samples/client/petstore/php/SwaggerPetstore-php/lib/models/User.php
2015-04-06 18:05:10 +08:00
wing328
3811a5a209 resolve conflict during rebase 2015-04-06 18:03:15 +08:00
wing328
c1046cc87b add php packaging support 2015-04-06 17:59:42 +08:00
Tony Tam
2bb42a1147 updated version 2015-04-05 16:12:04 -07:00
Tony Tam
1b4367ffba updated readme 2015-04-05 13:50:49 -07:00
Tony Tam
b4df8477d8 updated parser version 2015-04-05 13:48:48 -07:00
Tony Tam
27c7e69fba updated templates 2015-04-05 13:42:20 -07:00
Tony Tam
5a5bb6edbf Merge branch 'geekerzp-develop_2.0_objc_form_params' into develop_2.0 2015-04-04 22:12:41 -07:00
Tony Tam
448462552f updated logic, merged 2015-04-04 22:12:30 -07:00
Tony Tam
14cbc2d90d Merge branch 'develop_2.0_objc_form_params' of https://github.com/geekerzp/swagger-codegen into geekerzp-develop_2.0_objc_form_params 2015-04-04 21:34:26 -07:00
Tony Tam
dfa2c22e0c Merge pull request #566 from geoand/Apache_HttpClient_Connection_Manager
Switched SingleClientConnManager with ThreadSafeClientConnManager.
2015-04-04 21:33:38 -07:00
Tony Tam
a57588caa1 Merge pull request #588 from wing328/csharp_response_warning
Eliminated warning related to response in CSharp API files
2015-04-04 21:00:31 -07:00
Tony Tam
fad7246e05 removed file 2015-04-04 20:59:57 -07:00
Tony Tam
a0c9296ee8 name rebuilds, tests 2015-04-04 20:04:10 -07:00
Tony Tam
0c2e464c71 updated jetty version 2015-04-04 17:49:36 -07:00
Tony Tam
15236ef376 updated ruby template 2015-04-04 17:45:22 -07:00
Tony Tam
950bfff1c1 fixed serialization of arrays 2015-04-04 17:20:18 -07:00
Tony Tam
bba91c7e92 added android tests 2015-04-04 17:20:04 -07:00
Tony Tam
33c87e8e72 added sample 2015-04-04 17:02:16 -07:00
Tony Tam
ba2ccf788c name rebuilds, tests 2015-04-04 17:00:22 -07:00
Tony Tam
e114875f02 updated test 2015-04-04 16:58:28 -07:00
Tony Tam
09346c761b added script 2015-04-04 16:28:53 -07:00
Tony Tam
f0e41bf43e template updates 2015-04-04 16:28:43 -07:00
Tony Tam
9c75304832 updated to overwrite files 2015-04-04 16:28:33 -07:00
Tony Tam
02fd96a24a added spring-mvc sample 2015-04-04 13:46:35 -07:00
Tony Tam
568ca26747 renamed folder 2015-04-04 11:53:02 -07:00
Tony Tam
1e82fc5d24 removed old code 2015-04-04 11:49:40 -07:00
Tony Tam
d9f8fcb7a4 fixes for #501 2015-04-04 00:02:34 -07:00
Tony Tam
17ca7c4648 ahhhh scala 2015-04-03 23:18:03 -07:00
Tony Tam
acf2c8cc9d removed printlns 2015-04-03 23:12:50 -07:00
Tony Tam
43c88f51c6 fixed #497 2015-04-03 23:04:18 -07:00
Tony Tam
60e5899dc3 updated codegen 2015-04-03 23:02:38 -07:00
Tony Tam
f75312105d added property file 2015-04-03 22:41:00 -07:00
Tony Tam
610143f4ad fix for #577, added newline replacement 2015-04-03 22:22:31 -07:00
Tony Tam
2cc9b10a1e Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-04-03 22:15:10 -07:00
Tony Tam
f3ab28b92d fix for #589, escape text for parameter description 2015-04-03 22:15:00 -07:00
wing328
660d336646 fix warning related to csharp response, better code format for csharp api 2015-04-03 23:10:10 +08:00
Tony Tam
15c25c8277 Merge pull request #587 from geekerzp/develop_2.0_python_user_agent
Fixed user agent in python client
2015-04-03 07:34:19 -07:00
geekerzp
b4d4fa1a43 Update python sample code. 2015-04-03 18:21:33 +08:00
geekerzp
d4ac668cd4 Set default User-Agent for Python client. 2015-04-03 18:04:05 +08:00
Tony Tam
38e34e0dd6 Merge pull request #584 from wing328/ruby_fix_accept
Fixed Ruby header: "Accept", "Content-Type"
2015-04-02 21:56:44 -07:00
Tony Tam
9159892965 updated templates 2015-04-02 18:32:16 -07:00
Tony Tam
eda1a44fa3 updated parser 2015-04-02 18:30:00 -07:00
William Cheng
40d512fe43 fix test cases 2015-04-02 21:37:54 +08:00
William Cheng
e73957e790 update ruby petstore sample 2015-04-02 21:12:01 +08:00
William Cheng
b773d40034 fixed path variable double uri-encoded issue 2015-04-02 16:15:08 +08:00
Tony Tam
b6be19b266 Merge pull request #582 from guptasu/develop_2.0
Fixed the compile time error in the generated code caused due to unescaped new line characters.
2015-04-01 20:58:01 -07:00
William Cheng
1c0cb7f884 fix syntax 2015-04-02 06:12:07 +08:00
William Cheng
bc24e5e290 update ruby accept header 2015-04-02 05:23:53 +08:00
Sunny Gupta
80259fbcc4 Fixed the compile time error in the generated code caused due to unescaped new line characters.
Since the description text is not being escaped, if there is a new line character, it will cause a new line to be added to the source code. This can cause compile time error if the new line character is part of a string (e.g. java string) and there is no '+' sign explicitly added to the code. Note: The code was doing escapeText for properties but not for models. This patch fixes that.
2015-04-01 12:33:44 -07:00
Tony Tam
64292cdc9b Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-04-01 07:41:54 -07:00
Tony Tam
df771b5a4d updated springfox templates 2015-04-01 07:41:45 -07:00
Tony Tam
8b8e8d70f9 Merge pull request #580 from wing328/php_content_type
Fix content-type and accept in PHP API
2015-04-01 07:29:57 -07:00
William Cheng
27dfa12335 remove csharp model files (lower case) 2015-04-01 17:43:36 +08:00
Tony Tam
13ee40a4b8 added test script 2015-03-31 21:48:12 -07:00
Tony Tam
df9efe5734 added script 2015-03-31 21:48:04 -07:00
Tony Tam
f142474a54 updated templates 2015-03-31 21:47:30 -07:00
Tony Tam
084d448fd4 Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-03-31 21:00:34 -07:00
Tony Tam
1385a157e9 moved count 2015-03-31 21:00:15 -07:00
Tony Tam
fe3c3cc8bc fix for #578 2015-03-31 20:59:57 -07:00
Tony Tam
97e44679d3 Merge pull request #579 from xhh/fix-android-datetime-pattern
Fix date time format for Android client
2015-03-31 20:12:59 -07:00
xhh
d5ad4c4ae7 Fix date time format for Android client
According to Android's docs (https://developer.android.com/reference/java/text/SimpleDateFormat.html)
the `SimpleDateFormat` class in Android does not accept `XXX` as the timezone, it uses `Z` instead.

Also updated the date time format of Android and Java clients to include milliseconds.
2015-04-01 10:22:04 +08:00
Tony Tam
6ac497d774 rebuilt 2015-03-31 16:12:42 -07:00
Tony Tam
cd2c8f6527 Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-03-31 16:08:53 -07:00
Tony Tam
d4b9a41786 added ruby 2015-03-31 16:08:47 -07:00
Tony Tam
93fef67c7e added required check 2015-03-31 16:08:37 -07:00
Tony Tam
f72e5907bb formatting 2015-03-31 16:08:09 -07:00
Tony Tam
01c956caba cleanup 2015-03-31 16:07:56 -07:00
Tony Tam
5f07fb0b03 sorted 2015-03-31 16:07:37 -07:00
Tony Tam
f17968d5b3 fixed required flag 2015-03-31 16:07:24 -07:00
Tony Tam
055c4397e9 renamed 2015-03-31 16:07:07 -07:00
Tony Tam
62a99115fc renamed 2015-03-31 16:06:52 -07:00
Tony Tam
7483a06226 renamed 2015-03-31 16:06:46 -07:00
Tony Tam
f265ce361a Merge pull request #556 from FindTheBest/develop_2.0
Python Binding Request Headers
2015-03-31 15:58:34 -07:00
Tony Tam
744952aee4 formatting 2015-03-31 15:57:50 -07:00
Tony Tam
66591f567c Merge pull request #576 from wing328/ruby_petstore_test
Fix Ruby rspec
2015-03-31 15:47:54 -07:00
William Cheng
03c48af9e6 Fix content-type and accept in PHP API 2015-04-01 04:26:32 +08:00
Tony Tam
3096c6c3ce updated versions 2015-03-31 08:47:35 -07:00
William Cheng
cb2f1e1bb1 update test case for StoreApi.getOrderById (id: 1 => 2) 2015-03-31 14:37:59 +08:00
William Cheng
59140bd3f3 remove commented unused code from response spec 2015-03-31 14:17:58 +08:00
James Ebentier
ce700b9421 Fixing one more issue with the defaultHeaders merging and removing unnecessary code 2015-03-30 12:47:56 -07:00
James Ebentier
761ab22f08 Adding Self to setDefaultHeader method signature 2015-03-30 12:28:17 -07:00
William Cheng
0ee39c67fe fix rspec, update ruby client default configuration 2015-03-31 01:28:33 +08:00
James Ebentier
148b2daaa3 Python Formatting: removing semicolons from the python code 2015-03-30 08:42:12 -07:00
geekerzp
a927d679f0 fixed issue that it throw exceptions when request with form parameters
in objective-c client
2015-03-30 17:42:47 +08:00
Tony Tam
a4ce6d7074 updated scripts 2015-03-29 20:55:26 -07:00
Tony Tam
3739d2876e removed file 2015-03-29 20:50:23 -07:00
Tony Tam
0c50d9807e added jaxrs 2015-03-29 20:50:10 -07:00
Tony Tam
5e83b6602e updated templates for baseName 2015-03-29 20:49:51 -07:00
Tony Tam
5ab425e82d rebuilt 2015-03-29 20:42:20 -07:00
Tony Tam
b5be12a25b Merge branch 'wing328-add_csharp_codegen' into develop_2.0 2015-03-29 20:03:25 -07:00
Tony Tam
367f81d52d Merge branch 'add_csharp_codegen' of https://github.com/wing328/swagger-codegen into wing328-add_csharp_codegen 2015-03-29 20:03:16 -07:00
Tony Tam
b10445f3f6 Merge pull request #561 from wing328/ruby_doc
Update ruby api files with better documentation
2015-03-29 19:58:21 -07:00
Tony Tam
1e7862a466 Merge pull request #574 from geekerzp/develop_2.0_python_urlencode
Fixed issue that query parameters double url encoded in python client
2015-03-29 19:56:02 -07:00
Tony Tam
943efce971 rebuilt 2015-03-29 19:43:29 -07:00
Tony Tam
e7675e48ed updated snapshot 2015-03-29 19:42:12 -07:00
Tony Tam
63efc4f442 removed println 2015-03-29 19:41:58 -07:00
Tony Tam
a5c92be360 updated sample 2015-03-29 19:41:37 -07:00
Tony Tam
8de8f48679 fix for Optional 2015-03-29 19:41:24 -07:00
Tony Tam
63fae85ff4 updated sample 2015-03-29 19:40:54 -07:00
geekerzp
8f6afda99a fixed issue that query parameters double url encoded 2015-03-30 10:34:01 +08:00
Tony Tam
510254e5a3 fixed required flag 2015-03-29 19:17:54 -07:00
wing328
9981daad61 add back php petstore samples 2015-03-30 09:39:37 +08:00
wing328
c1824b5387 fix parameter name in API, update petstore sample 2015-03-30 09:31:49 +08:00
Tony Tam
517c0a4f52 Merge pull request #558 from geekerzp/develop_2.0_objc_jsonmodel
Add JSONModel to objective-c client
2015-03-29 08:53:14 -07:00
Tony Tam
cab50ccb59 Merge pull request #548 from xhh/java-android-user-agent
Set default User-Agent for Java and Android clients
2015-03-29 08:52:56 -07:00
Tony Tam
e51f548807 Merge pull request #559 from wing328/java_doc
Update Java documentation for methods (endpoints)
2015-03-29 08:52:32 -07:00
Tony Tam
8a214838e5 Merge pull request #565 from wing328/php_doc
Update PHP documentation for method
2015-03-29 08:52:01 -07:00
geekerzp
37118cab47 Merge branch 'develop_2.0' into develop_2.0_objc_jsonmodel
Conflicts:
	samples/client/petstore/objc/PetstoreClient/PetstoreClientTests/PetApiTest.m
2015-03-29 18:15:02 +08:00
geekerzp
e6d7517e63 Update api-body.mustache, api-header.mustache,
apiBodyResponseWithContainer.mustache and apiNonPrimitiveResponse.mustache
templates in objective-c client.

* Update `asDictionary` method to `toDictionary` method which provided by
  JSONModel.
* Update `initWithValues` method to `initWithDictionary` method which
  provided by JSONModel.
2015-03-29 18:06:52 +08:00
xhh
90db8e2147 Add setUserAgent method to Java and Android clients 2015-03-29 09:55:20 +08:00
xhh
65883a5d85 Set default User-Agent for Java and Android clients 2015-03-29 09:55:19 +08:00
Tony Tam
7383520639 added objc target 2015-03-28 10:48:18 -07:00
Tony Tam
49e9c74324 Merge pull request #572 from swagger-api/issue-567
Issue 570
2015-03-28 10:46:17 -07:00
Tony Tam
492ab20c00 fix for issue 567, added reserved words, rebuilt client 2015-03-28 10:42:02 -07:00
Tony Tam
92621f2f2d fix for issue 567, added reserved words, rebuilt client 2015-03-28 10:41:51 -07:00
Tony Tam
f2ce5ef273 Merge pull request #571 from lanwen/cli-doc
update docs and bash about CLI usage, deprecate old cli classes
2015-03-28 08:50:46 -07:00
William Cheng
836f7ecb95 rebase with develop_2.0 2015-03-28 22:55:15 +08:00
MerkushevKirill
0dcd307333 update docs and bash about CLI usage, deprecate old cli classes
(after #547)
2015-03-28 12:34:44 +03:00
William Cheng
c2b3e68f8c rebase on develop_2.0 2015-03-28 16:48:07 +08:00
William Cheng
11c8e2268a Merge branch 'java_doc' of https://github.com/wing328/swagger-codegen into java_doc 2015-03-28 16:48:02 +08:00
William Cheng
a12cc1c544 remove {{newline}} as it has no impact at all 2015-03-28 16:43:16 +08:00
William Cheng
27e1b1c4b2 update java doc 2015-03-28 16:43:15 +08:00
Tony Tam
a62cd193ad Merge pull request #569 from swagger-api/issue-567
updated camelize function for #567
2015-03-27 23:23:02 -07:00
Tony Tam
0686a91690 updated camelize function for #567 2015-03-27 23:18:54 -07:00
Tony Tam
4f6d5f6265 Merge pull request #568 from swagger-api/feature/objc-templates
Feature/objc templates
2015-03-27 23:04:16 -07:00
Tony Tam
99271e77ab added multi-param args 2015-03-27 22:55:06 -07:00
Tony Tam
c9a2a14da5 added queryParamCollection 2015-03-27 22:17:50 -07:00
Tony Tam
236a1147b7 minor comment 2015-03-27 09:53:40 -07:00
gandrianakis
7eba8670e3 Switched SingleClientConnManager with ThreadSafeClientConnManager.
The SingleClientConnManager cannot be used safely in multi-threaded environments
2015-03-27 18:41:16 +02:00
William Cheng
bdd1d1621f remove {{newLine}} and replace tab wtih 2 spaces 2015-03-27 23:55:26 +08:00
Tony Tam
98c8f867e5 enabled java test 2015-03-27 08:52:22 -07:00
William Cheng
bfb35aa3ee remove {{newline}} as it has no impact at all 2015-03-27 23:49:27 +08:00
William Cheng
6ab51bcb4e remove tab with 2 spaces in php api template 2015-03-27 23:11:13 +08:00
William Cheng
1c547e9598 update php documentation 2015-03-27 22:40:59 +08:00
geekerzp
19c05eefab Merge branch 'develop_2.0' into develop_2.0_objc_jsonmodel
Conflicts:
	pom.xml
2015-03-27 17:27:58 +08:00
Tony Tam
3d12c8847f Merge pull request #562 from swagger-api/feature/java-client
Feature/java client
2015-03-26 23:31:47 -07:00
Tony Tam
5d6d563a8e updated versions 2015-03-26 23:17:17 -07:00
Tony Tam
442be8624c rebuilt client, added tests 2015-03-26 23:10:10 -07:00
Tony Tam
287bb7d936 fixed builder, error msg 2015-03-26 23:09:47 -07:00
Tony Tam
ddb1d6e0d3 removed 404 handling 2015-03-26 23:09:29 -07:00
Tony Tam
8b98a92805 adds tests, fixes for java templates 2015-03-26 20:32:59 -07:00
William Cheng
8b4a077f8a Merge branch 'ruby_doc' of https://github.com/wing328/swagger-codegen into ruby_doc 2015-03-27 02:12:33 +08:00
William Cheng
3d53cfc298 better ruby method argument format 2015-03-27 02:11:49 +08:00
William Cheng
fb2ab79455 update ruby doc 2015-03-27 02:11:49 +08:00
William Cheng
731bfc1fc6 Merge branch 'java_doc' of https://github.com/wing328/swagger-codegen into java_doc 2015-03-27 02:00:05 +08:00
William Cheng
ae52a62c09 update java doc 2015-03-27 01:59:05 +08:00
William Cheng
9ba1398831 better ruby method argument format 2015-03-26 20:20:28 +08:00
William Cheng
a4690d76db update ruby doc 2015-03-26 19:55:48 +08:00
William Cheng
fe11b064af update java doc 2015-03-26 16:27:00 +08:00
Tony Tam
a2dc767559 Update .travis.yml 2015-03-25 20:57:48 -07:00
geekerzp
93e19e48db update swagger-core version to 1.5.4-M1-SNAPSHOT 2015-03-26 11:23:47 +08:00
geekerzp
fbe069cf5c add jsonmodel in objective-c client 2015-03-26 10:07:33 +08:00
Tony Tam
20add5b58e updated tests, jetty 2015-03-25 16:16:03 -07:00
Tony Tam
b7c2c3448e renamed package 2015-03-25 12:12:04 -07:00
Tony Tam
f577345b14 fixed examples, readme 2015-03-25 12:11:40 -07:00
James Ebentier
bf46da7c14 Python: modifying request headers in ApiClient to act like those in Java and PHP 2015-03-25 11:44:46 -07:00
Tony Tam
d2f5b9ea65 added recursion check 2015-03-25 11:11:04 -07:00
Tony Tam
e8052f0505 Merge pull request #550 from swagger-api/feature/ios-templates
added command-line tests
2015-03-25 09:27:42 -07:00
Tony Tam
be373f88d4 fixed test errors 2015-03-25 09:27:12 -07:00
Tony Tam
ceffa10ab7 added command-line tests 2015-03-24 23:24:13 -07:00
Tony Tam
b36f3c98ca Merge pull request #547 from lanwen/cli
add - new command line interface in distribution module
2015-03-24 20:34:34 -07:00
Tony Tam
f459982560 Merge pull request #549 from swagger-api/feature/ios-templates
Feature/ios templates
2015-03-24 19:59:54 -07:00
Tony Tam
56104566fc added void response 2015-03-24 19:57:51 -07:00
Tony Tam
85463f049c rebuilt sample 2015-03-24 19:56:45 -07:00
Tony Tam
30acfc1869 added sys property 2015-03-24 19:56:38 -07:00
Tony Tam
2ce0049ce4 updated templates to fix petstore build error 2015-03-24 19:56:28 -07:00
Tony Tam
e82ecf695d added array support 2015-03-24 19:56:04 -07:00
Tony Tam
dc9a00809c Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-03-24 17:13:02 -07:00
Tony Tam
31418b3936 added property for app name 2015-03-24 17:12:20 -07:00
Tony Tam
db14a3fd05 added property for app name 2015-03-24 17:02:12 -07:00
Tony Tam
de0e108d27 added property for app name 2015-03-24 17:02:03 -07:00
Tony Tam
b8cd52aa07 Merge pull request #540 from lanwen/develop_2.0
rft - only codestyle, remove wildcard imports and use string-utils from apache
2015-03-24 16:56:01 -07:00
Tony Tam
16403950d5 Merge pull request #545 from wing328/ruby_better_naming
Update ruby codgen for better naming convention
2015-03-24 16:53:20 -07:00
MerkushevKirill
8ba444141e add - new command line interface in distribution module
can replace Codegen and MetaGenerator classes. Provides a bit different cli interface
based on refactored pom from #541,
affects #349

```
usage: swagger <command> [<args>]

The most commonly used swagger commands are:
    generate   Generate code with chosen lang
    help       Display help information
    langs      Shows available langs
    meta       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.
 ```
  **generate** and **meta** commands have same as current cli options
2015-03-25 01:59:55 +03:00
William Cheng
fb3e44ecc4 break down ruby reservedWord list into multiple lines 2015-03-24 16:34:41 +08:00
William Cheng
8107162540 update ruby codgen for better naming convention 2015-03-24 16:24:31 +08:00
MerkushevKirill
ee096569c4 rft - only codestyle with indents, remove wildcard imports and use string-utils from apache 2015-03-24 11:13:01 +03:00
Tony Tam
81e1fd53e2 Merge pull request #544 from geekerzp/develop_2.0_python_key_map
Support attribute key mapping in python client
2015-03-23 22:18:25 -07:00
geekerzp
07237f8eb9 add model attribute name json key mapping in python clent 2015-03-24 11:55:20 +08:00
Tony Tam
9442e23fd9 Merge pull request #543 from wing328/remove_old_php_sample
Remove old model files in PHP petstore
2015-03-23 20:35:13 -07:00
Tony Tam
fe82d7dc05 Merge pull request #542 from mrwanny/fix_MissingTag_StringIndexOutOfBoundsException
fix StringIndexOutOfBoundsException when tag is not provided
2015-03-23 16:22:01 -07:00
Wanny
915fcf9b92 fix cleanup 2015-03-23 16:08:26 -07:00
Wanny
31e8d58b1d fix StringIndexOutOfBoundsException when tag is not provided 2015-03-23 15:29:39 -07:00
William Cheng
87b85e5b93 remove old php model files 2015-03-24 02:33:08 +08:00
Tony Tam
823ac04abb Merge pull request #534 from Juliens/master
add version in properties
2015-03-23 08:47:06 -07:00
Tony Tam
0cf1c3c74a Merge pull request #536 from wing328/android_better_naming
better naming convention for android-java codegen
2015-03-23 08:44:01 -07:00
William Cheng
fd602af180 better naming convention for android-java codegen 2015-03-23 15:41:24 +08:00
Tony Tam
048bea6249 Merge pull request #535 from wing328/java_beter_naming
Better variable and model property naming for Java
2015-03-22 21:19:01 -07:00
Tony Tam
601a519cb6 Merge pull request #530 from FindTheBest/master
PHP Request Headers and Deserialization
2015-03-22 21:17:10 -07:00
Tony Tam
f1f9805a01 Merge pull request #527 from geekerzp/develop_2.0_python
Support iso8601 datetime format in Python client
2015-03-22 19:35:18 -07:00
William Cheng
62d28ebca5 better variable and model property naming for java 2015-03-22 23:24:43 +08:00
Julien SALLEYRON
c46f3f9ee4 add version in properties 2015-03-21 20:12:44 +01:00
Tony Tam
f008b75e99 Merge pull request #528 from wing328/php_better_variable_naming
PHP better naming convention
2015-03-21 08:18:46 -07:00
Tony Tam
38204b2237 Merge pull request #531 from geekerzp/develop_2.0_python_datetime
Update santizeForSerialization to normalize parameters for Python client
2015-03-21 08:18:00 -07:00
Tony Tam
d71785470b Merge pull request #532 from xhh/android-form-params
Add support of form parameter to Android client
2015-03-21 08:16:20 -07:00
xhh
b5a4d5be04 Add support of form parameter to Android client
* Handle form parameters in a way similar to Java client.
* Handle file uploading.
* Normalize query, header and form parameters with the
  ApiInvoker.parameterToString method, which formats Date value to ISO 8601.
2015-03-21 22:20:28 +08:00
geekerzp
f085860eb1 Update sanitizeForSerialization to sanitize parameters to Python client
* Refactor santizeForSerialzation to static method.
* Sanitize header/query/form/body parameters.
* Sanitize datetime.datetime and datetime.date to iso8601 format string.
* Sanitize swagger model to dict.
2015-03-21 14:58:32 +08:00
James Ebentier
8323fdf8e8 Fixing deserialization bug in PHP bindings 2015-03-20 15:35:09 -07:00
James Ebentier
0c3f06604d Correcting spelling error in comment 2015-03-20 14:54:53 -07:00
James Ebentier
e782ea2c05 Default Headers: allowing the setting of defaultHeaders on ApiClient 2015-03-20 14:45:12 -07:00
Tony Tam
9062016bf0 Merge pull request #529 from mrwanny/add_springdox
Add server codegen for springdox
2015-03-20 14:17:31 -07:00
Wanny
2301e604b3 clean up README.md 2015-03-20 13:53:07 -07:00
Wanny
34eab98ce4 Merge branch 'develop_2.0' into add_springdox 2015-03-20 13:47:08 -07:00
Wanny
00c1018d79 add basi Springdox server generation 2015-03-20 13:45:01 -07:00
William Cheng
c36e5a96fe update php codegen with better naming convention 2015-03-20 21:56:41 +08:00
geekerzp
c024a4c099 use dateutil to parse string to datetime in python 2015-03-20 14:38:18 +08:00
Tony Tam
92e5574ec1 Merge pull request #526 from swagger-api/feature/example-generator
Feature/example generator
2015-03-19 15:49:47 -07:00
Tony Tam
cdf8648d3b made noservice option 2015-03-19 14:59:32 -07:00
Tony Tam
de56f76284 rebuilt sample 2015-03-19 14:52:45 -07:00
Tony Tam
ae1d43dc84 added more instructions, service template 2015-03-19 14:47:43 -07:00
Tony Tam
531e2d7032 added example generator, updated signatures to match 2015-03-19 14:45:22 -07:00
Tony Tam
32fe6b0333 Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-03-19 09:04:16 -07:00
Tony Tam
75714ac518 added default for filename generation 2015-03-19 09:04:12 -07:00
Tony Tam
8262d30202 Merge pull request #459 from geoand/objc-dictionary-fix-dev2_0
Fixed bug that prevented Objective-C code from compiling when using a Sw...
2015-03-19 08:52:25 -07:00
Tony Tam
d332cdf200 Merge pull request #522 from wing328/ruby_user_agent
Fix User-Agent in Ruby API cleint
2015-03-19 08:32:59 -07:00
Tony Tam
f6c18cd50f Merge pull request #524 from wing328/php_property_mapping
Add Attribute Mapping to PHP model
2015-03-19 08:28:02 -07:00
William Cheng
ab8d62214a add attributemap to php model, update php petstore sample 2015-03-19 20:58:22 +08:00
William Cheng
a149bb9120 update ruby petstore example 2015-03-19 17:17:39 +08:00
William Cheng
02283fae46 udpate ruby api client to support user-agent 2015-03-19 17:09:27 +08:00
gandrianakis
c82b31aa61 Reintroduce objc dictionary fix to updated develop_2.0 branch 2015-03-19 11:07:54 +02:00
gandrianakis
37303745df Merge branch 'develop_2.0' into objc-dictionary-fix-dev2_0
Conflicts:
	modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/DefaultCodegen.java
2015-03-19 10:59:47 +02:00
gandrianakis
e5357df67a Merge remote-tracking branch 'upstream/master' into objc-dictionary-fix-dev2_0 2015-03-19 10:45:27 +02:00
Tony Tam
c109c11bea added yaml output 2015-03-18 23:26:45 -07:00
Tony Tam
3a8c798596 Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-03-18 23:25:48 -07:00
Tony Tam
9311bdf972 added yaml generator 2015-03-18 23:24:47 -07:00
Tony Tam
925caa223a Merge pull request #482 from FindTheBest/master
Python: fixing an issue in swagger python code generation
2015-03-18 22:59:26 -07:00
Tony Tam
95e7265bd7 Merge pull request #498 from burmanm/issue_495
Fix NPE with resourcePath = /, issue #495
2015-03-18 22:58:45 -07:00
Tony Tam
93afc3bd95 Merge pull request #516 from wing328/ruby_header_param
Bug fix for ruby header parameter and better code format
2015-03-18 22:58:31 -07:00
Tony Tam
cbdb31048e updated to release version 2015-03-18 22:40:41 -07:00
Tony Tam
6b1f176a66 Merge pull request #417 from Helmsdown/additional-codegen-properties
Add API Version to Codegen Additional Properties
2015-03-18 17:05:59 -07:00
Tony Tam
f2ee9b39e9 Merge pull request #519 from swagger-api/feature/swagger-tools
updated nodejs server to swagger-tools, supports 2.0 spec
2015-03-18 16:30:57 -07:00
Tony Tam
b6e5c55817 updated nodejs server to swagger-tools, supports 2.0 spec 2015-03-18 16:10:54 -07:00
Tony Tam
963d92e23f Merge pull request #518 from cchafer/add_response_headers
Add defined response headers in CodegenResponse. at this time, only the ...
2015-03-18 14:10:08 -07:00
Camille Chafer
081757c592 headers list is CodegenResponse is always defined (no null list) 2015-03-18 19:01:45 +01:00
Camille Chafer
ac78c15fbf Add defined response headers in CodegenResponse. at this time, only the headers of the 'default' response are included in the operation. 2015-03-18 18:38:27 +01:00
Tony Tam
dd78de1ed8 updated basePath, contextPath 2015-03-18 09:34:38 -07:00
Tony Tam
64fbcb6045 rebuilt client 2015-03-18 09:34:19 -07:00
Tony Tam
86c6892eb6 rebuilt samples 2015-03-18 09:32:45 -07:00
Tony Tam
9cfbd8bde0 updated sample 2015-03-18 09:32:18 -07:00
Tony Tam
1e1d193556 Merge pull request #517 from xhh/java-param-to-str
Add parameterToString to normalize parameters for Java client
2015-03-18 07:12:32 -07:00
xhh
f8a5e900f8 Add parameterToString to normalize parameters for Java client
* Convert values to string for query/header/form parameters.
* For parameter of type Date, convert to ISO 8601 format.
* Also add utility methods to parse date in ISO 8601 format.
2015-03-18 18:58:13 +08:00
William Cheng
d0dcb2fb43 fix bug with ruby header parameter, remove extra linebreak in generated
code
2015-03-18 16:33:00 +08:00
Tony Tam
bb45790375 Merge pull request #513 from wing328/add_ruby_to_readme
update README with ruby on the codegen usage
2015-03-17 17:51:54 -07:00
Tony Tam
369689d001 merged 2015-03-17 16:30:59 -07:00
Tony Tam
df39fe5d08 added Json schema fields 2015-03-17 16:30:42 -07:00
sosso
b73340ab83 Java: properly add request headers
https://jersey.java.net/nonav/apidocs/1.8/jersey/com/sun/jersey/api/client/PartialRequestBuilder.html#header(java.lang.String, java.lang.Object)

We were running into issues with our headers not making it into our requests.  Upon some research, it appears that Jersey's header() method returns the builder object, meaning we have to do this assignment to properly construct the request.  After making the change, our requests work as expected.
2015-03-17 11:39:32 -07:00
William Cheng
a1d02785af update README with ruby on the codegen usage 2015-03-18 00:14:39 +08:00
Tony Tam
4f32e9dbff Merge pull request #502 from FindTheBest/develop_2.0
PHP Generated Models
2015-03-17 08:51:02 -07:00
Tony Tam
b6ca69f57a Merge pull request #510 from xhh/patch-2
update null comparison for query params in Java
2015-03-17 07:10:52 -07:00
Tony Tam
62992c2de1 Merge pull request #509 from wing328/ruby_form_parameter
update ruby client to support form parameters, add PATCH support
2015-03-17 07:05:09 -07:00
Xu Hui Hui
b2da6dc8a2 update null comparison for query params in Java
to make it clear and also allow a query parameter to be set with string value: "null" (4 characters string)
2015-03-17 16:34:01 +08:00
Tony Tam
c96853d5aa Merge pull request #507 from cchafer/security_schemes_definition
Adding defintion of security schemes in CodegenSecurity
2015-03-16 22:13:19 -07:00
Tony Tam
c215d8ab91 fix and tests for #503 2015-03-16 22:10:35 -07:00
Tony Tam
46d1950fbd removed unnecessary file 2015-03-16 21:04:21 -07:00
Tony Tam
03b764d404 Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-03-16 20:54:14 -07:00
Tony Tam
a8aebec9ba removed description 2015-03-16 20:54:08 -07:00
Tony Tam
fd72ff56bf fixed context path 2015-03-16 20:54:01 -07:00
Tony Tam
ebec85fd54 added context path 2015-03-16 20:53:48 -07:00
Tony Tam
fd792ef180 added more helpful error trace 2015-03-16 20:53:34 -07:00
Tony Tam
486186e042 Merge pull request #505 from wing328/php_support_user_agent
update User-agent in PHP API client
2015-03-16 20:44:46 -07:00
Tony Tam
8111d4e909 Merge pull request #506 from wing328/ruby_codegen
Add ruby codegen, update sample (petstore) for ruby
2015-03-16 19:49:21 -07:00
William Cheng
fc9d632522 update ruby client to support form parameters, add PATCH support, update
ruby petstore client
2015-03-17 05:24:43 +08:00
Camille Chafer
d580d294b6 Adding defintion of security schemes in CodegenSecurity 2015-03-16 11:58:29 +01:00
William Cheng
e9227ad7e5 add ruby codegen, update sample (petstore) for ruby 2015-03-16 18:47:22 +08:00
Tony Tam
156ec2a2dd Merge pull request #485 from wing328/fix_php_string_response
minor bug fixes and enhancement to Swagger.php
2015-03-15 21:02:37 -07:00
William Cheng
186310b553 Merge branch 'fix_php_string_response' of https://github.com/wing328/swagger-codegen into fix_php_string_response
Conflicts:
	modules/swagger-codegen/src/main/resources/php/Swagger.mustache
	samples/client/petstore/php/Swagger.php
2015-03-15 22:08:44 +08:00
William Cheng
bcdee4e038 update php petstore sample code 2015-03-15 22:06:42 +08:00
William Cheng
6bc8de1230 rebase on develop_2.0 2015-03-15 22:02:16 +08:00
William Cheng
b8166f283a update php to support user agent 2015-03-15 16:33:57 +08:00
Tony Tam
ad7a5967ff Merge pull request #504 from wing328/php_param_supppor_datetime
PHP parameters to suppport datetime (ISO8601)
2015-03-14 22:41:54 -07:00
William Cheng
a0dc2097eb update php api client to support datetime (iso8601) for parameters
(header, path, url, form)
2015-03-14 23:48:05 +08:00
James Ebentier
24842d4a29 PHP Models: fixing an issue with commas being where they shouldn't 2015-03-13 10:53:42 -07:00
James Ebentier
0854ca5ce5 PHP Models: updating the models generated for PHP styling 2015-03-13 10:53:19 -07:00
James Ebentier
6ca34e362d PHP Models: updating the models generated for PHP to be array accessable and have a simple constructor 2015-03-13 10:51:45 -07:00
Tony Tam
470ba201d8 build error fix 2015-03-13 10:45:12 -07:00
Tony Tam
fc52ab972b Merge pull request #494 from FindTheBest/develop_2.0
Fixing bug in new APIClientException
2015-03-13 09:44:02 -07:00
Tony Tam
7aca1cfb3f Merge pull request #486 from wing328/php_fix_deserialize
Bug fixes for Swagger.php deserialize function
2015-03-13 09:39:50 -07:00
Ron
d9b247f302 Merge pull request #500 from jwyterlin/patch-1
Update README.md
2015-03-13 09:38:18 -04:00
Jhonathan Wyterlin
c1e45a5931 Update README.md 2015-03-13 10:35:59 -03:00
Michael Burman
4748af4d59 Fix NPE with resourcePath = /, issue #495
(cherry picked from commit 01515e4ded6fa59da87d109dd8056c1b4a64e0f7)
2015-03-13 14:38:19 +02:00
James Ebentier
575967b5de Fixing bug in new APIClientException
This new exception had a typo in it for the construct class declaration.
2015-03-12 13:23:46 -07:00
Tony Tam
6c57d6a76e Merge pull request #491 from FindTheBest/develop_2.0
PHP Bindings: exposing response and response info in Exceptions
2015-03-12 12:23:34 -07:00
James Ebentier
56ff34dc47 PHP Bindings: exposing response and response info to be accessible through thrown exceptions when non 200 response code is received 2015-03-12 12:12:07 -07:00
David Valdez
5b72653d7f Update README.md 2015-03-12 12:07:24 -07:00
Tony Tam
0a949e26f0 Merge pull request #487 from wing328/update_php_form
form parameter(single quote), add more comments
2015-03-11 08:44:26 -07:00
William Cheng
5347915c12 form parameter(single quote), add more comment 2015-03-11 21:14:17 +08:00
William Cheng
d0edb836ac fix syntax error at 223, update array comparision (case insensitive) 2015-03-11 15:47:28 +08:00
James Ebentier
c75cd55e2c Merge remote-tracking branch 'wordnik/master' 2015-03-10 13:05:16 -07:00
Tony Tam
911be4360a Merge pull request #483 from wing328/add_patch_php
Add PATCH support to PHP API client
2015-03-10 11:42:57 -07:00
Tony Tam
939b4c713d per #458 2015-03-10 11:42:31 -07:00
Tony Tam
e6abc2a881 Merge pull request #458 from djvaldez/master
Update README.md - fixed incorrect flag for custom generator class
2015-03-10 11:40:34 -07:00
Tony Tam
b2977cd29b Merge pull request #477 from wing328/fix_php_basename
use baseName for parameter name in PHP api
2015-03-10 11:39:28 -07:00
Tony Tam
da6f0eec84 Merge pull request #481 from godaddy/develop_2.0
Develop 2.0 - Fix for python3 client deserialize passing wrong parameter
2015-03-10 11:38:59 -07:00
William Cheng
7555dda2bf add logic to handle all 2xx response code, bug fix for string response,
bug fix for showing error message using serialize
2015-03-11 01:37:39 +08:00
William Cheng
941f6e7757 add PATCH support to PHP API client 2015-03-10 18:13:55 +08:00
Tony Tam
1887170dad updated links 2015-03-09 18:50:23 -07:00
James Ebentier
b2cfb77222 Python: fixing an issue in swagger python code generation where attribute classes aren't respected 2015-03-09 18:18:20 -07:00
Brad Figler
5d77321dca syncing remote 2.0 branch 2015-03-09 20:47:48 +00:00
Brad Figler
f20522a586 Merge remote branch 'upstream/master' 2015-03-09 19:10:14 +00:00
Brad Figler
17435212ed Properly serailze the correct object type versus the parent objClass 2015-03-09 19:00:35 +00:00
Tony Tam
6207c2b5e9 fix for #475 building on java8 2015-03-09 10:09:33 -07:00
Tony Tam
b6f7f85baa updated links 2015-03-09 09:32:22 -07:00
Tony Tam
9c77742046 updated links 2015-03-09 09:31:34 -07:00
Tony Tam
e9d0619358 updated versions 2015-03-09 08:59:16 -07:00
William Cheng
7c23eedf07 use baseName for parameter name in PHP api 2015-03-09 23:15:12 +08:00
Ron
27c6af3491 Update README.md 2015-03-07 16:34:39 -05:00
Tony Tam
dc5ee9dcf5 added reserved words 2015-03-04 20:44:26 -08:00
Tony Tam
07ff6a2278 Merge pull request #468 from cor3ntin/fix_base_path_upstream
Fix {{basePath}} value in support files.
2015-03-04 07:25:29 -08:00
Tony Tam
dce9a81536 Merge pull request #467 from cor3ntin/security_upstream
Expose Security schemes of operations.
2015-03-04 07:25:00 -08:00
Corentin Jabot
156055fdd5 Fix {{basePath}} value in support files.
Make {{basePath}} value in support files be the
same as in operation files, aka host/path, instead of /path.
2015-03-04 15:01:07 +01:00
Corentin Jabot
3a5c03c778 Expose Security schemes of operations.
A template can now refer to the type ( oath2.0, apiKey, basic )
as well as the name of the security schemes it rquires.

Usage :

{{#operations}}
{{#authMethods}}
{{type}}  {{name}}
{{/authMethods}}
{{/operations}}
2015-03-04 14:54:48 +01:00
Tony Tam
9ce4156e4c Merge pull request #455 from cchafer/responses
Implements CodegenResponse, and return default response in Operaiton.Responses (#293)
2015-03-03 17:34:47 -08:00
Tony Tam
f82afe0026 Merge pull request #452 from herveDarritchon/develop_2.0
Defect (Issue #445) : change the call of initialCaps for getter and setter proper generation
2015-03-03 17:33:01 -08:00
Ron
c3bb458ed9 Merge pull request #463 from yzats/patch-3
Fixed spelling errors in README.md
2015-03-03 18:45:46 -05:00
yzats
5c2c8e1d76 Update README.md
Fix spelling errors
2015-03-03 12:42:15 -08:00
Tony Tam
ced95d658f added instructions for the meta generator 2015-03-02 23:37:21 -08:00
Tony Tam
a724cd0780 added meta generator 2015-03-02 23:28:59 -08:00
Tony Tam
6b823b88d9 moved logic into abstract class for extensions 2015-03-02 17:29:29 -08:00
Tony Tam
8fb180133a merged from master 2015-03-02 10:59:35 -08:00
Tony Tam
e877abf153 Merge pull request #461 from natechadwick/master
The --auth parameter was setup to ignore values.
2015-03-01 13:45:50 -08:00
nate
dd0ccff58a Minor typo in help text. 2015-03-01 14:18:11 -05:00
nate
a793d5c6cc Changed the --auth parameter to require a value so it is not ignored. 2015-03-01 14:13:08 -05:00
gandrianakis
d313d4da3f Fixed bug that prevented Objective-C code from compiling when using a Swagger 'map' type 2015-02-27 10:11:35 +02:00
David Valdez
dfc8f7c60f Update README.md 2015-02-26 12:42:41 -08:00
Camille Chafer
c15ac0b6d4 Each type used by any response is now added to the imports list 2015-02-25 17:12:28 +01:00
Camille Chafer
f9a16d856c Add 'default' response (200) to responses list, and add Types to the CodegenResponse object (#293). In the same time, clarify, simplfy and factorize code. 2015-02-25 16:46:33 +01:00
Camille Chafer
5713dce00a add missing types on the Responses Object implementation( CodegenResponse.java) (part of #293) 2015-02-25 16:39:10 +01:00
Tony Tam
23e848b437 added ignored test for #453, nested containers 2015-02-25 07:35:05 -08:00
Tony Tam
5b01e78a72 Merge branch 'godaddy-master' into develop_2.0 2015-02-24 23:23:40 -08:00
Tony Tam
eb68d0bdbd Merge branch 'master' of https://github.com/godaddy/swagger-codegen into godaddy-master 2015-02-24 23:23:19 -08:00
Tony Tam
05297e05a5 made annotations FQ to avoid collisions 2015-02-24 21:12:08 -08:00
Tony Tam
1a0d2d19f5 updated template 2015-02-24 18:07:13 -08:00
Tony Tam
292fc99bd5 fixed response types 2015-02-24 11:03:00 -08:00
Hervé Darritchon
b339db65be Pull request #452 : Add some unit tests for this PR 2015-02-24 09:23:07 +01:00
Tony Tam
e5c70d5961 updated online version, added tag example 2015-02-23 23:23:37 -08:00
Hervé Darritchon
69be95d586 Defect (Issue #445) : change the call of initialCaps for getter and setter with Introspector.decapitalize from pakage java.beans. 2015-02-24 08:20:49 +01:00
Tony Tam
c82dfa3a64 updated version 2015-02-23 23:03:18 -08:00
Tony Tam
4fd4c17036 Merge pull request #451 from swagger-api/develop_2.0
Merged from develop_2.0
2015-02-23 22:51:46 -08:00
Tony Tam
4bd227271a updated version 2015-02-23 22:45:06 -08:00
Tony Tam
5c31d68fee updated to add resolve flag 2015-02-23 22:42:45 -08:00
Tony Tam
bfc1ed3081 added async scala generator #440 2015-02-22 08:57:40 -08:00
Tony Tam
1c7c39c1ab added logback 2015-02-22 08:56:31 -08:00
Tony Tam
4ce0a65ad5 fix for #444, paths on windows 2015-02-22 08:56:03 -08:00
Tony Tam
784afee7b7 prepare for next dev version 2015-02-17 22:06:25 -08:00
Tony Tam
f89e04d210 Update README.md 2015-02-17 22:04:12 -08:00
Tony Tam
12531943d0 Merge pull request #438 from swagger-api/develop_2.0
merged to master for patch release
2015-02-17 21:48:20 -08:00
Tony Tam
3061cd8277 put parser back to 1.0.0 2015-02-17 21:41:36 -08:00
Tony Tam
686f3656c5 updated to new patch 2015-02-17 21:38:02 -08:00
Tony Tam
9ae106affd rebuilt clients 2015-02-17 21:37:51 -08:00
Tony Tam
2550539495 added shade plugin to properly include service descriptions 2015-02-17 18:54:57 -08:00
Tony Tam
06164cdc51 updated file separator replacement 2015-02-17 15:04:06 -08:00
Tony Tam
583a932fba Merge pull request #436 from kreymerman/patch-python-codegen
Fix StringIndexOutOfBoundsException on Windows
2015-02-17 15:02:58 -08:00
Mikhail Kreymerman
fdd485608f fixed StringIndexOutOfBoundsException on Windows 2015-02-17 23:00:23 +01:00
Tony Tam
0307d3818a added friendly download links 2015-02-17 12:59:31 -08:00
Tony Tam
9a473ceae6 enabled url-only reading of specs 2015-02-17 12:43:10 -08:00
Tony Tam
12365b9591 removed cruft 2015-02-17 12:43:01 -08:00
Tony Tam
c832889db8 added slf4j, updated server gen logic 2015-02-17 11:15:08 -08:00
Tony Tam
39487d9917 disabled outdated routes, made languages GET method dynamic 2015-02-17 10:29:35 -08:00
Tony Tam
aa37542411 added version to make swagger valid 2015-02-17 10:29:06 -08:00
Tony Tam
279f43d697 Update README.md 2015-02-17 08:57:39 -08:00
Tony Tam
fee6de5974 Merge branch 'geoand-jackson_array' into develop_2.0 2015-02-17 07:08:55 -08:00
gandrianakis
5fa98b12b8 Fixed bug that did not allow json arrays to be deserialized by Jackson 2015-02-17 15:17:32 +02:00
Tony Tam
ff94196295 updated to snapshot version 2015-02-16 22:16:40 -08:00
Tony Tam
0195749f3b merged 2015-02-16 22:08:52 -08:00
Tony Tam
97fca910a1 removed cruft 2015-02-16 22:06:10 -08:00
Tony Tam
577aad3364 added file 2015-02-16 22:02:27 -08:00
Tony Tam
05c6cc756c remove cruft 2015-02-16 22:01:33 -08:00
Tony Tam
66c6662f42 cleaned up poms 2015-02-16 21:53:51 -08:00
Tony Tam
6319167464 added placeholder for javadocs 2015-02-16 21:53:43 -08:00
Tony Tam
aea2909490 Merge pull request #434 from swagger-api/develop_2.0
Merged from develop_2.0
2015-02-16 21:16:09 -08:00
Tony Tam
842421bb44 Merge pull request #433 from tfoxcroft/develop_2.0
Minor fix to cater for empty array in php
2015-02-16 21:14:56 -08:00
Terence Foxcroft
c6f10ef1ea Minor fix to cater for empty array 2015-02-17 07:10:08 +02:00
Tony Tam
3df04839a6 Update README.md 2015-02-16 21:03:36 -08:00
Tony Tam
618b4698c2 Merge branch 'develop_2.0'
Conflicts:
	README.md
	bin/Version.scala
	build.sbt
	modules/swagger-codegen/src/main/resources/Java/api.mustache
	modules/swagger-codegen/src/main/resources/android-java/api.mustache
	modules/swagger-codegen/src/main/resources/nodejs/api.mustache
	modules/swagger-codegen/src/main/resources/objc/SWGApiClient.h
	modules/swagger-codegen/src/main/resources/objc/SWGApiClient.m
	modules/swagger-codegen/src/main/resources/objc/SWGDate.h
	modules/swagger-codegen/src/main/resources/objc/SWGDate.m
	modules/swagger-codegen/src/main/resources/objc/SWGFile.m
	modules/swagger-codegen/src/main/resources/objc/SWGObject.h
	modules/swagger-codegen/src/main/resources/objc/SWGObject.m
	modules/swagger-codegen/src/main/resources/objc/api-header.mustache
	modules/swagger-codegen/src/main/resources/php/api.mustache
	modules/swagger-codegen/src/main/resources/python/api.mustache
	modules/swagger-codegen/src/main/resources/scala/apiInvoker.mustache
	modules/swagger-codegen/src/main/resources/scala/pom.mustache
	project/build.properties
	samples/client/petstore/android-java/src/main/java/io/swagger/client/api/PetApi.java
	samples/client/petstore/android-java/src/main/java/io/swagger/client/api/StoreApi.java
	samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java
	samples/client/petstore/scala/pom.xml
	samples/client/petstore/scala/src/test/scala/PetApiTest.scala
	samples/client/petstore/scala/src/test/scala/StoreApiTest.scala
	samples/client/petstore/scala/src/test/scala/UserApiTest.scala
	samples/client/wordnik-apiobjc/client/SWGAccountApi.h
	samples/client/wordnik-apiobjc/client/SWGAccountApi.m
	samples/client/wordnik-apiobjc/client/SWGApiClient.h
	samples/client/wordnik-apiobjc/client/SWGApiClient.m
	samples/client/wordnik-apiobjc/client/SWGApiTokenStatus.h
	samples/client/wordnik-apiobjc/client/SWGAudioFile.h
	samples/client/wordnik-apiobjc/client/SWGAuthenticationToken.h
	samples/client/wordnik-apiobjc/client/SWGBigram.h
	samples/client/wordnik-apiobjc/client/SWGCitation.h
	samples/client/wordnik-apiobjc/client/SWGCitation.m
	samples/client/wordnik-apiobjc/client/SWGContentProvider.h
	samples/client/wordnik-apiobjc/client/SWGContentProvider.m
	samples/client/wordnik-apiobjc/client/SWGDate.h
	samples/client/wordnik-apiobjc/client/SWGDate.m
	samples/client/wordnik-apiobjc/client/SWGDefinition.h
	samples/client/wordnik-apiobjc/client/SWGDefinition.m
	samples/client/wordnik-apiobjc/client/SWGDefinitionSearchResults.h
	samples/client/wordnik-apiobjc/client/SWGDefinitionSearchResults.m
	samples/client/wordnik-apiobjc/client/SWGExample.h
	samples/client/wordnik-apiobjc/client/SWGExample.m
	samples/client/wordnik-apiobjc/client/SWGExampleSearchResults.h
	samples/client/wordnik-apiobjc/client/SWGExampleSearchResults.m
	samples/client/wordnik-apiobjc/client/SWGExampleUsage.h
	samples/client/wordnik-apiobjc/client/SWGExampleUsage.m
	samples/client/wordnik-apiobjc/client/SWGFacet.h
	samples/client/wordnik-apiobjc/client/SWGFacet.m
	samples/client/wordnik-apiobjc/client/SWGFacetValue.h
	samples/client/wordnik-apiobjc/client/SWGFacetValue.m
	samples/client/wordnik-apiobjc/client/SWGFile.h
	samples/client/wordnik-apiobjc/client/SWGFile.m
	samples/client/wordnik-apiobjc/client/SWGFrequency.h
	samples/client/wordnik-apiobjc/client/SWGFrequency.m
	samples/client/wordnik-apiobjc/client/SWGFrequencySummary.h
	samples/client/wordnik-apiobjc/client/SWGFrequencySummary.m
	samples/client/wordnik-apiobjc/client/SWGLabel.h
	samples/client/wordnik-apiobjc/client/SWGLabel.m
	samples/client/wordnik-apiobjc/client/SWGNote.h
	samples/client/wordnik-apiobjc/client/SWGObject.h
	samples/client/wordnik-apiobjc/client/SWGObject.m
	samples/client/wordnik-apiobjc/client/SWGRelated.h
	samples/client/wordnik-apiobjc/client/SWGScoredWord.h
	samples/client/wordnik-apiobjc/client/SWGSentence.h
	samples/client/wordnik-apiobjc/client/SWGSentence.m
	samples/client/wordnik-apiobjc/client/SWGSimpleDefinition.h
	samples/client/wordnik-apiobjc/client/SWGSimpleExample.h
	samples/client/wordnik-apiobjc/client/SWGStringValue.h
	samples/client/wordnik-apiobjc/client/SWGStringValue.m
	samples/client/wordnik-apiobjc/client/SWGSyllable.h
	samples/client/wordnik-apiobjc/client/SWGTextPron.h
	samples/client/wordnik-apiobjc/client/SWGUser.h
	samples/client/wordnik-apiobjc/client/SWGWordApi.h
	samples/client/wordnik-apiobjc/client/SWGWordList.h
	samples/client/wordnik-apiobjc/client/SWGWordList.m
	samples/client/wordnik-apiobjc/client/SWGWordListApi.h
	samples/client/wordnik-apiobjc/client/SWGWordListApi.m
	samples/client/wordnik-apiobjc/client/SWGWordListWord.h
	samples/client/wordnik-apiobjc/client/SWGWordListsApi.h
	samples/client/wordnik-apiobjc/client/SWGWordListsApi.m
	samples/client/wordnik-apiobjc/client/SWGWordObject.h
	samples/client/wordnik-apiobjc/client/SWGWordOfTheDay.h
	samples/client/wordnik-apiobjc/client/SWGWordOfTheDay.m
	samples/client/wordnik-apiobjc/client/SWGWordSearchResult.h
	samples/client/wordnik-apiobjc/client/SWGWordSearchResults.h
	samples/client/wordnik-apiobjc/client/SWGWordSearchResults.m
	samples/client/wordnik-apiobjc/client/SWGWordsApi.h
	samples/client/wordnik-apiobjc/client/SWGWordsApi.m
	samples/client/wordnik-api-objc/Podfile
	samples/client/wordnik-api-objc/client/SWGAccountApi.h
	samples/client/wordnik-api-objc/client/SWGAccountApi.m
	samples/client/wordnik-api-objc/client/SWGApiClient.h
	samples/client/wordnik-api-objc/client/SWGApiClient.m
	samples/client/wordnik-api-objc/client/SWGApiTokenStatus.h
	samples/client/wordnik-api-objc/client/SWGApiTokenStatus.m
	samples/client/wordnik-api-objc/client/SWGAudioFile.h
	samples/client/wordnik-api-objc/client/SWGAudioFile.m
	samples/client/wordnik-api-objc/client/SWGAuthenticationToken.h
	samples/client/wordnik-api-objc/client/SWGAuthenticationToken.m
	samples/client/wordnik-api-objc/client/SWGBigram.h
	samples/client/wordnik-api-objc/client/SWGBigram.m
	samples/client/wordnik-api-objc/client/SWGCitation.h
	samples/client/wordnik-api-objc/client/SWGCitation.m
	samples/client/wordnik-api-objc/client/SWGContentProvider.h
	samples/client/wordnik-api-objc/client/SWGContentProvider.m
	samples/client/wordnik-api-objc/client/SWGDate.h
	samples/client/wordnik-api-objc/client/SWGDate.m
	samples/client/wordnik-api-objc/client/SWGDefinition.h
	samples/client/wordnik-api-objc/client/SWGDefinition.m
	samples/client/wordnik-api-objc/client/SWGDefinitionSearchResults.h
	samples/client/wordnik-api-objc/client/SWGDefinitionSearchResults.m
	samples/client/wordnik-api-objc/client/SWGExample.h
	samples/client/wordnik-api-objc/client/SWGExample.m
	samples/client/wordnik-api-objc/client/SWGExampleSearchResults.h
	samples/client/wordnik-api-objc/client/SWGExampleSearchResults.m
	samples/client/wordnik-api-objc/client/SWGExampleUsage.h
	samples/client/wordnik-api-objc/client/SWGExampleUsage.m
	samples/client/wordnik-api-objc/client/SWGFacet.h
	samples/client/wordnik-api-objc/client/SWGFacet.m
	samples/client/wordnik-api-objc/client/SWGFacetValue.h
	samples/client/wordnik-api-objc/client/SWGFacetValue.m
	samples/client/wordnik-api-objc/client/SWGFile.h
	samples/client/wordnik-api-objc/client/SWGFile.m
	samples/client/wordnik-api-objc/client/SWGFrequency.h
	samples/client/wordnik-api-objc/client/SWGFrequency.m
	samples/client/wordnik-api-objc/client/SWGFrequencySummary.h
	samples/client/wordnik-api-objc/client/SWGFrequencySummary.m
	samples/client/wordnik-api-objc/client/SWGLabel.h
	samples/client/wordnik-api-objc/client/SWGLabel.m
	samples/client/wordnik-api-objc/client/SWGNote.h
	samples/client/wordnik-api-objc/client/SWGNote.m
	samples/client/wordnik-api-objc/client/SWGObject.h
	samples/client/wordnik-api-objc/client/SWGObject.m
	samples/client/wordnik-api-objc/client/SWGRelated.h
	samples/client/wordnik-api-objc/client/SWGRelated.m
	samples/client/wordnik-api-objc/client/SWGScoredWord.h
	samples/client/wordnik-api-objc/client/SWGScoredWord.m
	samples/client/wordnik-api-objc/client/SWGScrabbleScoreResult.h
	samples/client/wordnik-api-objc/client/SWGScrabbleScoreResult.m
	samples/client/wordnik-api-objc/client/SWGSentence.h
	samples/client/wordnik-api-objc/client/SWGSentence.m
	samples/client/wordnik-api-objc/client/SWGSimpleDefinition.h
	samples/client/wordnik-api-objc/client/SWGSimpleDefinition.m
	samples/client/wordnik-api-objc/client/SWGSimpleExample.h
	samples/client/wordnik-api-objc/client/SWGSimpleExample.m
	samples/client/wordnik-api-objc/client/SWGStringValue.h
	samples/client/wordnik-api-objc/client/SWGStringValue.m
	samples/client/wordnik-api-objc/client/SWGSyllable.h
	samples/client/wordnik-api-objc/client/SWGSyllable.m
	samples/client/wordnik-api-objc/client/SWGTextPron.h
	samples/client/wordnik-api-objc/client/SWGTextPron.m
	samples/client/wordnik-api-objc/client/SWGUser.h
	samples/client/wordnik-api-objc/client/SWGUser.m
	samples/client/wordnik-api-objc/client/SWGWordApi.h
	samples/client/wordnik-api-objc/client/SWGWordApi.m
	samples/client/wordnik-api-objc/client/SWGWordList.h
	samples/client/wordnik-api-objc/client/SWGWordList.m
	samples/client/wordnik-api-objc/client/SWGWordListApi.h
	samples/client/wordnik-api-objc/client/SWGWordListApi.m
	samples/client/wordnik-api-objc/client/SWGWordListWord.h
	samples/client/wordnik-api-objc/client/SWGWordListWord.m
	samples/client/wordnik-api-objc/client/SWGWordListsApi.h
	samples/client/wordnik-api-objc/client/SWGWordListsApi.m
	samples/client/wordnik-api-objc/client/SWGWordObject.h
	samples/client/wordnik-api-objc/client/SWGWordObject.m
	samples/client/wordnik-api-objc/client/SWGWordOfTheDay.h
	samples/client/wordnik-api-objc/client/SWGWordOfTheDay.m
	samples/client/wordnik-api-objc/client/SWGWordSearchResult.h
	samples/client/wordnik-api-objc/client/SWGWordSearchResult.m
	samples/client/wordnik-api-objc/client/SWGWordSearchResults.h
	samples/client/wordnik-api-objc/client/SWGWordSearchResults.m
	samples/client/wordnik-api-objc/client/SWGWordsApi.h
	samples/client/wordnik-api-objc/client/SWGWordsApi.m
	samples/client/wordnik-api-php/wordnik/AccountApi.php
	samples/client/wordnik-api/scala/src/test/scala/AccountApiTest.scala
	samples/client/wordnik-api/scala/src/test/scala/WordApiTest.scala
	samples/client/wordnik-api/scala/src/test/scala/WordListApiTest.scala
	samples/client/wordnik-api/scala/src/test/scala/WordsApiTest.scala
	samples/client/wordnik/objc/client/SWGAccountApi.h
	samples/client/wordnik/objc/client/SWGAccountApi.m
	samples/client/wordnik/objc/client/SWGApiTokenStatus.h
	samples/client/wordnik/objc/client/SWGAudioFile.h
	samples/client/wordnik/objc/client/SWGAuthenticationToken.h
	samples/client/wordnik/objc/client/SWGBigram.h
	samples/client/wordnik/objc/client/SWGCitation.h
	samples/client/wordnik/objc/client/SWGCitation.m
	samples/client/wordnik/objc/client/SWGContentProvider.h
	samples/client/wordnik/objc/client/SWGContentProvider.m
	samples/client/wordnik/objc/client/SWGDefinition.h
	samples/client/wordnik/objc/client/SWGDefinition.m
	samples/client/wordnik/objc/client/SWGDefinitionSearchResults.h
	samples/client/wordnik/objc/client/SWGDefinitionSearchResults.m
	samples/client/wordnik/objc/client/SWGExample.h
	samples/client/wordnik/objc/client/SWGExample.m
	samples/client/wordnik/objc/client/SWGExampleSearchResults.h
	samples/client/wordnik/objc/client/SWGExampleSearchResults.m
	samples/client/wordnik/objc/client/SWGExampleUsage.h
	samples/client/wordnik/objc/client/SWGExampleUsage.m
	samples/client/wordnik/objc/client/SWGFacet.h
	samples/client/wordnik/objc/client/SWGFacet.m
	samples/client/wordnik/objc/client/SWGFacetValue.h
	samples/client/wordnik/objc/client/SWGFacetValue.m
	samples/client/wordnik/objc/client/SWGFile.h
	samples/client/wordnik/objc/client/SWGFrequency.h
	samples/client/wordnik/objc/client/SWGFrequency.m
	samples/client/wordnik/objc/client/SWGFrequencySummary.h
	samples/client/wordnik/objc/client/SWGFrequencySummary.m
	samples/client/wordnik/objc/client/SWGLabel.h
	samples/client/wordnik/objc/client/SWGLabel.m
	samples/client/wordnik/objc/client/SWGNote.h
	samples/client/wordnik/objc/client/SWGRelated.h
	samples/client/wordnik/objc/client/SWGScoredWord.h
	samples/client/wordnik/objc/client/SWGSentence.h
	samples/client/wordnik/objc/client/SWGSentence.m
	samples/client/wordnik/objc/client/SWGSimpleDefinition.h
	samples/client/wordnik/objc/client/SWGSimpleExample.h
	samples/client/wordnik/objc/client/SWGStringValue.h
	samples/client/wordnik/objc/client/SWGStringValue.m
	samples/client/wordnik/objc/client/SWGSyllable.h
	samples/client/wordnik/objc/client/SWGTextPron.h
	samples/client/wordnik/objc/client/SWGUser.h
	samples/client/wordnik/objc/client/SWGWordApi.h
	samples/client/wordnik/objc/client/SWGWordList.h
	samples/client/wordnik/objc/client/SWGWordList.m
	samples/client/wordnik/objc/client/SWGWordListApi.h
	samples/client/wordnik/objc/client/SWGWordListApi.m
	samples/client/wordnik/objc/client/SWGWordListWord.h
	samples/client/wordnik/objc/client/SWGWordListsApi.h
	samples/client/wordnik/objc/client/SWGWordListsApi.m
	samples/client/wordnik/objc/client/SWGWordObject.h
	samples/client/wordnik/objc/client/SWGWordOfTheDay.h
	samples/client/wordnik/objc/client/SWGWordOfTheDay.m
	samples/client/wordnik/objc/client/SWGWordSearchResult.h
	samples/client/wordnik/objc/client/SWGWordSearchResults.h
	samples/client/wordnik/objc/client/SWGWordSearchResults.m
	samples/client/wordnik/objc/client/SWGWordsApi.h
	samples/client/wordnik/objc/client/SWGWordsApi.m
	samples/server-generator/node/README.md
	samples/server/petstore/jaxrs/src/main/java/io/swagger/model/Pet.java
	samples/server/petstore/nodejs/app/apis/PetApi.js
	samples/server/petstore/nodejs/app/apis/StoreApi.js
	samples/server/petstore/nodejs/app/apis/UserApi.js
	sbt
	src/main/resources/objc/api-body.mustache
	src/main/resources/php/Swagger.mustache
	src/main/resources/python/swagger.mustache
	src/main/scala/com/wordnik/swagger/codegen/BasicAndroidJavaClient.scala
	src/main/scala/com/wordnik/swagger/codegen/BasicGenerator.scala
	src/main/scala/com/wordnik/swagger/codegen/BasicPythonGenerator.scala
	src/main/scala/com/wordnik/swagger/codegen/BasicScalaGenerator.scala
	src/main/scala/com/wordnik/swagger/codegen/Codegen.scala
	src/main/scala/com/wordnik/swagger/codegen/ScalaAsyncClientGenerator.scala
	src/main/scala/com/wordnik/swagger/codegen/model/AuthorizationModels.scala
	src/main/scala/com/wordnik/swagger/codegen/spec/SwaggerSpecValidator.scala
	src/main/scala/com/wordnik/swagger/codegen/util/RemoteUrl.scala
	src/test/scala/CodegenTest.scala
2015-02-16 21:01:17 -08:00
Tony Tam
72feda8346 updated readme 2015-02-16 20:53:26 -08:00
Tony Tam
2e88dea3ac updated versions 2015-02-16 20:44:22 -08:00
Tony Tam
678bbd6676 made dynamic swagger config example 2015-02-16 20:17:00 -08:00
Tony Tam
5853326f6a removed file 2015-02-16 20:15:24 -08:00
Tony Tam
8befb95986 added type tag 2015-02-16 18:19:06 -08:00
Tony Tam
026c93a104 fixed models 2015-02-16 18:03:15 -08:00
Tony Tam
15fde46ca5 removed debug 2015-02-16 17:56:28 -08:00
Tony Tam
f3455397ec rebuilt clients 2015-02-16 17:56:13 -08:00
Tony Tam
4f0823bffa rebuilt client 2015-02-16 17:55:59 -08:00
Tony Tam
31eb392d40 rebuild client 2015-02-16 17:55:15 -08:00
Tony Tam
fde5014bf9 fix for #224, added safe php comparison 2015-02-16 17:49:22 -08:00
Tony Tam
39b2bf4204 fixed test errors from updating sample json 2015-02-16 17:38:04 -08:00
Tony Tam
a1cf365288 rebuilt 2015-02-16 17:37:45 -08:00
Tony Tam
166a18bfc8 pulled from live server 2015-02-16 17:37:25 -08:00
Tony Tam
a0ea195ffc rebuilt client 2015-02-16 17:37:05 -08:00
Tony Tam
0563be891c made scripts call local file to avoid transient server issues 2015-02-16 17:36:48 -08:00
Tony Tam
5790c7d289 fix for #191, not detecting correct file name 2015-02-16 17:18:19 -08:00
Tony Tam
c7c3c969db moved output 2015-02-15 22:22:42 -08:00
Tony Tam
04074bd853 updated client 2015-02-15 22:20:56 -08:00
Tony Tam
76a367072c updated client 2015-02-15 22:20:26 -08:00
Tony Tam
e4cf9c5d55 updated scripts 2015-02-15 22:20:08 -08:00
Tony Tam
a4bde0368e updated for separation with enums 2015-02-15 22:19:43 -08:00
Tony Tam
da8176e170 updated templates 2015-02-15 22:19:26 -08:00
Tony Tam
bd276f5680 rebuilt client 2015-02-15 22:18:13 -08:00
Tony Tam
f10da06188 updated client 2015-02-15 22:17:32 -08:00
Tony Tam
13ef879703 rebuilt client 2015-02-15 22:14:38 -08:00
Tony Tam
8cbba12282 rebuilt client 2015-02-15 22:14:25 -08:00
Tony Tam
d98e894b41 rebuilt client 2015-02-15 22:12:48 -08:00
Tony Tam
73a6c0c42d rebuilt client 2015-02-15 22:09:07 -08:00
Tony Tam
7363365447 rebuilt client 2015-02-15 22:06:22 -08:00
Tony Tam
3b501f4134 added better enum support 2015-02-15 22:05:45 -08:00
Tony Tam
ffe5353987 rebuilt client 2015-02-15 22:04:50 -08:00
Tony Tam
1556bf16a9 rebuilt client 2015-02-15 21:26:35 -08:00
Tony Tam
88351ed844 rebuilt client 2015-02-15 21:25:41 -08:00
Tony Tam
9707f0a1ab updated client 2015-02-15 21:18:54 -08:00
Tony Tam
4daac48c6b added readme, rebuilt client 2015-02-15 19:50:41 -08:00
Tony Tam
e943f5c864 added readme, rebuilt client 2015-02-15 19:50:23 -08:00
Tony Tam
719820c089 added help response if args not set 2015-02-15 19:11:15 -08:00
Tony Tam
fe06652931 removed scala compile step #205 2015-02-15 19:04:53 -08:00
Tony Tam
098f7930eb added script 2015-02-15 18:07:05 -08:00
Tony Tam
f942e82691 updated templates 2015-02-15 18:06:50 -08:00
Tony Tam
db5259b913 updated script, addressed #189 with type mapping 2015-02-15 18:06:40 -08:00
Tony Tam
dfc7750dda rebuilt client 2015-02-15 18:05:56 -08:00
Tony Tam
dd971f19e7 added support for headers when generating per #102 2015-02-15 17:15:40 -08:00
Tony Tam
785cc4e29a fixed file suffix 2015-02-14 17:49:33 -08:00
Tony Tam
0c3e82e375 updated templates 2015-02-14 17:49:19 -08:00
Tony Tam
a6744507ef updated version 2015-02-14 17:49:10 -08:00
Tony Tam
9614dd8b95 added sample 2015-02-14 17:48:55 -08:00
Tony Tam
5208b36939 updated client 2015-02-14 17:36:52 -08:00
Tony Tam
779bdb23eb rebuilt client 2015-02-14 17:36:39 -08:00
Tony Tam
4bd1b99213 Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-02-14 17:34:27 -08:00
Tony Tam
4841485456 Merge pull request #427 from lucamilanesio/scala-mustache-backward-compatibility
Scala api.mustache: make new constructor backward compatible
2015-02-14 17:34:23 -08:00
Tony Tam
d5ddf0c404 Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-02-14 17:33:46 -08:00
Tony Tam
7d4cc6bdde Merge pull request #425 from lucamilanesio/develop_2.0
SPNEGO auth fix: Authentication scheme should be set as String
2015-02-14 17:33:30 -08:00
Tony Tam
a0d74531f7 added petstore script 2015-02-14 17:09:07 -08:00
Tony Tam
feb6119572 added supporting data post processing 2015-02-14 17:08:51 -08:00
Tony Tam
dbc4ab51b1 removed deprecated call 2015-02-14 17:08:37 -08:00
Tony Tam
8daebf78f4 updated sample 2015-02-14 17:06:32 -08:00
Tony Tam
391806570c updated script 2015-02-14 16:30:38 -08:00
Tony Tam
ed1e082896 updated versions 2015-02-13 22:16:54 -08:00
Tony Tam
0640c63573 updated readme 2015-02-12 22:32:00 -08:00
Tony Tam
9985d9e2d9 removed template path 2015-02-12 22:26:42 -08:00
Tony Tam
cd3dfe164b rebuilt 2015-02-12 22:25:29 -08:00
Tony Tam
85b396ce88 rebuilt sample 2015-02-12 22:24:17 -08:00
Tony Tam
241c69fef7 updated templates 2015-02-12 22:24:04 -08:00
Tony Tam
20deb15c8c updated client 2015-02-12 21:54:34 -08:00
Tony Tam
2bc5e71f91 updated year in comments 2015-02-12 21:53:37 -08:00
Tony Tam
dd9da67f51 made match case insensitive 2015-02-12 21:51:44 -08:00
Tony Tam
10e9e8a51d rebuilt 2015-02-12 21:40:42 -08:00
Tony Tam
c3978d2ea3 updated dependencies for compat 2015-02-12 21:38:52 -08:00
Tony Tam
54db9f8f24 updated scripts 2015-02-12 21:38:31 -08:00
Tony Tam
8785759fdf Merge pull request #431 from devnulled/develop_2.0
Fixed The html.sh Sample Generation Script
2015-02-12 16:26:30 -08:00
Brandon Harper
59b0a062a0 Fixed/updated the swagger.json URL in the html.sh script so that it would generate a sample again. 2015-02-12 14:46:02 -07:00
Tony Tam
95155f07d8 added snapshots back 2015-02-11 08:27:52 -08:00
Luca Milanesio
14795df85d Scala api.mustache: make new constructor backward compatible
When default values have been provided with the api.mustache
constructor, backward compatibility was broken because of the public
instance variables becoming immutable vals whilst they were vars before.

We can now use the constructor arguments as default values for the internal
vars and establish backward compatibility with existing code.
2015-02-11 11:00:41 +00:00
Tony Tam
d821a897b3 Merge pull request #426 from lucamilanesio/scala-mustache-easy-override
Scala api.mustache: allow easy basePath and ApiInvoker override
2015-02-10 08:22:39 -08:00
Luca Milanesio
fd560f4dc1 Scala api.mustache: allow easy basePath and ApiInvoker override
Gets rid of the smelly vars inside Scala api.mustache allowing the
override of default basePath and ApiInvoker on the constructor.

Previously the code for overriding was:

  val myApi = new MyApi()
  myApi.basePath = "http://myapi.endpoint.com"
  myApi.apiInvoker = new ApiInvoker(authScheme = "SPNEGO")

after the change everything can be simply declared in the constructor:

  val myApi = new MyApi("http://myapi.endpoint.com",
                         new ApiInvoker(authScheme = "SPNEGO"))
2015-02-10 14:07:13 +00:00
Luca Milanesio
6ecc569abd SPNEGO auth fix: Authentication scheme should be set as String
Default authentication scheme is a String and must be later
on decoded as Realm enum
2015-02-10 12:17:27 +00:00
Tony Tam
ece072aee3 Merge pull request #418 from lucamilanesio/scala-async-http-support
Support for HTTP Async client transport for Jersey on Scala (legacy master)
2015-02-09 13:43:07 -08:00
Tony Tam
759c0aea80 Merge pull request #421 from lucamilanesio/scala-spnego-preemptive-auth-2.0
Support Secure SPNEGO kerberos negotiation for Scala
2015-02-09 12:33:59 -08:00
Luca Milanesio
8e327aa24b Support for Secure SPNEGO kerberos negotiation
Ability to integrate with a SPNEGO-protected REST API
with KerberosV5 ticket preemptive authentication.
2015-02-09 20:14:13 +00:00
Luca Milanesio
592d59ceb2 Support for HTTP Async client transport for Jersey on Scala
When generating Scala client, the ApiInvoker is a class with
overridable options, avoiding the need of public vars to be
manually modified.

Additionally it is possible to plug the AsyncHttp protocol
for Jersey in order to achieve Netty support and maximum scalability.

NOTE: Support for Scala 2.10.0-3 removed as largely obsolete
2015-02-09 19:59:26 +00:00
Luca Milanesio
2386e394ae Support for HTTP Async client transport for Jersey on Scala
When generating Scala client, the ApiInvoker is a class with
overridable options, avoiding the need of public vars to be
manually modified.

Additionally it is possible to plug the AsyncHttp protocol
for Jersey in order to achieve Netty support and maximum scalability.

NOTE: Support for Scala 2.10.0-3 removed as largely obsolete
2015-02-09 19:36:28 +00:00
Tony Tam
781c9f7d83 Merge pull request #416 from FindTheBest/develop_2.0
PHP/Python Enhancements
2015-02-08 22:15:34 -08:00
Tony Tam
70803a1d09 Update README.md 2015-02-07 15:32:06 -08:00
Tony Tam
ffe5fc7fd2 changed signature for usage in generator 2015-02-07 14:59:35 -08:00
Tony Tam
cbc9fdbe34 updated annotations 2015-02-07 11:08:21 -08:00
russellb337
bd91922072 Add API Version to Codeine Additional Properties
Also updated htmlDocs template so html documentation shows API version.
2015-02-06 16:26:33 -08:00
Tony Tam
416c087be0 removed old files 2015-02-06 11:36:58 -08:00
James Ebentier
09bfecf76e Python: adding in support for formParams as well as multipart-form requests 2015-02-06 11:32:15 -08:00
James Ebentier
8b4180ca4a PHP: moving over the addition of a setTimeout function for the APIClient 2015-02-06 11:16:16 -08:00
James Ebentier
73a702f91e PHP: adding the ability to use multipart-form submissions as well as adding formParams to the api 2015-02-06 11:15:22 -08:00
Tony Tam
f55d9eaa68 Merge pull request #412 from FindTheBest/master
Python/PHP Multipart-Form request support
2015-02-06 10:47:10 -08:00
Tony Tam
7315b0ce2c changed scope per #414 2015-02-06 05:55:30 -08:00
Tony Tam
de4534475c removed old samples 2015-02-06 05:52:57 -08:00
Tony Tam
0bf660ebe8 added podfile 2015-02-06 05:52:15 -08:00
Tony Tam
8b32db73c2 formatting 2015-02-06 05:52:05 -08:00
Tony Tam
bffd43c8fc fixed container type 2015-02-06 05:51:56 -08:00
Tony Tam
6f7a1bb7e3 added reserved words 2015-02-06 05:51:23 -08:00
Tony Tam
eb1dce3d11 fixed paths 2015-02-06 05:50:43 -08:00
Tony Tam
a841f94273 updated response types 2015-02-06 05:50:12 -08:00
Tony Tam
a7f12c04e6 updated samples 2015-02-06 05:49:38 -08:00
Tony Tam
422cd88b51 rebuilt samples 2015-02-06 05:49:08 -08:00
Tony Tam
eb9e95952d updated templates 2015-02-06 05:48:47 -08:00
Tony Tam
1e717addf4 removed old samples 2015-02-06 05:48:27 -08:00
Tony Tam
3885991439 rebuilt samples 2015-02-05 21:45:48 -08:00
Tony Tam
3815dfa6a2 updated packages 2015-02-05 21:06:35 -08:00
Tony Tam
5f65c5aa49 added client 2015-02-05 21:06:22 -08:00
Tony Tam
e86837dd9a added samples 2015-02-05 21:02:12 -08:00
Tony Tam
585311c06a added files 2015-02-05 21:00:24 -08:00
Tony Tam
69dceb7f69 updated samples 2015-02-05 20:58:32 -08:00
Tony Tam
f1ac82f8a0 updated dependencies 2015-02-05 20:58:21 -08:00
Tony Tam
2c55649797 renamed package 2015-02-05 20:57:21 -08:00
Tony Tam
5c519f6429 revert last commit 2015-02-05 16:17:53 -08:00
Tony Tam
20e600c80e updated multi-module pom 2015-02-05 16:16:19 -08:00
Tony Tam
2ed8e10fe4 added null check for simple definitions with no models 2015-02-05 16:16:04 -08:00
Tony Tam
caaa753f58 Merge pull request #413 from swagger-api/assembly
Created assembly and submodules
2015-02-05 11:51:00 -08:00
Tony Tam
f7c6810757 updated samples 2015-02-05 11:35:13 -08:00
Tony Tam
2f16ee3b29 renamed package 2015-02-05 11:34:23 -08:00
Tony Tam
d97c7c7668 updated bin scripts 2015-02-05 10:22:28 -08:00
Tony Tam
11df3530f3 added wordnik sample 2015-02-05 10:22:19 -08:00
Tony Tam
6bb2e4ccb4 moved to modules per #411 2015-02-05 07:17:38 -08:00
Tony Tam
450894c52e moved to modules 2015-02-05 07:16:56 -08:00
James Ebentier
0f041dae90 MultipartForm: adding support for php 2015-02-04 12:48:00 -08:00
James Ebentier
6c97a9c6c7 MultipartForm: some more fixing of formating 2015-02-04 10:54:55 -08:00
James Ebentier
257d67346c MultipartForm: fixing some spacing issues 2015-02-04 10:41:25 -08:00
James Ebentier
e955c9dcfd MultipartForm: getting the file uploading working 2015-02-04 09:56:10 -08:00
Tony Tam
8414046fc5 added test for form params 2015-02-04 07:21:26 -08:00
Tony Tam
fd270d7733 added copy function 2015-02-04 07:21:17 -08:00
Tony Tam
67a3fffad7 added copy function 2015-02-04 07:21:08 -08:00
Tony Tam
7d0e003bf2 added form params template 2015-02-04 06:51:16 -08:00
Tony Tam
bad6798433 added consumes, produces 2015-02-03 23:54:37 -08:00
Tony Tam
949b321e13 updated path 2015-02-03 21:52:03 -08:00
Tony Tam
c84fd54215 updated to m1 version 2015-02-03 21:51:38 -08:00
Tony Tam
5acb01eb6b moved to 2_0 folder 2015-02-03 21:51:20 -08:00
Tony Tam
568504ffb4 move to 2_0 folder 2015-02-03 21:51:05 -08:00
Tony Tam
eec525a40f shortened line breaks 2015-02-03 21:50:28 -08:00
Tony Tam
f8624dbcaa update to m1 release 2015-02-03 21:50:02 -08:00
Tony Tam
5fdb609767 changed package to io.swagger 2015-02-03 21:49:45 -08:00
Tony Tam
4c53d7b8c4 added formParam values 2015-02-03 21:49:21 -08:00
Tony Tam
3b96894e75 added file & forms 2015-02-03 21:49:05 -08:00
James Ebentier
63bb20238b MultipartForm: fixing syntax error 2015-02-03 19:01:31 -08:00
James Ebentier
55575541d8 MultipartForm: better formatting 2015-02-03 18:28:56 -08:00
James Ebentier
33e6105822 MultipartForm: adding in basic support for multipart form submissions on python bindings 2015-02-03 18:03:20 -08:00
Tony Tam
87be442ad9 Merge pull request #409 from ethanjcohen/master
Fix "properties" name in node server example template
2015-02-02 22:42:56 -08:00
Tony Tam
33834d6cce Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-02-02 06:28:24 -08:00
Tony Tam
212b7cee72 added void to default includes 2015-02-02 06:28:17 -08:00
Tony Tam
d9ca26c40d updated to m1 2015-02-02 06:27:58 -08:00
Ethan Cohen
65b3b594e3 Renamed the "params" operation property to "parameters" to conform to the swagger spec 2015-02-01 16:02:27 -06:00
Ethan Cohen
94ceb504b8 Changed the "params" operation property to "parameters" to conform to the swagger spec 2015-02-01 15:54:47 -06:00
Tony Tam
fcb21da7f9 Merge pull request #392 from ikuo/develop_2.0-support-upper-case-property-name
Support upper case-proprty names
2015-01-30 12:26:56 -08:00
Tony Tam
124e17fb8a Merge pull request #401 from fleque/fleque-fix-response-selection
Fix for the selection of the methodResponse during code-generation
2015-01-28 22:07:06 -08:00
Tony Tam
f914f26f3b Merge pull request #400 from FindTheBest/master
Fixing curl $postData for php bindings
2015-01-28 22:06:23 -08:00
Tony Tam
1bc5fcc29e Merge pull request #397 from fleque/fleque-python-codegen
[WIP] Support Python code generation
2015-01-28 21:53:14 -08:00
James Ebentier
4a6e719d6a APIClient: making the cURL timeout able to be variably set for better dynamic api calls 2015-01-28 16:04:11 -08:00
Fleque
35dc8d4e5d Fix for the selection of the methodResponse from an operation during code generation. Now all the smallest 2xx code is used 2015-01-27 23:01:21 +01:00
James Ebentier
61ea9564f8 building a fix for postData that will pass TravisCI build 2015-01-27 13:48:59 -08:00
James Ebentier
bfc14938d0 Fixing curl $postData for php bindings 2015-01-27 13:16:20 -08:00
Tony Tam
c98a78062f Merge pull request #398 from FindTheBest/master
Fixing issue with deserialization in PHP
2015-01-27 12:50:24 -08:00
James Ebentier
fd128cbab0 Update Swagger.mustache 2015-01-27 12:28:28 -08:00
James Ebentier
59568915de Fixing minor typo 2015-01-27 12:08:41 -08:00
James Ebentier
bff2515bf2 Fixing issue with deserialization in PHP
No longer will deserialize throw errors when converting a json response to a string
2015-01-27 11:48:20 -08:00
Tony Tam
d196c6656e added test for #393 2015-01-25 20:21:40 -08:00
Tony Tam
a2b01e9599 Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-01-25 20:20:36 -08:00
Tony Tam
34a61e1256 added scala client support for #393 2015-01-25 20:20:27 -08:00
Dan Peschman
ec995838fb python3: support PATCH verb for partial updates - http://tools.ietf.org/html/rfc5789 2015-01-24 21:58:33 +00:00
Ikuo Matsumura
b49572005b Fix typo name{ -> s} 2015-01-24 16:32:38 +09:00
Ikuo Matsumura
ea11b4fc35 Added spec on upper-case property name 2015-01-24 16:17:40 +09:00
Ikuo Matsumura
556485538f Added @JsonProperty to Java/model.mustache 2015-01-24 16:17:18 +09:00
Tony Tam
53e8683a5d Merge pull request #388 from fleque/template-resolving-fix
Fix for template resolving from classpath on windows
2015-01-23 16:55:09 -08:00
Fleque
6491223ed9 First attempt to port pythong code generation 2015-01-22 23:01:44 +01:00
Fleque
29a7375082 Applied import style of swagger-codegen project 2015-01-22 11:50:05 +01:00
Fleque
8f9947a20a Fix for the template resovling from classpath on Windows 2015-01-22 11:38:42 +01:00
Tony Tam
dcaf639bec Merge branch 'STRML-fixPHPFormParams' 2015-01-21 23:19:19 -08:00
Tony Tam
2f6bf95fa2 merged 2015-01-21 23:19:13 -08:00
Tony Tam
154c28b062 Merge pull request #385 from STRML/fixPHPComments
Rework generated PHP function comments.
2015-01-21 22:10:20 -08:00
Samuel Reed
8106de95dc Rework PHP function comments to match PHPDoc style.
Also eliminated bad newline.
2015-01-21 10:58:57 +01:00
Samuel Reed
7c342a060a Add missing formParams to PHP api.mustache. Fixes #383.
Also fixed mixed tabs and spaces in template.
2015-01-21 10:01:41 +01:00
Tony Tam
a15eb6f905 updated java version 2015-01-20 11:23:31 -08:00
Dan Peschman
4198779b5b python3: support datetime produced by datetime.isoformat like '2015-01-17T00:15:29.515' 2015-01-17 00:41:37 +00:00
Dan Peschman
711d2c8cf4 revert previous: no special handling for '' in python3 parseDatetime 2015-01-16 23:44:02 +00:00
Dan Peschman
42ad403e5e python3 parseDatetime: return None if passed '' 2015-01-16 23:09:54 +00:00
Dan Peschman
527fca5a8b python3 parseDatetime: return None if passed None 2015-01-15 23:19:01 +00:00
Dan Peschman
60bd56b91c python3: support more iso8601 datetime formats - http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#date.and.time.format.examples 2015-01-15 22:42:59 +00:00
Tony Tam
89c776a3b9 Update README.md 2015-01-14 11:16:06 -08:00
Tony Tam
6a5b4e2fb4 Merge pull request #364 from Helmsdown/jaxrs-path-annotation-fix
JAXRS Codegen should omit @PATH variable when it is not necessary
2015-01-11 22:55:36 -08:00
Tony Tam
fd39402116 Merge pull request #371 from cantecim/develop_2.0
Fixed apiFileFolder and modelFileFolder function results for android-java Fixes #369
2015-01-10 12:37:55 -08:00
Can Tecim
f6055dde30 Fixed apiFileFolder and modelFileFolder function results for android-java Fixes #369 2015-01-10 22:31:38 +02:00
Tony Tam
3abc42eee9 Merge pull request #368 from amandaducrou/master
Adding first and hasRequiredParams parameters to Codegen
2015-01-09 10:26:50 -08:00
Amanda Ducrou
2d81c71b52 Adding first and hasRequiredParams parameters to Codegen 2015-01-09 10:59:21 +10:00
Tony Tam
52db5b0925 Update README.md 2015-01-07 10:40:16 -08:00
russellb337
9aa9f4e842 fix JaxRS code gen to only generated @PATH annotation on a given resource function when that function is a "sub resource" (e.g. @PATH("/{id}") or @PATH("/{id}/operation") 2015-01-02 13:52:36 -08:00
Tony Tam
21396d0797 added map support for #360 2014-12-25 08:17:41 -08:00
Tony Tam
93eca2a6b6 php fixes 2014-12-24 19:29:25 -08:00
Tony Tam
74b9257de4 variable type fixes 2014-12-24 15:00:10 -08:00
Tony Tam
a921278650 added php generator 2014-12-24 10:19:42 -08:00
Tony Tam
2d193a0e92 Merge pull request #218 from JDiPierro/output_resource_path_for_no_models_found
Output the resourcePath when no models are found rather than the basePath
2014-12-23 22:23:14 -08:00
Tony Tam
09e7bd9c43 Merge pull request #286 from jebentier/master
Java binding comment creation issue fixed
2014-12-23 22:17:35 -08:00
Tony Tam
0ece4a084f Merge pull request #303 from butlermh/master
Can't run ./bin/scala-petstore.sh as instructed at README
2014-12-23 22:16:35 -08:00
Tony Tam
0821d1859b Merge pull request #321 from Laurent-Sarrazin/patch-doc
Fix a typo
2014-12-23 22:14:39 -08:00
Tony Tam
25aef5fd6e Merge pull request #240 from GerardSoleCa/master
Edit line 76 to place pom.xml correctly and dependency-jar generation
2014-12-23 20:31:26 -08:00
Tony Tam
20c21cb2f7 added debug info per #330 2014-12-23 19:56:32 -08:00
webron
3a77287f8b Update README.md 2014-12-23 17:29:49 +02:00
webron
d2111a8e68 Merge pull request #352 from FMJaguar/patch-2
Update README.md
2014-12-23 17:28:59 +02:00
Tony Tam
8fa4b196b4 Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2014-12-19 14:49:51 -08:00
Tony Tam
3bf45de1f7 added null check 2014-12-19 14:49:32 -08:00
Rich DeLauder
3c0d639d0e Update README.md 2014-12-19 13:10:02 -08:00
Tony Tam
ed1d0948a3 Merge pull request #351 from earldouglas/exec-maven-plugin
Add the Exec Maven Plugin
2014-12-18 11:01:52 -08:00
James Earl Douglas
83699e5324 Add the Exec Maven Plugin
This allows execution of the Codegen class via `mvn exec:java`,
with optional args passed via `-Dexec.args="..."`:

mvn exec:java -Dexec.args="-i .../swagger.json -l html -o samples/..."
2014-12-18 10:58:25 -08:00
Tony Tam
1f30c65464 Update README.md 2014-12-12 12:47:30 -08:00
Tony Tam
45d5e480c0 configured scala version #344 2014-12-11 09:42:39 -08:00
Tony Tam
5ecada11ef moved java-specific reserved words out of default 2014-12-08 13:13:29 -08:00
Tony Tam
4f6878a278 fallbacks for unmatched inner types 2014-12-08 11:49:47 -08:00
Tony Tam
50e0445ab4 Merge pull request #342 from martoe/codegenfactory
Introduced a factory for codegen data containers
2014-12-08 07:22:22 -08:00
Martin Ehrnhoefer
78b36e0ba9 Introduced a factory for codegen data containers
Moved parameter/response generation code to
dedicated methods so that subclasses may extend it
2014-12-08 11:21:17 +01:00
Martin Ehrnhoefer
7a5068d632 Introduced a factory for codegen data containers
Missing model elements added
2014-12-08 10:27:29 +01:00
Tony Tam
c010b4c9c6 Merge pull request #341 from martoe/responseheaders
Make response headers available to the code generator
2014-12-07 21:30:57 -08:00
Tony Tam
cc9029236b Merge pull request #340 from martoe/codegenfactory
Introduced a factory for codegen data containers
2014-12-07 21:29:18 -08:00
Martin Ehrnhoefer
3f0b71b3e0 Make response headers available to the code generator 2014-12-07 10:08:42 +01:00
Martin Ehrnhoefer
0eb467e46e Introduced a factory for codegen data containers
implementation completed
2014-12-07 09:52:52 +01:00
Tony Tam
f2c64a0fbb removed comments 2014-12-06 15:55:42 -08:00
Martin Ehrnhoefer
f4424a5eae Introduced a factory for codegen data containers
This enables users to extend the Codegen* classes
and add their own methods there (which then can
be accessed from the mustache templates)
2014-12-06 16:07:45 +01:00
webron
1b68671e98 Update README.md 2014-12-04 16:27:44 +02:00
Tony Tam
f3ac9a579f Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2014-12-03 00:55:55 -08:00
Tony Tam
6e858ee645 updated samples 2014-12-03 00:55:38 -08:00
Tony Tam
96ea15a4d0 updated readme 2014-12-03 00:55:25 -08:00
Tony Tam
586420b919 Merge pull request #335 from wing328/master
update deserialize to handle both array(primitive) and Array(model)
2014-12-02 22:07:24 -08:00
Tony Tam
c05e07c8aa Merge pull request #331 from yutenglei/develop_2.0
Assigned Accept and Content-Type request-header for python's api.mustach...
2014-12-02 21:44:51 -08:00
Tony Tam
43a5ece5b3 Merge pull request #312 from idosh/master
add support to multipart form data and urlencoded for android client
2014-12-02 20:40:02 -08:00
William Cheng
9f6d883e68 update deserialize to handle both array(primitive) and Array(model) 2014-11-29 18:23:44 +08:00
Tony Tam
23d2d09136 added help, dynamic loading 2014-11-26 16:37:44 -10:00
Tony Tam
f35c748fb2 added help, dynamic loading 2014-11-26 15:20:50 -10:00
Tony Tam
a24556f0be added static, updated reference to swagger parser 2014-11-26 14:06:00 -10:00
Tony Tam
a1d604feb3 updated to use swagger parser 2014-11-25 12:01:13 -10:00
webron
524497a606 Merge pull request #332 from mhurne/patch-1
Fix spelling errors and improve sentence in Compatibility section
2014-11-24 22:13:29 +02:00
Matt Hurne
665ba22c7a Fix spelling errors and improve sentence in Compatibility section 2014-11-24 15:11:38 -05:00
Yu Teng Lei
9085a0d148 Assigned Accept and Content-Type request-header for python's api.mustache
This was done in PHP but not in python
2014-11-23 16:39:35 -05:00
Tony Tam
74d4ff0fc9 added swagger output for conversion 2014-11-21 08:30:21 -10:00
Tony Tam
29d956d424 added static html generator 2014-11-21 08:14:33 -10:00
Tony Tam
06031a0a34 added 1.2 conversion 2014-11-21 08:14:14 -10:00
Tony Tam
9ffece910d added basePath 2014-11-19 13:36:59 -08:00
Tony Tam
d12a565032 added debug mode 2014-11-19 13:36:52 -08:00
Tony Tam
9d6e6b56c6 added tizen c++ support 2014-11-13 09:29:13 -08:00
Tony Tam
acc0bad668 changed permissions 2014-11-13 09:28:32 -08:00
Tony Tam
697457415d updated spec with auth 2014-11-10 21:18:19 -08:00
Tony Tam
bcfd2e8ab6 println 2014-11-10 21:17:29 -08:00
Tony Tam
5adb82f6f6 Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2014-11-10 13:15:36 -08:00
Tony Tam
4415cfe30d added escape 2014-11-10 13:15:27 -08:00
Ido Shamun
0614d1b221 update pom.xml with dependencies
fix Codegen.scala to support file as a param type
2014-11-08 01:19:53 +02:00
Ido Shamun
fb3f331e3c Merge remote-tracking branch 'upstream/master'
merge fork with master
2014-11-07 18:27:58 +02:00
Tony Tam
4e9378965b Merge pull request #324 from FindTheBest/pull_request
Adding the casting of integer -> int for python generated code
2014-11-05 15:47:44 -08:00
James Ebentier
d1fe146522 Adding the casting of integer -> int for python generated code 2014-11-05 15:37:22 -08:00
Tony Tam
718e6ba7b4 Merge pull request #302 from martoe/externalDocs
"External Documentation Object" implemented (according to spec)
2014-11-04 20:25:41 -08:00
Tony Tam
b9758107c3 Merge pull request #322 from Laurent-Sarrazin/patch-php-server-generator
Add a basic PHP server-generator example
2014-10-31 09:32:08 -07:00
Laurent Sarrazin
06332e5dce Add a basic PHP server-generator example 2014-10-31 17:00:34 +01:00
Laurent Sarrazin
aa262f6021 Fix a typo 2014-10-30 14:30:55 +01:00
Martin Ehrnhoefer
436d2530e4 "External Documentation Object" implemented (according to spec)
Depends on https://github.com/wordnik/swagger-core/pull/716
2014-10-30 10:22:00 +01:00
Tony Tam
77053fa855 added test case, update for #316 2014-10-28 13:21:50 -07:00
Tony Tam
810c7f9ed2 added test case, update for #316 2014-10-28 13:21:32 -07:00
Tony Tam
59b477d2da added test case, update for src/main/java/com/wordnik/swagger/codegen/DefaultCodegen.java 2014-10-28 13:08:41 -07:00
Tony Tam
4c674ca94b rebuilt samples 2014-10-26 21:46:26 -07:00
Tony Tam
63c428d048 updated templates 2014-10-26 21:46:14 -07:00
Tony Tam
2454bfa225 updated templates per #316 2014-10-26 21:40:13 -07:00
Tony Tam
d6bdd09273 removed unimplemented scripts 2014-10-24 14:50:40 -07:00
Tony Tam
73425fe582 rebuilt client 2014-10-23 21:22:19 -07:00
Tony Tam
bc974e6514 added bodyParam 2014-10-23 21:21:58 -07:00
Tony Tam
237f00e2e3 updated references 2014-10-22 15:46:47 -07:00
Tony Tam
88692ec42d updated references 2014-10-22 15:45:21 -07:00
Tony Tam
ee833da0ca fixed notes 2014-10-22 14:06:59 -07:00
Tony Tam
36aad8bc0a updated examples 2014-10-22 13:54:28 -07:00
Ivan Porto Carrero
a656ea301e updates the codegen to also include the project name for sbt 2014-10-21 10:59:35 -07:00
Tony Tam
e2ae99acac fixed import types 2014-10-21 00:02:28 -07:00
Tony Tam
461cb51f6a fixed summary/description mapping 2014-10-20 17:34:48 -07:00
Tony Tam
681628dba2 added model pacakge 2014-10-20 17:11:28 -07:00
Tony Tam
7167bf28c7 changed to Boolean to allow null values 2014-10-20 17:11:19 -07:00
Ido Shamun
5e4e838a48 add support to multipart form data and urlencoded for android client 2014-10-21 01:58:31 +03:00
Ivan Porto Carrero
f3dc69a7e7 update dependencies in async scala project 2014-10-20 15:42:10 -07:00
Tony Tam
86f9a0a58a fixed build error 2014-10-20 08:42:35 -07:00
Tony Tam
df1a987e2d Merge branch 'develop_2.0' of github.com:wordnik/swagger-codegen into develop_2.0 2014-10-20 08:24:46 -07:00
Tony Tam
40b4d34870 added required flag for parameter 2014-10-20 08:24:34 -07:00
Tony Tam
c6e3608ffa Merge pull request #310 from martoe/param_required
Parameter.required flag implemented
2014-10-20 07:07:50 -07:00
Martin Ehrnhoefer
0aa87cfbeb Parameter.required flag implemented
Made the "required" flag for Parameter objects available to the code generator templates
2014-10-20 15:56:25 +02:00
Tony Tam
053419234a renamed field to avoid nested naming collisions 2014-10-19 11:18:38 -07:00
Tony Tam
12eba440ae Update README.md 2014-10-18 17:14:00 -07:00
Tony Tam
5d43282f51 fixed typo 2014-10-17 14:46:47 -07:00
Tony Tam
2826b69487 removed profile 2014-10-17 14:31:26 -07:00
Tony Tam
63c6bc28c3 Merge branch 'berngp-feature/develop_2.0/scala_2.11' into develop_2.0 2014-10-17 14:29:37 -07:00
Tony Tam
bf3eb94c51 Merge branch 'feature/develop_2.0/scala_2.11' of github.com:berngp/swagger-codegen into berngp-feature/develop_2.0/scala_2.11 2014-10-17 14:28:58 -07:00
Tony Tam
350d736706 fixed case on scheme 2014-10-16 17:43:15 -07:00
Tony Tam
e0aed88e98 added default value 2014-10-16 17:42:39 -07:00
Tony Tam
52a4370c35 added default value 2014-10-16 17:42:27 -07:00
Bernardo Gomez Palacio
5c0577aa8e Adding Echo YAML Sample 2014-10-14 15:09:55 -07:00
Bernardo Gomez Palacio
1e1abde846 Updating the Scalatra Template for Scala 2.11
* Moved to Scala 2.11.2
* Updated the dependencies to use latest Jetty as well as Akka
* Added the SBT Dependency Graph plugin
* Build Properties now use SBT 0.13.5
* Updated the sbt executable.
2014-10-14 14:39:12 -07:00
Bernardo Gomez Palacio
b2f34a152b Enabling Maven Profile gen-scalatra 2014-10-14 14:24:59 -07:00
webron
4676c4cdf7 Merge pull request #307 from catherinedodge/master
Fixed broken link in README.md
2014-10-13 16:58:22 +03:00
catherinedodge
d5674c9a7b Fixed broken link in README.md 2014-10-13 09:48:29 -04:00
Tony Tam
7c998a2d67 addressed import mappings 2014-10-10 22:07:08 -07:00
Tony Tam
5a70550a37 added scalatra support 2014-10-10 21:41:21 -07:00
Tony Tam
4d214dbcef updated client 2014-10-10 21:39:45 -07:00
Tony Tam
97623af8df added apiInfo 2014-10-10 21:26:07 -07:00
Tony Tam
b87bc2a908 added scalatra 2014-10-10 21:25:19 -07:00
Mark H. Butler
c8dac4a3cf Reverting these files, they don't need to change 2014-10-08 08:25:23 -07:00
Mark H. Butler
6f30a6d65a Modifying the pom.xml template because it defaults to building with Scala 2.9.1, but that is broken because BeanProperty moved, so instead use 2.10 as the default but add the option of using Scala 2.11 2014-10-08 08:20:02 -07:00
Mark H. Butler
9d1f0bf568 Adding ignore for gedit files (Linux) 2014-10-08 08:19:08 -07:00
Tony Tam
643c211d72 Merge pull request #296 from lloydmeta/update/fix_deprecations
Update deprecated method calls
2014-10-07 21:42:13 -07:00
Tony Tam
fb84985e9b Merge pull request #298 from dreamfactorysoftware/master
adding a space in call to completionHandler to kill latest Xcode parse errors
2014-10-02 16:45:38 -07:00
Jason Sykes
afb34b4f2f adding a space in call to completionHandler to kill latest Xcode parse errors 2014-10-02 12:20:17 -04:00
Tony Tam
5024e0bbda added root checking per #279 2014-10-02 00:32:15 -07:00
Tony Tam
e771ed3332 added scheme, host, basePath per #295 2014-10-02 00:18:36 -07:00
Tony Tam
2e81b38838 Merge branch 'develop_2.0' of github.com:wordnik/swagger-codegen into develop_2.0 2014-10-02 00:10:42 -07:00
Tony Tam
67d28e8b3c added test 2014-10-02 00:10:39 -07:00
Tony Tam
b834ba436f added nodejs server 2014-10-02 00:10:15 -07:00
Tony Tam
6da7cbf095 Merge pull request #297 from martoe/#268
Windows path problem fixed
2014-10-02 00:00:54 -07:00
Martin Ehrnhoefer
d5d1eb2833 Windows path problem fixed
see #268, #269, #288
2014-10-02 08:56:30 +02:00
Tony Tam
e66f3c48ac Merge pull request #288 from martoe/268
Windows path problem fixed (again)
2014-10-01 23:29:46 -07:00
Tony Tam
c10cf7bf7f Merge branch 'develop_2.0' of github.com:wordnik/swagger-codegen into develop_2.0 2014-10-01 23:22:43 -07:00
Tony Tam
178d7d19c4 added files 2014-10-01 23:22:39 -07:00
Tony Tam
3c2845aaa6 updated file locations 2014-10-01 23:21:59 -07:00
Tony Tam
a215e93505 Merge pull request #294 from martoe/287
[2.0 Spec] Java generator: Implement Enums #287
2014-10-01 23:13:58 -07:00
Tony Tam
bc99361100 Merge branch 'develop_2.0' of github.com:wordnik/swagger-codegen into develop_2.0 2014-10-01 22:13:50 -07:00
Tony Tam
48f8e16fb0 added models support per #291 2014-10-01 22:12:50 -07:00
Tony Tam
ffda821f68 updated imports 2014-10-01 22:12:18 -07:00
Tony Tam
1bce51de7a updated imports 2014-10-01 22:11:51 -07:00
Lloyd
1734ac2e18 Update deprecated method calls
1. Update specs to inherit via `with Matchers`
2. Update `URLEncoder.encode` to pass "UTF-8" as charset
2014-10-02 10:49:20 +09:00
Tony Tam
ddb7aad530 Merge pull request #289 from maneeshsahu/develop_2.0
Added support for Map<String, Object>
2014-10-01 08:50:06 -07:00
Martin Ehrnhoefer
31ca832bdf [2.0 Spec] Java generator: Implement Enums #287
Unittest
2014-10-01 17:42:03 +02:00
Martin Ehrnhoefer
a80af33260 [2.0 Spec] Java generator: Implement Enums #287
Very basic implementation
2014-10-01 17:10:51 +02:00
Martin Ehrnhoefer
3971bbf334 [2.0 Spec] Java generator: Implement Enums #287
Very basic implementation
2014-10-01 16:58:38 +02:00
Maneesh Sahu-SSI
8cf9cb95f5 Added support for Map<String, Object> 2014-09-30 21:57:21 -07:00
Tony Tam
2787fa82c6 added docs 2014-09-30 06:11:51 -07:00
Tony Tam
05e1d02341 added custom class loading for configurations 2014-09-30 06:06:01 -07:00
Tony Tam
277f26a5bb Merge branch 'develop_2.0' of github.com:wordnik/swagger-codegen into develop_2.0 2014-09-30 05:10:30 -07:00
Tony Tam
c05a3c3a99 updated client 2014-09-30 05:10:24 -07:00
Tony Tam
ca06241307 updated scripts 2014-09-30 05:09:47 -07:00
Martin Ehrnhoefer
cb25eb6bc0 Windows path problem fixed (again) - #268 #269 2014-09-30 09:32:52 +02:00
James Ebentier
72bef1fb68 fixing the java comments above the api calls to allow for multiline comments in the swagger docs 2014-09-29 17:53:53 -07:00
Tony Tam
b7452fa8ee Merge pull request #284 from martoe/699
[2.0 Spec] Implement Schema Object.example field
2014-09-29 10:48:57 -07:00
Martin Ehrnhoefer
89a009c411 [2.0 Spec] Implement Schema Object.example field
see issue https://github.com/wordnik/swagger-core/issues/699,
 pull-request https://github.com/wordnik/swagger-core/pull/700
2014-09-29 16:26:06 +02:00
Tony Tam
c75a951668 updated sample 2014-09-28 00:52:32 -07:00
Tony Tam
d714f097eb updated static template 2014-09-28 00:50:47 -07:00
Tony Tam
48f05b41e4 updated android sample 2014-09-27 17:00:30 -07:00
Tony Tam
f04827c6d3 updated android sample 2014-09-27 17:00:03 -07:00
Tony Tam
2729070d7f updated android sample 2014-09-27 16:59:08 -07:00
Tony Tam
9e5576d3fe added empty var check 2014-09-27 16:50:36 -07:00
Tony Tam
530ebe1f7d added map, list model types with tests 2014-09-27 09:13:26 -07:00
Tony Tam
ba45641801 updated for objc tests 2014-09-26 22:52:27 -07:00
Tony Tam
f2b03d2930 added test files 2014-09-26 14:21:43 -07:00
Tony Tam
7006c2f6e9 updated README 2014-09-26 13:59:07 -07:00
Tony Tam
108880cbe9 updated README 2014-09-26 13:56:12 -07:00
Tony Tam
64aa948445 added android client 2014-09-26 10:25:44 -07:00
Tony Tam
eb6c09bfce merged from #271 2014-09-26 09:39:39 -07:00
Tony Tam
2dd73872a4 updated with tests 2014-09-26 09:38:07 -07:00
Tony Tam
ba94dc3d68 added subclass for ArrayModel support #273, removed path param brackets for auto-generated operationId #274 2014-09-23 21:44:09 -07:00
Tony Tam
5bc907f1d4 added template variable 2014-09-23 09:14:25 -07:00
Tony Tam
1406c36ced Merge branch 'develop_2.0' of github.com:wordnik/swagger-codegen into develop_2.0 2014-09-22 16:44:23 -07:00
Tony Tam
394a064cc3 added scripts 2014-09-22 16:44:19 -07:00
Tony Tam
db29ecc8d0 added file from master 2014-09-22 16:44:01 -07:00
Tony Tam
ec99bef893 Merge pull request #266 from FindTheBest/pull_request
Python binding generation pull request
2014-09-20 13:39:07 -07:00
Tony Tam
64f7aece12 Merge pull request #269 from martoe/develop_2.0
#268 Windows path problem fixed
2014-09-20 10:42:43 -07:00
Martin Ehrnhoefer
46f5fe0611 #268 Windows path problem fixed 2014-09-20 19:39:54 +02:00
Tony Tam
923ed596ac Merge pull request #267 from martoe/develop_2.0
Issue 244 - checkout on windows fails due to special chars
2014-09-20 08:47:44 -07:00
Tony Tam
2fd29d74f2 Merge pull request #263 from wordnik/basic-auth
Adds Basic auth as an authentication mechanism
2014-09-20 08:43:30 -07:00
Tony Tam
033a9a4b97 Merge pull request #262 from xhh/patch-1
Fixes #260 convert form parameters to string for Java client
2014-09-20 08:41:33 -07:00
isf
8762f38470 Issue 244 - checkout on windows fails due to special chars 2014-09-20 11:48:50 +00:00
Tony Tam
e5392dc21a added script 2014-09-19 16:41:09 -07:00
Tony Tam
7630fd4f85 added scripts 2014-09-19 16:36:28 -07:00
Tony Tam
134c900aa1 reorded for cleanliness 2014-09-19 16:28:56 -07:00
Tony Tam
a0876f24a3 added travis file 2014-09-19 14:38:00 -07:00
Tony Tam
504e1b28c5 added model package to templates 2014-09-19 14:05:31 -07:00
Tony Tam
885e463bcb added compatibility table 2014-09-19 11:50:20 -07:00
James Ebentier
b8f3201dba fixing a minor generation issue in api.mustashe to make sure that python scripts are as clean as possible for apis 2014-09-19 10:53:03 -07:00
James Ebentier
983edbd85b Adding in the ability to post forms using swagger codegen generate bindings for python 2014-09-19 10:52:57 -07:00
Tony Tam
24268661af Merge pull request #265 from fehguy/develop_2.0
added 2.0 support
2014-09-19 07:30:13 -07:00
Tony Tam
b90742e995 updated template location, added snapshot 2014-09-18 08:28:19 -07:00
Ivan Porto Carrero
86d56b978a also work on java 7 2014-09-16 20:52:07 -07:00
Ivan Porto Carrero
ed86bfb79b adds basic auth support 2014-09-16 20:41:32 -07:00
Ivan Porto Carrero
44a73c32fa more lenient Version.scala 2014-09-16 20:15:09 -07:00
Xu Hui Hui
39662e45b1 Fixes #260 convert form parameters to string for Java client 2014-09-16 18:58:17 +08:00
Tony Tam
9ab12eeda3 added mapping 2014-09-14 22:44:29 -07:00
Tony Tam
2128741218 removed println 2014-09-14 22:44:18 -07:00
Tony Tam
4442dcf203 added operationId generator 2014-09-14 22:44:05 -07:00
Tony Tam
fff1f30dba updated the query params 2014-09-14 21:44:07 -07:00
Tony Tam
c123bb9130 template cleanup 2014-09-14 17:52:25 -07:00
Tony Tam
5112b655bd added auth and response models 2014-09-14 17:47:59 -07:00
Tony Tam
d4122d197f updated to support jaxrs 2014-09-14 17:47:36 -07:00
webron
998bf633d8 Merge pull request #261 from czenker/patch-1
Fix typo in README.md
2014-09-12 15:48:22 +03:00
Christian Zenker
b927ffbd53 Fix typo in README.md 2014-09-12 14:26:15 +02:00
Tony Tam
cab4ffa286 property renames 2014-09-10 06:13:49 -07:00
Tony Tam
1ff47393ed Merge pull request #255 from martoe/master
Issue 244 - checkout on windows fails due to special chars
2014-09-07 23:59:01 -07:00
isf
a6ecc7a65b Issue 244 - checkout on windows fails due to special chars 2014-09-08 08:50:35 +02:00
Tony Tam
d5e62086c8 added cli parser, input opts 2014-09-04 12:42:35 -07:00
Tony Tam
370c22cddb made templates same as 2.0 2014-09-03 22:17:26 -07:00
Tony Tam
fbf8398324 fixes for return types, arrays 2014-09-03 22:10:34 -07:00
Tony Tam
79c456ecfc updates for reserved words 2014-09-03 11:18:19 -07:00
Tony Tam
bc0cc567d9 updated output filenames 2014-09-03 11:07:48 -07:00
Tony Tam
ad3006d49c added support for supporting files 2014-09-03 10:20:13 -07:00
Tony Tam
73ad502251 updated 2.0 support for objc 2014-09-03 01:10:02 -07:00
Tony Tam
7901d8a7c6 fixed api filenames 2014-09-03 00:41:06 -07:00
Tony Tam
6f63ba43ad added return types, media types 2014-09-03 00:38:24 -07:00
Tony Tam
812520e29f added support for models, partial for ops 2014-09-01 13:31:01 -07:00
Tony Tam
d1daf3a0e6 added 2.0 support files 2014-08-29 09:47:46 -07:00
Tony Tam
c5ccc0a908 update to swagger 2.0 2014-08-29 09:47:17 -07:00
Tony Tam
dbf04a9563 updated scripts 2014-08-27 01:09:28 -07:00
Tony Tam
d1603ba25e updated scalatest 2014-08-27 01:04:02 -07:00
Tony Tam
d4ce57bd15 added bigdecimal support 2014-08-27 01:03:49 -07:00
Tony Tam
5e56346dc9 updated scripts to use only assembly 2014-08-27 01:03:32 -07:00
Tony Tam
05db83a067 set to petstore 2014-08-27 00:17:45 -07:00
Tony Tam
707ee1c85b set version to 2.10.4 2014-08-27 00:17:33 -07:00
Tony Tam
a54adb925f added big decimal support 2014-08-27 00:16:12 -07:00
Tony Tam
8c53837802 updated scripts for assembly 2014-08-27 00:15:26 -07:00
Tony Tam
3625b89a15 updated to snapshot build 2014-08-26 16:53:52 -07:00
Tony Tam
2ed68c2df8 version 2.0.17 2014-08-26 16:52:26 -07:00
Tony Tam
db1915ec89 Merge pull request #252 from earldouglas/path-not-optional
Drop the 'optional' param for path params
2014-08-26 14:40:14 -07:00
James Earl Douglas
77e9ce5ede Drop the 'optional' param for path params 2014-08-26 14:38:27 -07:00
Tony Tam
013c19eb36 Merge pull request #251 from earldouglas/not-so-required
Set param as 'required' iff required, else set as 'optional'
2014-08-26 14:33:00 -07:00
James Earl Douglas
61c04ddaf1 Set param as 'required' iff required, else set as 'optional' 2014-08-26 14:31:45 -07:00
Tony Tam
b4d361130c Merge pull request #247 from xoom/issues/java_pom
Issues/java pom - remove scala dependencies from Java pom files
2014-08-25 23:05:04 -07:00
Tony Tam
8e7571c34f Merge pull request #248 from xhh/patch-1
Fixes #242 - Ruby model syntax error
2014-08-25 23:03:45 -07:00
xhh
1ba42ef6cc Fixes #242 - Ruby model syntax error 2014-08-26 09:18:54 +08:00
Rob Blair
fc77521d49 Simplify java sample poms.
* remove scala references from the java client pom template files.
* regenerate the petstore sample pom.xml, verify they can build properly.
2014-08-25 17:37:36 -07:00
Rob Blair
1522069281 Regenerate the java code before modifying templates 2014-08-25 17:35:44 -07:00
Tony Tam
a13f46e781 Merge pull request #245 from ganeshs/master
Added import mappings for java.util.Set and java.sql.Timestamp
2014-08-20 23:43:05 -07:00
Ganesh Subramanian
3ad1ecf153 Added import mapping for Timestamp 2014-08-21 12:11:19 +05:30
Ganesh Subramanian
6087181634 Added import mapping for Timestamp 2014-08-21 12:10:14 +05:30
Ganesh Subramanian
c09adc4539 Fix for issue #226 2014-08-21 12:01:44 +05:30
Tony Tam
a626dea181 Update api.mustache 2014-08-11 08:58:45 -07:00
Tony Tam
454ec4b438 fix for #235 2014-08-08 16:38:38 -04:00
Gerard Solé
4a64d602a0 Add plugin to build a jar with dependencies 2014-08-07 12:17:05 -07:00
Gerard Solé
f294656073 Edit line 76 to place pom.xml correctly 2014-08-07 11:28:08 -07:00
Ivan Porto Carrero
c7da910e68 remove sample files again 2014-08-05 10:56:20 -07:00
Ivan Porto Carrero
40d33693cf add typesafe releases resolver, fixes #232 2014-08-05 10:43:28 -07:00
Tony Tam
13eaf2bf63 Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-08-03 09:19:01 -07:00
Tony Tam
d4508ed112 updated resolvers 2014-08-03 09:16:30 -07:00
Tony Tam
c252e9f7c6 added sonatype as resolver 2014-08-03 09:12:16 -07:00
Tony Tam
6690b80b29 Update .travis.yml 2014-08-02 16:32:10 -07:00
Tony Tam
19bb97a725 updated travis to 2.10.4 2014-08-02 16:09:00 -07:00
Tony Tam
62ee62ebd3 Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-08-02 16:04:55 -07:00
Tony Tam
87083034ee Merge pull request #215 from JDiPierro/fix_java_generator_lists
Use config.processResponseClass to determine type of returnContainer
2014-07-24 11:48:19 -07:00
Tony Tam
d9de57da6f Merge pull request #223 from darkcube/master
CSharp: Multipart form submission
2014-07-23 08:43:37 -04:00
Timothy Lusk
d0b0323925 CSharp: Implement multipart form submission 2014-07-22 17:17:54 -04:00
Tony Tam
f592414409 Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-07-18 09:52:57 -06:00
Tony Tam
e1c8f58d28 added 2.10.4 2014-07-18 09:52:53 -06:00
Tony Tam
4870ed7e51 Merge pull request #220 from darkcube/master
CSharp Changes
2014-07-16 16:30:15 -06:00
Timothy Lusk
bbe48814b4 CSharp: Add optional api constructor argument to set the basePath 2014-07-15 15:41:57 -04:00
Timothy Lusk
3b6ffa4a1f CSharp: Close the WebResponse if we throw an ApiException 2014-07-15 15:41:56 -04:00
Tony Tam
527c40b996 Merge pull request #211 from wcandillon/patch-1
Link back to the swagger-js-codegen project
2014-07-13 07:21:22 -07:00
Justin DiPierro
3aa2c86991 Output the resourcePath when no models are found rather than the basePath 2014-07-10 10:14:22 -04:00
Justin DiPierro
e2a20447df Fixed comment in test 2014-07-10 10:02:18 -04:00
Tony Tam
5d42c8cc5f moved to petstore 2014-07-04 10:19:48 -07:00
Tony Tam
256485ec5b updated template 2014-07-04 10:19:28 -07:00
Tony Tam
7ab0394e76 added node.js instead of jetty 2014-07-04 10:19:09 -07:00
Tony Tam
89b04b2e10 formatting 2014-07-04 10:18:44 -07:00
Tony Tam
a019a438e0 changed to petstore sample 2014-07-04 10:08:54 -07:00
Justin DiPierro
9834059786 Fixed BasicScalaGeneratorTest to expect Some(List) 2014-07-03 11:32:37 -04:00
Justin DiPierro
550fade9e0 Codegen.apiToMap should use config.processResponseClass when setting the returnContainer property. Test passes now 2014-07-03 11:24:05 -04:00
Justin DiPierro
aa1b4fc0fb Wrote failing test for Codegen 2014-07-03 11:23:07 -04:00
Tony Tam
5a659803a8 Merge pull request #212 from darkcube/master
Various csharp codegen fixes
2014-06-29 13:59:21 -07:00
Timothy Lusk
7bc7789e81 CSharp: Invoker should handle WebException and rethrow ApiException 2014-06-27 17:55:10 -04:00
Timothy Lusk
cf0721da73 CSharp: Use nullable primitive types to allow optional parameters 2014-06-27 16:10:45 -04:00
Timothy Lusk
dcbf4d1bfd CSharp: Use the correct model package name 2014-06-27 16:01:24 -04:00
William Candillon
017b578502 Link back to the swagger-js-codegen project 2014-06-26 15:05:33 +02:00
Tony Tam
58bade3b01 Update README.md 2014-06-19 09:33:41 -07:00
Tony Tam
02631e674a Merge pull request #207 from emmekappa/master
Fixing extensions and namespaces for csharp common files.
2014-06-17 10:53:17 -07:00
Michele Cantelli
5f5e534d05 CSharp: renaming the "packages" to follow the .NET style. 2014-06-17 16:22:04 +02:00
Michele Cantelli
51deeb478d Fixing extensions for csharp common files. 2014-06-17 15:18:58 +02:00
Tony Tam
acff8229b3 Merge pull request #206 from xoom/issue/modelsFromStatus
Issue/models from status - utilize the responseModel, if present
2014-06-16 17:03:17 -07:00
Rob Blair
233555790a Regenerate sample java files with example response status codes
* none of existing examples use the responseMessage.responseModel feature, but I have tested it.
* Didn't want to muck with sample json
* update the scripts used to generate both java versions.
* see https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#525-response-message-object
2014-06-16 12:59:53 -07:00
Rob Blair
d5ddac8e7e Update java mustache to show error status codes and models in generated API, in comments.
* I wonder if there is some clever way to make exceptions based on the model thrown, and automatically fill them in with the parsed error models?
* Until then, it's comments, and roll your own.
2014-06-16 12:51:35 -07:00
Rob Blair
e8210cd5e3 allow list of models to be returned in errors
* for example, a list of validation errors with an exceptional status
2014-06-16 12:40:44 -07:00
Rob Blair
2dc6b485e0 Generate classes from the models declared in 'responseModel'
* ResponseMessage has new constructor parameter, an optional string for responseModel
* Make sure we add it to list of models
* make sure the responseModel is part of the error list available to mustache
2014-06-16 12:34:44 -07:00
Tony Tam
11bede2b7d improved validation messages 2014-06-12 00:45:27 -07:00
Tony Tam
ed51dd9dea added files 2014-06-11 06:41:59 -07:00
Tony Tam
218f514005 updated node sample 2014-06-11 06:41:31 -07:00
Tony Tam
209e8e066c Merge pull request #201 from xoom/issue/JavaSafeApiName
coerce API names for classesand files to valid Java names
2014-06-11 06:12:55 -07:00
Tony Tam
7d05b01a56 Merge pull request #202 from gonimar/patch-1
Unused local variable 'json_data'.
2014-06-11 06:12:36 -07:00
Tony Tam
64f6bedc37 Merge branch 'repackage' 2014-06-11 06:12:15 -07:00
Tony Tam
4ae4aa98bb formatting 2014-06-11 06:11:45 -07:00
Tony Tam
db8bda087b made nickname optional 2014-06-11 06:11:31 -07:00
Tony Tam
06eb52118e updated to 2.3.0 release 2014-06-11 06:03:44 -07:00
Tony Tam
63be7d0069 removed println 2014-06-11 05:50:44 -07:00
Tony Tam
c7468125fa added clientName 2014-06-10 20:37:36 -07:00
Tony Tam
7b3d8bf799 added file upload support 2014-06-10 20:37:24 -07:00
Tony Tam
c4913fe583 wrapped in apiInfo 2014-06-10 20:37:08 -07:00
Tony Tam
d3339cb087 fixed string default 2014-06-10 20:36:58 -07:00
Tony Tam
ba4fda12dc added additional params 2014-06-10 20:36:29 -07:00
Tony Tam
7a6d6d27ff enabled logging 2014-06-10 20:36:10 -07:00
Tony Tam
bcabb03225 added support for nickname generation 2014-06-10 20:05:19 -07:00
Tony Tam
a404823c54 updated copyright 2014-06-10 17:23:35 -07:00
Tony Tam
96ea70e3c9 added className key 2014-06-10 17:23:20 -07:00
Tony Tam
9a01331ddd updated copyright 2014-06-10 16:58:43 -07:00
Tony Tam
3bfa468ed1 fixed filemap 2014-06-10 16:57:39 -07:00
Tony Tam
fdf8572535 updated copyright 2014-06-10 16:57:12 -07:00
Tony Tam
cff8b1552d updated copyright 2014-06-10 16:57:01 -07:00
Tony Tam
e73dd0a7c4 updated copyrights 2014-06-10 16:56:06 -07:00
Tony Tam
9c4c2dfd37 updated copyrights 2014-06-10 16:55:57 -07:00
Tony Tam
2f8355c953 regenerated client 2014-06-10 16:55:34 -07:00
Tony Tam
3f480482b6 regenerated client 2014-06-10 16:55:17 -07:00
Tony Tam
8274196999 regenerated client 2014-06-10 16:55:13 -07:00
Tony Tam
4e8c71f754 regenerated client 2014-06-10 16:54:48 -07:00
Tony Tam
57e7b41e9c regenerated client 2014-06-10 16:52:16 -07:00
Tony Tam
58d9894f1f regenerated client 2014-06-10 16:51:41 -07:00
Tony Tam
4b4d4d32cd regenerated client 2014-06-10 16:51:36 -07:00
Tony Tam
6a2ea9f614 regenerated client 2014-06-10 16:51:10 -07:00
Tony Tam
0d6754e167 regenerated client 2014-06-10 16:50:17 -07:00
Tony Tam
cb5c2a9708 regenerated client 2014-06-10 16:48:27 -07:00
Tony Tam
dc8ad7edf5 updated client 2014-06-10 16:48:05 -07:00
Tony Tam
52bc82149f file rename 2014-06-10 16:34:40 -07:00
Tony Tam
f53b5e27e0 updated scalatra version, templates for files, forms 2014-06-10 15:51:15 -07:00
Tony Tam
ce5be3452c added patch class 2014-06-10 15:50:49 -07:00
Tony Tam
ce14c225e5 added patch 2014-06-10 10:36:46 -07:00
Tony Tam
b78721826e regenerated client 2014-06-10 10:36:13 -07:00
Tony Tam
85113df113 regenerated client 2014-06-10 08:41:44 -07:00
Tony Tam
607b56cb87 removed println 2014-06-10 08:40:19 -07:00
Tony Tam
2dbf8b7d41 regenerated 2014-06-10 08:40:03 -07:00
Tony Tam
7d4c10043d updated client 2014-06-10 08:22:40 -07:00
Tony Tam
64604124c9 added array support 2014-06-10 08:22:08 -07:00
Tony Tam
50f20ad836 updated templates 2014-06-10 08:21:51 -07:00
Tony Tam
ac40283501 updated samples 2014-06-10 08:01:53 -07:00
Sergey Gonimar
e03d4fc1a5 Unused local variable 'json_data'.
The value of the variable is not used anywhere.
2014-06-10 19:25:00 +06:00
Rob Blair
05e9443db5 coerce API names of class and file valid Java names
* Swagger allows names of apis to include characters like '-' Java does not like that
* use same replace strings as used in toVarName
2014-06-09 17:04:57 -07:00
Tony Tam
1250cc758f updated version 2014-06-09 16:34:42 -07:00
Tony Tam
a18784da6c updated file maps 2014-06-09 15:05:23 -07:00
Tony Tam
c87d637edd regenerated 2014-06-06 00:27:40 -07:00
Tony Tam
bf4a4e5296 fixed imports, nesting 2014-06-06 00:27:15 -07:00
Tony Tam
4f7b80dad2 added debug, fixed headers 2014-06-05 22:49:09 -07:00
Tony Tam
8a2f9bc7bb compatibility 2014-06-05 20:08:59 -07:00
Tony Tam
b9806c183b fixed case 2014-06-05 20:08:37 -07:00
Tony Tam
5aa4c4c999 made snapshot 2014-05-31 16:04:19 -07:00
Tony Tam
424cfac80f updated config 2014-05-30 16:27:54 -07:00
Ivan Porto Carrero
715913f3b4 Update slightly add some test files 2014-05-30 15:17:53 -07:00
Tony Tam
1c2c4fdcd3 removed function override 2014-05-30 15:03:10 -07:00
Ivan Porto Carrero
2ea6c2a3a7 Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-05-30 14:25:57 -07:00
Tony Tam
d91da857a0 removed unused code 2014-05-30 09:59:27 -07:00
Tony Tam
31e65969b3 removed printlns, cruft 2014-05-30 07:53:27 -07:00
Tony Tam
df250bc056 fixed model mapping, refactoring the processing of apiMap and modelMap so it's executed just once 2014-05-30 07:29:19 -07:00
Tony Tam
1569274684 fixed package 2014-05-20 00:14:01 -07:00
Tony Tam
6d8f751da4 added model package 2014-05-19 23:23:23 -07:00
Tony Tam
c2dd00a4ab fixed return type 2014-05-19 15:08:44 -07:00
Tony Tam
9e6ae6eef8 added opts for input 2014-05-15 08:51:41 -04:00
Tony Tam
58b985ba02 moved packages to address collisions with swagger-core per #145 2014-05-14 18:23:32 -04:00
Tony Tam
b4f3143c8c Merge pull request #159 from yanoosh/php-fix-sanitize
PHP - Improved/fixed serialization and deserialize.
2014-05-01 20:31:13 -07:00
Tony Tam
84ad6b5d50 rebuilt docs 2014-05-01 20:19:40 -07:00
Tony Tam
32c14af5ce added resize 2014-05-01 20:18:23 -07:00
Tony Tam
46023c47f5 Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-05-01 20:17:53 -07:00
Tony Tam
71212e5f68 reverted to artifactVersion 2014-05-01 20:16:46 -07:00
Tony Tam
6d1c34048c fix for #176 2014-05-01 20:16:27 -07:00
Tony Tam
f67006057e updated version 2014-05-01 20:14:41 -07:00
Tony Tam
e1e397a7b5 Merge pull request #179 from j-unior/scala-2.10
Added scala 2.10 support in generated maven profile.
2014-05-01 18:03:22 -07:00
Tony Tam
0f35799a77 fixed start script #188 2014-04-29 09:46:49 -07:00
Tony Tam
be44221d98 Merge pull request #187 from earldouglas/return-generated-files
Return files generated from BasicGenerator#generateClientWithoutExit
2014-04-24 16:06:12 -07:00
James Earl Douglas
94ad254a58 Return files generated from BasicGenerator#generateClientWithoutExit 2014-04-24 15:14:41 -07:00
James Earl Douglas
666a4be1f2 Return files generated from Codegen#writeSupportingClasses 2014-04-24 15:12:11 -07:00
James Earl Douglas
e542fbd0a2 De-duplicate code from Codegen#writeSupportingClasses 2014-04-24 15:07:45 -07:00
Pat
f4b2d13aa4 Update README.md 2014-04-09 10:15:08 -07:00
j-unior
abcae6da96 Added scala 2.10 support in generated maven profile. You can enable it with mvn install -P scala_2.10 on generated client 2014-04-01 16:56:08 +03:00
Tony Tam
1b9b3eaa8e Merge pull request #175 from STEAMULO/master
Filename misprint for Android generation
2014-03-25 11:33:03 -07:00
aansel
0babc4f192 Filename misprint for Android generation 2014-03-25 18:44:05 +01:00
webron
e51ffb37b4 Update README.md 2014-03-23 13:16:02 +02:00
Tony Tam
2fba96713c Merge pull request #172 from giovannibotta/master
Minor change to map used when generating supporting files
2014-03-19 08:27:49 -07:00
giodude
dccf8edc25 Minor change to map used when generating supporting files. 2014-03-19 11:18:23 -04:00
webron
d98aeac818 Create LICENSE 2014-03-19 16:08:55 +02:00
webron
62bfc4ea19 Update README.md
Updated license year.
2014-03-19 16:08:38 +02:00
Tony Tam
8d74029fba Merge pull request #170 from hsanjuan/master
Issue #168: Let runscala.sh run from everywhere without breaking
2014-03-18 18:54:28 -07:00
Hector Sanjuan
809cb5cf1f Issue #168: Let runscala.sh run from everywhere without breaking and correctly
setting the classpath
2014-03-17 16:21:36 +01:00
Tony Tam
a4196609c9 added friendly error message when SSL validation fails 2014-03-06 08:29:02 -08:00
Tony Tam
e7eedcf48d removed printlns 2014-03-05 07:54:12 -08:00
Tony Tam
8bf042b153 updated sample with form param support 2014-03-05 07:54:03 -08:00
Tony Tam
8325a12faf fixed hasMore 2014-03-04 20:05:16 -08:00
Tony Tam
03abccd8e8 fix for #154 2014-03-04 19:48:13 -08:00
Janusz Jablonski
19e79fedb2 Added backslash before DateTime object. 2014-03-03 00:40:45 +01:00
Tony Tam
71eacaa3b1 Merge pull request #160 from yanoosh/php-removed-escape
PHP - Removed escapeReservedWord method.
2014-03-02 13:30:08 -08:00
Janusz Jablonski
7cfa46d838 Removed escapeReservedWord method. 2014-03-02 18:31:35 +01:00
Janusz Jablonski
7989e78460 Improved/fixed serialization and deserialize. 2014-03-02 14:44:46 +01:00
Tony Tam
08466f615f Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-02-25 12:54:12 -08:00
Tony Tam
880d14990f added patch support 2014-02-25 12:53:11 -08:00
Tony Tam
39ac8f6d46 added patch support 2014-02-25 12:52:49 -08:00
Tony Tam
685fc7066f Update README.md 2014-02-22 07:21:13 -08:00
Tony Tam
127600e728 Update README.md 2014-02-21 17:29:22 -08:00
Tony Tam
d764328026 updated readme 2014-02-21 17:22:48 -08:00
Tony Tam
cae8296999 updated readme 2014-02-21 17:21:56 -08:00
Tony Tam
86efb71124 updated readme 2014-02-21 17:21:50 -08:00
Tony Tam
0899b08b8c Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-02-21 17:20:16 -08:00
Tony Tam
a770db9d3e added readme 2014-02-21 17:20:06 -08:00
Tony Tam
87b5c43166 Merge pull request #158 from mkantor/objc-safe-var-names
Prevent ObjC generator from producing invalid var names.
2014-02-21 13:41:26 -08:00
Matt Kantor
d14ab2aeff Prevent ObjC generator from producing invalid var names. 2014-02-21 13:35:13 -08:00
Ivan Porto Carrero
b39a609226 Merge branch 'master' of github.com:wordnik/swagger-codegen 2013-11-09 12:18:42 -08:00
Ivan Porto Carrero
d25f64cca0 change to return transpor client in async scala client 2013-11-09 12:18:20 -08:00
1449 changed files with 67152 additions and 61771 deletions

View File

@@ -1,3 +1,5 @@
language: scala
scala:
- 2.10.2
sudo: false
language: java
script: mvn verify
jdk:
- oraclejdk7

340
README.md
View File

@@ -1,230 +1,276 @@
# Swagger Code Generator
[![Build Status](https://travis-ci.org/wordnik/swagger-codegen.png)](https://travis-ci.org/wordnik/swagger-codegen)
[![Build Status](https://travis-ci.org/swagger-api/swagger-codegen.png)](https://travis-ci.org/swagger-api/swagger-codegen)
## Overview
This is the swagger codegen project, which allows generation of client libraries automatically from a
Swagger-compliant server. You can find out more about both the spec and the framework at
http://swagger.wordnik.com. For more information about Wordnik's APIs, please visit http://developer.wordnik.com.
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.
## Compatability
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)
### Prerequisites
You need the following installed and available in your $PATH:
* [Java 1.7](http://java.oracle.com)
Note! Some folks have had issues with OOM errors with java version "1.6.0_51". It's strongly suggested that you upgrade to 1.7!
* [Java 7](http://java.oracle.com)
* [Apache maven 3.0.3 or greater](http://maven.apache.org/)
* [Scala 2.9.1](http://www.scala-lang.org)
* [sbt (only download if you're building on Windows)](http://www.scala-sbt.org/)
You also need to add the scala binary to your PATH.
After cloning the project, you need to build it from source with this command:
After cloning the project, you can build it from source with this command:
```
./sbt assembly
mvn package
```
or for Windows...
```
sbt assembly
```
### To generate a sample client library
You can build a client against Wordnik's [petstore](http://petstore.swagger.wordnik.com) API as follows:
You can build a client against the swagger sample [petstore](http://petstore.swagger.io) API as follows:
```
./bin/scala-petstore.sh
./bin/java-petstore.sh
```
This will run the script in [samples/client/petstore/ScalaPetstoreCodegen.scala](https://github.com/wordnik/swagger-codegen/blob/master/samples/client/petstore/scala/ScalaPetstoreCodegen.scala) and create the client. You can then
compile and run the client, as well as unit tests against it:
This will run the generator with this command:
```
cd samples/client/petstore/scala
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
```
With a number of options. You can get the options with the `help generate` command:
```
NAME
swagger generate - Generate code with chosen lang
SYNOPSIS
swagger generate [(-a <authorization> | --auth <authorization>)]
(-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)]
OPTIONS
-a <authorization>, --auth <authorization>
adds authorization headers when fetching the swagger definitions
remotely. Pass in a URL-encoded string of name:header with a comma
separating multiple values
-i <spec file>, --input-spec <spec file>
location of the swagger spec, as URL or file (required)
-l <language>, --lang <language>
client language to generate (maybe class name in classpath,
required)
-o <output directory>, --output <output directory>
where to write the generated files (current dir by default)
-t <template directory>, --template-dir <template directory>
folder containing the template files
-v, --verbose
verbose mode
```
You can then compile and run the client, as well as unit tests against it:
```
cd samples/client/petstore/java
mvn package
```
Other languages have petstore samples, too:
```
./bin/flash-petstore.sh
./bin/android-petstore.sh
./bin/java-petstore.sh
./bin/objc-petstore.sh
./bin/php-petstore.sh
./bin/python-petstore.sh
./bin/python3-petstore.sh
./bin/ruby-petstore.sh
```
### Generating libraries from your server
It's just as easy--you can either run the default generators:
```
./bin/runscala.sh com.wordnik.swagger.codegen.BasicScalaGenerator http://petstore.swagger.wordnik.com/api/api-docs special-key
```
Replace `Scala` with `Flash`, `Java`, `Objc`, `PHP`, `Python`, `Python3`, `Ruby`.
You will probably want to override some of the defaults--like packages, etc. For doing this, just create a scala
script with the overrides you want. Follow [ScalaPetstoreCodegen](https://github.com/wordnik/swagger-codegen/blob/master/samples/client/petstore/scala/ScalaPetstoreCodegen.scala) as an example:
For example, create `src/main/scala/MyCodegen.scala` with these contents:
```scala
import com.wordnik.swagger.codegen.BasicScalaGenerator
object MyCodegen extends BasicScalaGenerator {
def main(args: Array[String]) = generateClient(args)
// location of templates
override def templateDir = "scala"
// where to write generated code
override def destinationDir = "client/scala/src/main/scala"
// api invoker package
override def invokerPackage = "com.myapi.client"
// package for models
override def modelPackage = Some("com.myapi.client.model")
// package for api classes
override def apiPackage = Some("com.myapi.client.api")
// supporting classes
override def supportingFiles = List(
("apiInvoker.mustache", destinationDir + java.io.File.separator + packageName.replaceAll("\\.", java.io.File.separator), "ApiInvoker.scala"),
("pom.mustache", destinationDir, "pom.xml")
)
}
```
Now you can generate your client like this:
```
./bin/runscala.sh src/main/scala/MyCodegen.scala http://my.api.com/resources.json super-secret-key
```
w00t! Thanks to the scala interpretor, you didn't even need to recompile.
It's just as easy--just use the `-i` flag to point to either a server or file.
### Modifying the client library format
Don't like the default swagger client syntax? Want a different language supported? No problem! Swagger codegen
processes mustache templates with the [scalate](http://scalate.fusesource.org/) engine. You can modify our templates or
make your own.
Don't like the default swagger client syntax? Want a different language supported? No problem! Swagger codegen processes mustache templates with the [jmustache](https://github.com/samskivert/jmustache) engine. You can modify our templates or make your own.
You can look at `src/main/resources/${your-language}` for examples. To make your own templates, create your own files
and override the `templateDir` in your script to point to the right place. It actually is that easy.
You can look at `modules/swagger-codegen/src/main/resources/${your-language}` for examples. To make your own templates, create your own files and use the `-t` flag to specify your template folder. It actually is that easy.
### Making your own codegen modules
If you're starting a project with a new language and don't see what you need, swagger-codegen can help you create a project to generate your own libraries:
```
java -jar modules/swagger-codegen-distribution/target/swagger-codegen-cli.jar meta \
-o output/myLibrary -n myClientCodegen -p com.my.company.codegen
```
This will write, in the folder `output/myLibrary`, all the files you need to get started, including a README.md. Once modified and compiled, you can load your library with the codegen and generate clients with your own, custom-rolled logic.
### Where is Javascript???
See our [javascript library](http://github.com/wordnik/swagger.js)--it's completely dynamic and doesn't require
See our [javascript library](http://github.com/swagger-api/swagger-js)--it's completely dynamic and doesn't require
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)
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:
```
-DfileMap=/path/to/files
-i ./modules/swagger-codegen/src/test/resources/2_0/petstore.json
```
Or for example:
Great for creating libraries on your ci server, from the [Swagger Editor](http://editor.swagger.io)... or while coding on an airplane.
### 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:
```
./bin/java-petstore-filemap.sh
$ ls -1 modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/
AndroidClientCodegen.java
AsyncScalaClientCodegen.java
CSharpClientCodegen.java
JavaClientCodegen.java
JaxRSServerCodegen.java
NodeJSServerCodegen.java
ObjcClientCodegen.java
PhpClientCodegen.java
PythonClientCodegen.java
RubyClientCodegen.java
ScalaClientCodegen.java
ScalatraServerCodegen.java
SpringMVCServerCodegen.java
StaticDocCodegen.java
StaticHtmlGenerator.java
SwaggerGenerator.java
SwaggerYamlGenerator.java
TizenClientCodegen.java
```
Which simple passes `-DfileMap=src/test/resources/petstore` as an argument. Great for creating libraries on your
ci server... or while coding on an airplane.
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.
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.*;
public class MyObjcCodegen extends ObjcClientCodegen {
static {
PREFIX = "HELO";
}
}
```
and specify the `classname` when running the generator:
```
-l com.mycompany.swagger.codegen.MyObjcCodegen
```
Your subclass will now be loaded and overrides the `PREFIX` value in the superclass.
### Validating your swagger spec
You can use the validation tool to see that your server is creating a proper spec file. If you want to learn
more about the spec file and format, please see [swagger-core](https://github.com/wordnik/swagger-core/wiki). This
tool will read the server and generate a report of any violations of the spec. If there are violations, the
client codegen and ui may not work correctly.
To validate an api and write output to ./swagger-errors.html:
You have options. The easiest is to use our [online validator](https://github.com/swagger-api/validator-badge) which not only will let you validate your spec, but with the debug flag, you can see what's wrong with your spec. For example:
http://online.swagger.io/validator/debug?url=http://petstore.swagger.io/v2/swagger.json
### Generating dynamic html api documentation
To do so, just use the `-l dynamic-html` flag when reading a spec file. This creates HTML documentation that is available as a single-page application with AJAX. To view the documentation:
```
./bin/validate.sh http://petstore.swagger.wordnik.com/api/api-docs "specia-key" ./swagger-errors.html
cd samples/dynamic-html/
npm install
node .
```
### Generating static api documentation
If you need to make static pages or don't want the sandbox of the swagger-ui, you can use the codegen to build them. Remember, the engine is just using mustache templates--the output format is your call.
Which launches a node.js server so the AJAX calls have a place to go.
### Generating static html api documentation
To do so, just use the `-l html` flag when reading a spec file. This creates a single, simple HTML file with embedded css so you can ship it as an email attachment, or load it from your filesystem:
```
./bin/static-docs.sh
cd samples/html/
open index.html
```
Will produce the output here:
```
https://github.com/wordnik/swagger-codegen/tree/master/samples/docs/swagger-static-docs
```
which is based on these templates:
```
https://github.com/wordnik/swagger-codegen/tree/master/src/main/resources/swagger-static
```
and looks like this
![Image](https://raw.github.com/wordnik/swagger-codegen/master/samples/docs/swagger-static-docs/static-docs.png)
### To build a server stub
You can also use the codegen to generate a server for a couple different frameworks. Take a look here:
* [javascript node.js Server generator](https://github.com/wordnik/swagger-codegen/tree/master/samples/server-generator/node)
* [ruby sinatra generator](https://github.com/wordnik/swagger-codegen/tree/master/samples/server-generator/sinatra)
* [scala scalatra generator](https://github.com/wordnik/swagger-codegen/tree/master/samples/server-generator/scalatra)
* [java jax-rs generator](https://github.com/wordnik/swagger-codegen/tree/master/samples/server-generator/java-jaxrs)
### Migrating from Swagger 1.1 to 1.2 format
If you've spent time hand-crafting your swagger spec files, you can use the [SpecConverter](https://github.com/wordnik/swagger-codegen/blob/master/src/main/scala/com/wordnik/swagger/codegen/SpecConverter.scala) to do the dirty work. For example:
```bash
$ ./bin/update-spec.sh http://developer.wordnik.com/v4/resources.json wordnik-developer
writing file wordnik-developer/api-docs
calling: http://developer.wordnik.com/v4/account.json
calling: http://developer.wordnik.com/v4/word.json
calling: http://developer.wordnik.com/v4/words.json
calling: http://developer.wordnik.com/v4/wordList.json
calling: http://developer.wordnik.com/v4/wordLists.json
writing file wordnik-developer/account
writing file wordnik-developer/word
writing file wordnik-developer/words
writing file wordnik-developer/wordList
writing file wordnik-developer/wordLists
### node.js
```
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i http://petstore.swagger.io/v2/swagger.json \
-l nodejs \
-o samples/server/petstore/nodejs
```
Will read the 1.1 spec from wordnik developer and write it into the folder called `wordnik-developer`.
### rails-grape
#### Not yet migrated to this branch
### scala scalatra
```
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i http://petstore.swagger.io/v2/swagger.json \
-l scalatra \
-o samples/server/petstore/scalatra
```
### java jax-rs
```
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i http://petstore.swagger.io/v2/swagger.json \
-l jaxrs \
-o samples/server/petstore/jaxrs
```
### java spring-mvc
```
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i http://petstore.swagger.io/v2/swagger.json \
-l spring-mvc \
-o samples/server/petstore/spring-mvc
```
### To build the codegen library
This will create the swagger-codegen library from source.
```
./sbt assembly
mvn package
```
Note! The templates are included in the library generated. If you want to modify the templates, you'll need to
either repackage the library OR modify your codegen script to use a file path!
Note! The templates are included in the library generated. If you want to modify the templates, you'll need to either repackage the library OR specify a path to your scripts
License
-------
Copyright 2013 Wordnik, Inc.
Copyright 2015 Reverb Technologies, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@@ -1,7 +0,0 @@
val version = scala.util.Properties.scalaPropOrElse("version.number", "unknown").toString match {
case "2.10.0" => "2.10"
case "2.10.2" => "2.10"
case "2.10.3" => "2.10"
case e: String => e
}
println(version)

View File

@@ -18,20 +18,16 @@ if [ ! -d "${APP_DIR}" ]; then
fi
cd $APP_DIR
./bin/java-wordnik-api.sh
./bin/php-wordnik-api.sh
./bin/python3-wordnik-api.sh
./bin/objc-wordnik-api.sh
./bin/python-wordnik-api.sh
./bin/scala-wordnik-api.sh
./bin/android-java-petstore.sh
./bin/csharp-petstore.sh
./bin/flash-petstore.sh
./bin/dynamic-html.sh
./bin/html-petstore.sh
./bin/jaxrs-petstore-server.sh
./bin/java-petstore.sh
./bin/objc-petstore.sh
./bin/php-petstore.sh
./bin/python-petstore.sh
./bin/python3-petstore.sh
./bin/ruby-petstore.sh
./bin/objc-petstore.sh
./bin/scala-petstore.sh
./bin/spring-mvc-petstore-server.sh
./bin/tizen-petstore.sh

24
bin/all-wordnik.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/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
cd $APP_DIR
./bin/android-java-wordnik-api.sh
./bin/java-wordnik-api.sh
./bin/objc-wordnik-api.sh
./bin/scala-wordnik-api.sh

View File

@@ -1,7 +1,6 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
@@ -18,15 +17,15 @@ if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
cd $APP_DIR
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="$@ samples/client/petstore/android-java/AndroidJavaPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/android-java -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l android -o samples/client/petstore/android-java"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,7 +1,6 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
@@ -18,15 +17,15 @@ if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
cd $APP_DIR
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="$@ samples/client/petstore/android-java/AndroidJavaPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/wordnik.json -l android -o samples/client/wordnik/android-java"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,7 +1,6 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
@@ -18,15 +17,15 @@ if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
cd $APP_DIR
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="$@ samples/client/petstore/csharp/CsharpPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l csharp -o samples/client/petstore/csharp"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,7 +1,6 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
@@ -18,15 +17,15 @@ if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
cd $APP_DIR
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="$@"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l dynamic-html -o samples/dynamic-html"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
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
cd $APP_DIR
# 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="$@ samples/client/petstore/flash/FlashPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -1,7 +1,6 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
@@ -18,15 +17,15 @@ if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
cd $APP_DIR
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="$@ samples/client/petstore/python3/Python3PetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l html -o samples/html"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
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
cd $APP_DIR
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DfileMap=src/test/resources/petstore-1.1/resources.json -DloggerPath=conf/log4j.properties"
ags="$@ samples/client/petstore/java/JavaPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -1,7 +1,6 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
@@ -18,15 +17,15 @@ if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
cd $APP_DIR
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="$@ samples/client/petstore/java/JavaPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -o samples/client/petstore/java"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,7 +1,6 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
@@ -18,15 +17,15 @@ if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
cd $APP_DIR
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 -DfileMap=samples/client/wordnik-api/spec-files/resources.json"
ags="$@ samples/client/wordnik-api/java/JavaWordnikApiCodegen.scala http://api.wordnik.com/v4/resources.json"
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/wordnik.json -l java -o samples/client/wordnik/java"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,7 +1,6 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
@@ -18,15 +17,15 @@ if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
cd $APP_DIR
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 -DfileMap=samples/client/wordnik-api/spec-files"
ags="$@ SwaggerDocGenerator http://developer.wordnik.com/v4/resources.json"
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"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,7 +1,6 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
@@ -18,14 +17,15 @@ if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
cd $APP_DIR
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.
ags="com.wordnik.swagger.codegen.SpecConverter $@"
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 nodejs -o samples/server/petstore/nodejs"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi
java $JAVA_OPTS -Dservice -jar $executable $ags

View File

@@ -1,9 +1,6 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
version="$(scala ./bin/Version.scala)"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
@@ -20,15 +17,15 @@ if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
cd $APP_DIR
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="$@ samples/client/petstore/objc/ObjcPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/objc -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l objc -o samples/client/petstore/objc"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi
java -DappName=PetstoreClient $JAVA_OPTS -jar $executable $ags

View File

@@ -1,7 +1,6 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
@@ -18,15 +17,15 @@ if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
cd $APP_DIR
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 -DfileMap=samples/client/wordnik-api/spec-files"
ags="$@ samples/client/wordnik-api/objc/ObjcWordnikApiCodegen.scala http://api.wordnik.com/v4/resources.json"
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/wordnik.json -l objc -o samples/client/wordnik/objc"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,7 +1,6 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
@@ -18,15 +17,15 @@ if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
cd $APP_DIR
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="$@ samples/client/petstore/php/PHPPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/php -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l php -o samples/client/petstore/php"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
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
cd $APP_DIR
# 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 -DfileMap=samples/client/wordnik-api/spec-files/resources.json"
ags="$@ samples/client/wordnik-api/php/PHPWordnikApiCodegen.scala http://api.wordnik.com/v4/resources.json"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -1,7 +1,6 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
@@ -18,15 +17,15 @@ if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
cd $APP_DIR
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="$@ samples/client/petstore/python/PythonPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/python -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l python -o samples/client/petstore/python"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
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
cd $APP_DIR
# 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 -DfileMap=samples/client/wordnik-api/spec-files/resources.json"
ags="$@ samples/client/wordnik-api/python/PythonWordnikApiCodegen.scala http://api.wordnik.com/v4/resources.json"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
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
cd $APP_DIR
# 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 -DfileMap=samples/client/wordnik-api/spec-files/resources.json"
ags="$@ samples/client/wordnik-api/python3/Python3WordnikApiCodegen.scala http://api.wordnik.com/v4/resources.json"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -1,7 +1,6 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
@@ -18,15 +17,15 @@ if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
cd $APP_DIR
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="$@ samples/client/petstore/ruby/RubyPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
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"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi
java $JAVA_OPTS -jar $executable $ags

31
bin/scala-async-petstore.sh Executable file
View 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/asyncscala -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l async-scala -o samples/client/petstore/async-scala"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,31 +0,0 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
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
cd $APP_DIR
# if you've executed sbt assembly previously it will use that instead.
ags="com.wordnik.swagger.codegen.ScalaAsyncClientGenerator $@"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -1,7 +1,6 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
@@ -18,15 +17,15 @@ if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
cd $APP_DIR
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="$@ samples/client/petstore/scala/ScalaPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/scala -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l scala -o samples/client/petstore/scala"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,7 +1,6 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
@@ -18,15 +17,15 @@ if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
cd $APP_DIR
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 -DfileMap=samples/client/wordnik-api/spec-files/resources.json"
ags="$@ samples/client/wordnik-api/scala/ScalaWordnikApiCodegen.scala http://api.wordnik.com/v4/resources.json"
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/wordnik.json -l scala -o samples/client/wordnik/scala"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi
java $JAVA_OPTS -jar $executable $ags

31
bin/scalatra-petstore-server.sh Executable file
View 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/scalatra -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l scalatra -o samples/server/petstore/scalatra"
java $JAVA_OPTS -jar $executable $ags

View 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/JavaSpringMVC -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l spring-mvc -o samples/server/petstore/spring-mvc"
java $JAVA_OPTS -jar $executable $ags

31
bin/tizen-petstore.sh Executable file
View 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/tizen -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l tizen -o samples/client/petstore/tizen"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,31 +0,0 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
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
cd $APP_DIR
# if you've executed sbt assembly previously it will use that instead.
ags="com.wordnik.swagger.codegen.spec.Validator $@"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -1,56 +0,0 @@
fs = require('fs')
yaml = require('js-yaml')
var args = process.argv.splice(2);
if(args.length == 0) {
process.exit(1);
}
var arg0 = args[0];
var outputdir = ".";
if(args.length > 1) {
outputdir = args[1];
}
var file = fs.lstatSync(arg0);
if(file.isFile()) {
convert(arg0, outputdir);
}
else if (file.isDirectory()) {
var files = fs.readdirSync(arg0);
files.map(function(item) {
var filename = arg0 + "/" + item;
var file = fs.lstatSync(filename);
if(file.isFile()) {
convert(filename, outputdir);
}
});
}
function convert(filename, outputdir) {
console.log("converting " + filename);
fs.readFile(filename, "utf8", function (err, data) {
if(err) {
console.log(err);
}
else {
try {
var js = yaml.load(data);
var prettyJs = JSON.stringify(js, undefined, 2);
var outputFilename = outputdir + "/" + filename.split("/").pop().replace(".yml", "") + ".json";
console.log("writing to " + outputFilename);
fs.writeFile(outputFilename, prettyJs, function(err) {
if(err) {
console.log(err);
}
});
}
catch (err) {
console.log(err);
}
}
});
}

133
build.sbt
View File

@@ -1,133 +0,0 @@
import xml.Group
import AssemblyKeys._
organization := "com.wordnik"
name := "swagger-codegen"
version := "2.0.13"
scalaVersion := "2.10.1"
crossVersion := CrossVersion.full
javacOptions ++= Seq("-target", "1.6", "-source", "1.6", "-Xlint:unchecked", "-Xlint:deprecation")
scalacOptions ++= Seq("-optimize", "-unchecked", "-deprecation", "-Xcheckinit", "-encoding", "utf8")
crossScalaVersions := Seq("2.9.0", "2.9.0-1", "2.9.1", "2.9.1-1", "2.9.2", "2.9.3", "2.10.0", "2.10.1", "2.10.2")
libraryDependencies ++= Seq(
"org.json4s" %% "json4s-jackson" % "3.2.5",
"io.backchat.inflector" %% "scala-inflector" % "1.3.5",
"commons-io" % "commons-io" % "2.3",
"ch.qos.logback" % "logback-classic" % "1.0.13" % "provided",
"org.rogach" %% "scallop" % "0.8.1",
"junit" % "junit" % "4.11" % "test",
"org.scalatest" %% "scalatest" % "1.9.1" % "test"
)
libraryDependencies <+= scalaVersion {
case v if v.startsWith("2.9") =>
"org.fusesource.scalate" % "scalate-core_2.9" % "1.6.1"
case v if v.startsWith("2.10") => {
"org.fusesource.scalate" %% "scalate-core" % "1.6.1"
}
}
libraryDependencies ++= {
scalaVersion.toString match {
case v if v.startsWith("2.10") => Seq("org.scala-lang" % "scala-reflect" % v)
case _ => Seq()
}
}
packageOptions <+= (name, version, organization) map {
(title, version, vendor) =>
Package.ManifestAttributes(
"Created-By" -> "Simple Build Tool",
"Built-By" -> System.getProperty("user.name"),
"Build-Jdk" -> System.getProperty("java.version"),
"Specification-Title" -> title,
"Specification-Version" -> version,
"Specification-Vendor" -> vendor,
"Implementation-Title" -> title,
"Implementation-Version" -> version,
"Implementation-Vendor-Id" -> vendor,
"Implementation-Vendor" -> vendor
)
}
publishTo <<= (version) { version: String =>
if (version.trim.endsWith("SNAPSHOT"))
Some("Sonatype Nexus Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots")
else
Some("Sonatype Nexus Releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2")
}
//publishTo := Some(Resolver.file("file", new File(Path.userHome.absolutePath+"/.m2/repository")))
artifact in (Compile, assembly) ~= { art =>
art.copy(`classifier` = Some("assembly"))
}
addArtifact(artifact in (Compile, assembly), assembly)
publishMavenStyle := true
publishArtifact in Test := false
pomIncludeRepository := { x => false }
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
homepage := Some(new URL("https://github.com/wordnik/swagger-codegen"))
parallelExecution in Test := false
startYear := Some(2009)
licenses := Seq(("Apache License 2.0", new URL("http://www.apache.org/licenses/LICENSE-2.0.html")))
pomExtra <<= (pomExtra, name, description) {(pom, name, desc) => pom ++ Group(
<scm>
<connection>scm:git:git@github.com:wordnik/swagger-codegen.git</connection>
<developerConnection>scm:git:git@github.com:wordnik/swagger-codegen.git</developerConnection>
<url>https://github.com/wordnik/swagger-codegen</url>
</scm>
<issueManagement>
<system>github</system>
<url>https://github.com/wordnik/swagger-codegen/issues</url>
</issueManagement>
<developers>
<developer>
<id>rpidikiti</id>
<name>Ramesh Pidikiti</name>
<email>ramesh@wordnik.com</email>
</developer>
<developer>
<id>ayush</id>
<name>Ayush Gupta</name>
<email>ayush@glugbot.com</email>
</developer>
<developer>
<id>fehguy</id>
<name>Tony Tam</name>
<email>fehguy@gmail.com</email>
</developer>
<developer>
<id>casualjim</id>
<name>Ivan Porto Carrero</name>
<url>http://flanders.co.nz/</url>
</developer>
<developer>
<id>radius314</id>
<name>Danny Gershman</name>
<email>danny.gershman@gmail.com</email>
</developer>
</developers>
)}
assemblySettings
jarName in assembly := "swagger-codegen.jar"

View File

@@ -1,124 +0,0 @@
<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>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>5</version>
</parent>
<groupId>com.wordnik</groupId>
<artifactId>swagger-codegen-distribution</artifactId>
<packaging>jar</packaging>
<version>2.0.2-SNAPSHOT</version>
<name>swagger-codegen-distribution</name>
<url>https://github.com/wordnik/swagger-codegen</url>
<scm>
<connection>scm:git:git@github.com:wordnik/swagger-codegen.git</connection>
<developerConnection>scm:git:git@github.com:wordnik/swagger-codegen.git</developerConnection>
<url>https://github.com/wordnik/swagger-codegen</url>
</scm>
<prerequisites>
<maven>2.2.0</maven>
</prerequisites>
<developers>
<developer>
<id>fehguy</id>
<name>Tony Tam</name>
<email>fehguy@gmail.com</email>
</developer>
</developers>
<issueManagement>
<system>github</system>
<url>https://github.com/wordnik/swagger-codegen/issues</url>
</issueManagement>
<mailingLists>
<mailingList>
<name>wordnik-api</name>
<archive>https://groups.google.com/forum/#!forum/wordnik-api</archive>
</mailingList>
</mailingLists>
<licenses>
<license>
<name>Apache License 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
<distribution>repo</distribution>
</license>
</licenses>
<build>
<plugins>
<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-failsafe-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<executions>
<execution>
<id>distro-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/distribution.xml</descriptor>
</descriptors>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>src-dependencies</id>
<phase>package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>com.wordnik</includeGroupIds>
<includeArtifactIds>text-data</includeArtifactIds>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-codegen_2.9.1</artifactId>
<version>${swagger.codegen.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
<properties>
<swagger.codegen.version>2.0.2-SNAPSHOT</swagger.codegen.version>
</properties>
</project>

View File

@@ -1,29 +0,0 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>distribution</id>
<baseDirectory>swagger-codegen</baseDirectory>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>zip</format>
</formats>
<dependencySets>
<dependencySet>
<scope>compile</scope>
<outputDirectory>target/lib</outputDirectory>
<includes>
<include>*:jar:*</include>
</includes>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>../bin</directory>
<includes>
<include>*.*</include>
</includes>
<outputDirectory>bin</outputDirectory>
</fileSet>
</fileSets>
</assembly>

View File

@@ -0,0 +1,95 @@
<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>
<artifactId>swagger-codegen-cli</artifactId>
<packaging>jar</packaging>
<name>swagger-codegen (executable)</name>
<build>
<finalName>swagger-codegen-cli</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.wordnik.swagger.codegen.SwaggerCodegen</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>reduced-pom</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>false</minimizeJar>
<createDependencyReducedPom>true</createDependencyReducedPom>
<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"/>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.wordnik</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>
</dependencies>
</project>

View File

@@ -0,0 +1,35 @@
package com.wordnik.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;
/**
* User: lanwen
* Date: 24.03.15
* Time: 17:56
*
* Command line interface for swagger codegen
* use `swagger-codegen-cli.jar help` for more info
*
* @since 2.1.3-M1
*/
public class SwaggerCodegen {
public static void main(String[] args) {
Cli.CliBuilder<Runnable> builder = Cli.<Runnable>builder("swagger")
.withDescription("Swagger code generator CLI. More info on swagger.io")
.withDefaultCommand(Langs.class)
.withCommands(
Generate.class,
Meta.class,
Langs.class,
Help.class
);
builder.build().parse(args).run();
}
}

View File

@@ -0,0 +1,120 @@
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);
}
}
}

View File

@@ -0,0 +1,23 @@
package com.wordnik.swagger.codegen.cmd;
import ch.lambdaj.collection.LambdaIterable;
import com.wordnik.swagger.codegen.CodegenConfig;
import io.airlift.airline.Command;
import static ch.lambdaj.Lambda.on;
import static ch.lambdaj.collection.LambdaCollections.with;
import static java.util.ServiceLoader.load;
/**
* User: lanwen
* Date: 24.03.15
* Time: 20:25
*/
@Command(name = "langs", description = "Shows available langs")
public class Langs implements Runnable {
@Override
public void run() {
LambdaIterable<String> langs = with(load(CodegenConfig.class)).extract(on(CodegenConfig.class).getName());
System.out.printf("Available languages: %s%n", langs);
}
}

View File

@@ -0,0 +1,144 @@
package com.wordnik.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 org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.util.List;
import java.util.Map;
import static ch.lambdaj.collection.LambdaCollections.with;
import static com.google.common.base.Joiner.on;
/**
* User: lanwen
* Date: 24.03.15
* Time: 20:22
*/
@Command(name = "meta", description = "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.")
public class Meta implements Runnable {
private static final Logger LOG = LoggerFactory.getLogger(Meta.class);
private static final String TEMPLATE_DIR_CLASSPATH = "codegen";
private static final String MUSTACHE_EXTENSION = ".mustache";
@Option(name = {"-o", "--output"}, title = "output directory",
description = "where to write the generated files (current dir by default)")
private String outputFolder = "";
@Option(name = {"-n", "--name"}, title = "name",
description = "the human-readable name of the generator")
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";
@Override
public void run() {
final File targetDir = new File(outputFolder);
LOG.info("writing to folder [{}]", targetDir.getAbsolutePath());
String mainClass = StringUtils.capitalize(name) + "Generator";
List<SupportingFile> supportingFiles = ImmutableList.of(
new SupportingFile("pom.mustache", "", "pom.xml"),
new SupportingFile("generatorClass.mustache",
on(File.separator).join("src/main/java", asPath(targetPackage)), mainClass.concat(".java")),
new SupportingFile("README.mustache", "", "README.md"),
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")
);
Map<String, Object> data = new ImmutableMap.Builder<String, Object>()
.put("generatorPackage", targetPackage)
.put("generatorClass", mainClass)
.put("name", name)
.put("fullyQualifiedGeneratorClass", targetPackage + "." + mainClass).build();
with(supportingFiles).convert(processFiles(targetDir, data));
}
/**
* 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
* @return converter object to pass to lambdaj
*/
private Converter<SupportingFile, File> processFiles(final File targetDir, final Map<String, Object> data) {
return new Converter<SupportingFile, File>() {
private DefaultGenerator generator = new DefaultGenerator();
@Override
public File convert(SupportingFile support) {
try {
File destinationFolder = new File(new File(targetDir.getAbsolutePath()), support.folder);
File outputFile = new File(destinationFolder, support.destinationFilename);
String template = generator
.readTemplate(new File(TEMPLATE_DIR_CLASSPATH, support.templateFile).getPath());
String formatted = template;
if (support.templateFile.endsWith(MUSTACHE_EXTENSION)) {
LOG.info("writing file to {}", outputFile.getAbsolutePath());
formatted = Mustache.compiler().withLoader(loader(generator))
.defaultValue("")
.compile(template)
.execute(data);
} else {
LOG.info("copying file to {}", outputFile.getAbsolutePath());
}
FileUtils.writeStringToFile(outputFile, formatted);
return outputFile;
} catch (IOException e) {
throw new RuntimeException("Can't generate project", e);
}
}
};
}
/**
* Creates mustache loader for template using classpath loader
* @param generator - class with reader getter
* @return loader for template
*/
private Mustache.TemplateLoader loader(final DefaultGenerator generator) {
return new Mustache.TemplateLoader() {
public Reader getTemplate(String name) {
return generator.getTemplateReader(TEMPLATE_DIR_CLASSPATH
+ File.separator + name.concat(MUSTACHE_EXTENSION));
}
};
}
/**
* Converts package name to path on file system
* @param packageName - package name to convert
* @return relative path
*/
private String asPath(String packageName) {
return packageName.replace(".", File.separator);
}
}

View File

@@ -0,0 +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>

View File

@@ -0,0 +1,341 @@
<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>
<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>
<configuration>
<sources>
<source>src/main/scala</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</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-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>
</project>

View File

@@ -0,0 +1,60 @@
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;
}
}

View File

@@ -0,0 +1,104 @@
/**
* 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;
}
}

View File

@@ -0,0 +1,52 @@
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();
}
}

View File

@@ -0,0 +1,143 @@
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);
}
}
}
}

View File

@@ -0,0 +1,59 @@
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);
}

View File

@@ -0,0 +1,16 @@
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;
}

View File

@@ -0,0 +1,38 @@
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);
}
}
}

View File

@@ -0,0 +1,21 @@
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;
}
}

View File

@@ -0,0 +1,32 @@
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;
}

View File

@@ -0,0 +1,40 @@
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;
}
}

View File

@@ -0,0 +1,25 @@
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;
}

View File

@@ -0,0 +1,17 @@
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;
}

View File

@@ -0,0 +1,11 @@
package com.wordnik.swagger.codegen;
public class CodegenSecurity {
String name;
String type;
Boolean hasMore, isBasic, isOAuth, isApiKey;
// ApiKey specific
String keyParamName;
Boolean isKeyInQuery, isKeyInHeader;
}

View File

@@ -0,0 +1,34 @@
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
}
}

View File

@@ -0,0 +1,440 @@
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;
}
}

View File

@@ -0,0 +1,11 @@
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();
}

View File

@@ -0,0 +1,185 @@
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;
}
}

View File

@@ -0,0 +1,13 @@
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;
}
}

View File

@@ -0,0 +1,6 @@
package com.wordnik.swagger.codegen.auth;
public interface AuthMethod {
String getType();
void setType(String type);
}

View File

@@ -0,0 +1,165 @@
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 "";
}
}

View File

@@ -0,0 +1,188 @@
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();
}
}

View File

@@ -0,0 +1,166 @@
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);
}
}

View File

@@ -0,0 +1,194 @@
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";
}
}

View File

@@ -0,0 +1,166 @@
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;
}
}

View File

@@ -0,0 +1,163 @@
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);
}
}

View File

@@ -0,0 +1,149 @@
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;
}
}

View File

@@ -0,0 +1,192 @@
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;
}
}

View File

@@ -0,0 +1,273 @@
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;
}
}

View File

@@ -0,0 +1,162 @@
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);
}
}

View File

@@ -0,0 +1,117 @@
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";
}
}

View File

@@ -0,0 +1,190 @@
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";
}
}

View File

@@ -0,0 +1,192 @@
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";
}
}

View File

@@ -0,0 +1,178 @@
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);
}
}

View File

@@ -0,0 +1,165 @@
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 SpringMVCServerCodegen extends JavaClientCodegen implements CodegenConfig {
protected String invokerPackage = "io.swagger.api";
protected String groupId = "io.swagger";
protected String artifactId = "swagger-spring-mvc-server";
protected String artifactVersion = "1.0.0";
protected String sourceFolder = "src/main/java";
protected String title = "Petstore Server";
protected String configPackage = "";
public CodegenType getTag() {
return CodegenType.SERVER;
}
public String getName() {
return "spring-mvc";
}
public String getHelp() {
return "Generates a Java Spring-MVC Server application using the SpringFox integration.";
}
public SpringMVCServerCodegen() {
super();
outputFolder = "generated-code/javaSpringMVC";
modelTemplateFiles.put("model.mustache", ".java");
apiTemplateFiles.put("api.mustache", ".java");
templateDir = "JavaSpringMVC";
apiPackage = "io.swagger.api";
modelPackage = "io.swagger.model";
configPackage = "io.swagger.configuration";
additionalProperties.put("invokerPackage", invokerPackage);
additionalProperties.put("groupId", groupId);
additionalProperties.put("artifactId", artifactId);
additionalProperties.put("artifactVersion", artifactVersion);
additionalProperties.put("title", title);
additionalProperties.put("apiPackage", apiPackage);
additionalProperties.put("configPackage", configPackage);
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("swaggerConfig.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "SwaggerConfig.java"));
supportingFiles.add(new SupportingFile("webApplication.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "WebApplication.java"));
supportingFiles.add(new SupportingFile("webMvcConfiguration.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "WebMvcConfiguration.java"));
supportingFiles.add(new SupportingFile("swaggerUiConfiguration.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "SwaggerUiConfiguration.java"));
supportingFiles.add(new SupportingFile("swagger.properties",
("src.main.resources").replace(".", java.io.File.separator), "swagger.properties"));
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;
}
}

View File

@@ -0,0 +1,76 @@
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";
}
}

View File

@@ -0,0 +1,79 @@
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;
}
}

View File

@@ -0,0 +1,45 @@
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();
}
}
}

View File

@@ -0,0 +1,44 @@
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();
}
}
}

View File

@@ -0,0 +1,247 @@
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;
}
}

View File

@@ -0,0 +1,108 @@
package {{package}};
import {{invokerPackage}}.ApiException;
import {{invokerPackage}}.ApiInvoker;
import {{modelPackage}}.*;
import java.util.*;
{{#imports}}import {{import}};
{{/imports}}
import com.sun.jersey.multipart.FormDataMultiPart;
import com.sun.jersey.multipart.file.FileDataBodyPart;
import javax.ws.rs.core.MediaType;
import java.io.File;
import java.util.Map;
import java.util.HashMap;
{{#operations}}
public class {{classname}} {
String basePath = "{{basePath}}";
ApiInvoker apiInvoker = ApiInvoker.getInstance();
public ApiInvoker getInvoker() {
return apiInvoker;
}
public void setBasePath(String basePath) {
this.basePath = basePath;
}
public String getBasePath() {
return basePath;
}
{{#operation}}
/**
* {{summary}}
* {{notes}}
{{#allParams}} * @param {{paramName}} {{description}}
{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
*/
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
Object postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
{{#requiredParamCount}}
// verify required params are set
if({{/requiredParamCount}}{{#requiredParams}} {{paramName}} == null {{#hasMore}}|| {{/hasMore}}{{/requiredParams}}{{#requiredParamCount}}) {
throw new ApiException(400, "missing required params");
}
{{/requiredParamCount}}
// create path and map variables
String path = "{{path}}".replaceAll("\\{format\\}","json"){{#pathParams}}
.replaceAll("\\{" + "{{paramName}}" + "\\}", apiInvoker.escapeString({{{paramName}}}.toString())){{/pathParams}};
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
{{#queryParams}}if ({{paramName}} != null)
queryParams.put("{{baseName}}", ApiInvoker.parameterToString({{paramName}}));
{{/queryParams}}
{{#headerParams}}headerParams.put("{{baseName}}", ApiInvoker.parameterToString({{paramName}}));
{{/headerParams}}
String[] contentTypes = {
{{#consumes}}"{{mediaType}}"{{#hasMore}},{{/hasMore}}{{/consumes}}
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
{{#formParams}}{{#notFile}}
hasFields = true;
mp.field("{{baseName}}", ApiInvoker.parameterToString({{paramName}}), MediaType.MULTIPART_FORM_DATA_TYPE);
{{/notFile}}{{#isFile}}
hasFields = true;
mp.field("{{baseName}}", file.getName());
mp.bodyPart(new FileDataBodyPart("{{baseName}}", {{paramName}}, MediaType.MULTIPART_FORM_DATA_TYPE));
{{/isFile}}{{/formParams}}
if(hasFields)
postBody = mp;
}
else {
{{#formParams}}{{#notFile}}formParams.put("{{baseName}}", ApiInvoker.parameterToString({{paramName}}));{{/notFile}}
{{/formParams}}
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "{{httpMethod}}", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return {{#returnType}}({{{returnType}}}) ApiInvoker.deserialize(response, "{{returnContainer}}", {{returnBaseType}}.class){{/returnType}};
}
else {
return {{#returnType}}null{{/returnType}};
}
} catch (ApiException ex) {
throw ex;
}
}
{{/operation}}
}
{{/operations}}

View File

@@ -0,0 +1,279 @@
package {{invokerPackage}};
import com.fasterxml.jackson.core.JsonGenerator.Feature;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.client.filter.LoggingFilter;
import com.sun.jersey.api.client.WebResource.Builder;
import com.sun.jersey.multipart.FormDataMultiPart;
import javax.ws.rs.core.Response.Status.Family;
import javax.ws.rs.core.MediaType;
import java.util.Collection;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.Date;
import java.util.TimeZone;
import java.net.URLEncoder;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.text.ParseException;
public class ApiInvoker {
private static ApiInvoker INSTANCE = new ApiInvoker();
private Map<String, Client> hostMap = new HashMap<String, Client>();
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
private boolean isDebug = false;
/**
* ISO 8601 date time format.
* @see https://en.wikipedia.org/wiki/ISO_8601
*/
public static final SimpleDateFormat DATE_TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
/**
* ISO 8601 date format.
* @see https://en.wikipedia.org/wiki/ISO_8601
*/
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
static {
// Use UTC as the default time zone.
DATE_TIME_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
// Set default User-Agent.
setUserAgent("Java-Swagger");
}
public static void setUserAgent(String userAgent) {
INSTANCE.addDefaultHeader("User-Agent", userAgent);
}
public static Date parseDateTime(String str) {
try {
return DATE_TIME_FORMAT.parse(str);
} catch (java.text.ParseException e) {
throw new RuntimeException(e);
}
}
public static Date parseDate(String str) {
try {
return DATE_FORMAT.parse(str);
} catch (java.text.ParseException e) {
throw new RuntimeException(e);
}
}
public static String formatDateTime(Date datetime) {
return DATE_TIME_FORMAT.format(datetime);
}
public static String formatDate(Date date) {
return DATE_FORMAT.format(date);
}
public static String parameterToString(Object param) {
if (param == null) {
return "";
} else if (param instanceof Date) {
return formatDateTime((Date) param);
} else if (param instanceof Collection) {
StringBuilder b = new StringBuilder();
for(Object o : (Collection)param) {
if(b.length() > 0) {
b.append(",");
}
b.append(String.valueOf(o));
}
return b.toString();
} else {
return String.valueOf(param);
}
}
public void enableDebug() {
isDebug = true;
}
public static ApiInvoker getInstance() {
return INSTANCE;
}
public void addDefaultHeader(String key, String value) {
defaultHeaderMap.put(key, value);
}
public String escapeString(String str) {
try{
return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20");
}
catch(UnsupportedEncodingException e) {
return str;
}
}
public static Object deserialize(String json, String containerType, Class cls) throws ApiException {
if(null != containerType) {
containerType = containerType.toLowerCase();
}
try{
if("list".equals(containerType) || "array".equals(containerType)) {
JavaType typeInfo = JsonUtil.getJsonMapper().getTypeFactory().constructCollectionType(List.class, cls);
List response = (List<?>) JsonUtil.getJsonMapper().readValue(json, typeInfo);
return response;
}
else if(String.class.equals(cls)) {
if(json != null && json.startsWith("\"") && json.endsWith("\"") && json.length() > 1)
return json.substring(1, json.length() - 2);
else
return json;
}
else {
return JsonUtil.getJsonMapper().readValue(json, cls);
}
}
catch (IOException e) {
throw new ApiException(500, e.getMessage());
}
}
public static String serialize(Object obj) throws ApiException {
try {
if (obj != null)
return JsonUtil.getJsonMapper().writeValueAsString(obj);
else
return null;
}
catch (Exception e) {
throw new ApiException(500, e.getMessage());
}
}
public String invokeAPI(String host, String path, String method, Map<String, String> queryParams, Object body, Map<String, String> headerParams, Map<String, String> formParams, String contentType) throws ApiException {
Client client = getClient(host);
StringBuilder b = new StringBuilder();
for(String key : queryParams.keySet()) {
String value = queryParams.get(key);
if (value != null){
if(b.toString().length() == 0)
b.append("?");
else
b.append("&");
b.append(escapeString(key)).append("=").append(escapeString(value));
}
}
String querystring = b.toString();
Builder builder = client.resource(host + path + querystring).accept("application/json");
for(String key : headerParams.keySet()) {
builder = builder.header(key, headerParams.get(key));
}
for(String key : defaultHeaderMap.keySet()) {
if(!headerParams.containsKey(key)) {
builder = builder.header(key, defaultHeaderMap.get(key));
}
}
ClientResponse response = null;
if("GET".equals(method)) {
response = (ClientResponse) builder.get(ClientResponse.class);
}
else if ("POST".equals(method)) {
if(body == null)
response = builder.post(ClientResponse.class, null);
else if(body instanceof FormDataMultiPart) {
response = builder.type(contentType).post(ClientResponse.class, body);
}
else
response = builder.type(contentType).post(ClientResponse.class, serialize(body));
}
else if ("PUT".equals(method)) {
if(body == null)
response = builder.put(ClientResponse.class, serialize(body));
else {
if("application/x-www-form-urlencoded".equals(contentType)) {
StringBuilder formParamBuilder = new StringBuilder();
// encode the form params
for(String key : formParams.keySet()) {
String value = formParams.get(key);
if(value != null && !"".equals(value.trim())) {
if(formParamBuilder.length() > 0) {
formParamBuilder.append("&");
}
try {
formParamBuilder.append(URLEncoder.encode(key, "utf8")).append("=").append(URLEncoder.encode(value, "utf8"));
}
catch (Exception e) {
// move on to next
}
}
}
response = builder.type(contentType).put(ClientResponse.class, formParamBuilder.toString());
}
else
response = builder.type(contentType).put(ClientResponse.class, serialize(body));
}
}
else if ("DELETE".equals(method)) {
if(body == null)
response = builder.delete(ClientResponse.class);
else
response = builder.type(contentType).delete(ClientResponse.class, serialize(body));
}
else {
throw new ApiException(500, "unknown method type " + method);
}
if(response.getClientResponseStatus() == ClientResponse.Status.NO_CONTENT) {
return null;
}
else if(response.getClientResponseStatus().getFamily() == Family.SUCCESSFUL) {
if(response.hasEntity()) {
return (String) response.getEntity(String.class);
}
else {
return "";
}
}
else {
String message = "error";
if(response.hasEntity()) {
try{
message = String.valueOf(response.getEntity(String.class));
}
catch (RuntimeException e) {
// e.printStackTrace();
}
}
throw new ApiException(
response.getClientResponseStatus().getStatusCode(),
message);
}
}
private Client getClient(String host) {
if(!hostMap.containsKey(host)) {
Client client = Client.create();
if(isDebug)
client.addFilter(new LoggingFilter());
hostMap.put(host, client);
}
return hostMap.get(host);
}
}

View File

@@ -0,0 +1,51 @@
package {{package}};
{{#imports}}import {{import}};
{{/imports}}
import com.wordnik.swagger.annotations.*;
import com.fasterxml.jackson.annotation.JsonProperty;
{{#models}}
{{#model}}{{#description}}
/**
* {{description}}
**/{{/description}}
@ApiModel(description = "{{{description}}}")
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
{{#vars}}{{#isEnum}}
public enum {{datatypeWithEnum}} {
{{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}}
};
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{^isEnum}}
private {{{datatype}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{/vars}}
{{#vars}}
/**{{#description}}
* {{{description}}}{{/description}}{{#minimum}}
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
* maximum: {{maximum}}{{/maximum}}
**/
@ApiModelProperty({{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
@JsonProperty("{{baseName}}")
public {{{datatypeWithEnum}}} {{getter}}() {
return {{name}};
}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
}
{{/vars}}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class {{classname}} {\n");
{{#parent}}sb.append(" " + super.toString()).append("\n");{{/parent}}
{{#vars}}sb.append(" {{name}}: ").append({{name}}).append("\n");
{{/vars}}sb.append("}\n");
return sb.toString();
}
}
{{/model}}
{{/models}}

View File

@@ -1,11 +1,11 @@
<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>
<groupId>com.wordnik</groupId>
<artifactId>wordnik-java-client</artifactId>
<groupId>{{groupId}}</groupId>
<artifactId>{{artifactId}}</artifactId>
<packaging>jar</packaging>
<name>wordnik-java-client</name>
<version>1.0.0</version>
<name>{{artifactId}}</name>
<version>{{artifactVersion}}</version>
<scm>
<connection>scm:git:git@github.com:wordnik/swagger-mustache.git</connection>
<developerConnection>scm:git:git@github.com:wordnik/swagger-codegen.git</developerConnection>
@@ -104,94 +104,51 @@
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>${scala-maven-plugin-version}</version>
<executions>
<execution>
<goals>
<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.5</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>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>${scala-maven-plugin-version}</version>
</plugin>
</plugins>
</reporting>
<dependencies>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger-annotations-version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>2.1.5</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${jodatime-version}</version>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.9.1</artifactId>
<version>${scala-test-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -199,16 +156,12 @@
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<jersey-version>1.7</jersey-version>
<jackson-version>2.1.4</jackson-version>
<scala-version>2.9.1-1</scala-version>
<junit-version>4.8.1</junit-version>
<swagger-annotations-version>1.5.3-M1</swagger-annotations-version>
<jersey-version>1.18</jersey-version>
<jackson-version>2.4.2</jackson-version>
<jodatime-version>2.3</jodatime-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<junit-version>4.8.1</junit-version>
<scala-test-version>1.6.1</scala-test-version>
<scala-maven-plugin-version>3.1.5</scala-maven-plugin-version>
</properties>
</project>

View File

@@ -3,7 +3,7 @@ package {{apiPackage}};
import javax.xml.bind.annotation.XmlTransient;
@javax.xml.bind.annotation.XmlRootElement
public class ApiResponse {
public class ApiResponseMessage {
public static final int ERROR = 1;
public static final int WARNING = 2;
public static final int INFO = 3;
@@ -14,9 +14,9 @@ public class ApiResponse {
String type;
String message;
public ApiResponse(){}
public ApiResponseMessage(){}
public ApiResponse(int code, String message){
public ApiResponseMessage(int code, String message){
this.code = code;
switch(code){
case ERROR:

View File

@@ -0,0 +1,46 @@
package {{package}};
import {{modelPackage}}.*;
import com.wordnik.swagger.annotations.ApiParam;
import com.sun.jersey.multipart.FormDataParam;
{{#imports}}import {{import}};
{{/imports}}
import java.util.List;
import {{package}}.NotFoundException;
import java.io.InputStream;
import com.sun.jersey.core.header.FormDataContentDisposition;
import com.sun.jersey.multipart.FormDataParam;
import javax.ws.rs.core.Response;
import javax.ws.rs.*;
@Path("/{{baseName}}")
@com.wordnik.swagger.annotations.Api(value = "/{{baseName}}", description = "the {{baseName}} API")
{{#operations}}
public class {{classname}} {
{{#operation}}
@{{httpMethod}}
{{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}}
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
@com.wordnik.swagger.annotations.ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}})
@com.wordnik.swagger.annotations.ApiResponses(value = { {{#responses}}
@com.wordnik.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}"){{#hasMore}},
{{/hasMore}}{{/responses}} })
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
{{/hasMore}}{{/allParams}})
throws NotFoundException {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
{{/operation}}
}
{{/operations}}

View File

@@ -0,0 +1 @@
{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{{dataType}}} {{paramName}}{{/isBodyParam}}

Some files were not shown because too many files have changed in this diff Show More