Compare commits

..

1178 Commits

Author SHA1 Message Date
Tony Tam
6aa66897aa updated readme 2015-08-24 00:44:03 -07:00
Tony Tam
9b0ddd3a7f Merge branch 'develop_2.0' 2015-08-24 00:39:03 -07:00
Tony Tam
ee05366d0b updated README for release 2015-08-24 00:37:23 -07:00
Tony Tam
d048a68438 added sample 2015-08-24 00:33:26 -07:00
Tony Tam
9cc7615b71 rebuilt, updated versions 2015-08-24 00:32:58 -07:00
Tony Tam
dfb9d26c75 Merge branch 'wing328-fix_java_serialize' into develop_2.0 2015-08-24 00:03:31 -07:00
Tony Tam
715c0af41f merged & rebuilt 2015-08-24 00:03:20 -07:00
Tony Tam
65829e5b6e merged & rebuilt 2015-08-24 00:03:08 -07:00
Tony Tam
a3c7e22d55 Merge pull request #1116 from swagger-api/issue-1115
fixes for jaxrs codegen
2015-08-23 23:56:14 -07:00
Tony Tam
d8ceb8c648 enabled samples 2015-08-23 23:47:01 -07:00
Tony Tam
87f1ef4dc2 re-ordered 2015-08-23 23:46:54 -07:00
Tony Tam
7c2310a13f updated to jersey 1.18.1, fixes for #1115 2015-08-23 23:34:35 -07:00
Tony Tam
6dcb8da2d8 altered to return inner type only 2015-08-23 23:33:55 -07:00
Tony Tam
a83f01ad60 made string safe 2015-08-23 23:33:27 -07:00
Tony Tam
6c1f7243bf rebuilt 2015-08-23 23:29:53 -07:00
wing328
164ed99812 fix serializableModel (boolean) 2015-08-24 11:50:21 +08:00
Tony Tam
355cc88e0d Merge pull request #1113 from swagger-api/issue-1112
moved file
2015-08-23 19:04:14 -07:00
Tony Tam
35ed412d1e moved file 2015-08-23 18:58:46 -07:00
Tony Tam
a5190266b6 Merge pull request #1111 from swagger-api/revert-1029-jaxrs-server-codegen-improvements
Revert "fixed generated code to go to target/generated-sources, added…
2015-08-23 18:53:05 -07:00
Tony Tam
d51fe80138 Revert "fixed generated code to go to target/generated-sources, added maven-c…" 2015-08-23 18:28:42 -07:00
Tony Tam
ec9cdca7cb Merge pull request #1109 from swagger-api/rebase-issue-838
update files as rebase from #838
2015-08-23 17:38:34 -07:00
Tony Tam
8a9f43b142 Merge pull request #910 from swagger-api/maven-plugin-configuration-improvements
Maven plugin configuration improvements
2015-08-23 17:33:55 -07:00
Tony Tam
0fc5702e4d Merge pull request #1029 from swagger-api/jaxrs-server-codegen-improvements
fixed generated code to go to target/generated-sources, added maven-c…
2015-08-23 17:32:29 -07:00
Tony Tam
3390fae15b Merge branch 'tiffanyperumpail-develop_2.0' into develop_2.0 2015-08-23 17:25:24 -07:00
Tony Tam
e19b883c89 Merge branch 'develop_2.0' of ssh://github.com/tiffanyperumpail/swagger-codegen into tiffanyperumpail-develop_2.0 2015-08-23 17:24:27 -07:00
Tony Tam
9531e1ae59 Merge branch 'Rogercf-support-to-array-of-enums' into develop_2.0 2015-08-23 17:22:44 -07:00
Tony Tam
3d38c41b0e resolved merge issue 2015-08-23 17:22:34 -07:00
Tony Tam
718e1ff68a Merge branch 'TobiasPfeifer-develop_2.0' into develop_2.0 2015-08-23 14:23:33 -07:00
Tony Tam
a6a9d743be added template 2015-08-23 14:23:20 -07:00
Tony Tam
414de00894 fixed return type, rebuilt 2015-08-23 14:23:00 -07:00
Tony Tam
cc7366787f Merge branch 'develop_2.0' of ssh://github.com/TobiasPfeifer/swagger-codegen into TobiasPfeifer-develop_2.0 2015-08-23 11:20:02 -07:00
Tony Tam
3486eecdfc Merge branch 'xhh-library-template-jersey2' into develop_2.0 2015-08-23 11:10:12 -07:00
Tony Tam
66e6d4fb8a rebuilt client 2015-08-23 11:10:04 -07:00
Tony Tam
f7dc066dec merged 2015-08-23 11:09:47 -07:00
Tony Tam
3160913433 update files as rebase from #838 2015-08-23 11:05:19 -07:00
Ole Lensmar
e253fdea33 Merge branches 'develop_2.0' and 'jaxrs-server-codegen-improvements' of https://github.com/swagger-api/swagger-codegen into jaxrs-server-codegen-improvements
Conflicts:
	modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java
2015-08-23 10:26:07 -04:00
Ole Lensmar
ac49d0dcdc post-merge fixes 2015-08-23 09:37:28 -04:00
Ole Lensmar
b956d47a9d Merge branches 'develop_2.0' and 'maven-plugin-configuration-improvements' of https://github.com/swagger-api/swagger-codegen into maven-plugin-configuration-improvements
Conflicts:
	modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java
2015-08-23 09:37:08 -04:00
wing328
f662699fd0 Merge pull request #1107 from wing328/php_fix_datetime
[PHP] Fixed deserialization for datetime object
2015-08-23 17:11:55 +08:00
wing328
1c1571cc3a Merge pull request #1106 from geekerzp/python-query
[Python] Fix issue that missing query parameters in python client.
2015-08-23 17:11:19 +08:00
wing328
e13374e1df Merge pull request #1105 from who/serializable_java_models
[Java] Adding an option so java models can implement Serializable
2015-08-23 17:10:57 +08:00
wing328
f2df26f6e6 fix deserializing datetime, add test case 2015-08-22 23:09:12 +08:00
xhh
569082743f Remove the unused LibraryHelp command 2015-08-22 22:05:43 +08:00
xhh
595c01c537 Merge branch 'develop_2.0' into library-template-jersey2
Conflicts:
	modules/swagger-codegen/src/main/resources/Java/JsonUtil.mustache
2015-08-22 21:53:04 +08:00
geekerzp
dc423cc11d Fix issue that Mssing query parameters in python client. 2015-08-22 17:46:13 +08:00
Andrew B
4f25a0e6c5 adding an option so java models can implement Serializable 2015-08-21 18:36:03 -07:00
Tony Tam
0af29cc5cf Merge pull request #1104 from swagger-api/issue-1103
added check, fix for #1103
2015-08-21 15:22:22 -07:00
Tony Tam
44b4af0374 added check, fix for #1103 2015-08-21 15:02:56 -07:00
Tony Tam
b68beefa69 Merge pull request #1101 from swagger-api/issue-1099
optional files are never written
2015-08-21 09:35:11 -07:00
Tony Tam
07162811a7 fix for #1099, added file check 2015-08-21 08:56:22 -07:00
wing328
4023460f2e Merge pull request #1096 from geekerzp/objc-param-to-str
[Objc] Sanitize request parameters in objc client
2015-08-21 22:22:17 +08:00
wing328
83bea6a0c5 Merge pull request #1095 from who/fix_issue_1089
[Java] Sanitize configurable package names (fixes #1089)
2015-08-21 22:15:53 +08:00
wing328
d03f680c64 Merge pull request #1090 from geekerzp/python-keyword
[Python] Change reserved word handling in python client.
2015-08-21 21:51:32 +08:00
geekerzp
4189d0765b Update api body template of objc client 2015-08-21 11:40:59 +08:00
geekerzp
6218ad139f Fix issue that it will throw error if not pass optional form param in objc client. 2015-08-21 11:20:29 +08:00
geekerzp
b7cd38d38b Update objc client.
Sanitize request parameters (path, query, header, form, body).
2015-08-21 09:42:31 +08:00
Andrew B
2b61305582 Fixing issue #1089 2015-08-20 14:16:10 -07:00
wing328
2057d0e144 Merge pull request #1068 from Helmsdown/add-generated-annotation
Add @Generated annotation to all generated Java templates
2015-08-20 17:45:17 +08:00
xhh
af2ec4cf85 Merge branch 'develop_2.0' into library-template-jersey2
Conflicts:
	modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java
	modules/swagger-codegen/src/main/resources/Java/api.mustache
2015-08-20 17:36:42 +08:00
wing328
9a239ad2a4 Merge pull request #1076 from DavidBiesack/static-html
improve static html; add template guards for collections.
2015-08-20 17:31:03 +08:00
wing328
a610fb5ac3 Merge pull request #1051 from who/develop_2.0
[Java] Fixing subClassed types so that they can use enums
2015-08-20 17:14:17 +08:00
Andrew B
fb4c62cc28 Fixing merge conflict in pom.xml 2015-08-19 23:08:49 -07:00
geekerzp
894d571ea5 Change reserved word handling in python client.
* First, remove the beginning underscores.
* Then, append underscore if the var is reserved word or number.
2015-08-19 18:05:47 +08:00
wing328
dc1992ad45 Merge pull request #1081 from wing328/php_var_name_number
[PHP, Perl, Silex] fixed variable names starting with number, made LOGGER protected
2015-08-19 14:56:13 +08:00
wing328
c62fca8c54 Merge pull request #1079 from wing328/add_flash_generator
[Flash] Add back Flash generator
2015-08-18 20:04:53 +08:00
wing328
5d52952ebd Merge pull request #1077 from geekerzp/objc-apiclient
[Objc] Change the ApiClient  initialization of objc client
2015-08-18 09:39:48 +08:00
wing328
c1fbf6bb1c Merge branch 'php_var_name_number' of https://github.com/wing328/swagger-codegen into php_var_name_number 2015-08-17 14:40:12 +08:00
wing328
10cd672529 fix variable name starting with number, make LOGGER protected 2015-08-17 14:39:29 +08:00
wing328
52918d325e Merge pull request #1082 from wing328/fix_pom_swagger_parser
update swagger-parser-version to 1.0.10 (removed snapshot)
2015-08-17 14:38:11 +08:00
wing328
8cff8fc55a update swagger-parser-version to 1.0.10 (removed snapshot) 2015-08-17 14:27:33 +08:00
wing328
90d5ce228a Merge pull request #1067 from Helmsdown/path-level-params
Codegen should honor path level parameters
2015-08-17 14:13:22 +08:00
wing328
d4ff25f0b3 fix variable name starting with number, make LOGGER protected 2015-08-17 10:43:03 +08:00
wing328
4163f07911 Merge pull request #1069 from geekerzp/python-httplib
[Python] Fix issues in python client
2015-08-16 15:03:16 +08:00
wing328
560fd5718d Merge pull request #1074 from wing328/php_improve1
[PHP] minor improvements
2015-08-16 14:59:43 +08:00
wing328
97580a8c45 Merge pull request #1070 from wing328/objc_readme_update
[Objc] minor wording change for readme based on feedback from developers
2015-08-16 14:59:27 +08:00
wing328
aee72d97c3 Merge pull request #1080 from wing328/update_pomxml
Update swagger-core-version to 1.5.4-SNAPSHOT
2015-08-16 00:22:54 +08:00
wing328
49ad008d7c update pom.xml 2015-08-16 00:14:24 +08:00
wing328
7a2c0a076a update readme, change default value, update pom 2015-08-16 00:03:19 +08:00
wing328
365f4bc0c0 beta release of flash generator 2015-08-15 23:56:01 +08:00
wing328
3478e053e1 add back flash generator 2015-08-15 18:12:14 +08:00
geekerzp
75536868f2 Add default api client in configuration class in objc client 2015-08-14 17:54:41 +08:00
geekerzp
84e8ef489c Update pom.xml 2015-08-14 11:55:22 +08:00
wing328
cffba0299a update core to 1.5.4 2015-08-14 11:19:04 +08:00
geekerzp
a6c07a8364 Change api client pool pattern to singleton pattern in objc client 2015-08-14 09:47:02 +08:00
David Biesack
b14edffc79 improve static html; add template guards for collections. Update -core dependency 2015-08-13 13:46:32 -04:00
wing328
b971aa7433 add example to config option, replace localhost with basePath 2015-08-13 23:27:59 +08:00
wing328
bb4311b7a2 minor wording change for objc readme based on feedback from developers 2015-08-12 20:53:15 +08:00
geekerzp
1c0eb60c71 Fix issues in python client 2015-08-12 11:19:29 +08:00
russellb337
a0eeb90a97 fixing bug 2015-08-11 12:50:19 -07:00
russellb337
38fccbd73d add @Generated to all Java class templates 2015-08-11 12:42:18 -07:00
russellb337
6fbb8ab1e0 add @Generated annotation to all Java class templates 2015-08-11 12:42:06 -07:00
russellb337
6044f0586e removing unnecessary getTypeDeclaration implementation in JaxRSServerCodegen 2015-08-11 09:19:22 -07:00
wing328
84ff5cfc87 Merge pull request #1064 from RMarinaro/develop_2.0
fix for #1061 java
2015-08-11 21:33:08 +08:00
wing328
96be2b196b Merge pull request #1037 from restlet/fix/nodejs_server_swagger
Fix swagger.json supporting file for the node.js server (fixes #652)
2015-08-11 21:28:06 +08:00
Hugo Wood
d93b404b23 Fix swagger.json supporting file for the node.js server (fixes #652) 2015-08-11 14:37:00 +02:00
wing328
be63776162 Merge pull request #1063 from geekerzp/objc-deserialize-bool
[Objc] Fix deserialize bool value issue
2015-08-11 10:18:52 +08:00
russellb337
ae4b4979a7 add defensive null check 2015-08-10 13:58:02 -07:00
russellb337
0a8fb1e532 codegen should honor path level parameters 2015-08-10 13:50:52 -07:00
wing328
e78844cb54 Merge pull request #1043 from marcospri/develop_2.0
Support for nested lists/maps for the python client
2015-08-10 18:30:02 +08:00
Ryan Marinaro
2eb0c8cea6 added a fix for #1061. The only problematic spot was the api.mustache file, although if more parameterized templates were to evolve in the other mustache files we could definitely add {{localVariablePrefix}} to those. For now I didn't want to add any extra noise to the template files which didn't need the prefixes. 2015-08-08 10:19:31 -04:00
geekerzp
2aaad03ab6 Fix the issue of bool deserialization in objc client 2015-08-08 15:13:13 +08:00
xhh
cb181e3480 Merge branch 'develop_2.0' into library-template-jersey2 2015-08-08 11:18:17 +08:00
xhh
b686b53259 Support overriding API/model templates with library template 2015-08-08 11:14:06 +08:00
wing328
f27eb7e0de Merge pull request #1058 from xhh/str-response-offset
Fix bug with truncated lone string responses for Android/Scala clients
2015-08-08 11:10:02 +08:00
wing328
36b7fb20b2 Merge pull request #1059 from geekerzp/objc-auth
[Objc] Fix issue about authentication
2015-08-08 09:37:47 +08:00
Ron
f2ef21e756 Merge pull request #1062 from swagger-api/dependencies-version-update
Update pom.xml
2015-08-07 17:32:28 -04:00
Ron
e57f1de21f Update pom.xml 2015-08-07 17:10:35 -04:00
xhh
a41361c959 Change the "--library" option into a config option 2015-08-07 22:16:32 +08:00
xhh
167e95bb3a Merge branch 'develop_2.0' into library-template-jersey2
Conflicts:
	modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache
2015-08-07 21:18:27 +08:00
geekerzp
732a9eb64d Fix issue in Configuration-body.mustache in objc client 2015-08-07 18:31:07 +08:00
xhh
c7f595fc91 Fix bug with truncated lone string responses for Android/Scala clients 2015-08-07 10:40:42 +08:00
Tony Tam
29e8a8f573 Merge pull request #1057 from who/fix_1056
Fixing a bug with truncated lone string responses
2015-08-06 17:38:54 -07:00
Andrew B
d5b959d8cd Fixing a bug with truncated lone string responses 2015-08-06 16:54:24 -07:00
Andrew B
7a92f53b55 Adding some tests for PR 1051 2015-08-06 15:22:18 -07:00
tiffanyperumpail
4ac8a93022 Change swagger-parser-version to 1.0.9-SNAPSHOT 2015-08-06 11:29:59 -07:00
Marcos Prieto
cad2f961bd Undo unicode on sanitize method. Keep the PR on point 2015-08-06 10:21:56 +02:00
tiffanyperumpail
5328c00e8f Simplified enum by changing CodeGenStatus to an enum instead of a wrapper. Updated version of swagger-parser to 1.0.9. 2015-08-05 16:53:39 -07:00
tiffanyperumpail
1b31a01b76 Added CodeGenStatus class with Status enum 2015-08-05 16:18:24 -07:00
Andrew B
c67a6582fc Bumping the version of swagger-parser to 1.0.9 2015-08-05 15:58:54 -07:00
Andrew B
dc76887820 Fixing subClassed types so that they can use enums 2015-08-05 15:50:34 -07:00
xhh
4321339d4f Java petstore sample: move to "default" sub-folder, add jersey2 2015-08-05 17:28:45 +08:00
xhh
07f10a8abc Add command to display all library templates supported
for a specific language
2015-08-05 16:37:08 +08:00
xhh
4ba521a5c0 Add jersey2 library template for Java client 2015-08-05 15:37:26 +08:00
xhh
d88ec847ae Remave unused imports 2015-08-05 09:43:15 +08:00
xhh
7c16dfcf13 Rebuild Java petstore sample 2015-08-04 18:36:03 +08:00
xhh
aff21e5e6b Add a "library" option to generate with sub-template 2015-08-04 18:32:54 +08:00
Marcos Prieto
befacc41bd Support for nested dict/list
Checking for `startwith` instead of just `in` to correctly categorize
nested structures.
2015-08-04 11:51:38 +02:00
Marcos Prieto
edebbcb802 Support for unicode headers, ie support for urlib3.util.make_headers 2015-08-04 11:51:25 +02:00
xhh
bfb4629ab7 Java client: decouple JSON handling 2015-08-04 15:47:55 +08:00
Tony Tam
1007534575 fix for #1042, removed empty / when basePath is null 2015-08-03 16:47:51 -07:00
Rogercf
97d24a7119 Update DefaultCodegen.java
Fixed indentation
2015-08-03 19:50:29 -03:00
Rogercf
13038d2a12 Update DefaultCodegen.java
Replaced hardcoded "String" with property.items.baseType
2015-08-03 19:46:10 -03:00
Rogercf
c5dc070685 Update model.mustache
Fixed generating array of enums properties in the java template
2015-08-03 19:21:54 -03:00
Rogercf
a30b66beb1 Update DefaultCodegen.java
Setting the "items" field when the type is array and updating some values if the array is an array of enums
2015-08-03 19:20:51 -03:00
Rogercf
aff766b785 Update CodegenProperty.java
Added a "items" field to keep track of the inner type to be accessed in the mustache templates
2015-08-03 19:19:10 -03:00
xhh
112a7ec8c1 Java client: move form params handling to ApiClient 2015-08-03 18:33:42 +08:00
wing328
55be0330e3 Merge pull request #1039 from geekerzp/python-desciption
[Python] Fix issue in python client
2015-08-03 10:48:56 +08:00
wing328
fe83d18a09 Merge pull request #1026 from geekerzp/objc-deserializtion
[Objc] Fix deserialize nested map error
2015-07-31 16:17:11 +08:00
wing328
a6f8f9e4ff Merge pull request #1017 from herveDarritchon/develop_2.0
Defect (Issue #905) : Add code to be able to override the configPackage …
2015-07-31 16:05:17 +08:00
geekerzp
79c988616c Fix issue #1038 2015-07-31 16:01:45 +08:00
wing328
dc62f688d9 Merge pull request #1015 from tandrup/conditional-copy-from-parent
Conditional copy properties from parent
2015-07-31 15:56:48 +08:00
wing328
db10bd764b Merge pull request #1036 from wing328/csharp_add_back_dll
[C#] add back RestSharp and Newtonsoft.Json DLL
2015-07-31 15:56:21 +08:00
wing328
92208b4ec2 Merge pull request #987 from xhh/retrofit-form-field-naming
Retrofit: fix form field naming by using baseName
2015-07-31 09:09:09 +08:00
xhh
0ef4702aa8 Merge branch 'develop_2.0' into retrofit-form-field-naming
Conflicts:
	samples/client/petstore/retrofit/src/main/java/io/swagger/client/api/PetApi.java
2015-07-30 16:40:43 +08:00
wing328
cc358cf9ce Merge pull request #1032 from xhh/retrofit-string-resp
Retrofit template: return body string directly when failed to parse response body as JSON
2015-07-30 15:58:05 +08:00
xhh
a1e6908b65 Merge branch 'develop_2.0' into retrofit-string-resp 2015-07-30 15:02:02 +08:00
xhh
2d4c07a474 Fix typo 2015-07-30 15:01:51 +08:00
wing328
05f00013f1 add back csharp dll, update sample 2015-07-30 10:19:46 +08:00
wing328
bc528ef928 Merge pull request #1027 from adamholdenyall/patch-3
Catch all exceptions on Deserialize
2015-07-30 10:06:32 +08:00
Tony Tam
318a239976 Merge pull request #1031 from Toilal/pom-issues
Fix issues in POM configuration
2015-07-29 07:35:05 -07:00
Toilal
189962208e Update scala maven plugin and fix issues in POM configuration 2015-07-29 15:15:12 +02:00
wing328
bd28271b0b Merge pull request #1019 from geekerzp/python-refactor
[Python] Enhancements of python client
2015-07-29 17:39:58 +08:00
xhh
14b808a910 Retrofit template: return body string directly
when failed to parse response body as JSON, fixing unit test for
UserApi#loginUser
2015-07-29 17:10:49 +08:00
wing328
d345f8fae3 Merge pull request #967 from moander/feature/docker
Docker build script and Dockerfile
2015-07-29 15:36:08 +08:00
Ole Lensmar
26336356cf added generated samples for jaxrs and inflector 2015-07-28 14:56:23 -07:00
Ole Lensmar
9c3fad3040 fixed generated code to go to target/generated-sources, added maven-codegen-plugin to generated jaxrs project together with initial swagger definition, fixed overwrite flag to kick in only if file exists, fixed initial readme 2015-07-28 14:40:43 -07:00
moander
d396a0a0e4 Friendly error message when project is not built 2015-07-28 22:48:18 +02:00
Tony Tam
dc7c2a4bab updated name 2015-07-28 13:35:33 -07:00
Tony Tam
0b85ad464a Merge pull request #1028 from swagger-api/inflector-template
added template for the inflector
2015-07-28 10:31:40 -07:00
Ole Lensmar
c5d02fe98e added template for the inflector 2015-07-28 10:19:36 -07:00
adamholdenyall
a81e5096f5 Catch all exceptions on Deserialize
If you look at the source of NewtonSoft.Json, you'll see that DeserializeObject never throws an IOException. All exceptions should be caught in this method, just like Serialize.
2015-07-28 09:53:10 -05:00
wing328
52971e6aa9 Merge pull request #1018 from wing328/fix_empty_operationid
[All] Better exception handling for empty operationId (method name)
2015-07-28 17:39:19 +08:00
geekerzp
b2e0d83f2e Update objc client.
* Fix issue that list of primitive types deserialization.
* Add test cases for list of primitive types deserialization and nested list deserialization.
2015-07-28 17:21:10 +08:00
geekerzp
2be3414357 Update python client.
Add test case for nested list deserialization.
2015-07-28 15:23:44 +08:00
geekerzp
ea901bf1ce Update python client.
Add test case for nested dict deserialization.
2015-07-28 14:34:50 +08:00
geekerzp
8bd282acd6 Change parameter name key to identifier of
Configuration#get_api_key_with_prefix in python client.
2015-07-28 11:25:19 +08:00
geekerzp
b51ef77401 Remove #!/usr/bin/env python from python client 2015-07-28 11:25:19 +08:00
geekerzp
3265ec0f72 Refactor python client. 2015-07-28 11:25:19 +08:00
wing328
732e645042 Merge pull request #1022 from SparrowJang/develop_2.0
fixed a error rule for parsing `)`
2015-07-28 11:15:28 +08:00
geekerzp
cc45ff17cb Fix deserialize nested map error in objc client 2015-07-28 10:51:20 +08:00
wing328
b843b55339 Merge pull request #1001 from who/csharp_dotnet2_template
C# .Net 2.0 generator and template
2015-07-28 09:32:03 +08:00
Sparrow.jang
75711f954b fixed a bug for parsing ) error 2015-07-27 18:50:32 +08:00
SparrowJang
d0b5af31a5 Merge pull request #1 from swagger-api/develop_2.0
Develop 2.0
2015-07-27 18:47:40 +08:00
wing328
c01c06b198 Merge pull request #1004 from mhardorf/conf-file-maven-plugin
Add support for specifying configuration file in maven plugin
2015-07-27 18:30:09 +08:00
Mads Mætzke Tandrup
586f4c14e1 Merge remote-tracking branch 'upstream/develop_2.0' into conditional-copy-from-parent
# Conflicts:
#	modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptNodeClientCodegen.java
2015-07-27 11:30:47 +02:00
wing328
fe0e43f963 Merge pull request #1012 from tandrup/combine-ts-node
Combine TypeScript Node output and beautify Angular output
2015-07-27 17:24:34 +08:00
wing328
47abfe7079 Merge pull request #1014 from 2rs2ts/module-generation-readme-path-fix
Fix path in instructions for making your own codegen modules
2015-07-27 17:12:13 +08:00
Mads Mætzke Tandrup
d0a3def441 Adding npm run clean command to clean the sample dir 2015-07-27 11:02:38 +02:00
Mads Mætzke Tandrup
64f2e85608 Update TypeScript angular sample 2015-07-27 10:20:55 +02:00
Mads Mætzke Tandrup
09ccf12a3b Update Typescript node samples 2015-07-27 10:19:12 +02:00
Mads Mætzke Tandrup
fde5c60cb0 Support authentication from swagger in TypeScript Node 2015-07-27 10:18:38 +02:00
Mads Mætzke Tandrup
b18cc5e0de Include header parameters 2015-07-27 10:13:36 +02:00
wing328
6d8dea5dfc better exception handling for empty method name 2015-07-27 12:07:35 +08:00
wing328
a8f580032f fix empty operationId in java codegen 2015-07-27 11:39:37 +08:00
wing328
d0baa48fcd fix empty operationId 2015-07-27 11:21:51 +08:00
wing328
31200acc1a Merge pull request #998 from geekerzp/objc-date
[Objc] Enhancements of objective-c client
2015-07-27 10:41:42 +08:00
geekerzp
3b9b3e82f9 Update comments in objc client 2015-07-27 10:29:27 +08:00
wing328
783a4c0572 Merge pull request #1016 from ngs/swift-podspec-version
[Swift] Add version to Podspec template
2015-07-27 08:33:44 +08:00
wing328
9ce824d720 Merge pull request #1007 from ngs/swift-alamofire-1.3.0
[Swift] Support file upload with Alamofire 1.3.0
2015-07-27 08:29:34 +08:00
Mads Mætzke Tandrup
dee828622a Test file upload in sample client 2015-07-26 14:26:01 +02:00
Hervé Darritchon
5c0ae7babe Defect (PR #905) : Add code to be able to override the configPackage in the spring mvc template. 2015-07-26 12:11:29 +02:00
Mads Mætzke Tandrup
02da80e837 Update sample with small test script 2015-07-26 08:22:32 +02:00
Mads Mætzke Tandrup
e41a475335 Update typescript node sample 2015-07-25 22:05:43 +02:00
Mads Mætzke Tandrup
fea8e680df Fix TypeScript node file upload 2015-07-25 22:05:29 +02:00
Mads Mætzke Tandrup
b0f6b49595 Fix TypeScript Map type 2015-07-25 22:02:06 +02:00
Atsushi Nagase
b56da43953 [Swift] Add version to Podspec template 2015-07-26 03:19:33 +09:00
Atsushi Nagase
979a704310 [Swift] Update Alamofire to 1.3 in Podspec 2015-07-26 03:01:11 +09:00
Atsushi Nagase
5dcdadb751 [Swift] tweak conditions
336bb87b53 (commitcomment-12318006)
2015-07-26 02:59:43 +09:00
Atsushi Nagase
f98974190e [Swift] Support file upload with Alamofire 1.3.0
refs:

- https://github.com/Alamofire/Alamofire/milestones/1.3.0
- https://github.com/Alamofire/Alamofire/pull/539
2015-07-26 02:59:43 +09:00
wing328
6719a6cc74 Merge pull request #1013 from SparrowJang/develop_2.0
added a utf8 declaration to fix #1011 issue
2015-07-25 23:15:04 +08:00
Mads Mætzke Tandrup
3f9b2a9678 Adding build system for typescript AngularJS sample 2015-07-25 14:11:10 +02:00
Mads Mætzke Tandrup
bbf0ce8c80 Adding README for sample 2015-07-25 13:57:45 +02:00
Mads Mætzke Tandrup
9fc8c770d3 Adding build system for poetaster typescript node sample 2015-07-25 13:55:30 +02:00
wing328
8f2c99f0af Merge pull request #1005 from mhardorf/sort-by-inheritance
Sort model objects by inheritance
2015-07-25 18:18:29 +08:00
Mads Mætzke Tandrup
81f5cc47e7 Rename property to be more language specific 2015-07-25 12:03:17 +02:00
wing328
db37c02ebd Merge pull request #1010 from onovy/develop_2.0
[Python] Allow to set cookie in python(3) API constructor.
2015-07-25 17:03:11 +08:00
wing328
fc71b23464 Merge pull request #1006 from ngs/podspec
[Swift] Add podspec template
2015-07-25 16:46:13 +08:00
Mads Mætzke Tandrup
e924cec595 Conditional copy properties from parent.
Pull request #946 broke the TypeScript generation with inheritance where a superclass defined an enum. This makes it up to each language to decide the behavior appropriate for the language.
2015-07-25 07:45:08 +02:00
Andrew Garrett
90f152da75 Fix path in instructions for making your own codegen modules 2015-07-24 11:44:30 -07:00
Sparrow.jang
713ae4a957 added a utf8 declaration to fix #1011 issue 2015-07-24 22:40:24 +08:00
Ondrej Novy
50736458d0 Allow to set cookie in python(3) API constructor. 2015-07-24 11:48:43 +02:00
Mads Mætzke Tandrup
34b341874c Include api and model package in angular 2015-07-24 11:05:36 +02:00
Mads Mætzke Tandrup
7a1f3dbf9e Fix angular output to go to one dir to make it build 2015-07-24 10:23:07 +02:00
Mads Mætzke Tandrup
3723a9ba2d Updating typescript samples 2015-07-24 10:22:41 +02:00
Mads Mætzke Tandrup
bc8eae838c Beautify typescript angular output 2015-07-24 10:14:42 +02:00
Mads Mætzke Tandrup
88ed496b44 Extract abstract class for TypeScript generators 2015-07-24 10:03:02 +02:00
Mads Mætzke Tandrup
646da19c7d Combine TypeScript node output in one file and add missing require statements 2015-07-24 09:48:49 +02:00
Atsushi Nagase
80b5363202 [Swift] add cliOptions for podspec
```
podSource
    Source information used for Podspec

podVersion
    Version used for Podspec

podAuthors
    Authors used for Podspec

podSocialMediaURL
    Social Media URL used for Podspec

podDocsetURL
    Docset URL used for Podspec

podLicense
    License used for Podspec

podHomepage
    Homepage used for Podspec

podSummary
    Summary used for Podspec

podDescription
    Description used for Podspec

podScreenshots
    Screenshots used for Podspec

podDocumentationURL
    Documentation URL used for Podspec
```
2015-07-24 16:27:28 +09:00
Atsushi Nagase
071fc2ded6 [Swift] Add podspec template 2015-07-23 22:22:45 +09:00
Martin Hardorf
992b0c7e5e Sort model objects by inheritance 2015-07-23 13:11:53 +02:00
Martin Hardorf
037f59d0df Add support for specifying configuration file in maven plugin 2015-07-23 13:10:59 +02:00
geekerzp
5a235c642a Update comments of objc client 2015-07-23 18:03:19 +08:00
geekerzp
08ea05f7a1 Update objc client.
* Add comments in SWGConfiguration.h
* Change `Date` to `date` in ObjcClientCodegen.java
* Update comments in model body template
2015-07-23 16:03:38 +08:00
Andrew B
e301d9d00e Adding sample generator and output 2015-07-22 11:31:29 -07:00
Andrew B
8a399ee1cb Renaming the C# .net 2.0 to be more generic 2015-07-22 11:13:13 -07:00
Andrew B
4e5b9e4af3 Renaming the C# .net 2.0 to be more generic 2015-07-22 11:13:08 -07:00
geekerzp
37c79525f7 Update model body template in objc client.
* Add some comments.
2015-07-22 18:31:50 +08:00
geekerzp
f9ad16e7aa Update objc client.
* Add test cases for deserialization.
* Pretty print model infomation.
2015-07-22 17:45:31 +08:00
wing328
cde8d7ba4c Merge pull request #984 from geekerzp/python-enum
[Python] Support enum for model property
2015-07-22 16:48:34 +08:00
geekerzp
bd6fa6a2e4 Update PetApiTests#test_find_pet_by_tags test case of python client 2015-07-22 15:50:40 +08:00
geekerzp
b9287cf417 Add to_str method in python client and add test cases. 2015-07-22 11:00:51 +08:00
Andrew B
df93ca80f7 Fixing an issue that was causing incorrect JSON key names 2015-07-21 15:49:37 -07:00
Andrew B
0247f0774d Updating the mono compile script to target .net 2 2015-07-21 11:12:17 -07:00
wing328
37dbd6e4cd Merge pull request #992 from who/develop_2.0
[C#] Fixing a mono compilation error
2015-07-21 21:43:06 +08:00
wing328
34db9814d8 Merge pull request #994 from wing328/fix_swagger_parser_version
Fix compilation error with a newer swagger parser
2015-07-21 17:39:24 +08:00
wing328
cf7082c2e6 fix swagger parser version to use 1.0.9-SNAPSHOT 2015-07-21 16:54:14 +08:00
wing328
6b4f810fec Merge pull request #981 from Edubits/develop_2.0
[Swift] Support use in Framework
2015-07-21 16:35:36 +08:00
Tony Tam
f7a07f72b8 added resolve option for #903 2015-07-20 23:31:49 -07:00
Andrew B
a6012ecf41 Initial commit of the Unity3D C# .net 2.0 generator 2015-07-20 23:26:59 -07:00
Andrew B
0b7b57bf4d [C#] Fixing a mono compilation error 2015-07-20 21:22:49 -07:00
wing328
498a400d4e Merge pull request #988 from wing328/csharp_update_unit_test
[C#] Updated unit test and minor change to conform style guide
2015-07-21 12:08:15 +08:00
wing328
405e5a7a35 Merge pull request #946 from xhh/model-all-of
Copy properties from parent models defined with allOf
2015-07-21 11:41:24 +08:00
wing328
f1304022b0 Merge pull request #852 from tomtit/issue837
Fixed #837: Generation of default values for complex arrays and maps has been improved.
2015-07-21 11:28:43 +08:00
wing328
fc7f2a92d0 Merge pull request #878 from lugaru1234/issue798
Fixed #798: original jar generation has been fixed.
2015-07-20 21:50:51 +08:00
wing328
27113cf326 Merge pull request #859 from lugaru1234/issue831
Fixed #831: skipOverwrite flag has been added
2015-07-20 21:14:33 +08:00
wing328
7179c15158 Merge pull request #966 from wing328/nodejs_fix_summary
[NodeJS] Add back summary and description to the endpoint definition
2015-07-20 11:12:15 +08:00
wing328
ba72e7344a remove nuget pacakges 2015-07-20 10:48:20 +08:00
wing328
596bde2ef6 remove leading space for path variable, update unit test 2015-07-20 10:43:08 +08:00
wing328
a863e538a8 Merge pull request #943 from psmay/develop_2.0-RestSharp-path-params
[C#] Use RestSharp's mechanism for path parameters in URL templates
2015-07-20 10:16:01 +08:00
xhh
a134b5ca76 Retrofit: fix form field naming by using baseName 2015-07-20 10:12:36 +08:00
Peter S. May
1f7664f81e Fixed case typo in previous edit. 2015-07-18 19:38:20 -04:00
geekerzp
68820e5a80 Update comments of api template of python client 2015-07-18 15:54:00 +08:00
geekerzp
195c71da37 Update comments of python client 2015-07-18 15:35:12 +08:00
geekerzp
ddfa713f55 Update wording of comment in api template of python client 2015-07-18 15:22:39 +08:00
geekerzp
c9889c5baf Update api template of python client 2015-07-18 15:03:55 +08:00
geekerzp
60d6cd744a Format python client using pep8 2015-07-18 14:30:19 +08:00
Peter S. May
1072c9d017 Merge remote-tracking branch 'upstream/develop_2.0' into develop_2.0-RestSharp-path-params
Conflicts:
	modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache
	modules/swagger-codegen/src/main/resources/csharp/api.mustache
2015-07-17 21:45:54 -04:00
Peter S. May
4bc4a8aed1 WIP pre-adding new sources for ApiClient and api 2015-07-17 21:09:05 -04:00
Robin Eggenkamp
0ad7005547 [Swift] Add support for basic form data 2015-07-16 17:56:20 +02:00
geekerzp
3993ef3dc8 Update python codegen.
Remove leading underscore.
2015-07-16 18:58:23 +08:00
geekerzp
8746f1544b Merge branch 'develop_2.0' into python-enum 2015-07-16 17:27:17 +08:00
geekerzp
f0e09ae33a Add enum support for model property of python client 2015-07-16 17:24:42 +08:00
wing328
e879268043 Merge pull request #941 from geekerzp/develop_2.0_python_async
[Python] Support asynchronous request in python client
2015-07-16 10:47:02 +08:00
geekerzp
33561fa159 Support date type in python client 2015-07-16 10:11:27 +08:00
Robin Eggenkamp
78760907a5 [Swift] Support use in a Framework
To support use in a Framework set access level of relevant classes,
methods and members to public
2015-07-15 18:22:36 +02:00
Robin Eggenkamp
30eb1f1075 Fix bug in api name placeholder 2015-07-15 18:20:05 +02:00
wing328
5c9afbafb2 Merge pull request #918 from geekerzp/develop_2.0_objc_issue
[Objc] Enhancements and Issue fix
2015-07-15 18:20:40 +08:00
geekerzp
0092d8a63b Update unit tests of objc client 2015-07-15 18:11:04 +08:00
wing328
3c6f07cbe3 Merge pull request #975 from wing328/sinatra_fix_tag
[Sinatra] Fixed outdated tag in mustache template
2015-07-15 17:50:25 +08:00
geekerzp
95cb5f73a3 Remove SWGFile from objc client 2015-07-15 17:10:24 +08:00
geekerzp
02f6c805af Update integration test of objc client 2015-07-15 17:10:24 +08:00
geekerzp
13d74f01a2 Add logging in objc client 2015-07-15 17:10:24 +08:00
geekerzp
8877be82f0 Update api-body.mustache of objc client 2015-07-15 17:10:24 +08:00
geekerzp
a25d3f2543 Update README file of objc client 2015-07-15 17:10:23 +08:00
geekerzp
3f017af464 Update objc client.
Replace SWGFile with NSURL.
2015-07-15 17:10:23 +08:00
geekerzp
0e56d0d1c6 Support file downloading in Objc codegen. 2015-07-15 17:10:23 +08:00
geekerzp
f48a7f20e6 Update config-help of objc cli 2015-07-15 17:10:23 +08:00
geekerzp
9a15ced211 Supoort customize classPrefix in objc client. 2015-07-15 17:10:23 +08:00
geekerzp
e244d20152 Remove lib files. 2015-07-15 17:10:23 +08:00
geekerzp
412b6b3839 Update objc client.
* Package objc client using cocoapods.
* Support cli options.
2015-07-15 17:08:45 +08:00
geekerzp
0a652a3d13 Fix issue#896 https://github.com/swagger-api/swagger-codegen/issues/896 2015-07-15 17:08:44 +08:00
geekerzp
4d302683f3 Update logging of python client 2015-07-15 15:58:45 +08:00
geekerzp
517717958d Update doc string of RESTClientObject#agent method of python client 2015-07-15 15:27:15 +08:00
geekerzp
b42ead3c0f Replace urllib3.util.url.parse_url with urllib3.util.parse_url 2015-07-15 15:27:14 +08:00
geekerzp
8a3c64aa41 Add logging and debug report for python client. 2015-07-15 15:27:14 +08:00
geekerzp
d97b0984cb Update ApiClient of python client.
Add docstring for method call_api.
2015-07-15 15:25:32 +08:00
geekerzp
0e8cf70dc4 Fix typo 2015-07-15 15:25:32 +08:00
geekerzp
88e5860d9b support asynchronous request in python client 2015-07-15 15:25:31 +08:00
wing328
157b07e552 Merge pull request #912 from gabrielar/develop_2.0-pull-requests/add-pathPrefix-key-to-operations
Add a `pathPrefix` key to the `operations` key
2015-07-15 10:26:13 +08:00
wing328
1f097ee1a1 Merge pull request #977 from who/develop_2.0
[PHP] Support for customizing namespace and Composer fields
2015-07-15 10:06:26 +08:00
wing328
7a5fd24785 Merge pull request #979 from xhh/auth-methods-fix
Fix NullPointerException for authMethods
2015-07-15 09:50:53 +08:00
wing328
59258be3dd Merge pull request #978 from tkQubo/fix/swift_bug
[Swift] Fix a bug
2015-07-15 09:42:39 +08:00
xhh
e5bdb3a0c1 Fix NullPointerException for authMethods 2015-07-15 09:21:09 +08:00
wing328
dd35c672f0 Merge pull request #935 from geekerzp/python-file-response
[Python] Support file downloading for Python API client
2015-07-14 17:45:11 +08:00
geekerzp
18ea21087f Update README file of python client 2015-07-14 17:34:38 +08:00
geekerzp
746a55be73 Update README file of python client 2015-07-14 17:15:24 +08:00
wing328
7242a664e3 Merge pull request #923 from xhh/ruby-debug
[Ruby] Some improvements & cleaning-up on Ruby API client
2015-07-14 16:34:41 +08:00
geekerzp
9f76acbbd7 Update README file of python client 2015-07-14 15:42:01 +08:00
geekerzp
af67353022 Update integration test of python client 2015-07-14 15:38:23 +08:00
kubo_takaichi
ecf4082d68 Fix bug in api name placeholder and api url 2015-07-14 13:41:28 +09:00
wing328
5821e41185 Merge pull request #927 from wing328/csharp_file_response
[C# ] Add file response
2015-07-14 12:34:51 +08:00
xhh
822e640e0a Merge branch 'develop_2.0' into ruby-debug
Conflicts:
	modules/swagger-codegen/src/main/resources/ruby/swagger/configuration.mustache
	modules/swagger-codegen/src/main/resources/ruby/swagger/request.mustache
	samples/client/petstore/ruby/lib/petstore/swagger/request.rb
	samples/client/petstore/ruby/lib/swagger_client.rb
	samples/client/petstore/ruby/lib/swagger_client/swagger/configuration.rb
2015-07-14 12:33:17 +08:00
geekerzp
30925b7800 Update pom.xml of python client 2015-07-14 10:28:36 +08:00
geekerzp
bb570d7efa Update integration-test of python client 2015-07-14 09:43:59 +08:00
geekerzp
c88c85a317 Enhancements intergration-test of python client 2015-07-14 09:39:19 +08:00
geekerzp
23dfac0194 Update deserialization of python client.
Return None if deserialize data is None.
2015-07-14 09:39:19 +08:00
geekerzp
b99f006861 Update Python client.
Throw ApiException if fail to parse string to datetime.
2015-07-14 09:39:19 +08:00
geekerzp
80d1deb2dd Update unit tests of Python client.
Add more test cases for deserialization.
2015-07-14 09:39:19 +08:00
geekerzp
2912ee8ae1 Update deserialize response of Python client. 2015-07-14 09:39:18 +08:00
geekerzp
6df6c079ee Support file downloading in Python codegen. 2015-07-14 09:39:18 +08:00
Andrew B
f4226474e2 Updating command-line parameter description for artifactVersion 2015-07-13 15:02:14 -07:00
Andrew B
b70a0bf0c6 Fixing an issue with errant namespace in the sample petstore 2015-07-13 14:56:33 -07:00
Andrew B
7dca394eca Support for customizing Composer package and namespaces 2015-07-13 14:46:56 -07:00
wing328
80303b524d Merge pull request #884 from xhh/params-order
Make sure "required" parameters are placed in front of "optional" parameters
2015-07-13 17:51:22 +08:00
wing328
6e7c70f247 fix sinatra outdated tag, use version tag 2015-07-13 17:43:18 +08:00
xhh
715c56afcc Rebuild petstore PHP sample with updated order on params 2015-07-13 16:51:19 +08:00
xhh
aad05c4dee Merge branch 'develop_2.0' into params-order
Conflicts:
	samples/client/petstore/php/SwaggerClient-php/lib/PetApi.php
	samples/client/petstore/php/SwaggerClient-php/lib/StoreApi.php
	samples/client/petstore/php/SwaggerClient-php/lib/UserApi.php
2015-07-13 16:48:19 +08:00
wing328
3f9d1607b6 Merge pull request #926 from wing328/php_support_file_response
[PHP] support "file" response
2015-07-13 15:51:20 +08:00
wing328
879c1b921c update php petstore sample 2015-07-13 15:31:20 +08:00
xhh
fb0b7d622f Merge branch 'develop_2.0' into params-order
Conflicts:
	modules/swagger-codegen/src/main/resources/php/api.mustache
2015-07-13 15:30:06 +08:00
wing328
f154e407d2 update coding style based on CodeSniffer 2015-07-13 15:26:12 +08:00
wing328
44705b566d add default version for package 2015-07-13 15:24:12 +08:00
wing328
71a22141bf add enum support for model property 2015-07-13 15:24:11 +08:00
wing328
38149173ff revert petstore json, fixed test case 2015-07-13 15:21:39 +08:00
wing328
2258a4632d fix test.php, fix default configuration 2015-07-13 15:21:39 +08:00
wing328
259b31ccd4 temporary folder setting 2015-07-13 15:21:38 +08:00
wing328
7f31da734d add file response for php, update test case 2015-07-13 15:09:09 +08:00
wing328
fcd0b31d7d add file response for php 2015-07-13 15:09:09 +08:00
wing328
4c2df94ec7 Merge pull request #953 from bletail/develop_2.0
Python/Python3 datetime and date type fixed
2015-07-13 15:05:13 +08:00
wing328
38760d2aa1 Merge pull request #915 from xhh/ruby-file-response
[Ruby] Support file downloading for Ruby API client
2015-07-13 14:50:40 +08:00
wing328
f6174051cb Merge pull request #931 from cbornet/oauth_support
generate oauth2 fields in the data for the templates
2015-07-13 14:39:14 +08:00
wing328
68915eeb8f Merge pull request #968 from mhardorf/develop_2.0
Cleaned up TypeScript code generator
2015-07-13 12:16:11 +08:00
wing328
1434691927 Merge pull request #916 from wing328/fix_optional
[Perl, Python AsyncScala] Fix optional tag in the template
2015-07-13 11:53:58 +08:00
wing328
b46efd839d Merge pull request #914 from webjunkie/patch-1
Optional is used in PHP template although not available
2015-07-13 11:52:55 +08:00
wing328
c7f8f0171b Merge pull request #919 from wing328/fix_java_android_path_issue
[Java, Android] Fix path variable name
2015-07-13 11:51:45 +08:00
wing328
045a3b44c1 Merge pull request #901 from tkQubo/feature/swift_develop_2.0
[Swift] Some fixes for SwiftGenerator for develop 2.0
2015-07-13 11:51:07 +08:00
wing328
6c85fc285a Merge pull request #959 from dilipkrish/develop_2.0
Updated the swagger-codegen sample for generating the service side stubs
2015-07-13 10:14:05 +08:00
Dilip Krishnan
7cc9581f04 Updated the mustache template to remove the spurious import
Also regenerated the spring-mvc server sample
2015-07-12 20:56:36 -05:00
Dilip Krishnan
9283249963 Updated the swagger-codegen sample for generating the service side stubs
for spring mvc using springfox implementation
2015-07-12 20:56:31 -05:00
Tony Tam
461f556289 Merge pull request #893 from sudohippie/develop_2.0-fork
Android & Java template modifications to check collectionFormat when creating query parameters
2015-07-09 10:11:54 -07:00
Martin Hardorf
e3d3641b96 Removed unused import 2015-07-09 14:57:40 +02:00
Martin Hardorf
7e8f8e85d7 Changed default name of the modelPackage 2015-07-09 14:55:15 +02:00
Martin Hardorf
abc7100a17 Removed unused code from the api classes 2015-07-09 14:54:36 +02:00
Morten Andersen
661b9d6315 Docker generate example 2015-07-09 12:58:33 +02:00
moander
a21c2be877 Set executable flag 2015-07-09 10:39:35 +00:00
moander
5c29cbf33d Build and run script for docker 2015-07-09 12:33:43 +02:00
Martin Hardorf
d3bc347e31 Changed base path to use contextPath 2015-07-09 10:34:39 +02:00
wing328
1f35f58841 add back summary and description to nodejs swagger.json 2015-07-09 14:05:08 +08:00
xhh
a51d71e728 Fix syntax error when there are no authMethods 2015-07-09 10:48:16 +08:00
wing328
b8c06505f6 use fully qualified name for Task 2015-07-09 10:21:55 +08:00
moander
80731633b4 Created a Dockerfile 2015-07-09 01:22:06 +02:00
Tobias Pfeifer
4c16366f45 fix SpringMVCServerCodegen for maps as in JavaClientCodegen 2015-07-08 15:45:38 +02:00
Martin Hardorf
4133cae2bc Fixed mustache to handle non-required parameters 2015-07-08 11:19:25 +02:00
Martin Hardorf
f6a1af2831 Changed maps to any and DateTime to Date 2015-07-08 11:17:06 +02:00
xhh
a24fee00cb Support primitive response in Ruby client 2015-07-08 16:46:31 +08:00
xhh
f42f329ace Parse "date" as Date in Ruby client 2015-07-08 13:10:28 +08:00
xhh
6fd2ccabee Merge branch 'develop_2.0' into ruby-debug 2015-07-08 12:38:21 +08:00
DariusM
20c7932df4 Python /python3 datetime and date fixed 2015-07-07 13:00:28 +02:00
wing328
e49fe7a12f better style for model, add <value> to all properties 2015-07-07 16:25:33 +08:00
wing328
b1b0e28f59 update c# style 2015-07-06 23:06:28 +08:00
Tony Tam
dfd8d5ef64 updated to latest release version 2015-07-06 04:55:12 -07:00
wing328
94768d44b5 better type comparision 2015-07-06 13:55:33 +08:00
wing328
3b1999af4b update csharp sample 2015-07-06 11:24:59 +08:00
wing328
7e4a82bcfb add readme 2015-07-06 11:18:05 +08:00
wing328
f823c0e26a update newtonsoft json 2015-07-06 11:03:36 +08:00
xhh
bf32777b67 Fix NullPointerException in tests, improve usage to addVars 2015-07-03 18:07:34 +08:00
wing328
987a61640b fix file upload issue. add error handling for status code 0 2015-07-03 17:39:27 +08:00
xhh
66d16cfeaf Validate parameter against allowed values (enum) 2015-07-03 16:46:23 +08:00
xhh
0bf4163389 Copy properties of intermediate (interface) models 2015-07-03 15:08:37 +08:00
xhh
b61a400d91 Copy properties of parent model to model with allOf
Also fix #936
2015-07-03 15:08:37 +08:00
wing328
55827fe516 fix model import for csharp 2015-07-03 14:20:54 +08:00
wing328
5c888ad039 better method comment 2015-07-03 13:55:51 +08:00
wing328
d7d6ba957e fix comment and use 4-space indentation 2015-07-03 11:45:31 +08:00
wing328
57b54d8ad7 update code style for apiclient, configuration and apiexception 2015-07-03 10:36:21 +08:00
Peter S. May
4b896c759c [C#] Use RestSharp's mechanism for path parameters in URL templates
Previously, a simple find-and-replace had been used to substitute path parameters into the path. Among other omissions, this resulted in special characters such as `/` being left unescaped.

The RestSharp request object, as it turns out, expects a path template in the same format as provided by Swagger (with param names in braces), to be filled in using `AddParameter()`. In this edit, the code now uses this mechanism. The form parameter values are now passed to `CallApi*()` as a `Dictionary<String, String>`, where they are added to the request before submission. Since this was already how query and form parameters (etc.) were implemented, the resulting code is more consistent with itself than before.
2015-07-02 15:33:30 -04:00
Ole Lensmar
aba755d3de Merge pull request #940 from xhh/jax-rs-classname
Sanitize API class name in Jax RS server codegen
2015-07-02 11:38:10 +02:00
xhh
fe35675168 Allow numbers for classname
and remove spaces
2015-07-02 17:15:53 +08:00
xhh
d825b96720 Sanitize API class name in Jax RS server codegen 2015-07-02 12:00:18 +08:00
wing328
422da698f6 import model only if it has import for c# 2015-07-02 11:18:41 +08:00
wing328
488e604207 use stream for file 2015-07-01 21:37:48 +08:00
xhh
846d282ba0 Add helper methods for last response 2015-07-01 18:48:31 +08:00
xhh
6f1dd5ce35 Store last response in a thread-safe way 2015-07-01 17:37:16 +08:00
xhh
108b2241c0 Validate model property against allowed values (enum)
when present with attribute setters
2015-07-01 17:18:29 +08:00
wing328
4d6dbf7d92 show return in doc only if it has a return 2015-07-01 15:16:28 +08:00
Nadezhda Makarkina
eca827613d Fixed #831: skipOverwrite flag has been added 2015-06-30 17:58:35 +03:00
wing328
2e76b56f30 revert file to String, add test case for upload file 2015-06-30 17:50:22 +08:00
wing328
f290de95dd update parameter name to camelize lower 2015-06-29 23:14:00 +08:00
wing328
59987a54a9 fix deserialization of string and other primitive 2015-06-29 22:16:38 +08:00
cbornet
2d59c5d190 generate oauth2 fields in the data for the templates
Fixes #347
2015-06-29 13:39:39 +02:00
wing328
9726ada8d1 fix return type and tempfolder 2015-06-29 15:30:34 +08:00
wing328
76ece5a4eb add file response support for c# (passed test cases) 2015-06-29 12:17:49 +08:00
kubo_takaichi
91af76cf41 Use CLI option 2015-06-27 23:24:49 +09:00
kubo_takaichi
65af735d6c Merge commit '4143e286374bdd384c39a68df1f8f3a3eb58e6a4' into feature/swift_develop_2.0 2015-06-27 21:19:32 +09:00
wing328
30bc58f6ff Merge branch 'fix_optional' of https://github.com/wing328/swagger-codegen into fix_optional 2015-06-26 23:57:06 +08:00
wing328
3eca940e7d fix perl and asyncscala optional tab 2015-06-26 23:56:20 +08:00
wing328
38d62d768a fix optional for python, python3 2015-06-26 23:56:20 +08:00
xhh
1de6952279 Support customizing default headers via config option
for example:

    config.default_headers['X-MY-HEADER'] = 'my-header-value'
2015-06-26 19:09:20 +08:00
xhh
54d6a7e19c Merge branch 'develop_2.0' into ruby-file-response 2015-06-26 17:44:37 +08:00
xhh
fafddbf040 Fix naming in specs 2015-06-26 17:16:38 +08:00
xhh
d8b0cb739f Add config file for bin/ruby-petstore.sh
to rename swagger_client to petstore
2015-06-26 17:15:14 +08:00
xhh
2d3d35cfd7 Rebuild Ruby petstore client 2015-06-26 16:37:58 +08:00
xhh
8c10e4f2b0 Remove unused code 2015-06-26 16:06:32 +08:00
xhh
0ac1ef266f Avoid more monkey-patching 2015-06-26 16:04:18 +08:00
xhh
327128dbba Fix "date" type deserialization 2015-06-26 15:57:46 +08:00
xhh
16e80c65d7 Avoiding monkey-patching in Ruby API client 2015-06-26 15:56:59 +08:00
xhh
40c9f05536 Merge branch 'develop_2.0' into ruby-debug 2015-06-26 10:38:58 +08:00
wing328
091e76703c update sample 2015-06-26 10:35:50 +08:00
wing328
6a24b328e3 fix variable name in path 2015-06-26 10:30:12 +08:00
Tony Tam
4143e28637 Merge branch 'wing328-csharp_add_cli_support' into develop_2.0 2015-06-25 11:55:41 -07:00
Tony Tam
31efefe0b9 Merge branch 'csharp_add_cli_support' of ssh://github.com/wing328/swagger-codegen into wing328-csharp_add_cli_support 2015-06-25 11:54:30 -07:00
Tony Tam
e60bd564cb Merge pull request #864 from geekerzp/python-cli-option
[Python] Enabling cli config options for python generator
2015-06-25 11:53:29 -07:00
Tony Tam
69b75bb1af Merge pull request #885 from mhardorf/develop_2.0
Added support for TypeScript generation for AngularJS and Node.js
2015-06-25 11:53:21 -07:00
Tony Tam
1fb796f14d Merge pull request #891 from who/develop_2.0
Replacing getClientResponseStatus() with getStatusInfo()
2015-06-25 11:53:10 -07:00
Tony Tam
e996498a24 Merge pull request #913 from xhh/scala-warnings
[Scala] Fix warnings and upgrade jersey for Scala client
2015-06-25 11:52:57 -07:00
Tony Tam
c3d1367e7c Merge pull request #894 from wing328/csharp_add_nunit
[C#] Add NUnit test
2015-06-25 11:52:19 -07:00
Tony Tam
69eae7d35b merged 2015-06-25 10:23:05 -07:00
Tony Tam
162d1d1f98 merged 2015-06-25 10:21:38 -07:00
Tony Tam
07d5365c5c merged from #902, rebuilt client 2015-06-25 10:17:28 -07:00
Tony Tam
f1239aba6c Merge pull request #908 from wing328/fix_php_file_sep
[PHP] Fix regular expression in toPackagePath
2015-06-25 10:10:30 -07:00
Tony Tam
37620518e7 Merge pull request #892 from wing328/add_sinatra
[Ruby] Add back Sinatra tempates
2015-06-25 10:10:22 -07:00
William Cheng
9d739a44cd update python test case 2015-06-25 21:47:00 +08:00
wing328
18ac6e8aae fix perl and asyncscala optional tab 2015-06-25 23:10:25 +08:00
wing328
8cce7ac053 fix optional for python, python3 2015-06-25 22:40:14 +08:00
xhh
e6e1db2064 Support looser format when detecting filename 2015-06-25 16:26:04 +08:00
xhh
ceafbcc97f Add config option for file downloading folder. Log about file downloading 2015-06-25 16:07:02 +08:00
xhh
f3a0f464f7 Support file downloading in Ruby generator 2015-06-25 15:35:48 +08:00
Raghav Sidhanti
1af23fb751 Unit tests for Android and Java parameterToPairs method 2015-06-24 11:55:03 -07:00
Raghav Sidhanti
ea76f34de5 Merge branch 'develop_2.0' of https://github.com/swagger-api/swagger-codegen into develop_2.0-fork 2015-06-24 11:25:32 -07:00
Julian Bez
8ce3823698 Change to not required 2015-06-24 16:34:32 +02:00
Julian Bez
644231b915 Change optional to required 2015-06-24 16:32:49 +02:00
xhh
621e3e7b1a Add comments for some configuration options 2015-06-24 15:57:01 +08:00
wing328
6aac24398a update model to support inheritance (#879) 2015-06-24 14:34:05 +08:00
xhh
545fb52b7d Merge branch 'develop_2.0' into ruby-debug 2015-06-24 14:10:47 +08:00
Ole Lensmar
8e6c0f96fb updated documentation and removed java-specific parameters from general configuration 2015-06-24 07:31:10 +02:00
Gabriel Radu
1b1f860c82 Add a pathPrefix key to the operations key 2015-06-24 03:28:38 +01:00
Ole Lensmar
50dd196d42 fixed code formatting and imports 2015-06-24 00:12:50 +02:00
Ole Lensmar
ce6ec20fef added config parameters for all default parameters and a configOptions map for language specific parameters 2015-06-24 00:11:13 +02:00
Ole Lensmar
11e56f5c9c Merge pull request #898 from garethjevans/develop_2.0
Contributed maven plugin to the swagger-codegen project
2015-06-23 23:20:49 +02:00
nmonterroso
efd5b806be updating php generated samples and updating tests 2015-06-23 09:27:52 -07:00
nmonterroso
1b4c71c280 re-adding Configuration->deleteDefaultHeader 2015-06-23 09:27:34 -07:00
wing328
d83036ccdf fix regular expression 2015-06-23 22:36:57 +08:00
wing328
d18426c69a fix reg expression 2015-06-23 22:30:43 +08:00
wing328
351833a923 test fix 2015-06-23 21:52:00 +08:00
wing328
2979d93829 use replace instead of replaceAll 2015-06-23 21:47:10 +08:00
Martin Hardorf
2fce2e4109 Removed wrong hasMore from Angular TypeScript mustache 2015-06-23 15:37:07 +02:00
xhh
13d350be2e Fix warnings and upgrade jersey for Scala client
* Upgrade jersey to latest version (from 1.7 to 1.19)
* Replace getClientResponseStatus() with getStatusInfo()
* Fix the following maven warnings and model import warnings

    [WARNING] 'build.plugins.plugin.version' for org.codehaus.mojo:build-helper-maven-plugin is missing. @ line 72, column 15
    [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!

    [WARNING]  Expected all dependencies to require Scala version: 2.10.4
    [WARNING]  com.fasterxml.jackson.module:jackson-module-scala_2.10:2.4.2 requires scala version: 2.10.4
    [WARNING]  org.scala-lang:scala-reflect:2.10.4 requires scala version: 2.10.4
    [WARNING]  io.swagger:swagger-scala-client:1.0.0 requires scala version: 2.10.4
    [WARNING]  org.scalatest:scalatest_2.10:2.1.3 requires scala version: 2.10.3
    [WARNING] Multiple versions of scala libraries detected!

   [WARNING] /Users/xhh/projects/swagger-codegen/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/Pet.scala:3: warning: imported `Category' is permanently hidden by definition of object Category in package model
2015-06-23 21:23:48 +08:00
wing328
550493ba84 fix php separator 2015-06-23 21:20:12 +08:00
Martin Hardorf
c45af23946 Fixed headerParams and paramName 2015-06-23 12:05:43 +02:00
xhh
19ee56592e Allow customizing SSL CA certificate
by adding a `ssl_ca_cert` configuration option
2015-06-23 17:23:22 +08:00
kubo_takaichi
aec4af1b88 Replace slash with File.separator 2015-06-23 16:10:21 +09:00
xhh
46869df631 Make HTTP response accessible by storing the last response
so that users are able to retrieve, for example, rate-limit headers
from the response
2015-06-23 15:02:40 +08:00
nmonterroso
c91a1b963b change serializer to be instanced, rather than static methods 2015-06-22 21:33:44 -07:00
nmonterroso
2fced0f634 Revert "Updates to csharp model template to support inheritance"
This reverts commit 5f1df9e093.
2015-06-22 21:12:13 -07:00
nmonterroso
60b0ffeb0e don't prepend the invokerPackage - an artifact from an earlier implementation 2015-06-22 21:06:22 -07:00
nmonterroso
6623e120cd renaming to Configuration 2015-06-22 20:53:59 -07:00
nmonterroso
46ec934a9c java7 doesn't have replace, but put operates as such, so switch to that 2015-06-22 20:49:12 -07:00
nmonterroso
5a9e9550ca fixing php-doc 2015-06-22 20:43:00 -07:00
nmonterroso
8e0142338e removing unused imports 2015-06-22 20:36:57 -07:00
nmonterroso
61e368ce87 Merge remote-tracking branch 'swagger/develop_2.0' into php-upgrades 2015-06-22 20:29:09 -07:00
nmonterroso
c93b0dd3b8 make srcBasePath configureable 2015-06-22 20:24:19 -07:00
kubo_takaichi
79e31a5761 Add a workaround against void forcibly being converted to string 2015-06-23 12:20:00 +09:00
kubo_takaichi
fa3a9a9d61 Change class package 2015-06-23 12:20:00 +09:00
kubo_takaichi
febaa340e3 Treat object as String (temporary measure) 2015-06-23 12:20:00 +09:00
kubo_takaichi
bcab55e3ef Tighten parameter requirement 2015-06-23 12:20:00 +09:00
kubo_takaichi
24465d2df4 Change model naming 2015-06-23 12:20:00 +09:00
kubo_takaichi
8540ac71c8 Update swift code generation script 2015-06-23 12:20:00 +09:00
kubo_takaichi
9e47042122 Update models 2015-06-23 12:20:00 +09:00
kubo_takaichi
e0109afc60 Fix typo 2015-06-23 12:20:00 +09:00
kubo_takaichi
ff88f7175d Update models 2015-06-23 12:20:00 +09:00
kubo_takaichi
c9a9b0ad2b Refine authMethods description 2015-06-23 12:20:00 +09:00
kubo_takaichi
db01ec801f Add suppressRequired functionality 2015-06-23 12:20:00 +09:00
kubo_takaichi
495e528eec Add generated code 2015-06-23 12:20:00 +09:00
kubo_takaichi
a7c91d610f Add error response body to NSError 2015-06-23 12:20:00 +09:00
kubo_takaichi
d08acf7298 Add a dateTime formatter candidate 2015-06-23 12:20:00 +09:00
kubo_takaichi
7be35bb02e Change method name to avoid name collision 2015-06-23 12:20:00 +09:00
Raghav sidhanti
b4d6fd3ba3 Returning when query param value is null. 2015-06-22 20:16:35 -07:00
nmonterroso
d5d1483656 properly account for custom and non-custom settings for modelPackage and apiPackage 2015-06-22 20:14:54 -07:00
Tony Tam
02c41ac574 fix for #900, invalid param name for java client 2015-06-22 20:00:28 -07:00
nmonterroso
3a6f431f62 make packagePath configureable, and remove unused code 2015-06-22 19:34:03 -07:00
nmonterroso
4fe979a8c0 code compiles and *should* work, but need to re-organize for separate client/api-specific class namespaces 2015-06-22 19:26:26 -07:00
xhh
3b6a3b4a38 Add logging for API call entry and result 2015-06-23 10:12:20 +08:00
nmonterroso
da14c9e692 changing to invokerPackage 2015-06-22 19:09:32 -07:00
nmonterroso
b8b003bc83 Merge remote-tracking branch 'swagger/develop_2.0' into php-upgrades
Conflicts:
	modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java
	modules/swagger-codegen/src/main/resources/php/ApiClient.mustache
	modules/swagger-codegen/src/main/resources/php/ApiException.mustache
	modules/swagger-codegen/src/main/resources/php/api.mustache
	modules/swagger-codegen/src/main/resources/php/autoload.mustache
	modules/swagger-codegen/src/main/resources/php/configuration.mustache
	modules/swagger-codegen/src/main/resources/php/model.mustache
	modules/swagger-codegen/src/test/scala/php/PhpModelTest.scala
2015-06-22 19:09:13 -07:00
xhh
229ea93627 Add debugging switch to Ruby generator 2015-06-23 10:06:01 +08:00
xhh
24296eacea Merge branch 'develop_2.0' into params-order
Conflicts:
	samples/client/petstore/ruby/lib/swagger_client/api/pet_api.rb
2015-06-23 10:02:18 +08:00
Raghav Sidhanti
6958db3d3d Refactored Pairs to use List instead of Set. 2015-06-22 17:14:18 -07:00
Raghav Sidhanti
32b50e7c8e Refactored parameterToPairs 2015-06-22 17:02:00 -07:00
Tony Tam
b803895750 Merge pull request #865 from ammmze/feature/php-namespace-and-doc
Improve PHP namespace support
2015-06-22 16:53:57 -07:00
Tony Tam
d1153dfeb4 Merge pull request #866 from geekerzp/develop_2.0_objc_deserialize_map
[Objc] bug fix for map response
2015-06-22 16:53:28 -07:00
Tony Tam
385fab225e Merge pull request #871 from xhh/ruby-object-type
[Ruby] Support deserialization of "object" type in Ruby generator
2015-06-22 16:53:21 -07:00
Tony Tam
89a5abb217 Merge pull request #870 from wing328/perl_cli_support
[Perl] Add CLI config options and code enhancement
2015-06-22 16:53:12 -07:00
Raghav Sidhanti
79a5614be9 Invalid strings will be passed as blank query param. 2015-06-22 15:55:29 -07:00
Raghav Sidhanti
a1b56c9b83 Renamed QueryParam to Pair class in Android templates. 2015-06-22 15:28:29 -07:00
Raghav Sidhanti
ecddfb7ccf Renamed QueryParam to Pair class in Java templates. 2015-06-22 15:16:45 -07:00
nmonterroso
bd5eb7ace3 update tests 2015-06-22 12:30:52 -07:00
nmonterroso
8e15bd6a85 call setHost on config 2015-06-22 12:13:39 -07:00
nmonterroso
5ef50f9f4b rename ApiConfiguration to ApiClientConfiguration 2015-06-22 12:07:48 -07:00
nmonterroso
a6331244e1 move all configuration to ApiConfiguration 2015-06-22 12:05:22 -07:00
nmonterroso
01d7776fc1 don't create a new response object, and keep the old string value in the exception and have the object as ApiException->responseObject 2015-06-22 11:47:23 -07:00
nmonterroso
109b7eeaec adding static setters/getters for models since members are no public 2015-06-22 11:19:01 -07:00
nmonterroso
5de99bafa7 fixing package output 2015-06-22 11:18:36 -07:00
Gareth Evans
a664abcf51 Contributed maven plugin to the swagger-codegen project 2015-06-22 19:17:29 +01:00
nmonterroso
6f11092a57 call setHost using API baspath when no apiclient is provided 2015-06-22 10:35:57 -07:00
nmonterroso
e598384d97 move authentication to the API level, so that supporting classes aren't api-specific 2015-06-22 10:31:38 -07:00
nmonterroso
53bddae904 separate serialization responsibility to ObjectSerializer class 2015-06-22 09:47:28 -07:00
nmonterroso
1519912a1a cleaning up some php doc 2015-06-22 09:26:45 -07:00
nmonterroso
b3a3bdd2e0 add fully-qualified class names to deserialize params 2015-06-22 09:18:41 -07:00
nmonterroso
04be474f56 moving $host back to ApiClient and making ApiClient setters fluent 2015-06-22 08:36:49 -07:00
nmonterroso
99e963709b renaming configuration 2015-06-22 08:30:08 -07:00
nmonterroso
b9ca19168a remove static fields in Configuration and make variable case more consistent 2015-06-22 08:28:22 -07:00
geekerzp
acf09da578 Fix typo in python codegen 2015-06-22 16:35:15 +08:00
wing328
1d59937150 add nunit test for csharp 2015-06-22 11:53:44 +08:00
nmonterroso
caa1b7f411 generate model imports for support files, and use them as imports 2015-06-19 15:20:29 -07:00
Raghav Sidhanti
7a9a41fe01 Java and Android template changes to accommodate query params defined by the collection-format. 2015-06-19 14:06:25 -07:00
nmonterroso
acdc5328fe deserialize thrown exceptions 2015-06-19 11:24:56 -07:00
nmonterroso
3252dd0d18 check for null array in constructor 2015-06-19 10:32:38 -07:00
nmonterroso
5c409884b9 make setters fluent 2015-06-19 10:31:05 -07:00
nmonterroso
f9f58596b8 account for return type where the response type is in a list container, and properly import models into operations 2015-06-18 16:51:24 -07:00
nmonterroso
bb11322919 use proper namespaces, getters/setters, and phpdocs 2015-06-18 15:41:12 -07:00
nmonterroso
4495774fd5 proper autoloader and move generated files to PSR-4 compliant locations 2015-06-18 15:08:45 -07:00
Andrew B
1aeb50feef Replacing getClientResponseStatus() with getStatusInfo() 2015-06-18 14:41:17 -07:00
Branden Cash
b74050dd7b Change to use the autoload.php and change the namespacing 2015-06-18 11:45:08 -07:00
Branden Cash
2ac7384abf Fix tests 2015-06-18 11:43:54 -07:00
Branden Cash
eed45a41a3 Fixed the missing closing doc chars and updated sample 2015-06-18 11:43:54 -07:00
Branden Cash
69c2f6f945 Add phpdoc for the api.apiClient 2015-06-18 11:43:54 -07:00
Branden Cash
5119299e8a Remove unused code 2015-06-18 11:43:54 -07:00
Branden Cash
719a0b732e Update sample client 2015-06-18 11:43:48 -07:00
Branden Cash
8ed690cad0 Better namespace support, so that your not limited to only having a single vendor space, you can have \Vendor\Package\Model as a namespace. Also updates with proper phpdoc comments so that IDE code hinting can function properly. 2015-06-18 11:41:14 -07:00
William Cheng
f957471509 update silex sample code location 2015-06-19 02:37:08 +08:00
William Cheng
0b0325b8af update readme, fix swaggering name 2015-06-19 02:32:50 +08:00
William Cheng
d178d5e7d8 add sinatra template 2015-06-19 02:11:08 +08:00
nmonterroso
4ef34680cd renaming to ApiClient.mustache 2015-06-18 10:30:53 -07:00
wing328
6ab7be4058 add package version 2015-06-18 22:20:52 +08:00
wing328
df72188bc0 add cli support to csharp 2015-06-18 22:06:59 +08:00
geekerzp
8d18aee2f2 Update test case test_deserialize_to_dict of python client 2015-06-18 22:02:54 +08:00
Martin Hardorf
449ba4f644 Fixed required parameters for APIs in TypeScript 2015-06-18 12:42:04 +02:00
geekerzp
194c8ff71d Update config-help message of python client 2015-06-18 10:43:25 +08:00
geekerzp
62f4c252f2 Update python codegen.
* Update config-help message.
* Do not sanitize packageName to underscore format.
2015-06-18 10:43:24 +08:00
geekerzp
5d19ef6146 Generate the python into python/ folder directly 2015-06-18 10:43:24 +08:00
geekerzp
a32335dfbc Enable cli config options for python generator 2015-06-18 10:43:24 +08:00
geekerzp
6b6480a026 Updated xcode project of objc client 2015-06-18 10:38:19 +08:00
geekerzp
a4df33d040 Add comments for SWGJSONResponseSerializer#responseObjectForResponse
method of objective-c client.
2015-06-18 10:03:51 +08:00
geekerzp
8b15416be5 Add SWGJSONResponseSerializer for objective-c client.
If the response data is valid json, return the deserialized json.
If the response data is invalid json, return the string of response data.
2015-06-18 10:03:51 +08:00
geekerzp
bc92465bf7 Update Objective-C method description (doc comments) style 2015-06-18 10:03:51 +08:00
geekerzp
a6bdc35d59 Support pure object response for objc client 2015-06-18 10:03:51 +08:00
geekerzp
c50c8b724d Support map response for objc client.
completed.
2015-06-18 10:03:50 +08:00
geekerzp
0da3e58fff Support map response for objc client.
not completed
2015-06-18 10:03:12 +08:00
xhh
edcb71ad22 Merge branch 'develop_2.0' into params-order
Conflicts:
	bin/all-petstore.sh
2015-06-18 09:59:13 +08:00
xhh
d6d707543d Merge branch 'develop_2.0' into ruby-object-type
Conflicts:
	modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java
2015-06-18 09:56:58 +08:00
William Cheng
8858e7d7e3 update perl sample 2015-06-18 02:44:40 +08:00
William Cheng
64b46c2e15 update indentation, remove export 2015-06-18 02:40:15 +08:00
wing328
82baa7ce4b update help text 2015-06-18 10:57:10 +08:00
wing328
d7315b56dc removed non-perl update 2015-06-18 10:57:10 +08:00
wing328
10e07eaf74 add support for cli (perl) 2015-06-18 10:57:09 +08:00
Martin Hardorf
e7d4a438dd Added tests for TypeScript Angular and Node.js 2015-06-17 17:58:52 +02:00
Martin Hardorf
9e8631b75f Added shell scripts for sample generation of TypeScript 2015-06-17 17:56:37 +02:00
Tony Tam
e39ec927a2 Merge pull request #879 from shoatman/master
Updates to csharp model template to support inheritance
2015-06-17 08:30:07 -07:00
Tony Tam
6ad3a717fe Merge pull request #882 from wing328/php_add_silex
[PHP] add Silex server-side codegen
2015-06-17 08:29:48 -07:00
Tony Tam
f66b5cf65b Merge pull request #867 from wing328/fix_jar_path
[Bug fix] Fix path inside JAR for non-template files
2015-06-17 08:28:30 -07:00
Tony Tam
d8c337185f Merge pull request #857 from wing328/php_warning
[PHP] Remove PHP5.3 warning
2015-06-17 08:27:47 -07:00
Tony Tam
5ade64b3e1 Merge pull request #856 from wing328/csharp_upgrade_restsharp
[C#] upgrade restsharp to 105.1.0
2015-06-17 08:27:10 -07:00
Tony Tam
e65a079f0e Merge pull request #855 from geekerzp/develop_2.0_python_deserialize_map
[Python] bug fix for map response
2015-06-17 08:26:58 -07:00
Tony Tam
378ffffdc7 Merge pull request #854 from geekerzp/develop_2.0_objc_pro_rename
[Objc] Change xcode project name in objc sample code
2015-06-17 08:26:42 -07:00
Tony Tam
dd356b54c0 Merge pull request #853 from wing328/perl_support_map3
[Perl] update deserialization to support Map and List
2015-06-17 08:25:45 -07:00
Tony Tam
f56388845c Merge pull request #850 from xhh/ruby-cli-option2
[Ruby] Enabling cli config options for ruby generator
2015-06-17 08:25:34 -07:00
William Cheng
436db1f8e7 add __toString and update php sample 2015-06-17 19:00:29 +08:00
Martin Hardorf
ba4b88ef86 Fixed TypeScript mustache 2015-06-17 12:22:15 +02:00
xhh
b39d44db03 Add missing petstore scripts to bin/all-petstore.sh 2015-06-17 16:16:44 +08:00
xhh
9c4e5ed596 Rebuild Petstare sample for Java, Android, PHP, etc. 2015-06-17 16:15:37 +08:00
wing328
ce40da0f71 add php silex server side codegen 2015-06-17 16:01:24 +08:00
xhh
7f4586a47f Fix comment regarding required parameter in PHP generator 2015-06-17 16:00:59 +08:00
xhh
24a2de7389 Sort parameters to move required ones in front of optional ones 2015-06-17 16:00:16 +08:00
Shane Oatman
5f1df9e093 Updates to csharp model template to support inheritance 2015-06-16 12:12:17 -07:00
xhh
5435777c65 Merge remote-tracking branch 'origin/develop_2.0' into ruby-object-type 2015-06-16 18:42:18 +08:00
xhh
7c355030f4 Add to_s method for models 2015-06-16 18:41:51 +08:00
Nadezhda Makarkina
7b5b874fdc Fixed #798: original jar generation has been fixed. 2015-06-16 11:58:22 +03:00
Martin Hardorf
f87bb12ebb Added support for TypeScript generation for AngularJS and Node.js 2015-06-16 10:44:05 +02:00
xhh
d2d5cf0d57 Add convention notes to Ruby CLI options 2015-06-16 12:17:11 +08:00
xhh
6348f67b18 Merge remote-tracking branch 'origin/develop_2.0' into ruby-cli-option2 2015-06-16 12:07:15 +08:00
Ron
eaf5a371ff Merge pull request #863 from wing328/fix_typo
Fixed a minor typo with the command example
2015-06-15 13:20:05 +03:00
Ron
dee0948e3e Update README.md 2015-06-15 13:19:56 +03:00
xhh
a59d4ba346 Add test case for finding nonexistent pet 2015-06-15 16:51:38 +08:00
xhh
ec8e5179cb Remove unused comments 2015-06-15 16:46:30 +08:00
xhh
9d5928551b Unify ClientError and ServerError into ApiError
in Ruby generator
2015-06-15 16:38:08 +08:00
wing328
456e17430b Merge branch 'php_warning' of https://github.com/wing328/swagger-codegen into php_warning 2015-06-15 15:51:12 +08:00
wing328
839f0971f0 rename php ApiClient 2015-06-15 15:50:40 +08:00
xhh
e9c1dd7842 Regard bare "object" type as Object, add comments
The handling of base "object" type (without definions of
"additionalProperties") is similar to Java generator now.
2015-06-15 12:49:17 +08:00
wing328
24b110be9d show writing file for non-template file 2015-06-14 01:27:47 +08:00
wing328
7a560865a0 fix jar path in windows 2015-06-14 00:59:40 +08:00
geekerzp
718a9a79ed Update test case test_deserialize_to_object of python client. 2015-06-13 19:05:15 +08:00
geekerzp
ff9623fb5c Support pure object response for python client. 2015-06-13 18:58:27 +08:00
xhh
80616b4c2b Add test cases for StoreApi#get_inventory 2015-06-12 23:03:17 +08:00
xhh
36f0ed6d0c Add test cases for Response#deserialize 2015-06-12 22:44:52 +08:00
xhh
4c8c6c3880 Rebuild Ruby Petstore sample 2015-06-12 20:18:50 +08:00
xhh
e38fc2c3da Deserialize response for "object" type in Ruby client 2015-06-12 20:15:48 +08:00
wing328
2fdae91cbc fix a typo in readme 2015-06-12 16:12:54 +08:00
William Cheng
7aab1eaffb update test.php to put exception test at last 2015-06-10 23:53:56 +08:00
wing328
a0c55693dc add test case for loginUser, separate test cases into different files 2015-06-10 21:59:48 +08:00
wing328
9aca2868b9 change static method to instance method, update test case to remove php warning 2015-06-10 21:18:48 +08:00
wing328
4982784d7c upgrade restsharp to 105.1.0 2015-06-10 15:57:07 +08:00
geekerzp
e2d441e862 support map type response for python client 2015-06-10 11:55:12 +08:00
wing328
303dbe7730 fix array,map for perl, add test case 2015-06-10 10:53:21 +08:00
geekerzp
d7b10a17c1 Renamed objc client from PetstoreClient to SwaggerClient 2015-06-10 10:53:16 +08:00
Alexey Nechaev
3f194d3288 Fixed #837: Generation of default values for complex arrays and maps has been improved. 2015-06-09 19:34:09 +03:00
fehguy
672fcd5a14 updated dev version 2015-06-09 01:36:52 -07:00
fehguy
3768932ba2 updated dev version 2015-06-09 01:36:48 -07:00
Tony Tam
eafcc43295 Merge pull request #851 from swagger-api/develop_2.0
merge from develop 2.0 for release
2015-06-09 01:13:42 -07:00
xhh
1315e2d72c Add new line to make code more readable 2015-06-09 15:47:37 +08:00
xhh
44780e6e1b Merge branch 'develop_2.0' into ruby-cli-option2
Conflicts:
	modules/swagger-codegen/src/main/resources/ruby/swagger/version.mustache
2015-06-09 15:44:50 +08:00
fehguy
570383d5d5 updated name, disabled test 2015-06-09 00:41:08 -07:00
fehguy
3d2f09a693 updated versions 2015-06-09 00:25:09 -07:00
Tony Tam
33c2b1b623 Merge pull request #849 from wing328/fix_podfile
Fix objc podfile in sample
2015-06-09 00:18:24 -07:00
wing328
207776cec6 udpate podfile 2015-06-09 15:14:37 +08:00
Tony Tam
3b3738e587 Merge pull request #847 from wing328/fix_indentation
Fix indentation
2015-06-08 23:43:09 -07:00
wing328
680078dc58 fix csharp refer to apiinvoker 2015-06-09 13:52:01 +08:00
wing328
a593271de1 rollback flash apiinvoker based on 8ee8eddcff 2015-06-09 13:33:30 +08:00
wing328
7fd996bc86 update php sample 2015-06-09 13:31:14 +08:00
wing328
d155ddd026 rollback java spring mvc template 2015-06-09 13:15:03 +08:00
wing328
fc38b9bb79 rollback akkascala to another commit (637ee77d66) 2015-06-09 13:13:56 +08:00
wing328
29c41adddf rollback java jxrs template 2015-06-09 13:11:16 +08:00
wing328
180d48e89d rollback java template 2015-06-09 13:08:32 +08:00
wing328
900f39686d rollback grovvy template 2015-06-09 13:07:45 +08:00
wing328
46c5b776ed rollback csharp template 2015-06-09 13:04:34 +08:00
wing328
7b6480f7f8 rollback codegen template 2015-06-09 13:04:03 +08:00
wing328
f610958209 rollback asyncscala template 2015-06-09 13:03:29 +08:00
wing328
ab9daaacd6 rollback android template 2015-06-09 13:02:54 +08:00
wing328
a8f6044c9b rollback akka-scala template 2015-06-09 13:01:50 +08:00
wing328
6efef51036 rollback validator template 2015-06-09 13:01:11 +08:00
wing328
6617af5209 rollback tizen template 2015-06-09 13:00:42 +08:00
wing328
410144ea1c rollback swift template 2015-06-09 13:00:13 +08:00
wing328
d8060f47a8 rollback swagger-static template 2015-06-09 12:58:41 +08:00
wing328
f2ee63da3b rollback scalatra template 2015-06-09 12:57:31 +08:00
wing328
b636d2a2c9 rollback scala template 2015-06-09 12:56:26 +08:00
wing328
7d6fdf96c0 rollback retroit template 2015-06-09 12:54:48 +08:00
wing328
b1f5c0314e rollback objc templates 2015-06-09 12:53:33 +08:00
wing328
eede02a6ab rollback nodejs and htmldocs template 2015-06-09 12:51:52 +08:00
wing328
eee8685847 rollback flash template 2015-06-09 12:47:18 +08:00
wing328
6253bbff3d roll back qt5cpp template 2015-06-09 12:42:07 +08:00
wing328
263b4080ee rollback python3 template 2015-06-09 12:40:45 +08:00
wing328
50ae9659ad rollback php template 2015-06-09 12:37:30 +08:00
wing328
2e12ac5957 rollback perl template 2015-06-09 12:34:38 +08:00
wing328
5f6622c70d rollback ruby template 2015-06-09 12:33:30 +08:00
wing328
d5cbbae182 rollback ruby swagger template 2015-06-09 12:26:02 +08:00
wing328
0dd8670724 rollback python template 2015-06-09 12:22:59 +08:00
xhh
d2a82d56aa Enable CLI options for Ruby generator 2015-06-09 10:16:52 +08:00
Tony Tam
915ad77d03 Merge branch 'develop_2.0' 2015-06-08 16:22:15 -07:00
Tony Tam
f025dda4e2 merged 2015-06-08 16:21:58 -07:00
Ron
1644956a9c Merge pull request #843 from swagger-api/repackage
merge repackage into development
2015-06-08 19:13:10 -04:00
Tony Tam
b1cea25237 updated version 2015-06-08 16:07:31 -07:00
Tony Tam
c1ddb84839 restored imports 2015-06-08 16:04:04 -07:00
Tony Tam
445d0f7928 rebuilt 2015-06-08 15:48:49 -07:00
Tony Tam
637ee77d66 added script, fixed templates 2015-06-08 15:40:05 -07:00
Ron
fb989fcd0e Integrated UI with the generator's packaging process 2015-06-08 16:25:37 -04:00
Tony Tam
64ea3f8177 rebuilt 2015-06-07 20:50:35 -07:00
Tony Tam
aaa0603e29 rebuilt, added back imports 2015-06-07 20:47:22 -07:00
Tony Tam
450edae160 fixed imports 2015-06-07 20:35:56 -07:00
Tony Tam
4f0198dd13 rebuilt, fixed test imports 2015-06-07 20:30:41 -07:00
Ron
56714e6c07 Code fixes after reformatting 2015-06-07 23:20:34 -04:00
Ron
aa0586c666 Dependency update 2015-06-07 11:56:34 -04:00
Ron
8ee8eddcff Code reformatting 2015-06-07 11:56:26 -04:00
Ron
1c2d0656b0 Code reformatting 2015-06-07 11:56:08 -04:00
Ron
22d7db2cb4 url changes 2015-06-07 11:46:11 -04:00
Ron
96107193e9 updated reverb references 2015-06-07 11:18:49 -04:00
Ron
1a39678206 Refactoring 2015-06-07 11:05:00 -04:00
Tony Tam
6c57810128 rebuilt 2015-06-07 00:08:01 -07:00
Tony Tam
8c340d52a4 updated packages 2015-06-06 23:58:36 -07:00
Tony Tam
1df3ed4487 repackaged 2015-06-06 23:44:20 -07:00
Tony Tam
0c1657d744 updated package 2015-06-06 23:43:34 -07:00
Tony Tam
44af46c9b3 updated files 2015-06-06 23:11:28 -07:00
Tony Tam
18eb3cde97 updated files 2015-06-06 23:11:20 -07:00
Ron
776508759d Merge pull request #834 from xhh/fix-package
Fix package name for generator/online/Generator.java
2015-06-05 23:26:43 -04:00
xhh
6a7fa67581 Fix package name in test 2015-06-06 10:43:04 +08:00
xhh
3f97d63886 Fix package name for generator/online/Generator.java 2015-06-06 09:01:08 +08:00
Tony Tam
c3d2a581c9 Merge pull request #790 from xhh/java-accept-contenttype
Minor improvement to Java API client accept and content-type header
2015-06-05 17:51:23 -07:00
xhh
d345283ab5 Merge branch 'develop_2.0' into java-accept-contenttype
Conflicts:
	modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/JavaClientCodegen.java
	modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache
	modules/swagger-codegen/src/main/resources/Java/api.mustache
	samples/client/petstore/java/src/main/java/io/swagger/client/ApiClient.java
	samples/client/petstore/java/src/main/java/io/swagger/client/api/PetApi.java
	samples/client/petstore/java/src/main/java/io/swagger/client/api/StoreApi.java
	samples/client/petstore/java/src/main/java/io/swagger/client/api/UserApi.java
	samples/client/petstore/java/src/test/java/io/swagger/client/ApiClientTest.java
2015-06-06 08:46:19 +08:00
Tony Tam
ddbef8b25d implemented processOpts to avoid clobbering by superclass 2015-06-05 11:40:30 -07:00
Tony Tam
d2cb05f14f Merge pull request #797 from geekerzp/develop_2.0_python_auth
[Python] Add authentication support (API key, HTTP basic)
2015-06-05 09:15:54 -07:00
Tony Tam
3fe2169ffa Merge branch 'Hadou1-Generic_API_Exception' into develop_2.0 2015-06-05 08:46:22 -07:00
Tony Tam
ab5b2da21a Merge branch 'Generic_API_Exception' of ssh://github.com/Hadou1/swagger-codegen into Hadou1-Generic_API_Exception 2015-06-05 08:46:02 -07:00
Tony Tam
b4f153c202 Merge pull request #826 from xhh/java-auth
[Java] Add authentication support (API key, HTTP basic)
2015-06-05 08:45:08 -07:00
Tony Tam
0d09d43257 Merge pull request #823 from wing328/fix_file_rename
[C#] Fix ApiException file name
2015-06-05 08:43:08 -07:00
Tony Tam
98c303042e Merge pull request #829 from wing328/php_support_map
[PHP] bug fix for map, added test case
2015-06-05 08:41:58 -07:00
wing328
d0f9345c5a fix php map, add test case for get inventory 2015-06-05 21:57:12 +08:00
xhh
fffc5d7c35 Move authentications into ApiClient 2015-06-05 20:00:32 +08:00
Fredrik Gustafsson
e737964f66 minor refactoring 2015-06-05 13:51:52 +02:00
Fredrik Gustafsson
8f2e84d263 Merge branch 'develop_2.0' into Generic_API_Exception
Conflicts:
	modules/swagger-codegen/src/main/resources/csharp/apiException.mustache
2015-06-05 12:47:48 +02:00
xhh
947935f3d9 Merge remote-tracking branch 'origin/develop_2.0' into java-auth
Conflicts:
	modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/JavaClientCodegen.java
	modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache
	modules/swagger-codegen/src/main/resources/Java/api.mustache
	samples/client/petstore/java/src/main/java/io/swagger/client/ApiClient.java
	samples/client/petstore/java/src/main/java/io/swagger/client/Configuration.java
	samples/client/petstore/java/src/main/java/io/swagger/client/api/PetApi.java
	samples/client/petstore/java/src/main/java/io/swagger/client/api/StoreApi.java
	samples/client/petstore/java/src/main/java/io/swagger/client/api/UserApi.java
	samples/client/petstore/java/src/test/java/io/swagger/client/ConfigurationTest.java
	samples/client/petstore/java/src/test/java/io/swagger/petstore/test/PetApiTest.java
2015-06-05 18:43:49 +08:00
Fredrik Gustafsson
277287a341 Merge branch 'develop_2.0' of https://github.com/Hadou1/swagger-codegen into develop_2.0
Conflicts:
	modules/swagger-codegen/src/main/resources/csharp/api.mustache
2015-06-05 12:33:49 +02:00
wing328
5a75eba42b regenerated perl sample 2015-06-05 18:30:58 +08:00
Fredrik Gustafsson
31c6a0a9da Extended the api-class generation by a interface generation 2015-06-05 12:29:25 +02:00
Fredrik Gustafsson
a1f156ca19 Updated 'api.mustache' to generate asynchronous methods aswell 2015-06-05 11:39:15 +02:00
geekerzp
eb90b907e7 rebuild python client 2015-06-05 17:02:38 +08:00
wing328
61a7d848f7 rename files in csharp and perl to fix issue 2015-06-05 17:00:11 +08:00
xhh
d70742119b Update unit tests 2015-06-05 16:45:19 +08:00
xhh
622b5c179a Merge remote-tracking branch 'origin/develop_2.0' into java-accept-contenttype
Conflicts:
	modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/JavaClientCodegen.java
	modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache
	modules/swagger-codegen/src/main/resources/Java/api.mustache
	samples/client/petstore/java/src/main/java/io/swagger/client/ApiClient.java
	samples/client/petstore/java/src/main/java/io/swagger/client/api/PetApi.java
	samples/client/petstore/java/src/main/java/io/swagger/client/api/StoreApi.java
	samples/client/petstore/java/src/main/java/io/swagger/client/api/UserApi.java
2015-06-05 16:31:21 +08:00
geekerzp
ddc5293e6a updated api.mustache of python. 2015-06-05 16:19:49 +08:00
geekerzp
a30f537f5f fixed typo 2015-06-05 16:19:49 +08:00
geekerzp
813c0119aa added test case for 500 response of python client 2015-06-05 16:19:49 +08:00
geekerzp
8ef4c4401e updated rest.mustache of python client 2015-06-05 16:19:48 +08:00
geekerzp
5fbda0e206 added test case for 404 response of python client 2015-06-05 16:19:48 +08:00
geekerzp
fbe327ac2f Updated PythonClientCodegen.java
* updated method apiFileFolder.
* udpated method modelFileFolder.
2015-06-05 16:19:48 +08:00
geekerzp
ab6f327f35 Updated python client.
* Rename `ResponseError` exception to `ApiException`
* Use `File.separatorChar` to build file path in
  PythonClientCodegen.java
* Rename `config.py` module to `configuration.py`
* Rename `swagger.py` module to `api_client.py`
2015-06-05 16:19:48 +08:00
geekerzp
51887c64b5 Updated python codegen.
Use File.separatorChar to create invokerPacakge variable instread of '\'
char.
2015-06-05 16:17:29 +08:00
geekerzp
654a73c5a8 rebuild python client 2015-06-05 16:17:29 +08:00
geekerzp
eac884d85b updated ApiClient of python sdk. 2015-06-05 16:16:48 +08:00
geekerzp
d7aaaea0df updated config.py of python client. 2015-06-05 16:15:57 +08:00
geekerzp
b09250ed33 added authentication for python client.
completed.
2015-06-05 16:15:57 +08:00
geekerzp
0ca97e4b68 added authentication for python client.
Not completed
2015-06-05 16:15:14 +08:00
Tony Tam
59ca8bd986 Merge pull request #821 from geekerzp/develop_2.0_objc_test
[Objc] Update test case
2015-06-05 00:55:57 -07:00
Tony Tam
e1393d1912 Merge pull request #817 from who/develop_2.0
[Android] Enabling cli config options for android generator
2015-06-05 00:53:20 -07:00
Tony Tam
ddb3bd5477 Merge pull request #816 from geekerzp/develop_2.0_objc_auth
[Objc] Add authentication support (API key, HTTP basic)
2015-06-05 00:52:35 -07:00
Tony Tam
2ec18a1397 Merge branch 'wing328-php_object_support' into develop_2.0 2015-06-05 00:52:06 -07:00
Tony Tam
34072faccd merged 2015-06-05 00:51:52 -07:00
Tony Tam
26d9215e43 Merge pull request #808 from wing328/csharp_api_instance
[C#] Added ApiClient (Pluggable) and authentication (API key and HTTP basic auth)
2015-06-05 00:42:44 -07:00
Tony Tam
496e06a373 Merge pull request #806 from geekerzp/develop_2.0_python_https
[Python] Verified HTTPS with SSL/TLS cert.
2015-06-05 00:42:13 -07:00
Tony Tam
513bd17610 Merge pull request #803 from wing328/objc_fix_filepath
[ObjC] Minor fix to output path
2015-06-05 00:41:52 -07:00
Tony Tam
d9fcb777c1 Merge pull request #799 from wing328/perl_apiinvoker_instance
[Perl] Make API client more pluggable (ref: #778)
2015-06-05 00:41:26 -07:00
Tony Tam
05700a6799 Merge pull request #794 from wing328/php_debug_switch
[PHP] add debug switch
2015-06-05 00:40:32 -07:00
Tony Tam
29bd743391 Merge pull request #793 from geekerzp/develop_2.0_objc_apiclient
Make objc client more pluggable
2015-06-05 00:40:17 -07:00
Tony Tam
13e14652e3 Merge pull request #787 from geekerzp/develop_2.0_python_apiclient
[Python] Make API client more pluggable
2015-06-05 00:38:11 -07:00
Tony Tam
b41e88e83a Merge pull request #785 from wing328/csharp_add_restsharp_dll
[C#] Added RestSharp.dll and updated compile.bat
2015-06-05 00:38:05 -07:00
Tony Tam
cbc4da58ab Merge pull request #783 from xhh/ruby-auth
[Ruby] Add authentication support (API key, HTTP basic)
2015-06-05 00:36:12 -07:00
Tony Tam
aecb4adf4a Merge pull request #791 from xhh/java-api-client
[Java] Make API client more pluggable
2015-06-05 00:36:05 -07:00
wing328
ba227b7e72 rename api client 2015-06-04 21:19:16 +08:00
wing328
0423e0a2df support object response 2015-06-04 21:12:26 +08:00
wing328
afe816efb6 remove unused file 2015-06-04 20:30:41 +08:00
geekerzp
58feda7c8e Updated test case testCreateAndGetPet of objc client. 2015-06-04 16:44:12 +08:00
Fredrik Gustafsson
217765998d Extended the APIException by ErrorContent from response body 2015-06-03 16:23:45 +02:00
xhh
0ffe53933d Bug fix: "null" was used as post body for empty form parameters
The form parameters could be empty when all of them are optional and no
values are assigned to them.
2015-06-03 21:17:42 +08:00
xhh
cf4b4de970 Skip null header/form parameters
and fix the bug of getting file name for file parameter
2015-06-03 20:26:14 +08:00
xhh
2e285ed562 Support skipping SSL certification verification
in Ruby clients by e.g.:

    SwaggerClient::Swagger.configure do |config|
      config.verify_ssl = false
    end
2015-06-03 12:49:09 +08:00
wing328
9b919c54dd added http basic auth test 2015-06-03 11:21:10 +08:00
xhh
9618960558 Merge branch 'develop_2.0' into ruby-auth 2015-06-03 11:19:40 +08:00
wing328
fceaed34e4 rename apiclient 2015-06-03 10:19:07 +08:00
xhh
eb4973237b Add comments to code 2015-06-03 10:09:36 +08:00
wing328
9c747e3e37 fix query parameters 2015-06-03 09:21:45 +08:00
wing328
3d16d8b2b6 fix header 2015-06-03 08:34:45 +08:00
Andrew B
1a75489b42 Enabling cli config options for android generator 2015-06-02 09:04:50 -07:00
xhh
24c29acc09 Merge branch 'develop_2.0' into java-api-client
Conflicts:
	modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/JavaClientCodegen.java
2015-06-02 22:36:55 +08:00
Ole Lensmar
2662167372 Merge pull request #805 from hyeghiazaryan/develop_2.0
Support for file based config. Implementation for #616.
2015-06-02 09:33:52 -04:00
Ole Lensmar
e98320862c Merge pull request #706 from 0legg/feature/retrofit-templates
[WIP] add template for Retrofit and Gson
2015-06-02 09:09:41 -04:00
wing328
2d6a7092e3 removed unused file 2015-06-02 20:43:11 +08:00
wing328
7080983521 return exception instead of null for 404, add properties to api exception class 2015-06-02 17:25:38 +08:00
xhh
19540ed7f0 Store response headers and body in ApiException 2015-06-02 15:33:44 +08:00
geekerzp
699df0029b updated comments for objc client. 2015-06-02 15:33:33 +08:00
geekerzp
86971ee752 added comments for objc client 2015-06-02 11:50:47 +08:00
Hrachya Yeghiazaryan
d258a6c1c2 Merge branch 'develop_2.0' of https://github.com/hyeghiazaryan/swagger-codegen into develop_2.0 2015-06-01 10:44:23 -07:00
hrachya
3e0913a813 removing generic header comments 2015-06-01 10:43:23 -07:00
wing328
762a3279ea clean up test.php 2015-06-01 14:50:57 +08:00
wing328
f357f4c9d7 fix default header 2015-06-01 14:24:09 +08:00
wing328
8d708c2442 add test case for default header 2015-05-31 11:17:59 +08:00
wing328
83d069d053 add support for obj, remove null from serialized json string 2015-05-31 09:49:24 +08:00
geekerzp
b5429d9e8e Added authentication for objc client. 2015-05-30 18:04:20 +08:00
Richie Azaria
0996901e72 add documentation -c option and config-help 2015-05-29 13:01:42 -07:00
Oleg Godovykh
ec08d31031 add template for Retrofit and Gson 2015-05-29 12:23:18 -04:00
Ron
ca46405850 Update README.md 2015-05-29 08:53:06 -04:00
Ron
7d7ed15fdc Update README.md 2015-05-29 08:52:48 -04:00
Ron
34315f7338 Create LICENSE 2015-05-29 08:52:29 -04:00
Ron
26a22a30a1 Create LICENSE 2015-05-29 08:52:03 -04:00
Fredrik Gustafsson
41e4fc79ae Extended the api-class generation by a interface generation 2015-05-29 12:19:28 +02:00
Fredrik Gustafsson
049299f07f Updated 'api.mustache' to generate asynchronous methods aswell 2015-05-29 10:53:48 +02:00
wing328
5f36ad3b75 add authentication support 2015-05-29 16:43:27 +08:00
geekerzp
18cf6bcfa6 Updated python client.
Verified HTTPS with SSL/TLS.
2015-05-29 15:09:19 +08:00
xhh
a8c526efd5 Add unit tests for Configuration and ApiClient 2015-05-29 12:08:42 +08:00
xhh
62c8f9e1e2 Rebuild Java Petstore sample 2015-05-29 12:08:42 +08:00
xhh
ac134c0afa Make ApiClient more pluggable for Java
- Rename ApiInvoker to ApiClient
- Make ApiClient pluggable by allowing setting the ApiClient field of
  API classes
- Introduce a Configuration class, containing the default
  ApiClient (which is also customizable)
- Move basePath from API class to ApiClient
- Change static methods in ApiClient to instance level
2015-05-29 12:08:42 +08:00
xhh
a29c3abeb8 Use File.separatorChar in Ruby generator, add comments 2015-05-29 12:05:47 +08:00
xhh
623a1278cf Add test case for API key auth 2015-05-29 11:57:46 +08:00
xhh
e52694cde0 Regenerate Ruby Petstore sample 2015-05-29 11:57:46 +08:00
xhh
95813714a5 Add support of HTTP basic and API key auth to Ruby codegen 2015-05-29 11:57:46 +08:00
xhh
6a6473ede3 Allow omitting username/password for HTTP basic auth 2015-05-29 11:55:48 +08:00
xhh
e10e1f5249 Refactor auth method naming, add comments 2015-05-29 11:29:06 +08:00
xhh
6eb1a89205 Add authentication helper methods and test cases 2015-05-29 11:28:03 +08:00
xhh
4d25d264c4 Merge remote-tracking branch 'origin/develop_2.0' into java-auth
Conflicts:
	modules/swagger-codegen/src/main/resources/Java/apiInvoker.mustache
	samples/client/petstore/java/src/main/java/io/swagger/client/ApiInvoker.java
2015-05-29 10:08:50 +08:00
hrachya
ba7025d54b Adding config-help command 2015-05-28 15:02:32 -07:00
hrachya
1f360961e0 Simplifying CliOption class 2015-05-28 14:55:36 -07:00
hrachya
08647b337f fixing property name 2015-05-28 13:08:52 -07:00
hrachya
c5a7800ec6 fixing typo 2015-05-28 13:02:30 -07:00
hrachya
26a2290078 adding classPrefix, sourceFolder, projectName cli options to objc 2015-05-28 13:01:54 -07:00
wing328
2edcd82094 minor fix to output path 2015-05-28 19:16:26 +08:00
wing328
165efdbdbb rename apiinvoker to apiclient, add configuration, make apiclient an instance 2015-05-28 18:24:03 +08:00
wing328
412fcf11f9 update file separator 2015-05-28 15:19:05 +08:00
wing328
e993d08563 rename APIClient to ApiClient, APIClientException to APIException 2015-05-28 15:06:31 +08:00
wing328
61bc652229 use file separator 2015-05-28 14:34:39 +08:00
wing328
699f6fff44 update file path 2015-05-28 14:18:05 +08:00
wing328
1a868abdfa rename APIClient to ApiClient 2015-05-28 10:51:36 +08:00
hrachya
c9c58cbe4c new -c/--config option for swagger-cli to specify json config file path
setting options passed in config file if those were allowed by lang specific CodegenConfig
2015-05-27 17:37:07 -07:00
hrachya
c3055c7cc4 Adding Config and ConfigParser classes 2015-05-27 17:30:42 -07:00
hrachya
2cca1a8c2c Changing templateDir back to explicit option for cli 2015-05-27 17:22:44 -07:00
hrachya
a9e767cbd8 Rolling back changes to deprecated class 2015-05-27 17:19:34 -07:00
Ron
1657f2e5f7 Merge pull request #801 from rlo2014/develop_2.0
Removing comment (// do some magic!) that is no longer necessary and …
2015-05-27 19:48:51 -04:00
rlo2014
e93a377982 Removing comment (// do some magic!) that is no longer necessary and confusing. After olensmar refactor of jax-rs codegen, magic/implementation should be placed in the delegate/implementation as opposed to the api itself. Any logic put in api itself will be overwritten with the next code gen, whereas the delegate implemenation will remain intact. 2015-05-27 14:55:28 -07:00
wing328
2c12312b97 update user agent and add more test cases 2015-05-27 22:44:56 +08:00
wing328
866b546cfd make api client pluggable 2015-05-27 17:56:39 +08:00
hrachya
74f5c769f9 removing extra file, was committed by mistake 2015-05-26 17:10:19 -07:00
hrachya
1e09f5149e Add 'invokerPackage', 'groupId', 'arifactId', 'artifactVersion', 'sourceFolder' command line options for java (and all the derived ones jaxrs, spring-mvc ...)
Add processOpts override to process java  specific options
Move supporting file initialization from constructor to processOpts, since it uses some of the options that are not yet set in the constructor
Add setters
2015-05-26 17:05:53 -07:00
hrachya
e08a5a9d83 Add 'modelPackage' and 'apiPackage' as command line options
Add setters for modelPackage and apiPackage
2015-05-26 17:01:07 -07:00
hrachya
d7dec5a43d Use new functionality to add 't' as a command line option to set 'templateDir' 2015-05-26 16:02:27 -07:00
hrachya
33436d62c3 Get all cliOptions for available codegen configs and add to command line options
Add all the specified ones to clientOpts properties
2015-05-26 15:57:01 -07:00
hrachya
9f1504062a add List<CliOption> cliOptions() method to CodegenConfig interface with default implementation in DefaultCodegen 2015-05-26 15:52:25 -07:00
hrachya
f8cafaaee7 new CliOption class for wrapping org.apache.commons.cli.Option 2015-05-26 15:49:32 -07:00
wing328
4d1d163a73 update php template to debug curl 2015-05-26 23:52:35 +08:00
wing328
171bf969c7 add debug switch to configuration 2015-05-26 23:20:34 +08:00
geekerzp
ca145297e9 Updated ApiClient of objc sdk.
When create api instance, if we don't pass the `apiClient` parameter,
then get api client instance from the pool.
2015-05-26 18:00:45 +08:00
wing328
c2c43bba37 make datetime nullable 2015-05-26 17:48:52 +08:00
xhh
951b7a9075 Do not use JSON as default Accept header when no produces present 2015-05-26 10:35:49 +08:00
wing328
f807e34b2b refactor csharp (no compile error) 2015-05-25 18:21:17 +08:00
xhh
aa03be7f76 Clean up old code 2015-05-25 17:25:32 +08:00
xhh
ed14c515bf Add comments to string utility methods 2015-05-25 16:01:57 +08:00
geekerzp
2d545c7f0b updated ApiClient of python sdk.
Change staticmethod to instance method.
2015-05-25 15:29:31 +08:00
geekerzp
3beeb6125e updated ApiClient of python sdk.
When create api instance, if we don't pass the `api_client` parameter,
then use the default api_client in `config` module.
2015-05-25 14:31:55 +08:00
xhh
19a8ac4841 Add unit tests 2015-05-25 12:32:24 +08:00
xhh
85d0e08a80 Rebuild Java Petstore client 2015-05-25 12:31:54 +08:00
xhh
fff8972a77 Extract utility methods to the StringUtil class
and ignore case when comparing Accept/Content-Type
2015-05-25 12:29:41 +08:00
wing328
92dd5cab93 add restsharp.dll, update compile.bat 2015-05-25 11:44:08 +08:00
xhh
141b580c8c Minor improvement to Java API client accept and content-type header 2015-05-24 08:52:14 +08:00
Tony Tam
095771d345 Merge pull request #738 from tomtit/issue429
Fixes #429: Handling of composed models has been added.
2015-05-23 15:10:38 -07:00
Alexey Nechaev
5d581c3b03 Fixes #429: Handling of composed models has been added. 2015-05-24 00:54:25 +03:00
Tony Tam
087c28dae4 rebuilt client 2015-05-23 09:04:46 -07:00
Tony Tam
85c37fbe27 fix for #781 2015-05-23 09:04:40 -07:00
Tony Tam
ad9b790712 updated sample 2015-05-23 09:04:06 -07:00
Tony Tam
82436c5b44 Merge pull request #780 from geekerzp/develop_2.0_objc_contenttype
Minor improvement to Objc API Client 'accept' and 'content-type' header
2015-05-23 08:54:53 -07:00
Tony Tam
156afa7795 Merge pull request #778 from wing328/php_apiclient_instance
[PHP] Make API client more pluggable
2015-05-23 08:54:33 -07:00
Tony Tam
74dc05bbf5 Merge pull request #776 from wing328/php53_fix_warning
[PHP] Fix warning/error related to PHP5.3
2015-05-23 08:53:52 -07:00
Tony Tam
b6d206aff7 Merge pull request #774 from geekerzp/develop_2.0_python_contenttype
Minor improvement to Python API Client 'accept' and 'content-type' header
2015-05-23 08:53:34 -07:00
Tony Tam
e3c116312b Merge pull request #773 from hyperworks/master
Adds isPrimitiveType flag to CodegenParameter.
2015-05-23 08:53:06 -07:00
Tony Tam
5527932a8e Merge branch 'xhh-ruby-void-response' into develop_2.0 2015-05-23 08:52:15 -07:00
Tony Tam
3cb9d094d3 Merge branch 'ruby-void-response' of ssh://github.com/xhh/swagger-codegen into xhh-ruby-void-response 2015-05-23 08:49:28 -07:00
Tony Tam
d83a275b6e Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-05-23 08:48:40 -07:00
Tony Tam
98d5dd727b Merge branch 'tkQubo-feature/swift-PromiseKit' into develop_2.0 2015-05-23 08:48:28 -07:00
Tony Tam
565f054b79 merged 2015-05-23 08:48:18 -07:00
Tony Tam
f4aee62fb4 Merge pull request #775 from wing328/csharp_fix_object_type
[C#] Fix "object' type for response
2015-05-23 08:43:14 -07:00
Tony Tam
864f0f5a3a Merge branch 'sosso-origin/develop_2.0' into develop_2.0 2015-05-23 08:34:01 -07:00
Tony Tam
d447c423b5 updated test to get expected value 2015-05-23 08:33:48 -07:00
Tony Tam
f9ed8a9a08 updated test to get expected value 2015-05-23 08:33:40 -07:00
Tony Tam
3638d79291 updated test to get expected value 2015-05-23 08:33:27 -07:00
geekerzp
2514f3aa08 update SWGApiClient.h of objc client. 2015-05-23 15:29:38 +08:00
geekerzp
3d3cbe115e minor improvement to objc client accept and content-type header 2015-05-23 15:22:12 +08:00
wing328
691838c47d add test case for api client instance 2015-05-23 10:35:19 +08:00
wing328
612abf134b api client as instance (not static class) 2015-05-22 22:09:51 +08:00
geekerzp
87a730b5a2 Merge branch 'develop_2.0' into develop_2.0_objc_contenttype
Conflicts:
	samples/client/petstore/objc/client/SWGPetApi.m
2015-05-22 17:32:57 +08:00
geekerzp
8d0efd812c updated unittests of python client 2015-05-22 15:50:09 +08:00
geekerzp
245ce642ce add test cases for ApiClient.select_header_accept and
ApiClient.select_header_content_type of python client.
2015-05-22 15:28:36 +08:00
wing328
df4b952312 fix object type without ref for CSharp 2015-05-22 14:12:53 +08:00
xhh
43cfc7d401 Setup authentications in test cases 2015-05-22 12:07:08 +08:00
xhh
16ba2a54ea Add test cases for API key and HTTP basic auth 2015-05-22 11:17:44 +08:00
geekerzp
bc9abceef3 removed temp files from python client 2015-05-22 11:12:35 +08:00
geekerzp
8a311d693b updated python client samples 2015-05-22 10:50:11 +08:00
geekerzp
52807c0724 minor improvement to python client accept and content-type header 2015-05-22 10:45:38 +08:00
William Cheng
fa15f58506 fix warning/error in php5.3 2015-05-22 05:15:46 +08:00
xhh
f616605e7e Regenerate Java Petstore sample 2015-05-21 22:09:08 +08:00
xhh
3d4b5a10c9 Add support of HTTP basic and API key auth to Java codegen 2015-05-21 22:05:46 +08:00
Ron
2b7bbd9513 Merge pull request #772 from tomtit/issue771
Fixes #771: Unit test has been fixed after merge.
2015-05-21 06:07:00 -06:00
Chakrit Wichian
89e3bcc4bb Adds isPrimitiveType flag to CodegenParameter.
This is required in some languages like Obj-C where there is no automatic value boxing and
handling of primitive types require extra work compared to non-primitive types.

Case in point: BOOL type. To assign BOOL into a dictionary, one needs to box it into an
(NSValue *) instance, so to build a dictionary for sending form data, for example, you
cannot do this in the template:

    dict["{{paramName}}"] = {{paramName}};

Because if the parameter ends up being of type BOOL, an error about boxing values will be
generated:

    BOOL boolValue = NO;
    dict["boolValue"] = boolValue;
                        ^---------------- Cannot do the assignment here.

The fix is to wrap it in @() like so:

    BOOL boolValue = NO;
    dict["boolValue"] = @(boolValue);

So a flag is needed in CodegenParameter so we can selectively emit the right boxing or
non-boxing assignment in the templates.
2015-05-21 15:28:57 +07:00
Alexey Nechaev
a590239df9 Fixes #771: Unit test has been fixed after merge. 2015-05-21 10:49:20 +03:00
Tony Tam
0c3f7a54cd Merge pull request #770 from swagger-api/jaxrs-interface-generation
Jaxrs interface generation
2015-05-20 22:52:00 -07:00
Tony Tam
99a11636da rebuilt 2015-05-20 22:51:30 -07:00
Tony Tam
3a2f258517 Merge branch 'geekerzp-develop_2.0_python_urllib3' into develop_2.0 2015-05-20 22:51:09 -07:00
Tony Tam
3629a190ae merged 2015-05-20 22:50:59 -07:00
Tony Tam
715a9b8678 merged 2015-05-20 22:50:41 -07:00
Tony Tam
4187be2dc3 Merge pull request #767 from geekerzp/develop_2.0_python_model
Pretty print for models of python client
2015-05-20 22:46:41 -07:00
Tony Tam
dd70a13c02 Merge branch 'wing328-php_auth_setting' into develop_2.0 2015-05-20 22:46:02 -07:00
Tony Tam
c8a56add5d merged 2015-05-20 22:45:52 -07:00
Tony Tam
01ebdb6122 Merge pull request #763 from tomtit/issue728
Fixed #728: Handling of recursive model definitions has been improved.
2015-05-20 22:42:37 -07:00
Tony Tam
e66f9d7fce Merge pull request #760 from geekerzp/develop_2.0_objc_required_parameter
Fix required parameter validation for Objc
2015-05-20 22:42:10 -07:00
Tony Tam
35f63b3f6a Merge branch 'wing328-php-improve-header' into develop_2.0 2015-05-20 22:41:23 -07:00
Tony Tam
9bf9b3edb7 rebuilt 2015-05-20 22:41:09 -07:00
Tony Tam
92b1a13438 Merge branch 'swinz-develop_2.0_fixSpringMVCRequestParamDefaultValue' into develop_2.0 2015-05-20 22:37:59 -07:00
Tony Tam
515f5440a1 merged 2015-05-20 22:37:51 -07:00
Tony Tam
632480787d Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-05-20 22:35:23 -07:00
Tony Tam
e4faa82cfa Merge branch 'geekerzp-develop_2.0_objc_iso8601' into develop_2.0 2015-05-20 22:35:12 -07:00
Tony Tam
779915a51f rebuilt 2015-05-20 22:34:54 -07:00
Tony Tam
c509bbcb99 updated 2015-05-20 22:34:29 -07:00
Tony Tam
8231e7e36a Merge branch 'develop_2.0_objc_iso8601' of ssh://github.com/geekerzp/swagger-codegen into geekerzp-develop_2.0_objc_iso8601 2015-05-20 22:29:26 -07:00
Tony Tam
ee145aebe7 Merge pull request #743 from lugaru1234/model_ids_with_dots
Fixed #593: Python code failure caused by Model IDs with dots has been fixed
2015-05-20 22:27:53 -07:00
Tony Tam
11dd7784f8 rebuilt 2015-05-20 22:20:51 -07:00
Tony Tam
6fe6a6daa7 Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-05-20 22:16:55 -07:00
Tony Tam
e921b7cbdc Merge branch 'Helmsdown-mime-type-fixes' into develop_2.0 2015-05-20 22:16:38 -07:00
Tony Tam
fd928a3d16 merged 2015-05-20 22:16:24 -07:00
Tony Tam
5a4d3317c2 Merge pull request #723 from swinz/develop_2.0_fixSpringMVCHeaderRequired
SpringMVC template is ignoring the required attribute in swagger definition when generating RequestHeader annotation
2015-05-20 22:14:29 -07:00
Tony Tam
ab23cccab4 Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-05-20 22:13:03 -07:00
Tony Tam
7d4cc82077 Merge branch 'who-feature/android-maven-artifact-publishing' into develop_2.0 2015-05-20 22:12:45 -07:00
Tony Tam
e58f8db9aa merged 2015-05-20 22:12:37 -07:00
Tony Tam
b059910a01 Merge pull request #700 from wing328/csharp_restcsharp
Use RestSharp for CSharp API client
2015-05-20 21:52:28 -07:00
Ole Lensmar
19de558f4a Merge branches 'develop_2.0' and 'jaxrs-interface-generation' of https://github.com/swagger-api/swagger-codegen into jaxrs-interface-generation
Conflicts:
	modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/DefaultCodegen.java
2015-05-20 22:51:49 -06:00
Tony Tam
2d9772e7a9 Merge branch 'tomtit-issue646' into develop_2.0 2015-05-20 21:48:14 -07:00
Tony Tam
0c1bdc0fd6 merged 2015-05-20 21:48:03 -07:00
Tony Tam
e592d1b46b Merge pull request #660 from denyago/master
Improve README for OS X Users with random Java versions
2015-05-20 21:42:40 -07:00
Tony Tam
8dbb1aa8e9 Merge pull request #654 from kvelakur/master
Issue #642 - Removing the unnecesary \n added to generated example reque...
2015-05-20 21:42:25 -07:00
Tony Tam
ef5cb5021b Merge branch 'cchafer-akka-scala' into develop_2.0 2015-05-20 21:41:24 -07:00
Tony Tam
ff81789b37 merged 2015-05-20 21:41:17 -07:00
Tony Tam
e6efcdb6af added files, updated parser version 2015-05-20 21:39:09 -07:00
xhh
9cf4c66331 Update method returning value comment 2015-05-21 11:30:30 +08:00
Tony Tam
956a3c024c Merge pull request #766 from swagger-api/core-1.5.2-M2-compatibility
updated core dependency version to 1.5.2-M2 with related fixes
2015-05-20 17:55:01 -07:00
Ole Lensmar
efb40e149f brought back scala tests 2015-05-20 18:23:44 -06:00
Ole Lensmar
a6876b8028 Merge branches 'core-1.5.2-M2-compatibility' and 'jaxrs-interface-generation' of https://github.com/swagger-api/swagger-codegen into jaxrs-interface-generation 2015-05-20 18:14:54 -06:00
Ole Lensmar
713e7a6584 updated core dependency version to 1.5.2-M2 with related fixes 2015-05-20 18:06:37 -06:00
Ole Lensmar
778ce0b9f6 Merge branches 'develop_2.0' and 'jaxrs-interface-generation' of https://github.com/swagger-api/swagger-codegen into jaxrs-interface-generation 2015-05-20 17:03:51 -06:00
Ole Lensmar
05268c2742 added system property for setting impl folder 2015-05-20 16:50:26 -06:00
Ole Lensmar
17d8d14cc8 defaulted sources to go to src/gen/main and added possibility to set impl folder via system property at command-line 2015-05-20 16:49:50 -06:00
wing328
4f310cd7b1 update function comment 2015-05-20 22:13:24 +08:00
geekerzp
9ff0d90853 Updated python models.
Overwrite the instance method `__repr__`,
make the `pprint` method output properties infos of the models.
2015-05-20 22:05:34 +08:00
wing328
6e13403a37 fix http basic auth, add test cases for new api client without host 2015-05-20 21:55:16 +08:00
xhh
8bf84aabe5 Add test case for nil return value 2015-05-20 21:13:20 +08:00
xhh
50a767ef03 Regenerate Ruby Petstore sample 2015-05-20 21:13:02 +08:00
xhh
4702285184 Correct indentation 2015-05-20 21:08:14 +08:00
xhh
dde73d592d Return nil in Ruby clients for operations that have no response type defined 2015-05-20 21:06:42 +08:00
wing328
9a1dedbe76 add test case (getPetbyId), remove old authenetication (only supports header) 2015-05-20 18:43:34 +08:00
wing328
20439e646f add test case and prefix support 2015-05-20 18:25:35 +08:00
wing328
06c7a6a109 add todo for oauth, support multiple api key 2015-05-20 17:13:52 +08:00
wing328
278a653154 add authentication 2015-05-20 17:13:52 +08:00
geekerzp
3a8b149f09 minor improvement to objc api client accept and content-type header 2015-05-20 15:52:00 +08:00
Tony Tam
deca6a0329 Merge pull request #662 from xhh/ruby-module-structure
Organize the generated Ruby code into a module structure
2015-05-19 20:16:52 -07:00
kubo_takaichi
7205407818 Add another date formatter (which should be externalized though) 2015-05-20 11:27:45 +09:00
kubo_takaichi
2f6b975669 Remove final mark 2015-05-20 11:27:45 +09:00
kubo_takaichi
16a4b60526 Handle NSNull 2015-05-20 11:27:45 +09:00
kubo_takaichi
9cf1835230 Fix bug 2015-05-20 11:27:45 +09:00
kubo_takaichi
3623a0dd56 Modify Cartfile 2015-05-20 11:27:45 +09:00
kubo_takaichi
e0c0d2a72a Remove dependency on SwiftyJSON 2015-05-20 11:27:45 +09:00
kubo_takaichi
dbfc46658f Add once-removed Array extension method 2015-05-20 11:27:45 +09:00
kubo_takaichi
bb3ec04ed1 Introduce Decoders class 2015-05-20 11:27:45 +09:00
kubo_takaichi
be7fccce68 Update JSONEncodable implementations 2015-05-20 11:27:45 +09:00
kubo_takaichi
f21d8503d5 Add manager storage to prevent request cancellation 2015-05-20 11:27:45 +09:00
kubo_takaichi
063e6d062d Introduce decodable array and dictionary 2015-05-20 11:27:45 +09:00
kubo_takaichi
0b7d758077 Add extension methods for primitives 2015-05-20 11:27:45 +09:00
kubo_takaichi
5dfa753f5c Do refactor and add extension methods 2015-05-20 11:27:45 +09:00
kubo_takaichi
23d714f2f1 Add swift code generator 2015-05-20 11:27:45 +09:00
kubo_takaichi
f627c81399 Remove some characters from param name and operation id
(since swagger-doc emits improper characters)
2015-05-20 11:27:45 +09:00
xhh
0fb1918196 Revert unnecessary changes on whitespace 2015-05-20 10:13:29 +08:00
xhh
312f1c6f25 Avoid the importPath field 2015-05-20 09:23:45 +08:00
xhh
792059f195 Avoid warnings for ruby gem building 2015-05-20 09:23:45 +08:00
xhh
70c74d282f Fix tests 2015-05-20 09:23:45 +08:00
xhh
ab4975b7f1 Regenerate petstore ruby sample 2015-05-20 09:23:44 +08:00
xhh
6eaaa5cc69 Include base_object model into module structure 2015-05-20 09:23:44 +08:00
xhh
f766614b4d Clean old files generated 2015-05-20 09:23:44 +08:00
xhh
fcf1327c1f Rename swagger-client to swagger_client
according to guides from rubygems: http://guides.rubygems.org/name-your-gem/
2015-05-20 09:23:44 +08:00
xhh
b140f1f152 Fix example code in README.md of Ruby petstore sample 2015-05-20 09:23:44 +08:00
xhh
87904e8b69 Set version dynamically in ruby codegen
Conflicts:
	modules/swagger-codegen/src/main/resources/ruby/swagger/version.mustache
	samples/client/petstore/ruby/lib/swagger/version.rb
2015-05-20 09:23:44 +08:00
xhh
194e9e6f05 Make petstore tests pass 2015-05-20 09:23:43 +08:00
xhh
8dd7d3aacd Regenerate ruby petstore sample code 2015-05-20 09:23:43 +08:00
xhh
104bcc1f89 Organize generated Ruby code into a module 2015-05-20 09:23:43 +08:00
Fake Bob Dobbs
a55c03013d use the defaultValue for spring mvc RequestHeader annotations; carry over the required value if set for RequestPart annotations 2015-05-19 11:47:34 -04:00
Fake Bob Dobbs
b783363c56 move the defaultValues for Forms and Headers as well 2015-05-19 11:45:48 -04:00
Alexey Nechaev
f0e4ea1780 Fixed #728: Handling of recursive model definitions has been improved. 2015-05-19 18:36:03 +03:00
Tony Tam
6a336f2e1e Merge pull request #758 from xhh/fix-android-form-test
Fix test of updatePetWithForm for Android Petstore sample
2015-05-19 08:29:48 -07:00
Ron
312637c94b Merge pull request #762 from wing328/update_readme
Update README.md with new generators
2015-05-19 07:21:52 -06:00
William Cheng
e717f74a0a update readme with new generators 2015-05-19 21:15:09 +08:00
Nadezhda Makarkina
3dde19bb59 Fixed #593: Python code failure caused by Model IDs with dots has been fixed 2015-05-19 14:31:42 +03:00
geekerzp
a0abea4b72 added required parameters check for objc 2015-05-19 17:12:46 +08:00
wing328
5744bd0138 better exception using InvalidArgumentException 2015-05-19 16:21:06 +08:00
xhh
db9ca1a485 Fix test of updatePetWithForm for Android Petstore sample 2015-05-19 15:42:29 +08:00
wing328
af260cba41 update api client to support default header 2015-05-19 15:33:03 +08:00
geekerzp
a77ae51318 update python tests 2015-05-19 15:21:09 +08:00
wing328
5aad44e628 added back test case for updatePetWithForm 2015-05-19 10:15:36 +08:00
wing328
41e178e268 better accept and content-type for php, added test cases 2015-05-18 22:16:54 +08:00
Tony Tam
e068ad4494 Merge pull request #756 from wing328/perl_improve_accept_header
[Perl] better logic for accept and content-type, added test cases
2015-05-18 06:36:11 -07:00
wing328
7fc2f74851 remove commented code 2015-05-18 16:39:33 +08:00
wing328
abbea5ec4c better logic for accept and content-type, added test cases 2015-05-18 16:23:46 +08:00
Tony Tam
72a4d2df2f Merge pull request #755 from wing328/ruby_cleanup_sample
[Ruby] Cleanup Ruby Petstore sample and bug fix
2015-05-17 21:41:21 -07:00
William Cheng
05ac516ffa clean up ruby sample, remove commented code, bug fix 2015-05-18 04:30:26 +08:00
Tony Tam
01423d4a6b Merge pull request #753 from wing328/ruby_model_improve
[Ruby] bug fixes for posting with sub-models and enhancements (refactoring)
2015-05-17 09:34:20 -07:00
William Cheng
3de9b4bfc8 remove (duplicated) object_to_http_body and object_to_hash from swagger.rb 2015-05-17 23:47:55 +08:00
William Cheng
92a2011207 fix post model, update rspec 2015-05-17 23:38:51 +08:00
William Cheng
8710fbfde7 add base object 2015-05-17 23:36:13 +08:00
Ron
0c94b89e42 Merge pull request #750 from sebest/patch-1
Fix a typo in the README
2015-05-17 07:33:48 +02:00
Sebastien Estienne
9e382ecf9a Fix a typo in the README 2015-05-16 22:05:44 -07:00
Tony Tam
0e0e265a2a Merge pull request #746 from wing328/ruby_fix_contenttype
Minor improvement to Ruby API Client 'accept' and 'content-type' header
2015-05-16 09:13:58 -07:00
Tony Tam
d6ac7c5ecf Merge pull request #659 from wing328/add_php_unit_test
Bug fix for PHP client POST (model) and add more PHP test cases
2015-05-16 09:13:35 -07:00
Tony Tam
8501ffe240 Merge pull request #716 from ponelat/fix/click-on-return-type-in-dynamic-html
Fix/click on return type in dynamic html
2015-05-16 09:11:26 -07:00
Tony Tam
919bab0765 Merge pull request #717 from ponelat/fix/dyn-html-pos-error
Fix dynamic-html positioning of parameters
2015-05-16 08:56:51 -07:00
Ron
3e719d087f Merge pull request #715 from ponelat/fix/dead-css-include
html: build and remove dead css include
2015-05-16 17:23:49 +02:00
Tony Tam
472e2afd8e Merge pull request #749 from wing328/perl_add_unittest
Add unit testing for Perl
2015-05-16 06:56:53 -07:00
geekerzp
68b0259c47 updated readme.md of python 2015-05-16 18:05:06 +08:00
geekerzp
9809ce1d18 updated python unittests 2015-05-16 17:30:42 +08:00
William Cheng
7a5db5e665 add pom.xml for perl integration test 2015-05-16 16:44:32 +08:00
Tony Tam
6ec7cf5a9d updated request process 2015-05-16 01:09:01 -07:00
Tony Tam
f4cbd88e2c fixed ordering 2015-05-16 00:45:42 -07:00
William Cheng
9904c0e09f add unit testing for pet 2015-05-16 15:37:58 +08:00
Fake Bob Dobbs
e4f5243e54 add defaultValues value to the SpringMVC RequestParam annotation 2015-05-15 17:17:46 -04:00
Fake Bob Dobbs
33138c139f A parameter's default value is not flowing from the swagger definition to the actual API implementation. This change makes the property from the swagger def json available to the templates. 2015-05-15 16:55:49 -04:00
Tony Tam
a2d2deeb0c Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-05-15 11:27:16 -07:00
Tony Tam
b4674d6fc5 template updates, tests 2015-05-15 11:27:03 -07:00
wing328
1f6a19b684 minor improvement to ruby api client accept and content-type header 2015-05-15 20:58:59 +08:00
geekerzp
c06cb38d64 updated objc client to support iso8601 datetime format 2015-05-15 17:49:56 +08:00
Josh Ponelat
3bc319d534 dynamic-html: refactor parameters view 2015-05-15 09:28:57 +02:00
Josh Ponelat
30496ffdc3 html: remove dead css line 2015-05-15 09:22:40 +02:00
Josh Ponelat
3544136ab1 dynamic-html: make sure clicking on return type works 2015-05-15 09:21:54 +02:00
geekerzp
6826a1d7df updated readme.mustache in python client 2015-05-15 14:51:51 +08:00
geekerzp
d798b943f5 added python 2.7 and python 3.4 test environments 2015-05-15 14:38:06 +08:00
wing328
4466b6e15e add test case for upload file, improve error handling 2015-05-15 11:08:33 +08:00
Tony Tam
0248d6fd9f Merge pull request #677 from wing328/fix_swagger_type2
Fix PHP swagger type
2015-05-14 11:50:57 -04:00
Tony Tam
bc66894553 Merge pull request #688 from xhh/scala-form-params
Add form parameters support to Scala codegen
2015-05-14 11:50:42 -04:00
wing328
c12673a407 fix error handling for 4xx, 5xx returned by server 2015-05-14 14:16:12 +08:00
geekerzp
86e48ceef8 refactor python client using urllib3 2015-05-14 10:45:05 +08:00
Ole Lensmar
adcd0f4bb8 changed interface to abstract class instead so we can use Override annotation to warn if we get dead methods when the definitions changes 2015-05-13 15:58:20 -07:00
Ole Lensmar
75b39e812e refactored to create separate serviceinterface, implementation and corresponding factory. JaxRs class uses the factory to find the implementation. Also fixed possibility for a code generator to control which API files that should be overwritten 2015-05-12 13:18:35 -04:00
Tony Tam
622d883344 fixed input type 2015-05-12 06:57:37 -04:00
Tony Tam
8519480f2c removed some cruft 2015-05-12 06:50:45 -04:00
Tony Tam
f9db729e75 added qt5 2015-05-12 06:05:09 -04:00
Tony Tam
0b2eced6a3 rebuilt 2015-05-12 06:05:00 -04:00
Tony Tam
dae01b5043 template update 2015-05-12 06:04:44 -04:00
Tony Tam
1912973d36 enabled qt5 2015-05-12 06:04:23 -04:00
Tony Tam
037a00720f added qt5 samples, script 2015-05-12 06:04:10 -04:00
Tony Tam
c2ee64e669 fixed version 2015-05-12 06:03:45 -04:00
Tony Tam
e703fc7982 fixed version 2015-05-12 06:03:37 -04:00
Tony Tam
5a1fa6ee65 added qt5 c++ templates 2015-05-12 05:56:12 -04:00
Tony Tam
d6016757cb Merge pull request #705 from wing328/fix_required_parameter
Fix required parameter validation for Java, Android, PHP and Ruby
2015-05-12 05:48:22 -04:00
Tony Tam
08184aab1d Merge pull request #679 from xhh/petstore-scala-tests
Fix tests for Scala petstore sample
2015-05-12 05:48:11 -04:00
Tony Tam
e33fbc67ad Merge pull request #648 from geekerzp/develop_2.0_objc_naming
Updated naming convention in objc client.
2015-05-12 05:47:51 -04:00
Tony Tam
f80238ae2d Merge pull request #737 from wing328/perl_codegen
Add templates for Perl
2015-05-12 05:47:25 -04:00
Ron
75ff9089af Merge pull request #739 from tomtit/revert726
Reverted JsonUtil.mustache for JavaClientCodegen after PR #726.
2015-05-12 09:42:37 +02:00
wing328
2f5f2b367b update package name to confirm to csharp convention, fix default header 2015-05-12 12:45:59 +08:00
Alexey Nechaev
66dea18b61 Reverted JsonUtil.mustache after PR #726. 2015-05-08 12:47:35 +00:00
Lorinda Brandon
bae40ded74 Update README.md 2015-05-07 19:23:49 -04:00
William Cheng
fc43828c20 update type mapping, update test.pl to use local file for testing upload 2015-05-08 03:58:02 +08:00
William Cheng
063a1ffd36 update type list in deserialize 2015-05-08 03:58:02 +08:00
William Cheng
1d4735f76d update subroutine argument 2015-05-08 03:58:01 +08:00
William Cheng
c03250132d update error message, update test script 2015-05-08 03:58:01 +08:00
William Cheng
48844442fc test post body (model), fix to_hash attribute mapping 2015-05-08 03:58:01 +08:00
William Cheng
f69fb40c71 add methods for static variable 2015-05-08 03:58:01 +08:00
William Cheng
0a34793f5a add inheritance to object (model) 2015-05-08 03:58:00 +08:00
William Cheng
07cd23edac seralization and deserialization work, get_pet_by_id and
update_pet_with_form work
2015-05-08 03:58:00 +08:00
William Cheng
a7ef1262e5 fix all swagger.pl syntax issue 2015-05-08 03:58:00 +08:00
William Cheng
c5fcf3ba2c remove pl files 2015-05-08 03:58:00 +08:00
William Cheng
d206035e0f add perl support - api template, bin, codegen 2015-05-08 03:57:59 +08:00
russellb337
2eeb96116d simplifying diff 2015-05-07 12:16:44 -07:00
russellb337
2edfb96c36 swagger codegen should honor global mime types 2015-05-07 12:02:25 -07:00
Tony Tam
c7e22b7a3b Merge pull request #726 from who/feature/gson-for-android-client
Feature: Use gson for android-client instead of jackson
2015-05-07 06:26:37 -07:00
Andrew B
20ced771ba Restoring the pom.xml so integration tests work 2015-05-07 01:09:25 -07:00
Andrew B
01b7385a5e Implementing gson in android client templates 2015-05-06 22:54:25 -07:00
wing328
070a6203e0 remove php comment 2015-05-07 13:35:19 +08:00
who
902c56f09b Initial commit of jackson-to-gson 2015-05-06 17:46:54 -07:00
russellb337
129086eea7 merge latest from develop_2.0 to fork 2015-05-06 13:44:10 -07:00
Tony Tam
157da246c0 added async test sample 2015-05-06 12:56:45 -07:00
Fake Bob Dobbs
321dfb7311 For SpringMVC, RequestHeader annotations are not setting the required attribute, even when required is false (RequestHeader uses default of true). This change always sets the required param 2015-05-06 09:05:57 -04:00
Tony Tam
65097a4908 Merge pull request #680 from geekerzp/develop_2.0_python_testing
Bug fix for deserialize model issue and added unit tests for python client
2015-05-04 21:11:35 -07:00
Tony Tam
df2cbfd0e9 Merge pull request #720 from akras14/master
Fixes a bug with Node.js example generating invalid package.json and swa...
2015-05-04 16:07:26 -07:00
Alex Kras
df95114a93 Fixes a bug with Node.js example generating invalid package.json and swagger.json
Currently string "... You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or ... " gets URL encoded, resuling in Node js throwing "Unable to parse" error.

Use of {{{ }}} forces mustache to skip URL encoding
http://mustache.github.io/mustache.5.html#Partials
2015-05-04 15:07:03 -07:00
Anthony Sosso
f7d30c847f Java: support x-www-form-urlencoded for PUT, POST, DELETE 2015-05-01 15:25:54 -07:00
who
b94eb443ea Adding some tests that were accidentally deleted 2015-04-30 12:52:21 -07:00
Ron
b70f5bc98b Merge pull request #709 from eerwitt/update_documentation_links
Found the 2.0.17 tag under 2.0.17 instead of v2.0.17.
2015-04-30 21:27:15 +03:00
e3
9876e792f1 Found the 2.0.17 tag under 2.0.17 instead of v2.0.17. 2015-04-30 11:22:45 -07:00
Ron
e3f09ae4cc Merge pull request #708 from eerwitt/update_documentation_links
Linked to the 2.0.18 tag instead of the no longer existing 2.0.17.
2015-04-30 21:21:32 +03:00
e3
cd2e030dc1 Linked to the 2.0.18 tag instead of the no longer existing 2.0.17. 2015-04-30 11:16:16 -07:00
who
6be2c06ed3 Adding maven publish functionality for android client 2015-04-30 10:34:43 -07:00
wing328
2e85871a4b remove hello.txt (created by mvn test) 2015-04-30 17:12:25 +08:00
wing328
47a8ef3031 fix required parameters in ruby 2015-04-30 17:01:36 +08:00
wing328
93e4ef0eec fix required parameters check for php 2015-04-30 16:52:33 +08:00
wing328
303378c5eb fix android required parameter check 2015-04-30 16:29:21 +08:00
Andrew B
5082f69631 Adding maven publish functionality for android client 2015-04-29 22:08:27 -07:00
Tony Tam
abe072c83d Merge pull request #703 from MaorBril/master
Added support for Basic Auth
2015-04-29 21:09:48 -07:00
maorb
5fbd0afdc5 Added support for Basic Auth 2015-04-29 18:19:16 -07:00
Tony Tam
4725dfb121 Merge pull request #702 from 0legg/feature/android-gradle
Jar and aar support for Android
2015-04-29 17:50:09 -07:00
Oleg Godovykh
14c2d14fc2 provide both jar and aar 2015-04-29 14:18:44 -04:00
Oleg Godovykh
119a981701 add possibility to create aar library 2015-04-29 13:39:00 -04:00
wing328
fb3088b765 fixed required parameter in java api 2015-04-29 17:31:38 +08:00
wing328
e7b170bf3c better comment on csharp api, add ParameterToString to handle date 2015-04-29 16:27:08 +08:00
wing328
96d837274e udpate csharp template with better comment and ParameterToString 2015-04-29 11:00:05 +08:00
wing328
8818c209df udpate csharp client with restsharp 2015-04-29 10:56:24 +08:00
wing328
5c057e1306 refactor csharp client using restsharp, getpetbyid working 2015-04-29 10:55:49 +08:00
Tony Tam
6c23a21312 Merge pull request #675 from marcinkiewiczblazej/issue-674
Fix for issue #674
2015-04-28 15:21:51 -07:00
Tony Tam
2f8e0bb09c Merge pull request #699 from 0legg/feature/android-gradle
Replace maven settings for Android client with gradle
2015-04-28 15:13:23 -07:00
Oleg Godovykh
b6495a9fc2 replace maven settings for Android client with gradle 2015-04-28 17:49:59 -04:00
Tony Tam
8952759eda Merge pull request #693 from lugaru1234/multiple_tags_operations
Generation of operations with multiple tags has been fixed #356
2015-04-28 07:03:23 -07:00
Tony Tam
c96f5f6fa8 added excludes for logback.xml per https://github.com/swagger-api/swagger-codegen/issues/689 2015-04-27 22:51:52 -07:00
Nadezhda Makarkina
b0d2d1116b Generation of operations with multiple tags has been fixed #356 2015-04-27 13:25:08 +03:00
xhh
4a55223a8f Add form parameters support to Scala codegen 2015-04-24 23:57:17 +08:00
geekerzp
3aa9982b23 Fixed issue that it will throw error when deserialize model in python client. 2015-04-23 18:19:08 +08:00
geekerzp
7d706f6a00 Added pom.xml for python client. 2015-04-23 18:09:32 +08:00
geekerzp
161aeb393b Add image file for python unit tests. 2015-04-23 17:38:57 +08:00
geekerzp
f9195a8a0e Added unit tests for python client. 2015-04-23 17:13:26 +08:00
Alexey Nechaev
9a36174685 Clean up of '\n' escaping. 2015-04-23 11:50:07 +03:00
xhh
4f5f6a9e8f Include Scala petstore sample into integration test 2015-04-23 15:27:44 +08:00
xhh
78072f753c Fix tests for Scala petstore sample 2015-04-23 09:38:27 +08:00
wing328
d5a3cc7300 fix php swagger type 2015-04-23 00:42:36 +08:00
Alexey Nechaev
fc0be6d503 Fixes #646: Example field handling has been fixed. 2015-04-22 16:17:28 +03:00
Alexey Nechaev
699973dcfe Group and version are avaiable from parent pom. 2015-04-22 16:11:16 +03:00
Blazej Marcinkiewicz
465266e219 Updated Java Spring MVC query param generation to include 'required' parameter if it's available. 2015-04-22 11:52:46 +02:00
Tony Tam
5c935a4c29 Merge pull request #668 from wing328/fix_swagger_type
[CSharp] Bug fix for swagger type
2015-04-21 10:01:35 -07:00
wing328
95ff0b9313 remove pettest, which is for testing only 2015-04-21 23:16:54 +08:00
wing328
eed04560c0 fix string? 2015-04-21 23:16:17 +08:00
William Cheng
2c0e8f6079 fix csharp model name issue 2015-04-21 22:42:13 +08:00
geekerzp
152eabbd6a Fixed PetstoreClient.xccheckout. 2015-04-21 16:33:28 +08:00
geekerzp
60ab624b23 Updated xcode project for petstore 2015-04-21 16:23:08 +08:00
geekerzp
4dd793c0ac Updated naming convention in objc client. 2015-04-21 16:23:08 +08:00
Tony Tam
7f4916f333 Merge pull request #664 from geekerzp/develop_2.0_python_content_type
Fixed encoding issue for request json body in python client.
2015-04-20 21:46:06 -07:00
Tony Tam
bf4d0a5466 Merge pull request #663 from wing328/better_method_doc
Better method documentation
2015-04-20 21:43:41 -07:00
geekerzp
d053d464dd Fixed encoding issue for request json body in python client. 2015-04-20 18:05:16 +08:00
William Cheng
5465708a42 add method documentation to android and scala 2015-04-19 23:51:46 +08:00
William Cheng
3622cfd169 add method documentation for objc client 2015-04-19 23:41:26 +08:00
William Cheng
ae389a8993 update python method documentation 2015-04-19 23:23:09 +08:00
Denis Yagofarov
1d175c1c7d + advices for OS X Users 2015-04-18 22:41:18 +03:00
wing328
7e37f3294a bug fix for post (model) and update php test cases 2015-04-17 20:01:58 +08:00
Karthik Velakur
1e273640b4 Issue #642 - Removing the unnecesary \n added to generated example requests 2015-04-16 13:26:52 -04:00
Tony Tam
cbbe29cf70 Merge pull request #651 from wing328/method_name_style
Update method name based on style guide
2015-04-16 10:09:47 -07:00
wing328
c87579e1f7 fix rspec due to change of optional parameter in ruby method 2015-04-17 01:03:15 +08:00
wing328
c30ed059fe update php api test with SwaggerClient.php 2015-04-17 00:26:06 +08:00
wing328
676c4d0835 add back php unit testing and readme to PHP SwaggerClient sample code 2015-04-17 00:26:06 +08:00
wing328
4c717829b3 update test.php, remove old SwaggerPetstore-php 2015-04-17 00:26:06 +08:00
wing328
8512259d02 update method name based on style guide, update petstore sample 2015-04-17 00:26:06 +08:00
Tony Tam
e45b04ef32 Merge pull request #649 from xhh/ruby-optional-params
Add support of optional parameters to Ruby codegen
2015-04-16 09:11:28 -07:00
xhh
de21088619 Support optional body parameter 2015-04-16 18:20:36 +08:00
xhh
61bf7f49cc Remove redundant blank lines 2015-04-16 15:56:08 +08:00
xhh
a819e4d523 Support optional parameters in Ruby client
* Pass optional parameters via the `opts` Hash
* Handle query parameters in a way similar to header/form parameters to
  support parameter name normalization, e.g. the "additional_metadata"
  key is passed for "additionalMetadata"
* Rename variables to be consistent: `query_params`, `header_params` and
  `form_params`
* Remove unnecessary blank lines
2015-04-16 15:56:08 +08:00
Tony Tam
57ca71fcc9 Merge pull request #626 from wing328/fix_ruby_rspec
Fixed Ruby rspec
2015-04-15 22:56:54 -07:00
Tony Tam
a03574e119 Merge pull request #631 from xhh/ruby-config
Fix hard-coded values in Ruby client: scheme, host and base_path
2015-04-15 22:54:46 -07:00
Tony Tam
19d7dad33c Merge pull request #618 from wing328/python3_codegen
Added back python 3 codegen
2015-04-15 22:53:15 -07:00
Tony Tam
2cd8ba9875 Merge branch 'geekerzp-develop_2.0_objc_tests' into develop_2.0 2015-04-15 22:49:05 -07:00
Tony Tam
dc11c94514 Merge branch 'develop_2.0_objc_tests' of https://github.com/geekerzp/swagger-codegen into geekerzp-develop_2.0_objc_tests 2015-04-15 22:46:46 -07:00
Tony Tam
037fe442dc Merge branch 'geekerzp-develop_2.0_objc_optional_property' into develop_2.0 2015-04-15 22:44:03 -07:00
Tony Tam
0525d66b86 regenerated 2015-04-15 22:43:48 -07:00
Tony Tam
a168c4bf06 Merge branch 'develop_2.0_objc_optional_property' of https://github.com/geekerzp/swagger-codegen into geekerzp-develop_2.0_objc_optional_property 2015-04-15 22:12:01 -07:00
Tony Tam
a465edd890 Merge pull request #645 from who/develop_2.0
[PHP Templates] Fixing a bug which was preventing payloads to serialize into JSON
2015-04-15 16:51:24 -07:00
who
164a01ed12 Fixing a bug which was preventing payloads to serialize into JSON 2015-04-15 16:17:21 -07:00
Tony Tam
39602c4b2b Merge pull request #644 from hyeghiazaryan/develop_2.0
Adding defaultHeaders dictionary to generated API classes.
2015-04-15 14:24:20 -07:00
hrachya
33dfcd247d Adding defaultHeaders dictionary to generated API classes. defaultHeaders will be merged with headerParams before sending the request.
fix for https://github.com/swagger-api/swagger-codegen/issues/638
2015-04-15 13:02:09 -07:00
Tony Tam
1617b76e27 Merge pull request #637 from hyeghiazaryan/develop_2.0
Adding import for Foundation.h to SWGQueryParamCollection.h
2015-04-15 10:08:21 -07:00
geekerzp
0a9df88e53 Using propertyIsOptional to implement optional property instead of
using `Optional` protocol in objc client.
2015-04-15 17:53:45 +08:00
geekerzp
989641892e Remove outdated tests in objc client 2015-04-15 15:10:46 +08:00
hrachya
21fcbc7acb Adding import for Foundation.h to SWGQueryParamCollection.h
fix for https://github.com/swagger-api/swagger-codegen/issues/636
2015-04-14 13:20:38 -07:00
Tony Tam
dfa17d2291 Merge pull request #630 from who/develop_2.0
Making default PHP namespace generic and fix issues 628 and 635
2015-04-14 12:35:44 -07:00
who
f4a2eff4b7 Fixing nested model deserialization - Issue #635 2015-04-14 12:24:59 -07:00
Tony Tam
f9fd511eb0 Merge pull request #634 from hyeghiazaryan/develop_2.0
Adding toParamName override to ObjcClientCodegen.java
2015-04-14 11:36:25 -07:00
hrachya
ff71a2cc60 Adding toParamName override to ObjcClientCodegen.java
fix for https://github.com/swagger-api/swagger-codegen/issues/633
2015-04-14 11:23:09 -07:00
xhh
41371bd901 Initialize a default configuration object 2015-04-14 15:03:21 +08:00
xhh
7db7b146be Fix hard-coded values in Ruby client: scheme, host and base_path 2015-04-14 12:32:25 +08:00
who
de25d63838 Making the default PHP package name more generic instead of being specific to Petstore 2015-04-13 16:27:30 -07:00
who
42829ffb13 A proposed fix for Issue #628 2015-04-13 13:14:10 -07:00
Tony Tam
444666a365 Merge pull request #629 from who/develop_2.0
Correct usage of strpos in PHP APIClient mustache template
2015-04-13 12:30:41 -07:00
who
41db8798af correct usage of strpos 2015-04-13 12:22:38 -07:00
Tony Tam
33bd614a42 Merge pull request #625 from geekerzp/develop_2.0_python_form_params
Fixed request content-type in python client
2015-04-13 10:26:17 -07:00
Tony Tam
10ad0b48dc Merge pull request #623 from wing328/php_fix_double
Fixed "double" response type in PHP client
2015-04-13 10:24:54 -07:00
wing328
4a0314849e fix ruby spec 2015-04-13 22:23:52 +08:00
geekerzp
10a9d298d7 Fixed request content-type in objc client.
In api.mustache the name of content-type is `Content-Type`,
but in swagger.mustache the name of content-type is `Content-type`.
2015-04-13 17:30:43 +08:00
William Cheng
13d513f02b fix double in php client response 2015-04-12 23:06:07 +08:00
Tony Tam
7f84deaf30 Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-04-10 23:07:27 -07:00
Tony Tam
765a5c6aa1 added uniqueness for nickname, #612 2015-04-10 23:07:00 -07:00
Tony Tam
f7c195a7ac updated pom for #612 2015-04-10 23:06:47 -07:00
Tony Tam
252cb18aeb Merge pull request #619 from geekerzp/develop_2.0_python_package
Update Python codegen to support packaging via Setuptools
2015-04-10 21:03:08 -07:00
Tony Tam
54a5ecb101 Merge pull request #620 from geekerzp/develop_2.0_objc_content_type
Fixed request content-type in objc client
2015-04-10 21:01:25 -07:00
geekerzp
63ca000482 fixed request content-type to multipart/form-data when upload file is null 2015-04-11 11:46:55 +08:00
geekerzp
00aa844964 update readme.md 2015-04-11 10:38:32 +08:00
geekerzp
e6bf58a707 package python sdk using setuptools 2015-04-11 10:38:32 +08:00
William Cheng
ccc0653923 add python 3 codegen 2015-04-10 19:42:09 +08:00
Tony Tam
70c14092f9 Merge pull request #610 from xhh/ruby-gemspec
Generate Ruby gemspec
2015-04-09 07:37:26 -06:00
Tony Tam
a1e62ea4b1 Merge pull request #611 from wing328/csharp_date_iso8601
Updated CSharp client to support ISO8601 format
2015-04-09 07:26:12 -06:00
wing328
22f72e2b23 update comment for escapeString 2015-04-09 16:05:13 +08:00
wing328
a0756bf6f2 remove composer.lock 2015-04-09 15:57:25 +08:00
wing328
78e1fb231e remove php vendor 2015-04-09 15:56:19 +08:00
wing328
5cbe5d60aa add iso8601 support to csharp, add more comments, add PATCH support 2015-04-09 15:55:13 +08:00
xhh
e9c5c1434b Fix spec 2015-04-09 11:37:48 +08:00
xhh
817a74d4df Add README.md file containing instructions on Ruby petstore sample 2015-04-09 11:34:10 +08:00
xhh
02fa04aec8 Generate gemspec for Ruby client 2015-04-09 11:34:09 +08:00
xhh
7cd8d0a1ac Restructure gemspec related files to ease importing the files 2015-04-09 11:34:09 +08:00
Tony Tam
7dcdaca288 Merge pull request #609 from geekerzp/develop_2.0_python_better_import
Better import for python client
2015-04-08 21:15:38 -06:00
geekerzp
3259a1d814 Fixed module name in __init__.py in python client. 2015-04-09 10:37:15 +08:00
geekerzp
806c26d54f Merge branch 'develop_2.0' into develop_2.0_python_better_import
Conflicts:
	modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/PythonClientCodegen.java
2015-04-09 09:31:50 +08:00
geekerzp
f2ecc271b5 Better import for python client. 2015-04-09 09:21:21 +08:00
Tony Tam
a05251da51 Merge pull request #601 from geekerzp/develop_2.0_python_unicode
Support unicode string in python client.
2015-04-08 06:56:19 -06:00
Tony Tam
555ef7677d Merge pull request #600 from wing328/python_variable_naming
Fixed parameter name, better naming convention for python client
2015-04-08 05:04:02 -06:00
Tony Tam
eb2ec92b66 Merge pull request #604 from wing328/php_fix_warning
Fixed PHP5.3 warning
2015-04-08 05:01:54 -06:00
Tony Tam
e1a3540caf fixed version 2015-04-08 05:00:10 -06:00
William Cheng
9de22c8146 update petstore php sample 2015-04-08 12:00:37 +08:00
William Cheng
eb0fccd1d2 fixed content-type check for model 2015-04-08 11:54:57 +08:00
William Cheng
cb2f5d3e25 fix php warning in php5.3 2015-04-08 11:33:09 +08:00
Tony Tam
73665a2b67 Merge pull request #602 from wing328/php_unit_test
Added unit testing for PHP Petstore client
2015-04-07 09:41:56 -06:00
geekerzp
24d5dc093f Support unicode string in python client. 2015-04-07 15:33:05 +08:00
William Cheng
18476114b9 update test case for php, add readme.md 2015-04-07 04:02:09 +08:00
William Cheng
bd07425b25 update php test case for PetApi 2015-04-07 03:59:20 +08:00
William Cheng
49ad6f47a5 fix parameter name, better naming convention for python client 2015-04-07 01:37:32 +08:00
Camille Chafer
65b6d210bc Examples updated with names lower-camelized 2015-04-02 18:02:21 +02:00
Camille Chafer
6c4765fd00 Parameters names where camelized with first letter not lower 2015-04-02 18:00:25 +02:00
Camille Chafer
ef3811390f Some fixes for Wordnik & Petstore examples 2015-04-02 17:46:26 +02:00
Camille Chafer
2ce55115a6 Add wordnik and petstore examples 2015-04-02 16:26:16 +02:00
Camille Chafer
0811e0bce3 Add Akka-Scala client generator. This client uses Spray as Http Client. 2015-04-02 16:22:52 +02:00
russellb337
62d4516fe7 Merge remote-tracking branch 'upstream/develop_2.0' into develop_2.0 2015-03-26 09:06:35 -07:00
russellb337
970facaa8a merge latest from develop_2.0 to fork 2015-03-23 17:01:49 -07:00
russellb337
fe92889b10 merge latest from develop_2.0 to to fork 2015-03-23 17:01:35 -07:00
1366 changed files with 106986 additions and 39623 deletions

47
.dockerignore Normal file
View File

@@ -0,0 +1,47 @@
*.iml
out/
*.ipr
*.iws
classpath.txt
version.properties
.project
.classpath
lib/*
build/*
generated-files/*
generated-sources/*
generated-code/*
*.swp
*.swo
/target
/generated-files
/nbactions.xml
*.pyc
__pycache__
samples/server-generator/scalatra/output
samples/server-generator/node/output/node_modules
samples/server-generator/scalatra/target
samples/server-generator/scalatra/output/.history
samples/client/petstore/qt5cpp/PetStore/moc_*
samples/client/petstore/qt5cpp/PetStore/*.o
samples/client/petstore/objc/PetstoreClient.xcworkspace/xcuserdata
samples/client/petstore/qt5cpp/build-*
samples/client/petstore/qt5cpp/PetStore/PetStore
samples/client/petstore/qt5cpp/PetStore/Makefile
samples/client/petstore/java/hello.txt
samples/client/petstore/android-java/hello.txt
samples/client/petstore/objc/Build
samples/client/petstore/objc/Pods
samples/server/petstore/nodejs/node_modules
target
.idea
.lib
atlassian-ide-plugin.xml
.DS_Store
samples/client/petstore/php/SwaggerClient-php/composer.lock
samples/client/petstore/php/SwaggerClient-php/vendor/
samples/client/petstore/silex/SwaggerServer/composer.lock
samples/client/petstore/silex/SwaggerServer/venodr/

24
.gitignore vendored
View File

@@ -9,6 +9,7 @@ version.properties
lib/*
build/*
generated-files/*
generated-sources/*
generated-code/*
*.swp
*.swo
@@ -22,9 +23,30 @@ samples/server-generator/scalatra/output
samples/server-generator/node/output/node_modules
samples/server-generator/scalatra/target
samples/server-generator/scalatra/output/.history
samples/client/petstore/qt5cpp/PetStore/moc_*
samples/client/petstore/qt5cpp/PetStore/*.o
samples/client/petstore/objc/PetstoreClient.xcworkspace/xcuserdata
samples/client/petstore/qt5cpp/build-*
samples/client/petstore/qt5cpp/PetStore/PetStore
samples/client/petstore/qt5cpp/PetStore/Makefile
samples/client/petstore/java/hello.txt
samples/client/petstore/android-java/hello.txt
samples/client/petstore/objc/SwaggerClientTests/Build
samples/client/petstore/objc/SwaggerClientTests/Pods
samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcworkspace
samples/client/petstore/objc/SwaggerClientTests/Podfile.lock
samples/server/petstore/nodejs/node_modules
target
.idea
.lib
atlassian-ide-plugin.xml
.DS_Store
samples/client/petstore/php/SwaggerClient-php/composer.lock
samples/client/petstore/php/SwaggerClient-php/vendor/
samples/client/petstore/silex/SwaggerServer/composer.lock
samples/client/petstore/silex/SwaggerServer/venodr/
samples/client/petstore/python/.projectile
samples/client/petstore/python/.venv/

View File

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

13
Dockerfile Normal file
View File

@@ -0,0 +1,13 @@
FROM maven:3.3-jdk-7
WORKDIR /src
VOLUME /src
VOLUME /root/.m2/repository
ADD . /opt/swagger-codegen
RUN cd /opt/swagger-codegen && mvn package
ENTRYPOINT ["java", "-jar", "/opt/swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"]
CMD ["help"]

11
LICENSE Normal file
View File

@@ -0,0 +1,11 @@
Copyright 2015 SmartBear Software
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

146
README.md
View File

@@ -5,22 +5,36 @@
## Overview
This is the swagger codegen project, which allows generation of client libraries automatically from a Swagger-compliant server.
## What's Swagger?
The goal of Swagger™ is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined via Swagger, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interfaces have done for lower-level programming, Swagger removes the guesswork in calling the service.
Check out [Swagger-Spec](https://github.com/swagger-api/swagger-spec) for additional information about the Swagger project, including additional libraries with support for other languages and more.
## Build and run using docker
## Compatability
```
git clone https://github.com/swagger-api/swagger-codegen
cd swagger-codegen
./run-in-docker.sh mvn package
```
Build a nodejs server stub:
```
./run-in-docker.sh generate \
-i http://petstore.swagger.io/v2/swagger.json \
-l nodejs \
-o samples/server/petstore/nodejs
```
## Compatibility
The Swagger Specification has undergone 3 revisions since initial creation in 2010. The swagger-codegen project has the following compatibilies with the swagger specification:
Swagger Codegen Version | Release Date | Swagger Spec compatibility | Notes
----------------------- | ------------ | -------------------------- | -----
2.1.0-M2 | 2015-04-06 | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen)
2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/v2.0.17)
1.0.4 | 2012-04-12 | 1.0, 1.1 | [tag v1.0.4](https://github.com/swagger-api/swagger-codegen/tree/swagger-codegen_2.9.1-1.1)
Swagger Codegen Version | Release Date | Swagger Spec compatibility | Notes
-------------------------- | ------------ | -------------------------- | -----
2.1.3 | | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen)
2.1.3 (**current stable**) | 2015-08-24 | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen/tree/v2.1.3)
2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/v2.0.17)
1.0.4 | 2012-04-12 | 1.0, 1.1 | [tag v1.0.4](https://github.com/swagger-api/swagger-codegen/tree/swagger-codegen_2.9.1-1.1)
### Prerequisites
@@ -29,6 +43,17 @@ You need the following installed and available in your $PATH:
* [Java 7](http://java.oracle.com)
* [Apache maven 3.0.3 or greater](http://maven.apache.org/)
#### OS X Users
Don't forget to install Java 7. You probably have 1.6 or 1.8.
Export JAVA_HOME in order to user proper Java version:
```
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
export PATH=${JAVA_HOME}/bin:$PATH
```
#### Building
After cloning the project, you can build it from source with this command:
@@ -60,11 +85,14 @@ NAME
SYNOPSIS
swagger generate [(-a <authorization> | --auth <authorization>)]
[(-c <configuration file> | --config <configuration file>)]
[-D <system properties>]
(-i <spec file> | --input-spec <spec file>)
(-l <language> | --lang <language>)
[(-o <output directory> | --output <output directory>)]
[(-t <template directory> | --template-dir <template directory>)]
[(-v | --verbose)]
[(-s | --skip-overwrite)]
OPTIONS
-a <authorization>, --auth <authorization>
@@ -72,6 +100,16 @@ OPTIONS
remotely. Pass in a URL-encoded string of name:header with a comma
separating multiple values
-c <configuration file>, --config <configuration file>
Path to json configuration file. File content should be in a json
format {"optionKey":"optionValue", "optionKey1":"optionValue1"...}
Supported options can be different for each language. Run
config-help -l {lang} command for language specific config options.
-D <system properties>
sets specified system properties in the format of
name=value,name=value
-i <spec file>, --input-spec <spec file>
location of the swagger spec, as URL or file (required)
@@ -87,7 +125,11 @@ OPTIONS
-v, --verbose
verbose mode
```
-s , --skip-overwrite
specifies if the existing files should be overwritten during
the generation
```
You can then compile and run the client, as well as unit tests against it:
@@ -142,35 +184,107 @@ Great for creating libraries on your ci server, from the [Swagger Editor](http:/
There are different aspects of customizing the code generator beyond just creating or modifying templates. Each language has a supporting configuration file to handle different type mappings, etc:
```
$ ls -1 modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/
$ ls -1 modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/
AbstractTypeScriptClientCodegen.java
AkkaScalaClientCodegen.java
AndroidClientCodegen.java
AsyncScalaClientCodegen.java
CSharpClientCodegen.java
CodeGenStatus.java
CsharpDotNet2ClientCodegen.java
FlashClientCodegen.java
JavaClientCodegen.java
JavaInflectorServerCodegen.java
JaxRSServerCodegen.java
NodeJSServerCodegen.java
ObjcClientCodegen.java
PerlClientCodegen.java
PhpClientCodegen.java
Python3ClientCodegen.java
PythonClientCodegen.java
Qt5CPPGenerator.java
RetrofitClientCodegen.java
RubyClientCodegen.java
ScalaClientCodegen.java
ScalatraServerCodegen.java
SilexServerCodegen.java
SinatraServerCodegen.java
SpringMVCServerCodegen.java
StaticDocCodegen.java
StaticHtmlGenerator.java
SwaggerGenerator.java
SwaggerYamlGenerator.java
SwiftCodegen.java
TizenClientCodegen.java
TypeScriptAngularClientCodegen.java
TypeScriptNodeClientCodegen.java
```
Each of these files creates reasonable defaults so you can get running quickly. But if you want to configure package names, prefixes, model folders, etc., you may want to extend these.
Each of these files creates reasonable defaults so you can get running quickly. But if you want to configure package names, prefixes, model folders, etc. you can use a json config file to pass the values.
```
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i http://petstore.swagger.io/v2/swagger.json \
-l java \
-o samples/client/petstore/java \
-c path/to/config.json
```
Supported config options can be different per language. Running `config-help -l {lang}` will show available options.
```
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar config-help -l java
```
Output
```
CONFIG OPTIONS
modelPackage
package for generated models
apiPackage
package for generated api classes
invokerPackage
root package for generated code
groupId
groupId in generated pom.xml
artifactId
artifactId in generated pom.xml
artifactVersion
artifact version in generated pom.xml
sourceFolder
source folder for generated code
library
library template (sub-template) to use:
<default> - HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2
jersey2 - HTTP client: Jersey client 2.6
```
Your config file for java can look like
```
{
"groupId":"com.my.company",
"artifactId":"MyClent",
"artifactVersion":"1.2.0"
}
```
For all the unspecified options default values will be used.
Another way to override default options is to extend config class for specific language.
To change, for example, the prefix for the Objective-C generated files, simply subclass the ObjcClientCodegen.java:
```
package com.mycompany.swagger.codegen;
import com.wordnik.swagger.codegen.languages.*;
import io.swagger.codegen.languages.*;
public class MyObjcCodegen extends ObjcClientCodegen {
static {
@@ -270,7 +384,7 @@ Note! The templates are included in the library generated. If you want to modi
License
-------
Copyright 2015 Reverb Technologies, Inc.
Copyright 2015 SmartBear Software
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

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

View File

@@ -18,16 +18,29 @@ if [ ! -d "${APP_DIR}" ]; then
fi
cd $APP_DIR
./bin/akka-scala-petstore.sh
./bin/android-java-petstore.sh
./bin/csharp-petstore.sh
./bin/dynamic-html.sh
./bin/html-petstore.sh
./bin/jaxrs-petstore-server.sh
./bin/java-petstore.sh
./bin/java-petstore-jersey2.sh
./bin/jaxrs-petstore-server.sh
./bin/nodejs-petstore-server.sh
./bin/objc-petstore.sh
./bin/perl-petstore.sh
./bin/php-petstore.sh
./bin/python-petstore.sh
./bin/python3-petstore.sh
./bin/qt5-petstore.sh
./bin/retrofit-petstore.sh
./bin/ruby-petstore.sh
./bin/objc-petstore.sh
./bin/scala-async-petstore.sh
./bin/scala-petstore.sh
./bin/scalatra-petstore-server.sh
./bin/silex-petstore-server.sh
./bin/spring-mvc-petstore-server.sh
./bin/swift-petstore.sh
./bin/tizen-petstore.sh
./bin/typescript-angular-petstore.sh
./bin/typescript-node-petstore.sh

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

View File

@@ -26,6 +26,6 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l csharp -o samples/client/petstore/csharp"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l csharp -o samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient"
java $JAVA_OPTS -jar $executable $ags

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

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

View File

@@ -0,0 +1,4 @@
{
"library": "jersey2",
"artifactId": "swagger-petstore-jersey2"
}

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

View File

@@ -26,6 +26,6 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -o samples/client/petstore/java"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -o samples/client/petstore/java/default"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -26,6 +26,6 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l jaxrs -o samples/server/petstore/jaxrs"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l jaxrs -o samples/server/petstore/jaxrs -Dswagger.codegen.jaxrs.impl.source=src/main/java"
java $JAVA_OPTS -jar $executable $ags

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

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

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

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

5
bin/ruby-petstore.json Normal file
View File

@@ -0,0 +1,5 @@
{
"gemName": "petstore",
"moduleName": "Petstore",
"gemVersion": "1.0.0"
}

View File

@@ -26,6 +26,6 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/ruby -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l ruby -o samples/client/petstore/ruby"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/ruby -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby"
java $JAVA_OPTS -jar $executable $ags

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

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

4
bin/swift-petstore.json Normal file
View File

@@ -0,0 +1,4 @@
{
"projectName": "PetstoreClient",
"responseAs": "PromiseKit"
}

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

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 -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-angular -o samples/client/petstore/typescript-angular"
java $JAVA_OPTS -jar $executable $ags

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

View File

@@ -1,9 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>com.wordnik</groupId>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-project</artifactId>
<version>2.1.0-M2</version>
<version>2.1.3</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -15,6 +15,14 @@
<build>
<finalName>swagger-codegen-cli</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>logback.xml</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -22,7 +30,7 @@
<configuration>
<archive>
<manifest>
<mainClass>com.wordnik.swagger.codegen.SwaggerCodegen</mainClass>
<mainClass>io.swagger.codegen.SwaggerCodegen</mainClass>
</manifest>
</archive>
</configuration>
@@ -33,7 +41,7 @@
<version>2.3</version>
<executions>
<execution>
<id>reduced-pom</id>
<id>process-resources</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
@@ -44,17 +52,9 @@
<dependencyReducedPomLocation>
${java.io.tmpdir}/dependency-reduced-pom.xml
</dependencyReducedPomLocation>
</configuration>
</execution>
<execution>
<id>process-resources</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
</configuration>
</execution>
@@ -66,7 +66,7 @@
<dependencies>
<dependency>
<groupId>com.wordnik</groupId>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen</artifactId>
<version>${project.version}</version>
</dependency>
@@ -90,6 +90,13 @@
<version>${slf4j-version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -1,16 +1,17 @@
package com.wordnik.swagger.codegen;
package io.swagger.codegen;
import com.wordnik.swagger.codegen.cmd.Generate;
import com.wordnik.swagger.codegen.cmd.Langs;
import com.wordnik.swagger.codegen.cmd.Meta;
import io.airlift.airline.Cli;
import io.airlift.airline.Help;
import io.swagger.codegen.cmd.ConfigHelp;
import io.swagger.codegen.cmd.Generate;
import io.swagger.codegen.cmd.Langs;
import io.swagger.codegen.cmd.Meta;
/**
* User: lanwen
* Date: 24.03.15
* Time: 17:56
*
* <p>
* Command line interface for swagger codegen
* use `swagger-codegen-cli.jar help` for more info
*
@@ -27,7 +28,8 @@ public class SwaggerCodegen {
Generate.class,
Meta.class,
Langs.class,
Help.class
Help.class,
ConfigHelp.class
);
builder.build().parse(args).run();

View File

@@ -0,0 +1,52 @@
package io.swagger.codegen.cmd;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import io.swagger.codegen.CliOption;
import io.swagger.codegen.CodegenConfig;
import java.util.ServiceLoader;
import static java.util.ServiceLoader.load;
@Command(name = "config-help", description = "Config help for chosen lang")
public class ConfigHelp implements Runnable {
@Option(name = {"-l", "--lang"}, title = "language", required = true,
description = "language to get config help for")
private String lang;
/**
* 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);
}
}
@Override
public void run() {
System.out.println();
CodegenConfig config = forName(lang);
System.out.println("CONFIG OPTIONS");
for (CliOption langCliOption : config.cliOptions()) {
System.out.println("\t" + langCliOption.getOpt());
System.out.println("\t " + langCliOption.getDescription().replaceAll("\n", "\n\t "));
System.out.println();
}
}
}

View File

@@ -1,12 +1,15 @@
package com.wordnik.swagger.codegen.cmd;
package io.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 config.Config;
import config.ConfigParser;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import io.swagger.codegen.CliOption;
import io.swagger.codegen.ClientOptInput;
import io.swagger.codegen.ClientOpts;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.DefaultGenerator;
import io.swagger.models.Swagger;
import io.swagger.parser.SwaggerParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -54,51 +57,22 @@ public class Generate implements Runnable {
"Pass in a URL-encoded string of name:header with a comma separating multiple values")
private String auth;
@Override
public void run() {
verbosed(verbose);
@Option(name = {"-D"}, title = "system properties", description = "sets specified system properties in " +
"the format of name=value,name=value")
private String systemProperties;
ClientOptInput input = new ClientOptInput();
@Option(name = {"-c", "--config"}, title = "configuration file", description = "Path to json configuration file. " +
"File content should be in a json format {\"optionKey\":\"optionValue\", \"optionKey1\":\"optionValue1\"...} " +
"Supported options can be different for each language. Run config-help -l {lang} command for language specific config options.")
private String configFile;
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", "");
}
@Option(name = {"-s", "--skip-overwrite"}, title = "skip overwrite", description = "specifies if the existing files should be " +
"overwritten during the generation.")
private boolean skipOverwrite;
/**
* 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
*/
@@ -117,4 +91,78 @@ public class Generate implements Runnable {
throw new RuntimeException("Can't load config class with name ".concat(name), e);
}
}
@Override
public void run() {
verbosed(verbose);
setSystemProperties();
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());
}
if (null != configFile) {
Config genConfig = ConfigParser.read(configFile);
if (null != genConfig) {
for (CliOption langCliOption : config.cliOptions()) {
String opt = langCliOption.getOpt();
if (genConfig.hasOption(opt)) {
config.additionalProperties().put(opt, genConfig.getOption(opt));
// the "library" config option is for library template (sub-template)
if ("library".equals(opt)) {
config.setLibrary(genConfig.getOption(opt));
}
}
}
}
}
config.setSkipOverwrite(skipOverwrite);
input.setConfig(config);
Swagger swagger = new SwaggerParser().read(spec, input.getAuthorizationValues(), true);
new DefaultGenerator().opts(input.opts(new ClientOpts()).swagger(swagger)).generate();
}
private void setSystemProperties() {
if (systemProperties != null && systemProperties.length() > 0) {
for (String property : systemProperties.split(",")) {
int ix = property.indexOf('=');
if (ix > 0 && ix < property.length() - 1) {
System.setProperty(property.substring(0, ix), property.substring(ix + 1));
}
}
}
}
/**
* 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", "");
}
}

View File

@@ -1,8 +1,8 @@
package com.wordnik.swagger.codegen.cmd;
package io.swagger.codegen.cmd;
import ch.lambdaj.collection.LambdaIterable;
import com.wordnik.swagger.codegen.CodegenConfig;
import io.airlift.airline.Command;
import io.swagger.codegen.CodegenConfig;
import static ch.lambdaj.Lambda.on;
import static ch.lambdaj.collection.LambdaCollections.with;

View File

@@ -1,13 +1,13 @@
package com.wordnik.swagger.codegen.cmd;
package io.swagger.codegen.cmd;
import ch.lambdaj.function.convert.Converter;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache;
import com.wordnik.swagger.codegen.DefaultGenerator;
import com.wordnik.swagger.codegen.SupportingFile;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import io.swagger.codegen.DefaultGenerator;
import io.swagger.codegen.SupportingFile;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@@ -47,8 +47,8 @@ public class Meta implements Runnable {
private String name = "default";
@Option(name = {"-p", "--package"}, title = "package",
description = "the package to put the main class into (defaults to com.wordnik.swagger.codegen)")
private String targetPackage = "com.wordnik.swagger.codegen";
description = "the package to put the main class into (defaults to io.swagger.codegen)")
private String targetPackage = "io.swagger.codegen";
@Override
public void run() {
@@ -65,7 +65,7 @@ public class Meta implements Runnable {
new SupportingFile("api.template", "src/main/resources" + File.separator + name, "api.mustache"),
new SupportingFile("model.template", "src/main/resources" + File.separator + name, "model.mustache"),
new SupportingFile("services.mustache",
"src/main/resources/META-INF/services", "com.wordnik.swagger.codegen.CodegenConfig")
"src/main/resources/META-INF/services", "io.swagger.codegen.CodegenConfig")
);
Map<String, Object> data = new ImmutableMap.Builder<String, Object>()
@@ -81,8 +81,9 @@ public class Meta implements Runnable {
/**
* Converter method to process supporting files: execute with mustache,
* or simply copy to destination directory
*
* @param targetDir - destination directory
* @param data - map with additional params needed to process templates
* @param data - map with additional params needed to process templates
* @return converter object to pass to lambdaj
*/
private Converter<SupportingFile, File> processFiles(final File targetDir, final Map<String, Object> data) {
@@ -121,6 +122,7 @@ public class Meta implements Runnable {
/**
* Creates mustache loader for template using classpath loader
*
* @param generator - class with reader getter
* @return loader for template
*/
@@ -135,6 +137,7 @@ public class Meta implements Runnable {
/**
* Converts package name to path on file system
*
* @param packageName - package name to convert
* @return relative path
*/

View File

@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
</layout>
</appender>
<logger name="com.wordnik" level="debug"/>
<root level="error">
<appender-ref ref="STDOUT" />
</root>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
</layout>
</appender>
<logger name="io.swagger" level="debug"/>
<root level="error">
<appender-ref ref="STDOUT"/>
</root>
</configuration>

View File

@@ -0,0 +1,73 @@
package io.swagger.codegen;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.apache.commons.io.FileUtils;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.fail;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
public class GenerateTest {
private static final String TEST_SKIP_OVERWRITE = "testSkipOverwrite";
private static final String POM_FILE = "pom.xml";
private static final String MODEL_ORDER_FILE = "/src/main/java/io/swagger/client/model/Order.java";
@Rule
public TemporaryFolder folder = new TemporaryFolder();
@Test
public void testSkipOverwrite() throws IOException {
final File output = folder.getRoot();
String[] args = {"generate", "-i", "src/test/resources/petstore.json", "-l", "java", "-o", output.getAbsolutePath()};
String[] argsWithSparam = Arrays.copyOf(args, args.length + 1);
argsWithSparam[args.length] = "-s";
//generate content first time without -s flag, so all generated files should be recorded
SwaggerCodegen.main(args);
final File order = new File(output, MODEL_ORDER_FILE);
assertTrue(order.exists());
//change content of one file
changeContent(order);
//generate content second time without -s flag, so changed file should be rewritten
SwaggerCodegen.main(args);
//order = new File(output, MODEL_ORDER_FILE);
assertTrue(!TEST_SKIP_OVERWRITE.equals(FileUtils.readFileToString(order, StandardCharsets.UTF_8)));
//change content again
changeContent(order);
//delete file
final File pom = new File(output, POM_FILE);
if (!pom.delete()) {
fail();
}
//generate content third time with -s flag, so changed file should not be rewritten
//and deleted file should be recorded
SwaggerCodegen.main(argsWithSparam);
assertEquals(FileUtils.readFileToString(order, StandardCharsets.UTF_8), TEST_SKIP_OVERWRITE);
assertTrue(pom.exists());
}
private void changeContent(File file) throws IOException {
Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), UTF_8));
out.write(TEST_SKIP_OVERWRITE);
out.close();
}
}

View File

@@ -0,0 +1,977 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"email": "apiteam@swagger.io"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.io",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pet": {
"post": {
"tags": [
"pet"
],
"summary": "Add a new pet to the store",
"description": "",
"operationId": "addPet",
"consumes": [
"application/json",
"application/xml"
],
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"in": "body",
"name": "body",
"description": "Pet object that needs to be added to the store",
"required": false,
"schema": {
"$ref": "#/definitions/Pet"
}
}
],
"responses": {
"405": {
"description": "Invalid input"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
]
},
"put": {
"tags": [
"pet"
],
"summary": "Update an existing pet",
"description": "",
"operationId": "updatePet",
"consumes": [
"application/json",
"application/xml"
],
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"in": "body",
"name": "body",
"description": "Pet object that needs to be added to the store",
"required": false,
"schema": {
"$ref": "#/definitions/Pet"
}
}
],
"responses": {
"405": {
"description": "Validation exception"
},
"404": {
"description": "Pet not found"
},
"400": {
"description": "Invalid ID supplied"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
]
}
},
"/pet/findByStatus": {
"get": {
"tags": [
"pet"
],
"summary": "Finds Pets by status",
"description": "Multiple status values can be provided with comma seperated strings",
"operationId": "findPetsByStatus",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "status",
"in": "query",
"description": "Status values that need to be considered for filter",
"required": false,
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "multi",
"default": "available"
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
},
"400": {
"description": "Invalid status value"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
]
}
},
"/pet/findByTags": {
"get": {
"tags": [
"pet"
],
"summary": "Finds Pets by tags",
"description": "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.",
"operationId": "findPetsByTags",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "tags",
"in": "query",
"description": "Tags to filter by",
"required": false,
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "multi"
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
},
"400": {
"description": "Invalid tag value"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
]
}
},
"/pet/{petId}": {
"get": {
"tags": [
"pet"
],
"summary": "Find pet by ID",
"description": "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions",
"operationId": "getPetById",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "petId",
"in": "path",
"description": "ID of pet that needs to be fetched",
"required": true,
"type": "integer",
"format": "int64"
}
],
"responses": {
"404": {
"description": "Pet not found"
},
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/Pet"
}
},
"400": {
"description": "Invalid ID supplied"
}
},
"security": [
{
"api_key": []
},
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
]
},
"post": {
"tags": [
"pet"
],
"summary": "Updates a pet in the store with form data",
"description": "",
"operationId": "updatePetWithForm",
"consumes": [
"application/x-www-form-urlencoded"
],
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "petId",
"in": "path",
"description": "ID of pet that needs to be updated",
"required": true,
"type": "string"
},
{
"name": "name",
"in": "formData",
"description": "Updated name of the pet",
"required": false,
"type": "string"
},
{
"name": "status",
"in": "formData",
"description": "Updated status of the pet",
"required": false,
"type": "string"
}
],
"responses": {
"405": {
"description": "Invalid input"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
]
},
"delete": {
"tags": [
"pet"
],
"summary": "Deletes a pet",
"description": "",
"operationId": "deletePet",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "api_key",
"in": "header",
"description": "",
"required": false,
"type": "string"
},
{
"name": "petId",
"in": "path",
"description": "Pet id to delete",
"required": true,
"type": "integer",
"format": "int64"
}
],
"responses": {
"400": {
"description": "Invalid pet value"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
]
}
},
"/pet/{petId}/uploadImage": {
"post": {
"tags": [
"pet"
],
"summary": "uploads an image",
"description": "",
"operationId": "uploadFile",
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "petId",
"in": "path",
"description": "ID of pet to update",
"required": true,
"type": "integer",
"format": "int64"
},
{
"name": "additionalMetadata",
"in": "formData",
"description": "Additional data to pass to server",
"required": false,
"type": "string"
},
{
"name": "file",
"in": "formData",
"description": "file to upload",
"required": false,
"type": "file"
}
],
"responses": {
"default": {
"description": "successful operation"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
]
}
},
"/store/inventory": {
"get": {
"tags": [
"store"
],
"summary": "Returns pet inventories by status",
"description": "Returns a map of status codes to quantities",
"operationId": "getInventory",
"produces": [
"application/json",
"application/xml"
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"type": "object",
"additionalProperties": {
"type": "integer",
"format": "int32"
}
}
}
},
"security": [
{
"api_key": []
}
]
}
},
"/store/order": {
"post": {
"tags": [
"store"
],
"summary": "Place an order for a pet",
"description": "",
"operationId": "placeOrder",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"in": "body",
"name": "body",
"description": "order placed for purchasing the pet",
"required": false,
"schema": {
"$ref": "#/definitions/Order"
}
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/Order"
}
},
"400": {
"description": "Invalid Order"
}
}
}
},
"/store/order/{orderId}": {
"get": {
"tags": [
"store"
],
"summary": "Find purchase order by ID",
"description": "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
"operationId": "getOrderById",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "orderId",
"in": "path",
"description": "ID of pet that needs to be fetched",
"required": true,
"type": "string"
}
],
"responses": {
"404": {
"description": "Order not found"
},
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/Order"
}
},
"400": {
"description": "Invalid ID supplied"
}
}
},
"delete": {
"tags": [
"store"
],
"summary": "Delete purchase order by ID",
"description": "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
"operationId": "deleteOrder",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "orderId",
"in": "path",
"description": "ID of the order that needs to be deleted",
"required": true,
"type": "string"
}
],
"responses": {
"404": {
"description": "Order not found"
},
"400": {
"description": "Invalid ID supplied"
}
}
}
},
"/user": {
"post": {
"tags": [
"user"
],
"summary": "Create user",
"description": "This can only be done by the logged in user.",
"operationId": "createUser",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"in": "body",
"name": "body",
"description": "Created user object",
"required": false,
"schema": {
"$ref": "#/definitions/User"
}
}
],
"responses": {
"default": {
"description": "successful operation"
}
}
}
},
"/user/createWithArray": {
"post": {
"tags": [
"user"
],
"summary": "Creates list of users with given input array",
"description": "",
"operationId": "createUsersWithArrayInput",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"in": "body",
"name": "body",
"description": "List of user object",
"required": false,
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/User"
}
}
}
],
"responses": {
"default": {
"description": "successful operation"
}
}
}
},
"/user/createWithList": {
"post": {
"tags": [
"user"
],
"summary": "Creates list of users with given input array",
"description": "",
"operationId": "createUsersWithListInput",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"in": "body",
"name": "body",
"description": "List of user object",
"required": false,
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/User"
}
}
}
],
"responses": {
"default": {
"description": "successful operation"
}
}
}
},
"/user/login": {
"get": {
"tags": [
"user"
],
"summary": "Logs user into the system",
"description": "",
"operationId": "loginUser",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "username",
"in": "query",
"description": "The user name for login",
"required": false,
"type": "string"
},
{
"name": "password",
"in": "query",
"description": "The password for login in clear text",
"required": false,
"type": "string"
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"type": "string"
}
},
"400": {
"description": "Invalid username/password supplied"
}
}
}
},
"/user/logout": {
"get": {
"tags": [
"user"
],
"summary": "Logs out current logged in user session",
"description": "",
"operationId": "logoutUser",
"produces": [
"application/json",
"application/xml"
],
"responses": {
"default": {
"description": "successful operation"
}
}
}
},
"/user/{username}": {
"get": {
"tags": [
"user"
],
"summary": "Get user by user name",
"description": "",
"operationId": "getUserByName",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "username",
"in": "path",
"description": "The name that needs to be fetched. Use user1 for testing. ",
"required": true,
"type": "string"
}
],
"responses": {
"404": {
"description": "User not found"
},
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/User"
},
"examples": {
"application/json": {
"id": 1,
"username": "johnp",
"firstName": "John",
"lastName": "Public",
"email": "johnp@swagger.io",
"password": "-secret-",
"phone": "0123456789",
"userStatus": 0
}
}
},
"400": {
"description": "Invalid username supplied"
}
}
},
"put": {
"tags": [
"user"
],
"summary": "Updated user",
"description": "This can only be done by the logged in user.",
"operationId": "updateUser",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "username",
"in": "path",
"description": "name that need to be deleted",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "body",
"description": "Updated user object",
"required": false,
"schema": {
"$ref": "#/definitions/User"
}
}
],
"responses": {
"404": {
"description": "User not found"
},
"400": {
"description": "Invalid user supplied"
}
}
},
"delete": {
"tags": [
"user"
],
"summary": "Delete user",
"description": "This can only be done by the logged in user.",
"operationId": "deleteUser",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "username",
"in": "path",
"description": "The name that needs to be deleted",
"required": true,
"type": "string"
}
],
"responses": {
"404": {
"description": "User not found"
},
"400": {
"description": "Invalid username supplied"
}
}
}
}
},
"securityDefinitions": {
"api_key": {
"type": "apiKey",
"name": "api_key",
"in": "header"
},
"petstore_auth": {
"type": "oauth2",
"authorizationUrl": "http://petstore.swagger.io/api/oauth/dialog",
"flow": "implicit",
"scopes": {
"write:pets": "modify pets in your account",
"read:pets": "read your pets"
}
}
},
"definitions": {
"User": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"username": {
"type": "string"
},
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"email": {
"type": "string"
},
"password": {
"type": "string"
},
"phone": {
"type": "string"
},
"userStatus": {
"type": "integer",
"format": "int32",
"description": "User Status"
}
},
"xml": {
"name": "User"
}
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
},
"xml": {
"name": "Category"
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"xml": {
"name": "photoUrl",
"wrapped": true
},
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"xml": {
"name": "tag",
"wrapped": true
},
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store",
"enum": [
"available",
"pending",
"sold"
]
}
},
"xml": {
"name": "Pet"
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
},
"xml": {
"name": "Tag"
}
},
"Order": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"petId": {
"type": "integer",
"format": "int64"
},
"quantity": {
"type": "integer",
"format": "int32"
},
"shipDate": {
"type": "string",
"format": "date-time"
},
"status": {
"type": "string",
"description": "Order Status",
"enum": [
"placed",
"approved",
"delivered"
]
},
"complete": {
"type": "boolean"
}
},
"xml": {
"name": "Order"
}
}
}
}

View File

@@ -0,0 +1,55 @@
swagger-codegen-maven-plugin
============================
A Maven plugin to support the [swagger](http://swagger.io) code generation project
Usage
============================
Add to your `build->plugins` section (default phase is `generate-sources` phase)
```xml
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>src/main/resources/api.yaml</inputSpec>
<language>java</language>
<configOptions>
<sourceFolder>src/gen/java/main</sourceFolder>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
```
Followed by:
```
mvn clean compile
```
### General Configuration parameters
- `inputSpec` - swagger spec file path
- `language` - target generation language
- `output` - target output path (default is `${project.build.directory}/generated-sources/swagger`)
- `templateDirectory` - directory with mustache templates
- `addCompileSourceRoot` - add the output directory to the project as a source root (`true` by default)
- `modelPackage` - the package to use for generated model objects/classes
- `apiPackage` - the package to use for generated api objects/classes
- `invokerPackage` - the package to use for the generated invoker objects
- `configOptions` - a map of language-specific parameters (see below)
### Java-specific parameters (under configOptions)
- `sourceFolder` - the folder to use for generated sources under the output folder
- `groupId` - groupId in generated pom.xml
- `artifactId` - artifactId in generated pom.xml
- `artifactVersion` - artifact version in generated pom.xml

View File

@@ -0,0 +1,87 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-project</artifactId>
<version>2.1.3</version>
<relativePath>../..</relativePath>
</parent>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<name>swagger-codegen (maven-plugin)</name>
<packaging>maven-plugin</packaging>
<description>maven plugin to build modules from swagger codegen</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>3.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.4</version>
<configuration>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
<executions>
<execution>
<id>mojo-descriptor</id>
<phase>process-classes</phase>
<goals>
<goal>descriptor</goal>
</goals>
</execution>
<execution>
<id>help-goal</id>
<goals>
<goal>helpmojo</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@@ -0,0 +1,16 @@
package io.swagger.codegen.plugin;
/**
* User: lanwen
* Date: 24.03.15
* Time: 14:47
*/
public final class AdditionalParams {
public static final String TEMPLATE_DIR_PARAM = "templateDir";
public static final String MODEL_PACKAGE_PARAM = "modelPackage";
public static final String API_PACKAGE_PARAM = "apiPackage";
public static final String INVOKER_PACKAGE_PARAM = "invokerPackage";
private AdditionalParams() {
}
}

View File

@@ -0,0 +1,186 @@
package io.swagger.codegen.plugin;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import io.swagger.codegen.CliOption;
import io.swagger.codegen.ClientOptInput;
import io.swagger.codegen.ClientOpts;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.DefaultGenerator;
import io.swagger.models.Swagger;
import io.swagger.parser.SwaggerParser;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import config.Config;
import config.ConfigParser;
import java.io.File;
import java.util.Map;
import java.util.ServiceLoader;
import static io.swagger.codegen.plugin.AdditionalParams.API_PACKAGE_PARAM;
import static io.swagger.codegen.plugin.AdditionalParams.INVOKER_PACKAGE_PARAM;
import static io.swagger.codegen.plugin.AdditionalParams.MODEL_PACKAGE_PARAM;
import static io.swagger.codegen.plugin.AdditionalParams.TEMPLATE_DIR_PARAM;
/**
* Goal which generates client/server code from a swagger json/yaml definition.
*/
@Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
public class CodeGenMojo extends AbstractMojo {
/**
* Location of the output directory.
*/
@Parameter(name = "output",
property = "swagger.codegen.maven.plugin.output",
defaultValue = "${project.build.directory}/generated-sources/swagger")
private File output;
/**
* Location of the swagger spec, as URL or file.
*/
@Parameter(name = "inputSpec", required = true)
private String inputSpec;
/**
* Folder containing the template files.
*/
@Parameter(name = "templateDirectory")
private File templateDirectory;
/**
* The package to use for generated model objects/classes
*/
@Parameter(name = "modelPackage")
private String modelPackage;
/**
* The package to use for generated api objects/classes
*/
@Parameter(name = "apiPackage")
private String apiPackage;
/**
* The package to use for the generated invoker objects
*/
@Parameter(name = "invokerPackage")
private String invokerPackage;
/**
* Client language to generate.
*/
@Parameter(name = "language", required = true)
private String language;
/**
* Path to separate json configuration file.
*/
@Parameter(name = "configurationFile", required = false)
private String configurationFile;
/**
* A map of language-specific parameters as passed with the -c option to the command line
*/
@Parameter(name = "configOptions")
private Map configOptions;
/**
* Add the output directory to the project as a source root, so that the
* generated java types are compiled and included in the project artifact.
*/
@Parameter(defaultValue = "true")
private boolean addCompileSourceRoot = true;
/**
* The project being built.
*/
@Parameter(readonly = true, required = true, defaultValue = "${project}")
private MavenProject project;
@Override
public void execute() throws MojoExecutionException {
Swagger swagger = new SwaggerParser().read(inputSpec);
CodegenConfig config = forName(language);
config.setOutputDir(output.getAbsolutePath());
if (null != templateDirectory) {
config.additionalProperties().put(TEMPLATE_DIR_PARAM, templateDirectory.getAbsolutePath());
}
if (null != modelPackage) {
config.additionalProperties().put(MODEL_PACKAGE_PARAM, modelPackage);
}
if (null != apiPackage) {
config.additionalProperties().put(API_PACKAGE_PARAM, apiPackage);
}
if (null != invokerPackage) {
config.additionalProperties().put(INVOKER_PACKAGE_PARAM, invokerPackage);
}
if (configOptions != null) {
for (CliOption langCliOption : config.cliOptions()) {
if (configOptions.containsKey(langCliOption.getOpt())) {
config.additionalProperties().put(langCliOption.getOpt(),
configOptions.get(langCliOption.getOpt()));
}
}
}
if (null != configurationFile) {
Config genConfig = ConfigParser.read(configurationFile);
if (null != genConfig) {
for (CliOption langCliOption : config.cliOptions()) {
if (genConfig.hasOption(langCliOption.getOpt())) {
config.additionalProperties().put(langCliOption.getOpt(), genConfig.getOption(langCliOption.getOpt()));
}
}
} else {
throw new RuntimeException("Unable to read configuration file");
}
}
ClientOptInput input = new ClientOptInput().opts(new ClientOpts()).swagger(swagger);
input.setConfig(config);
new DefaultGenerator().opts(input).generate();
if (addCompileSourceRoot) {
project.addCompileSourceRoot(output.toString());
}
}
private CodegenConfig forName(String name) {
ServiceLoader<CodegenConfig> loader = ServiceLoader.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

@@ -1,341 +1,347 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>com.wordnik</groupId>
<artifactId>swagger-codegen-project</artifactId>
<version>2.1.0-M2</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.wordnik</groupId>
<artifactId>swagger-codegen</artifactId>
<packaging>jar</packaging>
<name>swagger-codegen (core library)</name>
<version>2.1.0-M2</version>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<defaultGoal>install</defaultGoal>
<extensions>
<extension>
<groupId>org.jvnet.wagon-svn</groupId>
<artifactId>wagon-svn</artifactId>
<version>1.8</version>
</extension>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh-external</artifactId>
<version>1.0-alpha-6</version>
</extension>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav</artifactId>
<version>1.0-beta-1</version>
</extension>
</extensions>
<directory>target</directory>
<finalName>${project.artifactId}-${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.wordnik.swagger.codegen.Codegen</mainClass>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<configuration>
<recompileMode>incremental</recompileMode>
</configuration>
<jvmArgs>
<jvmArg>-Xmx384m</jvmArg>
</jvmArgs>
<args>
<arg>-target:jvm-1.6</arg>
<arg>-deprecation</arg>
</args>
<launchers>
<launcher>
<id>run-scalatest</id>
<mainClass>org.scalatest.tools.Runner</mainClass>
<args>
<arg>-p</arg>
<arg>${project.build.testOutputDirectory}</arg>
</args>
<jvmArgs>
<jvmArg>-Xmx512m</jvmArg>
</jvmArgs>
</launcher>
</launchers>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifestEntries>
<mode>development</mode>
<url>${project.url}</url>
<implementation-version>${project.version}</implementation-version>
<package>com.wordnik</package>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.1</version>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>${scala-maven-plugin-version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<configuration>
<releaseProfiles>release</releaseProfiles>
<goals>sign</goals>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>release-profile</id>
<properties>
<skipTests>true</skipTests>
</properties>
<build>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-project</artifactId>
<version>2.1.3</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>swagger-codegen</artifactId>
<packaging>jar</packaging>
<name>swagger-codegen (core library)</name>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<defaultGoal>install</defaultGoal>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>logback.xml</exclude>
</excludes>
</resource>
</resources>
<extensions>
<extension>
<groupId>org.jvnet.wagon-svn</groupId>
<artifactId>wagon-svn</artifactId>
<version>1.8</version>
</extension>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh-external</artifactId>
<version>1.0-alpha-6</version>
</extension>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav</artifactId>
<version>1.0-beta-1</version>
</extension>
</extensions>
<directory>target</directory>
<finalName>${project.artifactId}-${project.version}</finalName>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration />
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>prepare-package</phase>
<goals>
<goal>add-source</goal>
</goals>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<source>src/main/scala</source>
</sources>
<mainClass>io.swagger.codegen.Codegen</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<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>
<recompileMode>incremental</recompileMode>
<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>io.swagger</package>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.1</version>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release-sign-artifacts</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>${scala-maven-plugin-version}</version>
</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>
<scalaVersion>${scala-version}</scalaVersion>
</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-gpg-plugin</artifactId>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<configuration>
<aggregate>true</aggregate>
<debug>true</debug>
<links>
<link>http://java.sun.com/javaee/5/docs/api</link>
<link>http://java.sun.com/j2se/1.5.0/docs/api</link>
</links>
<excludePackageNames/>
</configuration>
</plugin>
<plugin>
<groupId>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>
</build>
</profile>
</profiles>
<reporting>
<outputDirectory>target/site</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<configuration>
<aggregate>true</aggregate>
<debug>true</debug>
<links>
<link>http://java.sun.com/javaee/5/docs/api</link>
<link>http://java.sun.com/j2se/1.5.0/docs/api</link>
</links>
<excludePackageNames />
</configuration>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>${scala-maven-plugin-version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
<configuration>
<aggregate>true</aggregate>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.6</version>
<reportSets>
<reportSet>
<reports>
<report>project-team</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
<dependencies>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-parser</artifactId>
<version>${swagger-parser-version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-compat-spec-parser</artifactId>
<version>${swagger-parser-version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>swagger-core</artifactId>
<version>${swagger-core-version}</version>
</dependency>
<dependency>
<groupId>com.samskivert</groupId>
<artifactId>jmustache</artifactId>
<version>${jmustache-version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io-version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-tools-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${felix-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-ext</artifactId>
<version>${slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j-version}</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commons-lang-version}</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>${commons-cli-version}</version>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.11</artifactId>
<version>${scala-test-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</reporting>
<dependencies>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-parser</artifactId>
<version>${swagger-parser-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-compat-spec-parser</artifactId>
<version>${swagger-parser-version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>swagger-core</artifactId>
<version>${swagger-core-version}</version>
</dependency>
<dependency>
<groupId>com.samskivert</groupId>
<artifactId>jmustache</artifactId>
<version>${jmustache-version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io-version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-tools-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${felix-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-ext</artifactId>
<version>${slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j-version}</version>
</dependency>
<dependency>
<groupId>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>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala-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

@@ -1,60 +0,0 @@
package com.wordnik.swagger.codegen;
import com.samskivert.mustache.*;
import java.util.regex.Pattern;
import java.io.*;
public abstract class AbstractGenerator {
public File writeToFile(String filename, String contents) throws IOException {
System.out.println("writing file " + filename);
File output = new File(filename);
if(output.getParent() != null && !new File(output.getParent()).exists()) {
File parent = new File(output.getParent());
parent.mkdirs();
}
Writer out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(output), "UTF-8"));
out.write(contents);
out.close();
return output;
}
public String readTemplate(String name) {
try{
Reader reader = getTemplateReader(name);
if(reader == null)
throw new RuntimeException("no file found");
java.util.Scanner s = new java.util.Scanner(reader).useDelimiter("\\A");
return s.hasNext() ? s.next() : "";
}
catch(Exception e) {
e.printStackTrace();
}
throw new RuntimeException("can't load template " + name);
}
public Reader getTemplateReader(String name) {
try{
InputStream is = this.getClass().getClassLoader().getResourceAsStream(getCPResourcePath(name));
if(is == null)
is = new FileInputStream(new File(name));
if(is == null)
throw new RuntimeException("no file found");
return new InputStreamReader(is);
}
catch(Exception e) {
e.printStackTrace();
}
throw new RuntimeException("can't load template " + name);
}
private String getCPResourcePath(String name) {
if (!"/".equals(File.separator))
return name.replaceAll(Pattern.quote(File.separator), "/");
return name;
}
}

View File

@@ -1,104 +0,0 @@
/**
* Copyright 2015 Reverb, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wordnik.swagger.codegen;
import com.wordnik.swagger.codegen.ClientOpts;
import com.wordnik.swagger.annotations.*;
import com.wordnik.swagger.models.Swagger;
import com.wordnik.swagger.models.auth.AuthorizationValue;
import java.util.*;
import java.net.URLEncoder;
import java.net.URLDecoder;
public class ClientOptInput {
private ClientOpts opts;
private Swagger swagger;
private List<AuthorizationValue> auths;
protected CodegenConfig config;
public ClientOptInput swagger(Swagger swagger) {
this.setSwagger(swagger);
return this;
}
public ClientOptInput opts(ClientOpts opts) {
this.setOpts(opts);
return this;
}
public void setAuth(String urlEncodedAuthString) {
List<AuthorizationValue> auths = new ArrayList<AuthorizationValue>();
if(urlEncodedAuthString != null && !"".equals(urlEncodedAuthString)) {
String[] parts = urlEncodedAuthString.split(",");
for(String part : parts) {
String[] kvPair = part.split(":");
if(kvPair.length == 2) {
auths.add(new AuthorizationValue(URLDecoder.decode(kvPair[0]), URLDecoder.decode(kvPair[1]), "header"));
}
}
}
this.auths = auths;
}
public String getAuth() {
if(auths != null) {
StringBuilder b = new StringBuilder();
for(AuthorizationValue v : auths) {
try {
if(b.toString().length() > 0)
b.append(",");
b.append(URLEncoder.encode(v.getKeyName(), "UTF-8"))
.append(":")
.append(URLEncoder.encode(v.getValue(), "UTF-8"));
}
catch (Exception e) {
// continue
e.printStackTrace();
}
}
return b.toString();
}
else
return null;
}
public List<AuthorizationValue> getAuthorizationValues() {
return auths;
}
public CodegenConfig getConfig() {
return config;
}
public void setConfig(CodegenConfig config) {
this.config = config;
}
public void setOpts(ClientOpts opts) {
this.opts = opts;
}
public ClientOpts getOpts() {
return opts;
}
public void setSwagger(Swagger swagger) {
this.swagger = swagger;
}
@ApiModelProperty(dataType="Object")
public Swagger getSwagger() {
return swagger;
}
}

View File

@@ -1,52 +0,0 @@
package com.wordnik.swagger.codegen;
import com.wordnik.swagger.codegen.auth.*;
import java.util.*;
public class ClientOpts {
protected String uri;
protected String target;
protected AuthMethod auth;
protected Map<String, String> properties = new HashMap<String, String>();
protected String outputDirectory;
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getTarget() {
return target;
}
public void setTarget(String target) {
this.target = target;
}
public Map<String, String> getProperties() {
return properties;
}
public void setProperties(Map<String, String> properties) {
this.properties = properties;
}
public String getOutputDirectory() {
return outputDirectory;
}
public void setOutputDirectory(String outputDirectory) {
this.outputDirectory = outputDirectory;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("ClientOpts: {\n");
sb.append(" uri: ").append(uri).append(",");
sb.append(" auth: ").append(auth).append(",");
sb.append(properties);
sb.append("}");
return sb.toString();
}
}

View File

@@ -1,143 +0,0 @@
package com.wordnik.swagger.codegen;
import com.wordnik.swagger.codegen.languages.*;
import com.wordnik.swagger.models.Swagger;
import com.wordnik.swagger.models.auth.AuthorizationValue;
import com.wordnik.swagger.util.*;
import io.swagger.parser.SwaggerParser;
import org.apache.commons.cli.*;
import java.io.File;
import java.util.*;
/**
* @deprecated use instead {@link com.wordnik.swagger.codegen.DefaultGenerator}
* or cli interface from https://github.com/swagger-api/swagger-codegen/pull/547
*/
@Deprecated
public class Codegen extends DefaultGenerator {
static Map<String, CodegenConfig> configs = new HashMap<String, CodegenConfig>();
static String configString;
static {
List<CodegenConfig> extensions = getExtensions();
StringBuilder sb = new StringBuilder();
for(CodegenConfig config : extensions) {
if(sb.toString().length() != 0)
sb.append(", ");
sb.append(config.getName());
configs.put(config.getName(), config);
configString = sb.toString();
}
}
static String debugInfoOptions = "\nThe following additional debug options are available for all codegen targets:" +
"\n -DdebugSwagger prints the swagger specification as interpreted by the codegen" +
"\n -DdebugModels prints models passed to the template engine" +
"\n -DdebugOperations prints operations passed to the template engine" +
"\n -DdebugSupportingFiles prints additional data passed to the template engine";
public static void main(String[] args) {
StringBuilder sb = new StringBuilder();
Options options = new Options();
options.addOption("h", "help", false, "shows this message");
options.addOption("l", "lang", true, "client language to generate.\nAvailable languages include:\n\t[" + configString + "]");
options.addOption("o", "output", true, "where to write the generated files");
options.addOption("i", "input-spec", true, "location of the swagger spec, as URL or file");
options.addOption("t", "template-dir", true, "folder containing the template files");
options.addOption("d", "debug-info", false, "prints additional info for debugging");
options.addOption("a", "auth", true, "adds authorization headers when fetching the swagger definitions remotely. Pass in a URL-encoded string of name:header with a comma separating multiple values");
ClientOptInput clientOptInput = new ClientOptInput();
ClientOpts clientOpts = new ClientOpts();
Swagger swagger = null;
CommandLine cmd = null;
try {
CommandLineParser parser = new BasicParser();
CodegenConfig config = null;
cmd = parser.parse(options, args);
if (cmd.hasOption("d")) {
usage(options);
System.out.println(debugInfoOptions);
return;
}
if (cmd.hasOption("a"))
clientOptInput.setAuth(cmd.getOptionValue("a"));
if (cmd.hasOption("l"))
clientOptInput.setConfig(getConfig(cmd.getOptionValue("l")));
else {
usage(options);
return;
}
if (cmd.hasOption("o"))
clientOptInput.getConfig().setOutputDir(cmd.getOptionValue("o"));
if (cmd.hasOption("h")) {
if(cmd.hasOption("l")) {
config = getConfig(String.valueOf(cmd.getOptionValue("l")));
if(config != null) {
options.addOption("h", "help", true, config.getHelp());
usage(options);
return;
}
}
usage(options);
return;
}
if (cmd.hasOption("i"))
swagger = new SwaggerParser().read(cmd.getOptionValue("i"), clientOptInput.getAuthorizationValues(), true);
if (cmd.hasOption("t"))
clientOpts.getProperties().put("templateDir", String.valueOf(cmd.getOptionValue("t")));
}
catch (Exception e) {
usage(options);
return;
}
try{
clientOptInput
.opts(clientOpts)
.swagger(swagger);
new Codegen().opts(clientOptInput).generate();
}
catch (Exception e) {
e.printStackTrace();
}
}
public static List<CodegenConfig> getExtensions() {
ServiceLoader<CodegenConfig> loader = ServiceLoader.load(CodegenConfig.class);
List<CodegenConfig> output = new ArrayList<CodegenConfig>();
Iterator<CodegenConfig> itr = loader.iterator();
while(itr.hasNext()) {
output.add(itr.next());
}
return output;
}
static void usage(Options options) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp( "Codegen", options );
}
public static CodegenConfig getConfig(String name) {
if(configs.containsKey(name)) {
return configs.get(name);
}
else {
// see if it's a class
try {
System.out.println("loading class " + name);
Class customClass = Class.forName(name);
System.out.println("loaded");
return (CodegenConfig)customClass.newInstance();
}
catch (Exception e) {
throw new RuntimeException("can't load class " + name);
}
}
}
}

View File

@@ -1,59 +0,0 @@
package com.wordnik.swagger.codegen;
import com.wordnik.swagger.models.*;
import com.wordnik.swagger.models.auth.SecuritySchemeDefinition;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
public interface CodegenConfig {
CodegenType getTag();
String getName();
String getHelp();
Map<String, Object> additionalProperties();
String apiPackage();
String apiFileFolder();
String fileSuffix();
String outputFolder();
String templateDir();
String modelFileFolder();
String modelPackage();
String toApiName(String name);
String toApiVarName(String name);
String toModelName(String name);
String toParamName(String name);
String escapeText(String text);
String escapeReservedWord(String name);
String getTypeDeclaration(Property p);
String getTypeDeclaration(String name);
void processOpts();
String generateExamplePath(String path, Operation operation);
Set<String> reservedWords();
List<SupportingFile> supportingFiles();
void setOutputDir(String dir);
String getOutputDir();
CodegenModel fromModel(String name, Model model);
CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, Map<String, Model> definitions);
List<CodegenSecurity> fromSecurity(Map<String, SecuritySchemeDefinition> schemes);
Set<String> defaultIncludes();
Map<String, String> typeMapping();
Map<String, String> instantiationTypes();
Map<String, String> importMapping();
Map<String, String> apiTemplateFiles();
Map<String, String> modelTemplateFiles();
void processSwagger(Swagger swagger);
String toApiFilename(String name);
String toModelFilename(String name);
String toModelImport(String name);
String toApiImport(String name);
void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations);
Map<String, Object> postProcessModels(Map<String, Object> objs);
Map<String, Object> postProcessOperations(Map<String, Object> objs);
Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs);
}

View File

@@ -1,16 +0,0 @@
package com.wordnik.swagger.codegen;
import com.wordnik.swagger.models.*;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
public class CodegenModel {
public String parent;
public String name, classname, description, classVarName, modelJson;
public String defaultValue;
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>();
public Set<String> imports = new HashSet<String>();
public Boolean hasVars, emptyVars, hasMoreModels;
public ExternalDocs externalDocs;
}

View File

@@ -1,38 +0,0 @@
package com.wordnik.swagger.codegen;
import java.util.HashMap;
import java.util.Map;
public final class CodegenModelFactory {
private static final Map<CodegenModelType, Class<?>> typeMapping = new HashMap<CodegenModelType, Class<?>>();
/**
* Configure a different implementation class.
* @param type the type that shall be replaced
* @param implementation the implementation class must extend the default class and must provide a public no-arg constructor
*/
public static void setTypeMapping(CodegenModelType type, Class<?> implementation) {
if (!type.getDefaultImplementation().isAssignableFrom(implementation)) {
throw new IllegalArgumentException(implementation.getSimpleName() + " doesn't extend " + type.getDefaultImplementation().getSimpleName());
}
try {
implementation.newInstance();
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
typeMapping.put(type, implementation);
}
@SuppressWarnings("unchecked")
public static <T> T newInstance(CodegenModelType type) {
Class<?> classType = typeMapping.get(type);
try {
return (T) (classType != null ? classType : type.getDefaultImplementation()).newInstance();
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -1,21 +0,0 @@
package com.wordnik.swagger.codegen;
public enum CodegenModelType {
MODEL(CodegenModel.class),
OPERATION(CodegenOperation.class),
PARAMETER(CodegenParameter.class),
PROPERTY(CodegenProperty.class),
RESPONSE(CodegenResponse.class),
SECURITY(CodegenSecurity.class);
private final Class<?> defaultImplementation;
private CodegenModelType(Class<?> defaultImplementation) {
this.defaultImplementation = defaultImplementation;
}
public Class<?> getDefaultImplementation() {
return defaultImplementation;
}
}

View File

@@ -1,32 +0,0 @@
package com.wordnik.swagger.codegen;
import com.wordnik.swagger.models.*;
import java.util.*;
public class CodegenOperation {
public Boolean hasConsumes, hasProduces, hasParams, returnTypeIsPrimitive,
returnSimpleType, subresourceOperation, isMapContainer, isListContainer,
hasMore = Boolean.TRUE;
public String path, operationId, returnType, httpMethod, returnBaseType,
returnContainer, summary, notes, baseName, defaultResponse;
public List<Map<String, String>> consumes, produces;
public CodegenParameter bodyParam;
public List<CodegenParameter> allParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> bodyParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> pathParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> queryParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> headerParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> formParams = new ArrayList<CodegenParameter>();
public List<CodegenSecurity> authMethods;
public List<String> tags;
public List<CodegenResponse> responses = new ArrayList<CodegenResponse>();
public final List<CodegenProperty> responseHeaders = new ArrayList<CodegenProperty>();
public Set<String> imports = new HashSet<String>();
public List<Map<String, String>> examples;
public ExternalDocs externalDocs;
// legacy support
public String nickname;
}

View File

@@ -1,40 +0,0 @@
package com.wordnik.swagger.codegen;
public class CodegenParameter {
public Boolean isFormParam, isQueryParam, isPathParam, isHeaderParam,
isCookieParam, isBodyParam, isFile, notFile, hasMore, isContainer, secondaryParam;
public String baseName, paramName, dataType, collectionFormat, description, baseType;
public String jsonSchema;
/**
* Determines whether this parameter is mandatory. If the parameter is in "path",
* this property is required and its value MUST be true. Otherwise, the property
* MAY be included and its default value is false.
*/
public Boolean required;
public CodegenParameter copy() {
CodegenParameter output = new CodegenParameter();
output.isFile = this.isFile;
output.notFile = this.notFile;
output.hasMore = this.hasMore;
output.isContainer = this.isContainer;
output.secondaryParam = this.secondaryParam;
output.baseName = this.baseName;
output.paramName = this.paramName;
output.dataType = this.dataType;
output.collectionFormat = this.collectionFormat;
output.description = this.description;
output.baseType = this.baseType;
output.isFormParam = this.isFormParam;
output.isQueryParam = this.isQueryParam;
output.isPathParam = this.isPathParam;
output.isHeaderParam = this.isHeaderParam;
output.isCookieParam = this.isCookieParam;
output.isBodyParam = this.isBodyParam;
output.required = this.required;
output.jsonSchema = this.jsonSchema;
return output;
}
}

View File

@@ -1,25 +0,0 @@
package com.wordnik.swagger.codegen;
import java.util.*;
public class CodegenProperty {
public String baseName, complexType, getter, setter, description, datatype, datatypeWithEnum,
name, min, max, defaultValue, baseType, containerType;
/** maxLength validation for strings, see http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.1 */
public Integer maxLength;
/** minLength validation for strings, see http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.2 */
public Integer minLength;
/** pattern validation for strings, see http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.3 */
public String pattern;
/** A free-form property to include an example of an instance for this schema. */
public String example;
public String jsonSchema;
public Double minimum, maximum, exclusiveMinimum, exclusiveMaximum;
public Boolean hasMore = null, required = null, secondaryParam = null;
public Boolean isPrimitiveType, isContainer, isNotContainer;
public boolean isEnum;
public List<String> _enum;
public Map<String, Object> allowableValues;
}

View File

@@ -1,17 +0,0 @@
package com.wordnik.swagger.codegen;
import java.util.*;
public class CodegenResponse {
public String code, message;
public Boolean hasMore;
public List<Map<String, String>> examples;
public final List<CodegenProperty> headers = new ArrayList<CodegenProperty>();
public String dataType, baseType, containerType;
public Boolean simpleType;
public Boolean primitiveType;
public Boolean isMapContainer;
public Boolean isListContainer;
public Object schema;
public String jsonSchema;
}

View File

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

View File

@@ -1,34 +0,0 @@
package com.wordnik.swagger.codegen;
import com.fasterxml.jackson.annotation.*;
import java.util.Map;
import java.util.HashMap;
public enum CodegenType {
CLIENT, SERVER, DOCUMENTATION, OTHER;
private static Map<String, CodegenType> names = new HashMap<String, CodegenType>();
static {
names.put("client", CLIENT);
names.put("server", SERVER);
names.put("documentation", DOCUMENTATION);
names.put("other", OTHER);
}
@JsonCreator
public static CodegenType forValue(String value) {
return names.get(value.toLowerCase());
}
@JsonValue
public String toValue() {
for (Map.Entry<String, CodegenType> entry : names.entrySet()) {
if (entry.getValue() == this)
return entry.getKey();
}
return null; // or fail
}
}

View File

@@ -1,440 +0,0 @@
package com.wordnik.swagger.codegen;
import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template;
import com.wordnik.swagger.models.Contact;
import com.wordnik.swagger.models.Info;
import com.wordnik.swagger.models.License;
import com.wordnik.swagger.models.Model;
import com.wordnik.swagger.models.Operation;
import com.wordnik.swagger.models.Path;
import com.wordnik.swagger.models.Swagger;
import com.wordnik.swagger.models.auth.SecuritySchemeDefinition;
import com.wordnik.swagger.util.Json;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import java.io.File;
import java.io.Reader;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static org.apache.commons.lang3.StringUtils.capitalize;
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
public class DefaultGenerator extends AbstractGenerator implements Generator {
protected CodegenConfig config;
protected ClientOptInput opts = null;
protected Swagger swagger = null;
public Generator opts(ClientOptInput opts) {
this.opts = opts;
this.swagger = opts.getSwagger();
this.config = opts.getConfig();
this.config.additionalProperties().putAll(opts.getOpts().getProperties());
return this;
}
public List<File> generate() {
if (swagger == null || config == null) {
throw new RuntimeException("missing swagger input or config!");
}
if (System.getProperty("debugSwagger") != null) {
Json.prettyPrint(swagger);
}
List<File> files = new ArrayList<File>();
try {
config.processOpts();
if (swagger.getInfo() != null) {
Info info = swagger.getInfo();
if (info.getTitle() != null) {
config.additionalProperties().put("appName", info.getTitle());
}
if (info.getVersion() != null) {
config.additionalProperties().put("appVersion", info.getVersion());
}
if (info.getDescription() != null) {
config.additionalProperties().put("appDescription",
config.escapeText(info.getDescription()));
}
if (info.getContact() != null) {
Contact contact = info.getContact();
config.additionalProperties().put("infoUrl", contact.getUrl());
if (contact.getEmail() != null) {
config.additionalProperties().put("infoEmail", contact.getEmail());
}
}
if (info.getLicense() != null) {
License license = info.getLicense();
if (license.getName() != null) {
config.additionalProperties().put("licenseInfo", license.getName());
}
if (license.getUrl() != null) {
config.additionalProperties().put("licenseUrl", license.getUrl());
}
}
if (info.getVersion() != null) {
config.additionalProperties().put("version", info.getVersion());
}
}
StringBuilder hostBuilder = new StringBuilder();
if (swagger.getSchemes() != null && swagger.getSchemes().size() > 0) {
hostBuilder.append(swagger.getSchemes().get(0).toValue());
hostBuilder.append("://");
} else {
hostBuilder.append("https://");
}
if (swagger.getHost() != null) {
hostBuilder.append(swagger.getHost());
} else {
hostBuilder.append("localhost");
}
if (swagger.getBasePath() != null) {
hostBuilder.append(swagger.getBasePath());
} else {
hostBuilder.append("/");
}
String contextPath = swagger.getBasePath() == null ? "/" : swagger.getBasePath();
String basePath = hostBuilder.toString();
List<Object> allOperations = new ArrayList<Object>();
List<Object> allModels = new ArrayList<Object>();
// models
Map<String, Model> definitions = swagger.getDefinitions();
if (definitions != null) {
for (String name : definitions.keySet()) {
Model model = definitions.get(name);
Map<String, Model> modelMap = new HashMap<String, Model>();
modelMap.put(name, model);
Map<String, Object> models = processModels(config, modelMap);
models.putAll(config.additionalProperties());
allModels.add(((List<Object>) models.get("models")).get(0));
for (String templateName : config.modelTemplateFiles().keySet()) {
String suffix = config.modelTemplateFiles().get(templateName);
String filename = config.modelFileFolder() + File.separator + config.toModelFilename(name) + suffix;
String template = readTemplate(config.templateDir() + File.separator + templateName);
Template tmpl = Mustache.compiler()
.withLoader(new Mustache.TemplateLoader() {
public Reader getTemplate(String name) {
return getTemplateReader(config.templateDir() + File.separator + name + ".mustache");
}
})
.defaultValue("")
.compile(template);
writeToFile(filename, tmpl.execute(models));
files.add(new File(filename));
}
}
}
if (System.getProperty("debugModels") != null) {
System.out.println("############ Model info ############");
Json.prettyPrint(allModels);
}
// apis
Map<String, List<CodegenOperation>> paths = processPaths(swagger.getPaths());
for (String tag : paths.keySet()) {
List<CodegenOperation> ops = paths.get(tag);
Map<String, Object> operation = processOperations(config, tag, ops);
operation.put("basePath", basePath);
operation.put("contextPath", contextPath);
operation.put("baseName", tag);
operation.put("modelPackage", config.modelPackage());
operation.putAll(config.additionalProperties());
operation.put("classname", config.toApiName(tag));
operation.put("classVarName", config.toApiVarName(tag));
allOperations.add(new HashMap<String, Object>(operation));
for (int i = 0; i < allOperations.size(); i++) {
Map<String, Object> oo = (Map<String, Object>) allOperations.get(i);
if (i < (allOperations.size() - 1)) {
oo.put("hasMore", "true");
}
}
for (String templateName : config.apiTemplateFiles().keySet()) {
String suffix = config.apiTemplateFiles().get(templateName);
String filename = config.apiFileFolder() +
File.separator +
config.toApiFilename(tag) +
suffix;
String template = readTemplate(config.templateDir() + File.separator + templateName);
Template tmpl = Mustache.compiler()
.withLoader(new Mustache.TemplateLoader() {
public Reader getTemplate(String name) {
return getTemplateReader(config.templateDir() + File.separator + name + ".mustache");
}
})
.defaultValue("")
.compile(template);
writeToFile(filename, tmpl.execute(operation));
files.add(new File(filename));
}
}
if (System.getProperty("debugOperations") != null) {
System.out.println("############ Operation info ############");
Json.prettyPrint(allOperations);
}
// supporting files
Map<String, Object> bundle = new HashMap<String, Object>();
bundle.putAll(config.additionalProperties());
bundle.put("apiPackage", config.apiPackage());
Map<String, Object> apis = new HashMap<String, Object>();
apis.put("apis", allOperations);
if (swagger.getHost() != null) {
bundle.put("host", swagger.getHost());
}
bundle.put("basePath", basePath);
bundle.put("contextPath", contextPath);
bundle.put("apiInfo", apis);
bundle.put("models", allModels);
bundle.put("apiFolder", config.apiPackage().replace('.', File.separatorChar));
bundle.put("modelPackage", config.modelPackage());
if (swagger.getExternalDocs() != null) {
bundle.put("externalDocs", swagger.getExternalDocs());
}
for (int i = 0; i < allModels.size() - 1; i++) {
HashMap<String, CodegenModel> cm = (HashMap<String, CodegenModel>) allModels.get(i);
CodegenModel m = cm.get("model");
m.hasMoreModels = true;
}
config.postProcessSupportingFileData(bundle);
if (System.getProperty("debugSupportingFiles") != null) {
System.out.println("############ Supporting file info ############");
Json.prettyPrint(bundle);
}
for (SupportingFile support : config.supportingFiles()) {
String outputFolder = config.outputFolder();
if (isNotEmpty(support.folder)) {
outputFolder += File.separator + support.folder;
}
File of = new File(outputFolder);
if (!of.isDirectory()) {
of.mkdirs();
}
String outputFilename = outputFolder + File.separator + support.destinationFilename;
if (support.templateFile.endsWith("mustache")) {
String template = readTemplate(config.templateDir() + File.separator + support.templateFile);
Template tmpl = Mustache.compiler()
.withLoader(new Mustache.TemplateLoader() {
public Reader getTemplate(String name) {
return getTemplateReader(config.templateDir() + File.separator + name + ".mustache");
}
})
.defaultValue("")
.compile(template);
writeToFile(outputFilename, tmpl.execute(bundle));
files.add(new File(outputFilename));
} else {
InputStream in = null;
try {
in = new FileInputStream(config.templateDir() + File.separator + support.templateFile);
}
catch (Exception e) {
// continue
}
if(in == null) {
in = this.getClass().getClassLoader().getResourceAsStream(config.templateDir() + File.separator + support.templateFile);
}
File outputFile = new File(outputFilename);
OutputStream out = new FileOutputStream(outputFile, false);
if(in != null && out != null)
IOUtils.copy(in,out);
else {
if(in == null)
System.out.println("can't open " + config.templateDir() + File.separator + support.templateFile + " for input");
if(out == null)
System.out.println("can't open " + outputFile + " for output");
}
files.add(outputFile);
}
}
config.processSwagger(swagger);
} catch (Exception e) {
e.printStackTrace();
}
return files;
}
public Map<String, List<CodegenOperation>> processPaths(Map<String, Path> paths) {
Map<String, List<CodegenOperation>> ops = new HashMap<String, List<CodegenOperation>>();
for (String resourcePath : paths.keySet()) {
Path path = paths.get(resourcePath);
processOperation(resourcePath, "get", path.getGet(), ops);
processOperation(resourcePath, "put", path.getPut(), ops);
processOperation(resourcePath, "post", path.getPost(), ops);
processOperation(resourcePath, "delete", path.getDelete(), ops);
processOperation(resourcePath, "patch", path.getPatch(), ops);
processOperation(resourcePath, "options", path.getOptions(), ops);
}
return ops;
}
public SecuritySchemeDefinition fromSecurity(String name) {
Map<String, SecuritySchemeDefinition> map = swagger.getSecurityDefinitions();
if (map == null) {
return null;
}
return map.get(name);
}
public void processOperation(String resourcePath, String httpMethod, Operation operation, Map<String, List<CodegenOperation>> operations) {
if (operation != null) {
List<String> tags = operation.getTags();
if (tags == null) {
tags = new ArrayList<String>();
tags.add("default");
}
for (String tag : tags) {
CodegenOperation co = config.fromOperation(resourcePath, httpMethod, operation, swagger.getDefinitions());
co.tags = new ArrayList<String>();
co.tags.add(sanitizeTag(tag));
config.addOperationToGroup(sanitizeTag(tag), resourcePath, operation, co, operations);
List<Map<String, List<String>>> securities = operation.getSecurity();
if (securities == null) {
continue;
}
Map<String, SecuritySchemeDefinition> authMethods = new HashMap<String, SecuritySchemeDefinition>();
for (Map<String, List<String>> security : securities) {
if (security.size() != 1) {
//Not sure what to do
continue;
}
String securityName = security.keySet().iterator().next();
SecuritySchemeDefinition securityDefinition = fromSecurity(securityName);
if (securityDefinition != null) {
authMethods.put(securityName, securityDefinition);
}
}
if (!authMethods.isEmpty()) {
co.authMethods = config.fromSecurity(authMethods);
}
}
}
}
protected String sanitizeTag(String tag) {
// remove spaces and make strong case
String[] parts = tag.split(" ");
StringBuilder buf = new StringBuilder();
for (String part : parts) {
if (isNotEmpty(part)) {
buf.append(capitalize(part));
}
}
return buf.toString().replaceAll("[^a-zA-Z ]", "");
}
public Map<String, Object> processOperations(CodegenConfig config, String tag, List<CodegenOperation> ops) {
Map<String, Object> operations = new HashMap<String, Object>();
Map<String, Object> objs = new HashMap<String, Object>();
objs.put("classname", config.toApiName(tag));
objs.put("operation", ops);
operations.put("operations", objs);
operations.put("package", config.apiPackage());
Set<String> allImports = new LinkedHashSet<String>();
for (CodegenOperation op : ops) {
allImports.addAll(op.imports);
}
List<Map<String, String>> imports = new ArrayList<Map<String, String>>();
for (String nextImport : allImports) {
Map<String, String> im = new LinkedHashMap<String, String>();
String mapping = config.importMapping().get(nextImport);
if (mapping == null) {
mapping = config.toModelImport(nextImport);
}
if (mapping != null) {
im.put("import", mapping);
imports.add(im);
}
}
operations.put("imports", imports);
config.postProcessOperations(operations);
if (objs.size() > 0) {
List<CodegenOperation> os = (List<CodegenOperation>) objs.get("operation");
if (os != null && os.size() > 0) {
CodegenOperation op = os.get(os.size() - 1);
op.hasMore = null;
}
}
return operations;
}
public Map<String, Object> processModels(CodegenConfig config, Map<String, Model> definitions) {
Map<String, Object> objs = new HashMap<String, Object>();
objs.put("package", config.modelPackage());
List<Object> models = new ArrayList<Object>();
Set<String> allImports = new LinkedHashSet<String>();
for (String key : definitions.keySet()) {
Model mm = definitions.get(key);
CodegenModel cm = config.fromModel(key, mm);
Map<String, Object> mo = new HashMap<String, Object>();
mo.put("model", cm);
models.add(mo);
allImports.addAll(cm.imports);
}
objs.put("models", models);
List<Map<String, String>> imports = new ArrayList<Map<String, String>>();
for (String nextImport : allImports) {
Map<String, String> im = new LinkedHashMap<String, String>();
String mapping = config.importMapping().get(nextImport);
if (mapping == null) {
mapping = config.toModelImport(nextImport);
}
if (mapping != null && !config.defaultIncludes().contains(mapping)) {
im.put("import", mapping);
imports.add(im);
}
// add instantiation types
mapping = config.instantiationTypes().get(nextImport);
if (mapping != null && !config.defaultIncludes().contains(mapping)) {
im.put("import", mapping);
imports.add(im);
}
}
objs.put("imports", imports);
config.postProcessModels(objs);
return objs;
}
}

View File

@@ -1,11 +0,0 @@
package com.wordnik.swagger.codegen;
import com.wordnik.swagger.models.Swagger;
import java.io.File;
import java.util.List;
public interface Generator {
Generator opts(ClientOptInput opts);
List<File> generate();
}

View File

@@ -1,185 +0,0 @@
package com.wordnik.swagger.codegen;
import com.wordnik.swagger.codegen.languages.*;
import com.wordnik.swagger.models.Swagger;
import com.wordnik.swagger.models.auth.AuthorizationValue;
import com.wordnik.swagger.util.*;
import io.swagger.parser.SwaggerParser;
import com.samskivert.mustache.*;
import org.apache.commons.cli.*;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.Reader;
import java.util.*;
/**
* @deprecated use instead {@link com.wordnik.swagger.codegen.DefaultGenerator}
* or cli interface from https://github.com/swagger-api/swagger-codegen/pull/547
*/
@Deprecated
public class MetaGenerator extends AbstractGenerator {
static Map<String, CodegenConfig> configs = new HashMap<String, CodegenConfig>();
static String configString;
static {
List<CodegenConfig> extensions = getExtensions();
StringBuilder sb = new StringBuilder();
for(CodegenConfig config : extensions) {
if(sb.toString().length() != 0)
sb.append(", ");
sb.append(config.getName());
configs.put(config.getName(), config);
configString = sb.toString();
}
}
public static void main(String[] args) {
new MetaGenerator().generate(args);
}
protected void generate(String[] args) {
StringBuilder sb = new StringBuilder();
String targetLanguage = null;
String outputFolder = null;
String name = null;
String targetPackage = "com.wordnik.swagger.codegen";
final String templateDir = "codegen";
Options options = new Options();
options.addOption("h", "help", false, "shows this message");
options.addOption("l", "lang", false, "client language to generate.\nAvailable languages include:\n\t[" + configString + "]");
options.addOption("o", "output", true, "where to write the generated files");
options.addOption("n", "name", true, "the human-readable name of the generator");
options.addOption("p", "package", true, "the package to put the main class into (defaults to com.wordnik.swagger.codegen");
ClientOptInput clientOptInput = new ClientOptInput();
Swagger swagger = null;
CommandLine cmd = null;
try {
CommandLineParser parser = new BasicParser();
cmd = parser.parse(options, args);
if (cmd.hasOption("h")) {
usage(options);
return;
}
if (cmd.hasOption("n"))
name = cmd.getOptionValue("n");
else {
System.out.println("name is required");
usage(options);
return;
}
if (cmd.hasOption("l"))
targetLanguage = cmd.getOptionValue("l");
if (cmd.hasOption("p"))
targetPackage = cmd.getOptionValue("p");
if (cmd.hasOption("o"))
outputFolder = cmd.getOptionValue("o");
else {
System.out.println("output folder is required");
usage(options);
return;
}
}
catch (Exception e) {
usage(options);
return;
}
System.out.println("writing to folder " + outputFolder);
File outputFolderLocation = new File(outputFolder);
if(!outputFolderLocation.exists())
outputFolderLocation.mkdirs();
File sourceFolder = new File(outputFolder + File.separator + "src/main/java/" + targetPackage.replace('.', File.separatorChar));
if(!sourceFolder.exists())
sourceFolder.mkdirs();
File resourcesFolder = new File(outputFolder + File.separator + "src/main/resources/META-INF/services");
if(!resourcesFolder.exists())
resourcesFolder.mkdirs();
String mainClass = Character.toUpperCase(name.charAt(0)) + name.substring(1) + "Generator";
List<SupportingFile> supportingFiles = new ArrayList<SupportingFile>();
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("generatorClass.mustache",
"src/main/java/" + File.separator + targetPackage.replace('.', File.separatorChar),
mainClass + ".java"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("api.template", "src/main/resources" + File.separator + name, "api.mustache"));
supportingFiles.add(new SupportingFile("model.template", "src/main/resources" + File.separator + name, "model.mustache"));
supportingFiles.add(new SupportingFile("services.mustache", "src/main/resources/META-INF/services", "com.wordnik.swagger.codegen.CodegenConfig"));
List<File> files = new ArrayList<File>();
Map<String, Object> data = new HashMap<String, Object>();
data.put("generatorPackage", targetPackage);
data.put("generatorClass", mainClass);
data.put("name", name);
data.put("fullyQualifiedGeneratorClass", targetPackage + "." + mainClass);
for(SupportingFile support : supportingFiles) {
try {
String destinationFolder = outputFolder;
if(support.folder != null && !"".equals(support.folder))
destinationFolder += File.separator + support.folder;
File of = new File(destinationFolder);
if(!of.isDirectory())
of.mkdirs();
String outputFilename = destinationFolder + File.separator + support.destinationFilename;
if(support.templateFile.endsWith("mustache")) {
String template = readTemplate(templateDir + File.separator + support.templateFile);
Template tmpl = Mustache.compiler()
.withLoader(new Mustache.TemplateLoader() {
public Reader getTemplate (String name) {
return getTemplateReader(templateDir + File.separator + name + ".mustache");
};
})
.defaultValue("")
.compile(template);
writeToFile(outputFilename, tmpl.execute(data));
files.add(new File(outputFilename));
}
else {
String template = readTemplate(templateDir + File.separator + support.templateFile);
FileUtils.writeStringToFile(new File(outputFilename), template);
System.out.println("copying file to " + outputFilename);
files.add(new File(outputFilename));
}
}
catch (java.io.IOException e) {
e.printStackTrace();
}
}
}
public static List<CodegenConfig> getExtensions() {
ServiceLoader<CodegenConfig> loader = ServiceLoader.load(CodegenConfig.class);
List<CodegenConfig> output = new ArrayList<CodegenConfig>();
Iterator<CodegenConfig> itr = loader.iterator();
while(itr.hasNext()) {
output.add(itr.next());
}
return output;
}
static void usage(Options options) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp( "MetaGenerator. Generator for creating a new template set " +
"and configuration for Codegen. The output will be based on the language you " +
"specify, and includes default templates to include.", options );
}
public static CodegenConfig getConfig(String name) {
if(configs.containsKey(name)) {
return configs.get(name);
}
return null;
}
}

View File

@@ -1,13 +0,0 @@
package com.wordnik.swagger.codegen;
public class SupportingFile {
public String templateFile;
public String folder;
public String destinationFilename;
public SupportingFile(String templateFile, String folder, String destinationFilename) {
this.templateFile = templateFile;
this.folder = folder;
this.destinationFilename = destinationFilename;
}
}

View File

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

View File

@@ -1,165 +0,0 @@
package com.wordnik.swagger.codegen.examples;
import com.wordnik.swagger.models.*;
import com.wordnik.swagger.models.properties.*;
import com.wordnik.swagger.util.Json;
import java.text.SimpleDateFormat;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import java.math.BigDecimal;
import java.util.*;
public class ExampleGenerator {
protected Map<String, Model> examples;
public ExampleGenerator(Map<String, Model> examples) {
this.examples = examples;
}
public List<Map<String, String>> generate(Map<String, String> examples, List<String> mediaTypes, Property property) {
List<Map<String, String>> output = new ArrayList<Map<String, String>>();
Set<String> processedModels = new HashSet<String>();
if(examples == null ) {
if(mediaTypes == null) {
// assume application/json for this
mediaTypes = Arrays.asList("application/json");
}
for(String mediaType : mediaTypes) {
Map<String, String> kv = new HashMap<String, String>();
kv.put("contentType", mediaType);
if(property != null && mediaType.startsWith("application/json")) {
String example = Json.pretty(resolvePropertyToExample(mediaType, property, processedModels));
if(example != null) {
example = example.replaceAll("\n", "\\\\n");
kv.put("example", example);
output.add(kv);
}
}
else if(property != null && mediaType.startsWith("application/xml")) {
String example = new XmlExampleGenerator(this.examples).toXml(property);
if(example != null) {
example = example.replaceAll("\n", "\\\\n");
kv.put("example", example);
output.add(kv);
}
}
}
}
else {
for(String key: examples.keySet()) {
String value = examples.get(key);
Map<String, String> kv = new HashMap<String, String>();
kv.put("contentType", key);
kv.put("example", value);
output.add(kv);
}
}
if(output.size() == 0) {
Map<String, String> kv = new HashMap<String, String>();
kv.put("output", "none");
output.add(kv);
}
return output;
}
protected Object resolvePropertyToExample(String mediaType, Property property, Set<String> processedModels) {
if(property.getExample() != null) {
return property.getExample();
}
else if(property instanceof StringProperty) {
return "aeiou";
}
else if(property instanceof BooleanProperty) {
return Boolean.TRUE;
}
else if(property instanceof ArrayProperty) {
Property innerType = ((ArrayProperty)property).getItems();
if(innerType != null) {
Object[] output = new Object[]{
resolvePropertyToExample(mediaType, innerType, processedModels)
};
return output;
}
}
else if(property instanceof DateProperty) {
return new java.util.Date(System.currentTimeMillis());
}
else if(property instanceof DateTimeProperty) {
return new java.util.Date(System.currentTimeMillis());
}
else if(property instanceof DecimalProperty) {
return new BigDecimal(1.3579);
}
else if(property instanceof DoubleProperty) {
return new Double(3.149);
}
else if(property instanceof FileProperty) {
return ""; // TODO
}
else if(property instanceof FloatProperty) {
return new Float(1.23);
}
else if(property instanceof IntegerProperty) {
return new Integer(123);
}
else if(property instanceof LongProperty) {
return new Long(123456789);
}
else if(property instanceof MapProperty) {
Map<String, Object> mp = new HashMap<String, Object>();
if(property.getName() != null) {
mp.put(property.getName(),
resolvePropertyToExample(mediaType, ((MapProperty)property).getAdditionalProperties(), processedModels));
}
else {
mp.put("key",
resolvePropertyToExample(mediaType, ((MapProperty)property).getAdditionalProperties(), processedModels));
}
return mp;
}
else if(property instanceof ObjectProperty) {
return "{}";
}
else if(property instanceof RefProperty) {
String simpleName = ((RefProperty)property).getSimpleRef();
Model model = examples.get(simpleName);
if(model != null)
return resolveModelToExample(simpleName, mediaType, model, processedModels);
}
else if(property instanceof UUIDProperty) {
return "046b6c7f-0b8a-43b9-b35d-6489e6daee91";
}
return "";
}
public Object resolveModelToExample(String name, String mediaType, Model model, Set<String> processedModels) {
if(processedModels.contains(name)) {
return "";
}
if(model instanceof ModelImpl) {
processedModels.add(name);
ModelImpl impl = (ModelImpl) model;
Map<String, Object> values = new HashMap<String, Object>();
if(impl != null && impl.getProperties() != null) {
for(String propertyName : impl.getProperties().keySet()) {
Property property = impl.getProperties().get(propertyName);
values.put(propertyName, resolvePropertyToExample(mediaType, property, processedModels));
}
}
return values;
}
return "";
}
}

View File

@@ -1,188 +0,0 @@
package com.wordnik.swagger.codegen.examples;
import com.wordnik.swagger.util.Json;
import com.wordnik.swagger.models.*;
import com.wordnik.swagger.models.properties.*;
import java.text.SimpleDateFormat;
import java.util.*;
public class XmlExampleGenerator {
public static String NEWLINE = "\n";
public static String TAG_START = "<";
public static String CLOSE_TAG = ">";
public static String TAG_END = "</";
protected Map<String, Model> examples;
protected SimpleDateFormat dtFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
protected SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
public XmlExampleGenerator(Map<String, Model> examples) {
this.examples = examples;
if(examples == null)
examples = new HashMap<String, Model>();
}
public String toXml(Property property) {
return toXml(null, property, 0);
}
protected String toXml(Model model, int indent) {
if(model instanceof RefModel) {
RefModel ref = (RefModel) model;
Model actualModel = examples.get(ref.getSimpleRef());
if(actualModel instanceof ModelImpl)
return modelImplToXml((ModelImpl)actualModel, indent);
}
else if(model instanceof ModelImpl) {
return modelImplToXml((ModelImpl)model, indent);
}
return null;
}
protected String modelImplToXml(ModelImpl model, int indent) {
StringBuilder sb = new StringBuilder();
// attributes
Map<String, Property> attributes = new LinkedHashMap<String, Property>();
Map<String, Property> elements = new LinkedHashMap<String, Property>();
String name = model.getName();
String namespace;
String prefix;
Boolean wrapped;
Xml xml = model.getXml();
if(xml != null) {
if(xml.getName() != null)
name = xml.getName();
}
for(String pName : model.getProperties().keySet()) {
Property p = model.getProperties().get(pName);
if(p != null && p.getXml() != null && p.getXml().getAttribute() != null && p.getXml().getAttribute())
attributes.put(pName, p);
else
elements.put(pName, p);
}
sb.append(indent(indent)).append(TAG_START);
sb.append(name);
for(String pName : attributes.keySet()) {
Property p = attributes.get(pName);
sb.append(" ").append(pName).append("=").append(quote(toXml(null, p, 0)));
}
sb.append(CLOSE_TAG);
sb.append(NEWLINE);
for(String pName : elements.keySet()) {
Property p = elements.get(pName);
sb.append(toXml(pName, p, indent + 1));
sb.append(NEWLINE);
}
sb.append(indent(indent)).append(TAG_END).append(name).append(CLOSE_TAG);
return sb.toString();
}
protected String quote(String string) {
return "\"" + string + "\"";
}
protected String toXml(String name, Property property, int indent) {
if(property == null) {
return "";
}
StringBuilder sb = new StringBuilder();
if(property instanceof ArrayProperty) {
ArrayProperty p = (ArrayProperty) property;
Property inner = p.getItems();
boolean wrapped = false;
if(property.getXml() != null && property.getXml().getWrapped())
wrapped = true;
if(wrapped) {
if(name != null) {
sb.append(indent(indent));
sb.append(openTag(name));
sb.append(NEWLINE);
}
sb.append(toXml(name, inner, indent + 1));
if(name != null) {
sb.append(NEWLINE);
sb.append(indent(indent));
sb.append(closeTag(name));
}
}
else
sb.append(toXml(name, inner, indent));
}
else if(property instanceof RefProperty) {
RefProperty ref = (RefProperty) property;
Model actualModel = examples.get(ref.getSimpleRef());
sb.append(toXml(actualModel, indent));
}
else {
if(name != null) {
sb.append(indent(indent));
sb.append(openTag(name));
}
sb.append(getExample(property));
if(name != null)
sb.append(closeTag(name));
}
return sb.toString();
}
protected String getExample(Property property) {
if(property instanceof DateTimeProperty) {
if(property.getExample() != null)
return property.getExample();
else
return dtFormat.format(new Date());
}
else if(property instanceof StringProperty) {
if(property.getExample() != null)
return property.getExample();
else
return "string";
}
else if(property instanceof DateProperty) {
if(property.getExample() != null)
return property.getExample();
else
return dateFormat.format(new Date());
}
else if(property instanceof IntegerProperty) {
if(property.getExample() != null)
return property.getExample();
else
return "0";
}
else if(property instanceof BooleanProperty) {
if(property.getExample() != null)
return property.getExample();
else
return "true";
}
else if(property instanceof LongProperty) {
if(property.getExample() != null)
return property.getExample();
else
return "123456";
}
return "not implemented " + property;
}
protected String openTag(String name) {
return "<" + name + ">";
}
protected String closeTag(String name) {
return "</" + name + ">";
}
protected String indent(int indent) {
StringBuffer sb = new StringBuffer();
for(int i = 0; i < indent; i++) {
sb.append(" ");
}
return sb.toString();
}
}

View File

@@ -1,166 +0,0 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
import java.io.File;
public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfig {
protected String invokerPackage = "io.swagger.client";
protected String groupId = "io.swagger";
protected String artifactId = "swagger-android-client";
protected String artifactVersion = "1.0.0";
protected String sourceFolder = "src/main/java";
public CodegenType getTag() {
return CodegenType.CLIENT;
}
public String getName() {
return "android";
}
public String getHelp() {
return "Generates an Android client library.";
}
public AndroidClientCodegen() {
super();
outputFolder = "generated-code/android";
modelTemplateFiles.put("model.mustache", ".java");
apiTemplateFiles.put("api.mustache", ".java");
templateDir = "android-java";
apiPackage = "io.swagger.client.api";
modelPackage = "io.swagger.client.model";
reservedWords = new HashSet<String> (
Arrays.asList(
"abstract", "continue", "for", "new", "switch", "assert",
"default", "if", "package", "synchronized", "boolean", "do", "goto", "private",
"this", "break", "double", "implements", "protected", "throw", "byte", "else",
"import", "public", "throws", "case", "enum", "instanceof", "return", "transient",
"catch", "extends", "int", "short", "try", "char", "final", "interface", "static",
"void", "class", "finally", "long", "strictfp", "volatile", "const", "float",
"native", "super", "while")
);
additionalProperties.put("invokerPackage", invokerPackage);
additionalProperties.put("groupId", groupId);
additionalProperties.put("artifactId", artifactId);
additionalProperties.put("artifactVersion", artifactVersion);
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("apiInvoker.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiInvoker.java"));
supportingFiles.add(new SupportingFile("httpPatch.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "HttpPatch.java"));
supportingFiles.add(new SupportingFile("jsonUtil.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "JsonUtil.java"));
supportingFiles.add(new SupportingFile("apiException.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiException.java"));
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList(
"String",
"boolean",
"Boolean",
"Double",
"Integer",
"Long",
"Float",
"Object")
);
instantiationTypes.put("array", "ArrayList");
instantiationTypes.put("map", "HashMap");
}
@Override
public String escapeReservedWord(String name) {
return "_" + name;
}
@Override
public String apiFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
}
public String modelFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
}
@Override
public String getTypeDeclaration(Property p) {
if(p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
Property inner = ap.getItems();
return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">";
}
else if (p instanceof MapProperty) {
MapProperty mp = (MapProperty) p;
Property inner = mp.getAdditionalProperties();
return getSwaggerType(p) + "<String, " + getTypeDeclaration(inner) + ">";
}
return super.getTypeDeclaration(p);
}
@Override
public String getSwaggerType(Property p) {
String swaggerType = super.getSwaggerType(p);
String type = null;
if(typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType);
if(languageSpecificPrimitives.contains(type))
return toModelName(type);
}
else
type = swaggerType;
return toModelName(type);
}
@Override
public String toVarName(String name) {
// replace - with _ e.g. created-at => created_at
name = name.replaceAll("-", "_");
// if it's all uppper case, do nothing
if (name.matches("^[A-Z_]*$"))
return name;
// camelize (lower first character) the variable name
// pet_id => petId
name = camelize(name, true);
// for reserved word or word starting with number, append _
if(reservedWords.contains(name) || name.matches("^\\d.*"))
name = escapeReservedWord(name);
return name;
}
@Override
public String toParamName(String name) {
// should be the same as variable name
return toVarName(name);
}
@Override
public String toModelName(String name) {
// model name cannot use reserved keyword, e.g. return
if(reservedWords.contains(name))
throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
// camelize the model name
// phone_number => PhoneNumber
return camelize(name);
}
@Override
public String toModelFilename(String name) {
// should be the same as the model name
return toModelName(name);
}
}

View File

@@ -1,194 +0,0 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
import java.io.File;
public class AsyncScalaClientCodegen extends DefaultCodegen implements CodegenConfig {
protected String invokerPackage = "io.swagger.client";
protected String groupId = "com.wordnik";
protected String artifactId = "swagger-async-scala-client";
protected String artifactVersion = "1.0.0";
protected String sourceFolder = "src/main/scala";
protected String clientName = "SwaggerClient";
protected String authScheme = "";
protected boolean authPreemptive = false;
protected boolean asyncHttpClient = !authScheme.isEmpty();
public CodegenType getTag() {
return CodegenType.CLIENT;
}
public String getName() {
return "async-scala";
}
public String getHelp() {
return "Generates an Asynchronous Scala client library.";
}
public AsyncScalaClientCodegen() {
super();
outputFolder = "generated-code/async-scala";
modelTemplateFiles.put("model.mustache", ".scala");
apiTemplateFiles.put("api.mustache", ".scala");
templateDir = "asyncscala";
apiPackage = "io.swagger.client.api";
modelPackage = "io.swagger.client.model";
reservedWords = new HashSet<String> (
Arrays.asList(
"abstract", "case", "catch", "class", "def", "do", "else", "extends",
"false", "final", "finally", "for", "forSome", "if", "implicit",
"import", "lazy", "match", "new", "null", "object", "override", "package",
"private", "protected", "return", "sealed", "super", "this", "throw",
"trait", "try", "true", "type", "val", "var", "while", "with", "yield")
);
additionalProperties.put("invokerPackage", invokerPackage);
additionalProperties.put("groupId", groupId);
additionalProperties.put("artifactId", artifactId);
additionalProperties.put("artifactVersion", artifactVersion);
additionalProperties.put("asyncHttpClient", asyncHttpClient);
additionalProperties.put("authScheme", authScheme);
additionalProperties.put("authPreemptive", authPreemptive);
additionalProperties.put("clientName", clientName);
supportingFiles.add(new SupportingFile("sbt.mustache", "", "build.sbt"));
supportingFiles.add(new SupportingFile("client.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), clientName + ".scala"));
importMapping.remove("List");
importMapping.remove("Set");
importMapping.remove("Map");
importMapping.put("DateTime", "org.joda.time.DateTime");
importMapping.put("ListBuffer", "scala.collections.mutable.ListBuffer");
typeMapping = new HashMap<String, String>();
typeMapping.put("enum", "NSString");
typeMapping.put("array", "List");
typeMapping.put("set", "Set");
typeMapping.put("boolean", "Boolean");
typeMapping.put("string", "String");
typeMapping.put("int", "Int");
typeMapping.put("long", "Long");
typeMapping.put("float", "Float");
typeMapping.put("byte", "Byte");
typeMapping.put("short", "Short");
typeMapping.put("char", "Char");
typeMapping.put("long", "Long");
typeMapping.put("double", "Double");
typeMapping.put("object", "Any");
typeMapping.put("file", "File");
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList(
"String",
"boolean",
"Boolean",
"Double",
"Int",
"Long",
"Float",
"Object",
"List",
"Map")
);
instantiationTypes.put("array", "ListBuffer");
instantiationTypes.put("map", "HashMap");
}
@Override
public String escapeReservedWord(String name) {
return "_" + name;
}
@Override
public String apiFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
}
public String modelFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
}
@Override
public String getTypeDeclaration(Property p) {
if(p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
Property inner = ap.getItems();
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
}
else if (p instanceof MapProperty) {
MapProperty mp = (MapProperty) p;
Property inner = mp.getAdditionalProperties();
return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
}
return super.getTypeDeclaration(p);
}
@Override
public String getSwaggerType(Property p) {
String swaggerType = super.getSwaggerType(p);
String type = null;
if(typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType);
if(languageSpecificPrimitives.contains(type))
return toModelName(type);
}
else
type = swaggerType;
return toModelName(type);
}
@Override
public String toInstantiationType(Property p) {
if (p instanceof MapProperty) {
MapProperty ap = (MapProperty) p;
String inner = getSwaggerType(ap.getAdditionalProperties());
return instantiationTypes.get("map") + "[String, " + inner + "]";
}
else if (p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
String inner = getSwaggerType(ap.getItems());
return instantiationTypes.get("array") + "[" + inner + "]";
}
else
return null;
}
public String toDefaultValue(Property p) {
if(p instanceof StringProperty)
return "null";
else if (p instanceof BooleanProperty)
return "null";
else if(p instanceof DateProperty)
return "null";
else if(p instanceof DateTimeProperty)
return "null";
else if (p instanceof DoubleProperty)
return "null";
else if (p instanceof FloatProperty)
return "null";
else if (p instanceof IntegerProperty)
return "null";
else if (p instanceof LongProperty)
return "null";
else if (p instanceof MapProperty) {
MapProperty ap = (MapProperty) p;
String inner = getSwaggerType(ap.getAdditionalProperties());
return "new HashMap[String, " + inner + "]() ";
}
else if (p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
String inner = getSwaggerType(ap.getItems());
return "new ListBuffer[" + inner + "]() ";
}
else
return "null";
}
}

View File

@@ -1,166 +0,0 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
import java.io.File;
public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig {
protected String invokerPackage = "io.swagger.client";
protected String groupId = "io.swagger";
protected String artifactId = "swagger-csharp-client";
protected String artifactVersion = "1.0.0";
protected String sourceFolder = "src/main/csharp";
public CodegenType getTag() {
return CodegenType.CLIENT;
}
public String getName() {
return "csharp";
}
public String getHelp() {
return "Generates a CSharp client library.";
}
public CSharpClientCodegen() {
super();
outputFolder = "generated-code/csharp";
modelTemplateFiles.put("model.mustache", ".cs");
apiTemplateFiles.put("api.mustache", ".cs");
templateDir = "csharp";
apiPackage = "io.swagger.Api";
modelPackage = "io.swagger.Model";
reservedWords = new HashSet<String> (
Arrays.asList(
"abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", "false", "finally", "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock", "long", "namespace", "new", "null", "object", "operator", "out", "override", "params", "private", "protected", "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while")
);
additionalProperties.put("invokerPackage", invokerPackage);
supportingFiles.add(new SupportingFile("apiInvoker.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiInvoker.cs"));
supportingFiles.add(new SupportingFile("apiException.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiException.cs"));
supportingFiles.add(new SupportingFile("Newtonsoft.Json.dll", "bin", "Newtonsoft.Json.dll"));
supportingFiles.add(new SupportingFile("compile.mustache", "", "compile.bat"));
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList(
"String",
"boolean",
"Boolean",
"Double",
"Integer",
"Long",
"Float",
"Object")
);
instantiationTypes.put("array", "List");
instantiationTypes.put("map", "Dictionary");
typeMapping = new HashMap<String, String>();
typeMapping.put("boolean", "bool?");
typeMapping.put("integer", "int?");
typeMapping.put("float", "float?");
typeMapping.put("long", "long?");
typeMapping.put("double", "double?");
typeMapping.put("number", "double?");
typeMapping.put("Date", "DateTime");
typeMapping.put("file", "byte[]");
typeMapping.put("array", "List");
typeMapping.put("map", "Dictionary");
}
@Override
public String escapeReservedWord(String name) {
return "_" + name;
}
@Override
public String apiFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
}
public String modelFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
}
@Override
public String toVarName(String name) {
// replace - with _ e.g. created-at => created_at
name = name.replaceAll("-", "_");
// if it's all uppper case, do nothing
if (name.matches("^[A-Z_]*$"))
return name;
// camelize the variable name
// pet_id => PetId
name = camelize(name);
// for reserved word or word starting with number, append _
if(reservedWords.contains(name) || name.matches("^\\d.*"))
name = escapeReservedWord(name);
return name;
}
@Override
public String toParamName(String name) {
// should be the same as variable name
return toVarName(name);
}
@Override
public String toModelName(String name) {
// model name cannot use reserved keyword, e.g. return
if(reservedWords.contains(name))
throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
// camelize the model name
// phone_number => PhoneNumber
return camelize(name);
}
@Override
public String toModelFilename(String name) {
// should be the same as the model name
return toModelName(name);
}
@Override
public String getTypeDeclaration(Property p) {
if(p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
Property inner = ap.getItems();
return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">";
}
else if (p instanceof MapProperty) {
MapProperty mp = (MapProperty) p;
Property inner = mp.getAdditionalProperties();
return getSwaggerType(p) + "<String, " + getTypeDeclaration(inner) + ">";
}
return super.getTypeDeclaration(p);
}
@Override
public String getSwaggerType(Property p) {
String swaggerType = super.getSwaggerType(p);
String type = null;
if(typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType);
if(languageSpecificPrimitives.contains(type))
return type;
}
else
type = swaggerType;
return type;
}
}

View File

@@ -1,163 +0,0 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
import java.io.File;
public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
protected String invokerPackage = "io.swagger.client";
protected String groupId = "io.swagger";
protected String artifactId = "swagger-java-client";
protected String artifactVersion = "1.0.0";
protected String sourceFolder = "src/main/java";
public CodegenType getTag() {
return CodegenType.CLIENT;
}
public String getName() {
return "java";
}
public String getHelp() {
return "Generates a Java client library.";
}
public JavaClientCodegen() {
super();
outputFolder = "generated-code/java";
modelTemplateFiles.put("model.mustache", ".java");
apiTemplateFiles.put("api.mustache", ".java");
templateDir = "Java";
apiPackage = "io.swagger.client.api";
modelPackage = "io.swagger.client.model";
reservedWords = new HashSet<String> (
Arrays.asList(
"abstract", "continue", "for", "new", "switch", "assert",
"default", "if", "package", "synchronized", "boolean", "do", "goto", "private",
"this", "break", "double", "implements", "protected", "throw", "byte", "else",
"import", "public", "throws", "case", "enum", "instanceof", "return", "transient",
"catch", "extends", "int", "short", "try", "char", "final", "interface", "static",
"void", "class", "finally", "long", "strictfp", "volatile", "const", "float",
"native", "super", "while")
);
additionalProperties.put("invokerPackage", invokerPackage);
additionalProperties.put("groupId", groupId);
additionalProperties.put("artifactId", artifactId);
additionalProperties.put("artifactVersion", artifactVersion);
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("apiInvoker.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiInvoker.java"));
supportingFiles.add(new SupportingFile("JsonUtil.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "JsonUtil.java"));
supportingFiles.add(new SupportingFile("apiException.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiException.java"));
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList(
"String",
"boolean",
"Boolean",
"Double",
"Integer",
"Long",
"Float",
"Object")
);
instantiationTypes.put("array", "ArrayList");
instantiationTypes.put("map", "HashMap");
}
@Override
public String escapeReservedWord(String name) {
return "_" + name;
}
@Override
public String apiFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
}
public String modelFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
}
@Override
public String toVarName(String name) {
// replace - with _ e.g. created-at => created_at
name = name.replaceAll("-", "_");
// if it's all uppper case, do nothing
if (name.matches("^[A-Z_]*$"))
return name;
// camelize (lower first character) the variable name
// pet_id => petId
name = camelize(name, true);
// for reserved word or word starting with number, append _
if(reservedWords.contains(name) || name.matches("^\\d.*"))
name = escapeReservedWord(name);
return name;
}
@Override
public String toParamName(String name) {
// should be the same as variable name
return toVarName(name);
}
@Override
public String toModelName(String name) {
// model name cannot use reserved keyword, e.g. return
if(reservedWords.contains(name))
throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
// camelize the model name
// phone_number => PhoneNumber
return camelize(name);
}
@Override
public String toModelFilename(String name) {
// should be the same as the model name
return toModelName(name);
}
@Override
public String getTypeDeclaration(Property p) {
if(p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
Property inner = ap.getItems();
return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">";
}
else if (p instanceof MapProperty) {
MapProperty mp = (MapProperty) p;
Property inner = mp.getAdditionalProperties();
return getSwaggerType(p) + "<String, " + getTypeDeclaration(inner) + ">";
}
return super.getTypeDeclaration(p);
}
@Override
public String getSwaggerType(Property p) {
String swaggerType = super.getSwaggerType(p);
String type = null;
if(typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType);
if(languageSpecificPrimitives.contains(type))
return toModelName(type);
}
else
type = swaggerType;
return toModelName(type);
}
}

View File

@@ -1,149 +0,0 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.models.Operation;
import com.wordnik.swagger.models.Path;
import com.wordnik.swagger.util.Json;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
import java.io.File;
public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConfig {
protected String invokerPackage = "io.swagger.api";
protected String groupId = "io.swagger";
protected String artifactId = "swagger-jaxrs-server";
protected String artifactVersion = "1.0.0";
protected String sourceFolder = "src/main/java";
protected String title = "Swagger Server";
public CodegenType getTag() {
return CodegenType.SERVER;
}
public String getName() {
return "jaxrs";
}
public String getHelp() {
return "Generates a Java JAXRS Server application.";
}
public JaxRSServerCodegen() {
super();
outputFolder = "generated-code/javaJaxRS";
modelTemplateFiles.put("model.mustache", ".java");
apiTemplateFiles.put("api.mustache", ".java");
templateDir = "JavaJaxRS";
apiPackage = "io.swagger.api";
modelPackage = "io.swagger.model";
additionalProperties.put("invokerPackage", invokerPackage);
additionalProperties.put("groupId", groupId);
additionalProperties.put("artifactId", artifactId);
additionalProperties.put("artifactVersion", artifactVersion);
additionalProperties.put("title", title);
supportingFiles.clear();
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("ApiException.mustache",
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiException.java"));
supportingFiles.add(new SupportingFile("ApiOriginFilter.mustache",
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiOriginFilter.java"));
supportingFiles.add(new SupportingFile("ApiResponseMessage.mustache",
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiResponseMessage.java"));
supportingFiles.add(new SupportingFile("NotFoundException.mustache",
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "NotFoundException.java"));
supportingFiles.add(new SupportingFile("web.mustache",
("src/main/webapp/WEB-INF"), "web.xml"));
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList(
"String",
"boolean",
"Boolean",
"Double",
"Integer",
"Long",
"Float")
);
}
@Override
public String getTypeDeclaration(Property p) {
if(p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
Property inner = ap.getItems();
return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">";
}
else if (p instanceof MapProperty) {
MapProperty mp = (MapProperty) p;
Property inner = mp.getAdditionalProperties();
return getTypeDeclaration(inner);
}
return super.getTypeDeclaration(p);
}
@Override
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
String basePath = resourcePath;
if(basePath.startsWith("/"))
basePath = basePath.substring(1);
int pos = basePath.indexOf("/");
if(pos > 0)
basePath = basePath.substring(0, pos);
if(basePath == "")
basePath = "default";
else {
if(co.path.startsWith("/" + basePath))
co.path = co.path.substring(("/" + basePath).length());
co.subresourceOperation = !co.path.isEmpty();
}
List<CodegenOperation> opList = operations.get(basePath);
if(opList == null) {
opList = new ArrayList<CodegenOperation>();
operations.put(basePath, opList);
}
opList.add(co);
co.baseName = basePath;
}
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
Map<String, Object> operations = (Map<String, Object>)objs.get("operations");
if(operations != null) {
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
for(CodegenOperation operation : ops) {
if(operation.returnType == null)
operation.returnType = "Void";
else if(operation.returnType.startsWith("List")) {
String rt = operation.returnType;
int end = rt.lastIndexOf(">");
if(end > 0) {
operation.returnType = rt.substring("List<".length(), end);
operation.returnContainer = "List";
}
}
else if(operation.returnType.startsWith("Map")) {
String rt = operation.returnType;
int end = rt.lastIndexOf(">");
if(end > 0) {
operation.returnType = rt.substring("Map<".length(), end);
operation.returnContainer = "Map";
}
}
else if(operation.returnType.startsWith("Set")) {
String rt = operation.returnType;
int end = rt.lastIndexOf(">");
if(end > 0) {
operation.returnType = rt.substring("Set<".length(), end);
operation.returnContainer = "Set";
}
}
}
}
return objs;
}
}

View File

@@ -1,192 +0,0 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.util.Json;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
import java.io.File;
public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig {
protected String apiVersion = "1.0.0";
protected int serverPort = 8080;
protected String projectName = "swagger-server";
public String apiPackage() {
return "controllers";
}
/**
* Configures the type of generator.
*
* @return the CodegenType for this generator
* @see com.wordnik.swagger.codegen.CodegenType
*/
public CodegenType getTag() {
return CodegenType.SERVER;
}
/**
* Configures a friendly name for the generator. This will be used by the generator
* to select the library with the -l flag.
*
* @return the friendly name for the generator
*/
public String getName() {
return "nodejs";
}
/**
* Returns human-friendly help for the generator. Provide the consumer with help
* tips, parameters here
*
* @return A string value for the help message
*/
public String getHelp() {
return "Generates a nodejs server library using the swagger-tools project. By default, " +
"it will also generate service classes--which you can disable with the `-Dnoservice` environment variable.";
}
public NodeJSServerCodegen() {
super();
// set the output folder here
outputFolder = "generated-code/nodejs";
/**
* Models. You can write model files using the modelTemplateFiles map.
* if you want to create one template for file, you can do so here.
* for multiple files for model, just put another entry in the `modelTemplateFiles` with
* a different extension
*/
modelTemplateFiles.clear();
/**
* Api classes. You can write classes for each Api file with the apiTemplateFiles map.
* as with models, add multiple entries with different extensions for multiple files per
* class
*/
apiTemplateFiles.put(
"controller.mustache", // the template to use
".js"); // the extension for each file to write
/**
* Template Location. This is the location which templates will be read from. The generator
* will use the resource stream to attempt to read the templates.
*/
templateDir = "nodejs";
/**
* Reserved words. Override this with reserved words specific to your language
*/
reservedWords = new HashSet<String> (
Arrays.asList(
"break", "case", "class", "catch", "const", "continue", "debugger",
"default", "delete", "do", "else", "export", "extends", "finally",
"for", "function", "if", "import", "in", "instanceof", "let", "new",
"return", "super", "switch", "this", "throw", "try", "typeof", "var",
"void", "while", "with", "yield")
);
/**
* Additional Properties. These values can be passed to the templates and
* are available in models, apis, and supporting files
*/
additionalProperties.put("apiVersion", apiVersion);
additionalProperties.put("serverPort", serverPort);
/**
* Supporting Files. You can write single files for the generator with the
* entire object tree available. If the input file has a suffix of `.mustache
* it will be processed by the template engine. Otherwise, it will be copied
*/
// supportingFiles.add(new SupportingFile("controller.mustache",
// "controllers",
// "controller.js")
// );
supportingFiles.add(new SupportingFile("swagger.mustache",
"api",
"swagger.json")
);
supportingFiles.add(new SupportingFile("index.mustache",
"",
"index.js")
);
supportingFiles.add(new SupportingFile("package.mustache",
"",
"package.json")
);
if(System.getProperty("noservice") == null) {
apiTemplateFiles.put(
"service.mustache", // the template to use
"Service.js"); // the extension for each file to write
}
}
@Override
public String toApiName(String name) {
if(name.length() == 0)
return "DefaultController";
return initialCaps(name);
}
@Override
public String toApiFilename(String name) {
return toApiName(name);
}
/**
* Escapes a reserved word as defined in the `reservedWords` array. Handle escaping
* those terms here. This logic is only called if a variable matches the reseved words
*
* @return the escaped term
*/
@Override
public String escapeReservedWord(String name) {
return "_" + name; // add an underscore to the name
}
/**
* Location to write api files. You can use the apiPackage() as defined when the class is
* instantiated
*/
@Override
public String apiFileFolder() {
return outputFolder + File.separator + apiPackage().replace('.', File.separatorChar);
}
@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
Map<String, Object> objectMap = (Map<String, Object>)objs.get("operations");
List<CodegenOperation> operations = (List<CodegenOperation>)objectMap.get("operation");
for(CodegenOperation operation : operations) {
operation.httpMethod = operation.httpMethod.toLowerCase();
List<CodegenParameter> params = operation.allParams;
if(params != null && params.size() == 0)
operation.allParams = null;
List<CodegenResponse> responses = operation.responses;
if(responses != null) {
for(CodegenResponse resp : responses) {
if("0".equals(resp.code))
resp.code = "default";
}
}
if(operation.examples != null && operation.examples.size() > 0) {
List<Map<String, String>> examples = operation.examples;
for(int i = examples.size() - 1; i >= 0; i--) {
Map<String, String> example = examples.get(i);
String contentType = example.get("contentType");
if(contentType != null && contentType.indexOf("application/json") == 0) {
String jsonExample = example.get("example");
if(jsonExample != null) {
jsonExample = jsonExample.replaceAll("\\\\n", "\n");
example.put("example", jsonExample);
}
}
else
examples.remove(i);
}
}
}
return objs;
}
}

View File

@@ -1,273 +0,0 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.util.Json;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
import java.io.File;
public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
protected Set<String> foundationClasses = new HashSet<String>();
protected String sourceFolder = "client";
protected static String PREFIX = "SWG";
public CodegenType getTag() {
return CodegenType.CLIENT;
}
public String getName() {
return "objc";
}
public String getHelp() {
return "Generates an Objective-C client library.";
}
public ObjcClientCodegen() {
super();
outputFolder = "generated-code/objc";
modelTemplateFiles.put("model-header.mustache", ".h");
modelTemplateFiles.put("model-body.mustache", ".m");
apiTemplateFiles.put("api-header.mustache", ".h");
apiTemplateFiles.put("api-body.mustache", ".m");
templateDir = "objc";
modelPackage = "";
String appName = System.getProperty("appName");
if(appName == null) {
appName = "swaggerClient";
}
additionalProperties.put("projectName", appName);
defaultIncludes = new HashSet<String>(
Arrays.asList(
"bool",
"int",
"NSString",
"NSObject",
"NSArray",
"NSNumber",
"NSDate",
"NSDictionary",
"NSMutableArray",
"NSMutableDictionary")
);
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList(
"NSNumber",
"NSString",
"NSObject",
"NSDate",
"bool")
);
reservedWords = new HashSet<String>(
Arrays.asList(
"void", "char", "short", "int", "void", "char", "short", "int",
"long", "float", "double", "signed", "unsigned", "id", "const",
"volatile", "in", "out", "inout", "bycopy", "byref", "oneway",
"self", "super", "description"
));
typeMapping = new HashMap<String, String>();
typeMapping.put("enum", "NSString");
typeMapping.put("Date", "NSDate");
typeMapping.put("DateTime", "NSDate");
typeMapping.put("boolean", "NSNumber");
typeMapping.put("string", "NSString");
typeMapping.put("integer", "NSNumber");
typeMapping.put("int", "NSNumber");
typeMapping.put("float", "NSNumber");
typeMapping.put("long", "NSNumber");
typeMapping.put("double", "NSNumber");
typeMapping.put("array", "NSArray");
typeMapping.put("map", "NSDictionary");
typeMapping.put("number", "NSNumber");
typeMapping.put("List", "NSArray");
typeMapping.put("object", "NSObject");
importMapping = new HashMap<String, String> ();
foundationClasses = new HashSet<String> (
Arrays.asList(
"NSNumber",
"NSObject",
"NSString",
"NSDate",
"NSDictionary")
);
instantiationTypes.put("array", "NSMutableArray");
instantiationTypes.put("map", "NSMutableDictionary");
supportingFiles.add(new SupportingFile("SWGObject.h", sourceFolder, "SWGObject.h"));
supportingFiles.add(new SupportingFile("SWGObject.m", sourceFolder, "SWGObject.m"));
supportingFiles.add(new SupportingFile("SWGQueryParamCollection.h", sourceFolder, "SWGQueryParamCollection.h"));
supportingFiles.add(new SupportingFile("SWGQueryParamCollection.m", sourceFolder, "SWGQueryParamCollection.m"));
supportingFiles.add(new SupportingFile("SWGApiClient.h", sourceFolder, "SWGApiClient.h"));
supportingFiles.add(new SupportingFile("SWGApiClient.m", sourceFolder, "SWGApiClient.m"));
supportingFiles.add(new SupportingFile("SWGFile.h", sourceFolder, "SWGFile.h"));
supportingFiles.add(new SupportingFile("SWGFile.m", sourceFolder, "SWGFile.m"));
supportingFiles.add(new SupportingFile("SWGDate.h", sourceFolder, "SWGDate.h"));
supportingFiles.add(new SupportingFile("SWGDate.m", sourceFolder, "SWGDate.m"));
supportingFiles.add(new SupportingFile("Podfile.mustache", "", "Podfile"));
}
@Override
public String toInstantiationType(Property p) {
if (p instanceof MapProperty) {
MapProperty ap = (MapProperty) p;
String inner = getSwaggerType(ap.getAdditionalProperties());
return instantiationTypes.get("map");
}
else if (p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
String inner = getSwaggerType(ap.getItems());
return instantiationTypes.get("array");
}
else
return null;
}
@Override
public String getTypeDeclaration(String name) {
if(languageSpecificPrimitives.contains(name) && !foundationClasses.contains(name))
return name;
else
return name + "*";
}
@Override
public String getSwaggerType(Property p) {
String swaggerType = super.getSwaggerType(p);
String type = null;
if(typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType);
if(languageSpecificPrimitives.contains(type) && !foundationClasses.contains(type))
return toModelName(type);
}
else
type = swaggerType;
return toModelName(type);
}
@Override
public String getTypeDeclaration(Property p) {
if (p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
Property inner = ap.getItems();
String innerType = getSwaggerType(inner);
// In this codition, type of property p is array of primitive,
// return container type with pointer, e.g. `NSArray*'
if (languageSpecificPrimitives.contains(innerType))
return getSwaggerType(p) + "*";
// In this codition, type of property p is array of model,
// return container type combine inner type with pointer, e.g. `NSArray<SWGTag>*'
String innerTypeDeclaration = getTypeDeclaration(inner);
if (innerTypeDeclaration.endsWith("*"))
innerTypeDeclaration = innerTypeDeclaration.substring(0, innerTypeDeclaration.length() - 1);
return getSwaggerType(p) + "<" + innerTypeDeclaration + ">*";
}
else {
String swaggerType = getSwaggerType(p);
// In this codition, type of p is objective-c primitive type, e.g. `NSSNumber',
// return type of p with pointer, e.g. `NSNumber*'
if (languageSpecificPrimitives.contains(swaggerType) &&
foundationClasses.contains(swaggerType)) {
return swaggerType + "*";
}
// In this codition, type of p is c primitive type, e.g. `bool',
// return type of p, e.g. `bool'
else if (languageSpecificPrimitives.contains(swaggerType)) {
return swaggerType;
}
// In this codition, type of p is objective-c object type, e.g. `SWGPet',
// return type of p with pointer, e.g. `'
else {
return swaggerType + "*";
}
}
}
@Override
public String toModelName(String type) {
if(typeMapping.keySet().contains(type) ||
foundationClasses.contains(type) ||
importMapping.values().contains(type) ||
defaultIncludes.contains(type) ||
languageSpecificPrimitives.contains(type)) {
return Character.toUpperCase(type.charAt(0)) + type.substring(1);
}
else {
return PREFIX + Character.toUpperCase(type.charAt(0)) + type.substring(1);
}
}
@Override
protected void setNonArrayMapProperty(CodegenProperty property, String type) {
super.setNonArrayMapProperty(property, type);
if("NSDictionary".equals(type)) {
property.setter = "initWithDictionary";
}
else {
property.setter = "initWithValues";
}
}
@Override
public String toModelImport(String name) {
if("".equals(modelPackage()))
return name;
else
return modelPackage() + "." + name;
}
@Override
public String toDefaultValue(Property p) {
return null;
}
@Override
public String apiFileFolder() {
return outputFolder + File.separator + sourceFolder;
}
@Override
public String modelFileFolder() {
return outputFolder + File.separator + sourceFolder;
}
@Override
public String toModelFilename(String name) {
return PREFIX + initialCaps(name);
}
@Override
public String toApiName(String name) {
return PREFIX + initialCaps(name) + "Api";
}
public String toApiFilename(String name) {
return PREFIX + initialCaps(name) + "Api";
}
@Override
public String toVarName(String name) {
String paramName = name.replaceAll("[^a-zA-Z0-9_]","");
if(paramName.startsWith("new") || reservedWords.contains(paramName)) {
return escapeReservedWord(paramName);
}
else
return paramName;
}
public String escapeReservedWord(String name) {
return "_" + name;
}
}

View File

@@ -1,162 +0,0 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.util.Json;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
import java.io.File;
public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
protected String invokerPackage = "com.wordnik.client";
protected String groupId = "com.wordnik";
protected String artifactId = "swagger-client";
protected String artifactVersion = "1.0.0";
public CodegenType getTag() {
return CodegenType.CLIENT;
}
public String getName() {
return "php";
}
public String getHelp() {
return "Generates a PHP client library.";
}
public PhpClientCodegen() {
super();
//TODO determine hte package name from host name
invokerPackage = camelize("SwaggerPetstore");
String packagePath = invokerPackage + "-php";
modelPackage = packagePath + "/lib/models";
apiPackage = packagePath + "/lib";
outputFolder = "generated-code/php";
modelTemplateFiles.put("model.mustache", ".php");
apiTemplateFiles.put("api.mustache", ".php");
templateDir = "php";
typeMapping.clear();
languageSpecificPrimitives.clear();
reservedWords = new HashSet<String> (
Arrays.asList(
"__halt_compiler", "abstract", "and", "array", "as", "break", "callable", "case", "catch", "class", "clone", "const", "continue", "declare", "default", "die", "do", "echo", "else", "elseif", "empty", "enddeclare", "endfor", "endforeach", "endif", "endswitch", "endwhile", "eval", "exit", "extends", "final", "for", "foreach", "function", "global", "goto", "if", "implements", "include", "include_once", "instanceof", "insteadof", "interface", "isset", "list", "namespace", "new", "or", "print", "private", "protected", "public", "require", "require_once", "return", "static", "switch", "throw", "trait", "try", "unset", "use", "var", "while", "xor")
);
additionalProperties.put("invokerPackage", invokerPackage);
additionalProperties.put("groupId", groupId);
additionalProperties.put("artifactId", artifactId);
additionalProperties.put("artifactVersion", artifactVersion);
languageSpecificPrimitives.add("int");
languageSpecificPrimitives.add("array");
languageSpecificPrimitives.add("map");
languageSpecificPrimitives.add("string");
languageSpecificPrimitives.add("DateTime");
typeMapping.put("long", "int");
typeMapping.put("integer", "int");
typeMapping.put("Array", "array");
typeMapping.put("String", "string");
typeMapping.put("List", "array");
typeMapping.put("map", "map");
supportingFiles.add(new SupportingFile("composer.mustache", packagePath, "composer.json"));
supportingFiles.add(new SupportingFile("APIClient.mustache", packagePath + "/lib", "APIClient.php"));
supportingFiles.add(new SupportingFile("APIClientException.mustache", packagePath + "/lib", "APIClientException.php"));
supportingFiles.add(new SupportingFile("require.mustache", packagePath, invokerPackage + ".php"));
}
@Override
public String escapeReservedWord(String name) {
return "_" + name;
}
@Override
public String apiFileFolder() {
return outputFolder + "/" + apiPackage().replace('.', File.separatorChar);
}
public String modelFileFolder() {
return outputFolder + "/" + modelPackage().replace('.', File.separatorChar);
}
@Override
public String getTypeDeclaration(Property p) {
if(p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
Property inner = ap.getItems();
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
}
else if (p instanceof MapProperty) {
MapProperty mp = (MapProperty) p;
Property inner = mp.getAdditionalProperties();
return getSwaggerType(p) + "[string," + getTypeDeclaration(inner) + "]";
}
return super.getTypeDeclaration(p);
}
@Override
public String getSwaggerType(Property p) {
String swaggerType = super.getSwaggerType(p);
String type = null;
if(typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType);
if(languageSpecificPrimitives.contains(type)) {
return type;
}
}
else
type = swaggerType;
if(type == null)
return null;
return type;
}
public String toDefaultValue(Property p) {
return "null";
}
@Override
public String toVarName(String name) {
// parameter name starting with number won't compile
// need to escape it by appending _ at the beginning
if (name.matches("^[0-9]")) {
name = "_" + name;
}
// return the name in underscore style
// PhoneNumber => phone_number
return underscore(name);
}
@Override
public String toParamName(String name) {
// should be the same as variable name
return toVarName(name);
}
@Override
public String toModelName(String name) {
// model name cannot use reserved keyword
if(reservedWords.contains(name))
escapeReservedWord(name); // e.g. return => _return
// camelize the model name
// phone_number => PhoneNumber
return camelize(name);
}
@Override
public String toModelFilename(String name) {
// should be the same as the model name
return toModelName(name);
}
}

View File

@@ -1,117 +0,0 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import java.io.File;
import java.util.*;
public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig {
String module = "client";
public CodegenType getTag() {
return CodegenType.CLIENT;
}
public String getName() {
return "python";
}
public String getHelp() {
return "Generates a Python client library.";
}
public PythonClientCodegen() {
super();
outputFolder = "generated-code/python";
modelTemplateFiles.put("model.mustache", ".py");
apiTemplateFiles.put("api.mustache", ".py");
templateDir = "python";
apiPackage = module;
modelPackage = module + ".models";
languageSpecificPrimitives.clear();
languageSpecificPrimitives.add("int");
languageSpecificPrimitives.add("float");
languageSpecificPrimitives.add("long");
languageSpecificPrimitives.add("list");
languageSpecificPrimitives.add("bool");
languageSpecificPrimitives.add("str");
languageSpecificPrimitives.add("datetime");
typeMapping.clear();
typeMapping.put("integer", "int");
typeMapping.put("float", "float");
typeMapping.put("long", "long");
typeMapping.put("double", "float");
typeMapping.put("array", "list");
typeMapping.put("map", "map");
typeMapping.put("boolean", "bool");
typeMapping.put("string", "str");
typeMapping.put("date", "datetime");
// from https://docs.python.org/release/2.5.4/ref/keywords.html
reservedWords = new HashSet<String> (
Arrays.asList(
"and", "del", "from", "not", "while", "as", "elif", "global", "or", "with",
"assert", "else", "if", "pass", "yield", "break", "except", "import",
"print", "class", "exec", "in", "raise", "continue", "finally", "is",
"return", "def", "for", "lambda", "try"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("swagger.mustache", module, "swagger.py"));
supportingFiles.add(new SupportingFile("__init__.mustache", module, "__init__.py"));
supportingFiles.add(new SupportingFile("__init__.mustache", modelPackage.replace('.', File.separatorChar), "__init__.py"));
}
@Override
public String escapeReservedWord(String name) {
return "_" + name;
}
@Override
public String apiFileFolder() {
return outputFolder + "/" + apiPackage().replace('.', File.separatorChar);
}
public String modelFileFolder() {
return outputFolder + "/" + modelPackage().replace('.', File.separatorChar);
}
@Override
public String getTypeDeclaration(Property p) {
if(p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
Property inner = ap.getItems();
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
}
else if (p instanceof MapProperty) {
MapProperty mp = (MapProperty) p;
Property inner = mp.getAdditionalProperties();
return getSwaggerType(p) + "(String, " + getTypeDeclaration(inner) + ")";
}
return super.getTypeDeclaration(p);
}
@Override
public String getSwaggerType(Property p) {
String swaggerType = super.getSwaggerType(p);
String type = null;
if(typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType);
if(languageSpecificPrimitives.contains(type)) {
return type;
}
}
else
type = swaggerType;
return type;
}
public String toDefaultValue(Property p) {
// TODO: Support Python def value
return "null";
}
}

View File

@@ -1,190 +0,0 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.util.Json;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
import java.io.File;
public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
protected String invokerPackage = "com.wordnik.client";
protected String groupId = "com.wordnik";
protected String artifactId = "swagger-client";
protected String artifactVersion = "1.0.0";
public CodegenType getTag() {
return CodegenType.CLIENT;
}
public String getName() {
return "ruby";
}
public String getHelp() {
return "Generates a Ruby client library.";
}
public RubyClientCodegen() {
super();
modelPackage = "models";
apiPackage = "lib";
outputFolder = "generated-code/ruby";
modelTemplateFiles.put("model.mustache", ".rb");
apiTemplateFiles.put("api.mustache", ".rb");
templateDir = "ruby";
typeMapping.clear();
languageSpecificPrimitives.clear();
reservedWords = new HashSet<String> (
Arrays.asList(
"__FILE__", "and", "def", "end", "in", "or", "self", "unless", "__LINE__",
"begin", "defined?", "ensure", "module", "redo", "super", "until", "BEGIN",
"break", "do", "false", "next", "rescue", "then", "when", "END", "case",
"else", "for", "nil", "retry", "true", "while", "alias", "class", "elsif",
"if", "not", "return", "undef", "yield")
);
additionalProperties.put("invokerPackage", invokerPackage);
additionalProperties.put("groupId", groupId);
additionalProperties.put("artifactId", artifactId);
additionalProperties.put("artifactVersion", artifactVersion);
languageSpecificPrimitives.add("int");
languageSpecificPrimitives.add("array");
languageSpecificPrimitives.add("map");
languageSpecificPrimitives.add("string");
languageSpecificPrimitives.add("DateTime");
typeMapping.put("long", "int");
typeMapping.put("integer", "int");
typeMapping.put("Array", "array");
typeMapping.put("String", "string");
typeMapping.put("List", "array");
typeMapping.put("map", "map");
supportingFiles.add(new SupportingFile("swagger.mustache", "", "lib/swagger.rb"));
supportingFiles.add(new SupportingFile("monkey.mustache", "", "lib/monkey.rb"));
supportingFiles.add(new SupportingFile("swagger/request.mustache", "", "lib/swagger/request.rb"));
supportingFiles.add(new SupportingFile("swagger/response.mustache", "", "lib/swagger/response.rb"));
supportingFiles.add(new SupportingFile("swagger/version.mustache", "", "lib/swagger/version.rb"));
supportingFiles.add(new SupportingFile("swagger/configuration.mustache", "", "lib/swagger/configuration.rb"));
}
@Override
public String escapeReservedWord(String name) {
return "_" + name;
}
@Override
public String apiFileFolder() {
return outputFolder + "/" + apiPackage().replace('.', File.separatorChar);
}
public String modelFileFolder() {
return outputFolder + "/" + modelPackage().replace('.', File.separatorChar);
}
@Override
public String getTypeDeclaration(Property p) {
if(p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
Property inner = ap.getItems();
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
}
else if (p instanceof MapProperty) {
MapProperty mp = (MapProperty) p;
Property inner = mp.getAdditionalProperties();
return getSwaggerType(p) + "[string," + getTypeDeclaration(inner) + "]";
}
return super.getTypeDeclaration(p);
}
@Override
public String getSwaggerType(Property p) {
String swaggerType = super.getSwaggerType(p);
String type = null;
if(typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType);
if(languageSpecificPrimitives.contains(type)) {
return type;
}
}
else
type = swaggerType;
if(type == null)
return null;
return type;
}
public String toDefaultValue(Property p) {
return "null";
}
@Override
public String toVarName(String name) {
// replace - with _ e.g. created-at => created_at
name = name.replaceAll("-", "_");
// if it's all uppper case, convert to lower case
if (name.matches("^[A-Z_]*$"))
name = name.toLowerCase();
// camelize (lower first character) the variable name
// petId => pet_id
name = underscore(name);
// for reserved word or word starting with number, append _
if(reservedWords.contains(name) || name.matches("^\\d.*"))
name = escapeReservedWord(name);
return name;
}
@Override
public String toParamName(String name) {
// should be the same as variable name
return toVarName(name);
}
@Override
public String toModelName(String name) {
// model name cannot use reserved keyword, e.g. return
if(reservedWords.contains(name))
throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
// camelize the model name
// phone_number => PhoneNumber
return camelize(name);
}
@Override
public String toModelFilename(String name) {
// model name cannot use reserved keyword, e.g. return
if(reservedWords.contains(name))
throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
// underscore the model file name
// PhoneNumber.rb => phone_number.rb
return underscore(name);
}
@Override
public String toApiFilename(String name) {
// replace - with _ e.g. created-at => created_at
name = name.replaceAll("-", "_");
// e.g. PhoneNumberApi.rb => phone_number_api.rb
return underscore(name) + "_api";
}
@Override
public String toApiName(String name) {
if(name.length() == 0)
return "DefaultApi";
// e.g. phone_number_api => PhoneNumberApi
return camelize(name) + "Api";
}
}

View File

@@ -1,192 +0,0 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
import java.io.File;
public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig {
protected String invokerPackage = "io.swagger.client";
protected String groupId = "com.wordnik";
protected String artifactId = "swagger-scala-client";
protected String artifactVersion = "1.0.0";
protected String sourceFolder = "src/main/scala";
protected String authScheme = "";
protected boolean authPreemptive = false;
protected boolean asyncHttpClient = !authScheme.isEmpty();
public CodegenType getTag() {
return CodegenType.CLIENT;
}
public String getName() {
return "scala";
}
public String getHelp() {
return "Generates a Scala client library.";
}
public ScalaClientCodegen() {
super();
outputFolder = "generated-code/scala";
modelTemplateFiles.put("model.mustache", ".scala");
apiTemplateFiles.put("api.mustache", ".scala");
templateDir = "scala";
apiPackage = "io.swagger.client.api";
modelPackage = "io.swagger.client.model";
reservedWords = new HashSet<String> (
Arrays.asList(
"abstract", "case", "catch", "class", "def", "do", "else", "extends",
"false", "final", "finally", "for", "forSome", "if", "implicit",
"import", "lazy", "match", "new", "null", "object", "override", "package",
"private", "protected", "return", "sealed", "super", "this", "throw",
"trait", "try", "true", "type", "val", "var", "while", "with", "yield")
);
additionalProperties.put("invokerPackage", invokerPackage);
additionalProperties.put("groupId", groupId);
additionalProperties.put("artifactId", artifactId);
additionalProperties.put("artifactVersion", artifactVersion);
additionalProperties.put("asyncHttpClient", asyncHttpClient);
additionalProperties.put("authScheme", authScheme);
additionalProperties.put("authPreemptive", authPreemptive);
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("apiInvoker.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiInvoker.scala"));
importMapping.remove("List");
importMapping.remove("Set");
importMapping.remove("Map");
importMapping.put("DateTime", "org.joda.time.DateTime");
importMapping.put("ListBuffer", "scala.collections.mutable.ListBuffer");
typeMapping = new HashMap<String, String>();
typeMapping.put("enum", "NSString");
typeMapping.put("array", "List");
typeMapping.put("set", "Set");
typeMapping.put("boolean", "Boolean");
typeMapping.put("string", "String");
typeMapping.put("int", "Int");
typeMapping.put("long", "Long");
typeMapping.put("float", "Float");
typeMapping.put("byte", "Byte");
typeMapping.put("short", "Short");
typeMapping.put("char", "Char");
typeMapping.put("long", "Long");
typeMapping.put("double", "Double");
typeMapping.put("object", "Any");
typeMapping.put("file", "File");
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList(
"String",
"boolean",
"Boolean",
"Double",
"Int",
"Long",
"Float",
"Object",
"List",
"Map")
);
instantiationTypes.put("array", "ListBuffer");
instantiationTypes.put("map", "HashMap");
}
@Override
public String escapeReservedWord(String name) {
return "_" + name;
}
@Override
public String apiFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
}
public String modelFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
}
@Override
public String getTypeDeclaration(Property p) {
if(p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
Property inner = ap.getItems();
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
}
else if (p instanceof MapProperty) {
MapProperty mp = (MapProperty) p;
Property inner = mp.getAdditionalProperties();
return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
}
return super.getTypeDeclaration(p);
}
@Override
public String getSwaggerType(Property p) {
String swaggerType = super.getSwaggerType(p);
String type = null;
if(typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType);
if(languageSpecificPrimitives.contains(type))
return toModelName(type);
}
else
type = swaggerType;
return toModelName(type);
}
@Override
public String toInstantiationType(Property p) {
if (p instanceof MapProperty) {
MapProperty ap = (MapProperty) p;
String inner = getSwaggerType(ap.getAdditionalProperties());
return instantiationTypes.get("map") + "[String, " + inner + "]";
}
else if (p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
String inner = getSwaggerType(ap.getItems());
return instantiationTypes.get("array") + "[" + inner + "]";
}
else
return null;
}
public String toDefaultValue(Property p) {
if(p instanceof StringProperty)
return "null";
else if (p instanceof BooleanProperty)
return "null";
else if(p instanceof DateProperty)
return "null";
else if(p instanceof DateTimeProperty)
return "null";
else if (p instanceof DoubleProperty)
return "null";
else if (p instanceof FloatProperty)
return "null";
else if (p instanceof IntegerProperty)
return "null";
else if (p instanceof LongProperty)
return "null";
else if (p instanceof MapProperty) {
MapProperty ap = (MapProperty) p;
String inner = getSwaggerType(ap.getAdditionalProperties());
return "new HashMap[String, " + inner + "]() ";
}
else if (p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
String inner = getSwaggerType(ap.getItems());
return "new ListBuffer[" + inner + "]() ";
}
else
return "null";
}
}

View File

@@ -1,178 +0,0 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import com.wordnik.swagger.util.Json;
import java.util.*;
import java.io.File;
public class ScalatraServerCodegen extends DefaultCodegen implements CodegenConfig {
protected String invokerPackage = "com.wordnik.client";
protected String groupId = "com.wordnik";
protected String artifactId = "swagger-client";
protected String artifactVersion = "1.0.0";
protected String sourceFolder = "src/main/scala";
public CodegenType getTag() {
return CodegenType.SERVER;
}
public String getName() {
return "scalatra";
}
public String getHelp() {
return "Generates a Scala server application with Scalatra.";
}
public ScalatraServerCodegen() {
super();
outputFolder = "generated-code/scalatra";
modelTemplateFiles.put("model.mustache", ".scala");
apiTemplateFiles.put("api.mustache", ".scala");
templateDir = "scalatra";
apiPackage = "com.wordnik.client.api";
modelPackage = "com.wordnik.client.model";
reservedWords = new HashSet<String> (
Arrays.asList(
"abstract", "continue", "for", "new", "switch", "assert",
"default", "if", "package", "synchronized", "boolean", "do", "goto", "private",
"this", "break", "double", "implements", "protected", "throw", "byte", "else",
"import", "public", "throws", "case", "enum", "instanceof", "return", "transient",
"catch", "extends", "int", "short", "try", "char", "final", "interface", "static",
"void", "class", "finally", "long", "strictfp", "volatile", "const", "float",
"native", "super", "while")
);
defaultIncludes = new HashSet<String>(
Arrays.asList("double",
"Int",
"Long",
"Float",
"Double",
"char",
"float",
"String",
"boolean",
"Boolean",
"Double",
"Integer",
"Long",
"Float",
"List",
"Set",
"Map")
);
typeMapping.put("integer", "Int");
typeMapping.put("long", "Long");
additionalProperties.put("appName", "Swagger Sample");
additionalProperties.put("appName", "Swagger Sample");
additionalProperties.put("appDescription", "A sample swagger server");
additionalProperties.put("infoUrl", "http://developers.helloreverb.com");
additionalProperties.put("infoEmail", "hello@helloreverb.com");
additionalProperties.put("licenseInfo", "All rights reserved");
additionalProperties.put("licenseUrl", "http://apache.org/licenses/LICENSE-2.0.html");
additionalProperties.put("invokerPackage", invokerPackage);
additionalProperties.put("groupId", groupId);
additionalProperties.put("artifactId", artifactId);
additionalProperties.put("artifactVersion", artifactVersion);
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("build.sbt", "", "build.sbt"));
supportingFiles.add(new SupportingFile("web.xml", "/src/main/webapp/WEB-INF", "web.xml"));
supportingFiles.add(new SupportingFile("JettyMain.scala", sourceFolder, "JettyMain.scala"));
supportingFiles.add(new SupportingFile("Bootstrap.mustache", sourceFolder, "ScalatraBootstrap.scala"));
supportingFiles.add(new SupportingFile("ServletApp.mustache", sourceFolder, "ServletApp.scala"));
supportingFiles.add(new SupportingFile("project/build.properties", "project", "build.properties"));
supportingFiles.add(new SupportingFile("project/plugins.sbt", "project", "plugins.sbt"));
supportingFiles.add(new SupportingFile("sbt", "", "sbt"));
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList(
"String",
"boolean",
"Boolean",
"Double",
"Integer",
"Long",
"Float",
"Object")
);
instantiationTypes.put("array", "ArrayList");
instantiationTypes.put("map", "HashMap");
importMapping = new HashMap<String, String> ();
importMapping.put("BigDecimal", "java.math.BigDecimal");
importMapping.put("UUID", "java.util.UUID");
importMapping.put("File", "java.io.File");
importMapping.put("Date", "java.util.Date");
importMapping.put("Timestamp", "java.sql.Timestamp");
importMapping.put("Map", "java.util.Map");
importMapping.put("HashMap", "java.util.HashMap");
importMapping.put("Array", "java.util.List");
importMapping.put("ArrayList", "java.util.ArrayList");
importMapping.put("DateTime", "org.joda.time.DateTime");
importMapping.put("LocalDateTime", "org.joda.time.LocalDateTime");
importMapping.put("LocalDate", "org.joda.time.LocalDate");
importMapping.put("LocalTime", "org.joda.time.LocalTime");
}
@Override
public String escapeReservedWord(String name) {
return "_" + name;
}
@Override
public String apiFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
}
public String modelFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
}
@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
for(CodegenOperation op: operationList) {
op.httpMethod = op.httpMethod.toLowerCase();
}
return objs;
}
@Override
public String getTypeDeclaration(Property p) {
if(p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
Property inner = ap.getItems();
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
}
else if (p instanceof MapProperty) {
MapProperty mp = (MapProperty) p;
Property inner = mp.getAdditionalProperties();
return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
}
return super.getTypeDeclaration(p);
}
@Override
public String getSwaggerType(Property p) {
String swaggerType = super.getSwaggerType(p);
String type = null;
if(typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType);
if(languageSpecificPrimitives.contains(type))
return toModelName(type);
}
else
type = swaggerType;
return toModelName(type);
}
}

View File

@@ -1,76 +0,0 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
import java.io.File;
public class StaticDocCodegen extends DefaultCodegen implements CodegenConfig {
protected String invokerPackage = "com.wordnik.client";
protected String groupId = "com.wordnik";
protected String artifactId = "swagger-client";
protected String artifactVersion = "1.0.0";
protected String sourceFolder = "docs";
public CodegenType getTag() {
return CodegenType.DOCUMENTATION;
}
public String getName() {
return "dynamic-html";
}
public String getHelp() {
return "Generates a dynamic HTML site.";
}
public StaticDocCodegen() {
super();
outputFolder = "docs";
modelTemplateFiles.put("model.mustache", ".html");
apiTemplateFiles.put("operation.mustache", ".html");
templateDir = "swagger-static";
additionalProperties.put("invokerPackage", invokerPackage);
additionalProperties.put("groupId", groupId);
additionalProperties.put("artifactId", artifactId);
additionalProperties.put("artifactVersion", artifactVersion);
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
supportingFiles.add(new SupportingFile("main.mustache", "", "main.js"));
supportingFiles.add(new SupportingFile("assets/css/bootstrap-responsive.css",
outputFolder + "/assets/css", "bootstrap-responsive.css"));
supportingFiles.add(new SupportingFile("assets/css/bootstrap.css",
outputFolder + "/assets/css", "bootstrap.css"));
supportingFiles.add(new SupportingFile("assets/css/style.css",
outputFolder + "/assets/css", "style.css"));
supportingFiles.add(new SupportingFile("assets/images/logo.png",
outputFolder + "/assets/images", "logo.png"));
supportingFiles.add(new SupportingFile("assets/js/bootstrap.js",
outputFolder + "/assets/js", "bootstrap.js"));
supportingFiles.add(new SupportingFile("assets/js/jquery-1.8.3.min.js",
outputFolder + "/assets/js", "jquery-1.8.3.min.js"));
supportingFiles.add(new SupportingFile("assets/js/main.js",
outputFolder + "/assets/js", "main.js"));
supportingFiles.add(new SupportingFile("index.mustache",
outputFolder, "index.html"));
instantiationTypes.put("array", "ArrayList");
instantiationTypes.put("map", "HashMap");
}
@Override
public String escapeReservedWord(String name) {
return "_" + name;
}
@Override
public String apiFileFolder() {
return outputFolder + File.separator + sourceFolder + File.separator + "operations";
}
public String modelFileFolder() {
return outputFolder + File.separator + sourceFolder + File.separator + "models";
}
}

View File

@@ -1,79 +0,0 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import com.wordnik.swagger.util.Json;
import java.util.*;
import java.io.File;
public class StaticHtmlGenerator extends DefaultCodegen implements CodegenConfig {
protected String invokerPackage = "com.wordnik.client";
protected String groupId = "com.wordnik";
protected String artifactId = "swagger-client";
protected String artifactVersion = "1.0.0";
protected String sourceFolder = "src/main/scala";
public CodegenType getTag() {
return CodegenType.DOCUMENTATION;
}
public String getName() {
return "html";
}
public String getHelp() {
return "Generates a static HTML file.";
}
public StaticHtmlGenerator() {
super();
outputFolder = "docs";
templateDir = "htmlDocs";
defaultIncludes = new HashSet<String>();
additionalProperties.put("appName", "Swagger Sample");
additionalProperties.put("appDescription", "A sample swagger server");
additionalProperties.put("infoUrl", "https://helloreverb.com");
additionalProperties.put("infoEmail", "hello@helloreverb.com");
additionalProperties.put("licenseInfo", "All rights reserved");
additionalProperties.put("licenseUrl", "http://apache.org/licenses/LICENSE-2.0.html");
additionalProperties.put("invokerPackage", invokerPackage);
additionalProperties.put("groupId", groupId);
additionalProperties.put("artifactId", artifactId);
additionalProperties.put("artifactVersion", artifactVersion);
supportingFiles.add(new SupportingFile("index.mustache", "", "index.html"));
reservedWords = new HashSet<String>();
languageSpecificPrimitives = new HashSet<String>();
importMapping = new HashMap<String, String> ();
}
@Override
public String getTypeDeclaration(Property p) {
if(p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
Property inner = ap.getItems();
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
}
else if (p instanceof MapProperty) {
MapProperty mp = (MapProperty) p;
Property inner = mp.getAdditionalProperties();
return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
}
return super.getTypeDeclaration(p);
}
@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
for(CodegenOperation op: operationList) {
op.httpMethod = op.httpMethod.toLowerCase();
}
return objs;
}
}

View File

@@ -1,45 +0,0 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.util.*;
import com.wordnik.swagger.models.Swagger;
import org.apache.commons.io.FileUtils;
import java.io.File;
public class SwaggerGenerator extends DefaultCodegen implements CodegenConfig {
public CodegenType getTag() {
return CodegenType.DOCUMENTATION;
}
public String getName() {
return "swagger";
}
public String getHelp() {
return "Creates a static swagger.json file.";
}
public SwaggerGenerator() {
super();
templateDir = "swagger";
outputFolder = "generated-code/swagger";
supportingFiles.add(new SupportingFile("README.md", "", "README.md"));
}
@Override
public void processSwagger(Swagger swagger) {
String swaggerString = Json.pretty(swagger);
try{
String outputFile = outputFolder + File.separator + "swagger.json";
FileUtils.writeStringToFile(new File(outputFile), swaggerString);
System.out.println("wrote file to " + outputFile);
}
catch(Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -1,44 +0,0 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.util.*;
import com.wordnik.swagger.models.Swagger;
import org.apache.commons.io.FileUtils;
import java.io.File;
public class SwaggerYamlGenerator extends DefaultCodegen implements CodegenConfig {
public CodegenType getTag() {
return CodegenType.DOCUMENTATION;
}
public String getName() {
return "swagger-yaml";
}
public String getHelp() {
return "Creates a static swagger.yaml file.";
}
public SwaggerYamlGenerator() {
super();
templateDir = "swagger";
outputFolder = "generated-code/swagger";
supportingFiles.add(new SupportingFile("README.md", "", "README.md"));
}
@Override
public void processSwagger(Swagger swagger) {
try{
String swaggerString = Yaml.mapper().writeValueAsString(swagger);
String outputFile = outputFolder + File.separator + "swagger.yaml";
FileUtils.writeStringToFile(new File(outputFile), swaggerString);
System.out.println("wrote file to " + outputFile);
}
catch(Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -1,247 +0,0 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.util.Json;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
import java.io.File;
public class TizenClientCodegen extends DefaultCodegen implements CodegenConfig {
protected Set<String> foundationClasses = new HashSet<String>();
protected String sourceFolder = "client";
protected static String PREFIX = "Sami";
protected Map<String, String> namespaces = new HashMap<String, String>();
public CodegenType getTag() {
return CodegenType.CLIENT;
}
public String getName() {
return "tizen";
}
public String getHelp() {
return "Generates a Samsung Tizen C++ client library.";
}
public TizenClientCodegen() {
super();
outputFolder = "generated-code/tizen";
modelTemplateFiles.put("model-header.mustache", ".h");
modelTemplateFiles.put("model-body.mustache", ".cpp");
apiTemplateFiles.put("api-header.mustache", ".h");
apiTemplateFiles.put("api-body.mustache", ".cpp");
templateDir = "tizen";
modelPackage = "";
defaultIncludes = new HashSet<String>(
Arrays.asList(
"bool",
"int",
"long")
);
languageSpecificPrimitives = new HashSet<String>();
additionalProperties().put("prefix", PREFIX);
reservedWords = new HashSet<String>(
// VERIFY
Arrays.asList(
"void", "char", "short", "int", "void", "char", "short", "int",
"long", "float", "double", "signed", "unsigned", "id", "const",
"volatile", "in", "out", "inout", "bycopy", "byref", "oneway",
"self", "super"
));
super.typeMapping = new HashMap<String, String>();
typeMapping.put("Date", "DateTime");
typeMapping.put("DateTime", "DateTime");
typeMapping.put("string", "String");
typeMapping.put("integer", "Integer");
typeMapping.put("float", "Float");
typeMapping.put("long", "Long");
typeMapping.put("boolean", "Boolean");
typeMapping.put("double", "Double");
typeMapping.put("array", "IList");
typeMapping.put("map", "HashMap");
typeMapping.put("number", "Long");
typeMapping.put("object", PREFIX + "Object");
importMapping = new HashMap<String, String>();
namespaces = new HashMap<String, String> ();
namespaces.put("DateTime", "Tizen::Base::DateTime");
namespaces.put("Integer", "Tizen::Base::Integer");
namespaces.put("Long", "Tizen::Base::Long");
namespaces.put("Boolean", "Tizen::Base::Boolean");
namespaces.put("Float", "Tizen::Base::Float");
namespaces.put("String", "Tizen::Base::String");
namespaces.put("Double", "Tizen::Base::Double");
namespaces.put("IList", "Tizen::Base::Collection::IList");
namespaces.put("HashMap", "Tizen::Base::Collection::HashMap");
namespaces.put("ArrayList", "Tizen::Base::Collection::ArrayList");
namespaces.put("JsonNumber", "Tizen::Web::Json");
namespaces.put("JsonString", "Tizen::Web::Json");
foundationClasses = new HashSet<String> (
Arrays.asList(
"String",
"Integer",
"Float")
);
supportingFiles.clear();
supportingFiles.add(new SupportingFile("modelFactory.mustache", sourceFolder, PREFIX + "ModelFactory.h"));
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder, PREFIX + "Helpers.h"));
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder, PREFIX + "Helpers.cpp"));
supportingFiles.add(new SupportingFile("apiclient-header.mustache", sourceFolder, PREFIX + "ApiClient.h"));
supportingFiles.add(new SupportingFile("apiclient-body.mustache", sourceFolder, PREFIX + "ApiClient.cpp"));
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, PREFIX + "Object.h"));
supportingFiles.add(new SupportingFile("error-header.mustache", sourceFolder, PREFIX + "Error.h"));
supportingFiles.add(new SupportingFile("error-body.mustache", sourceFolder, PREFIX + "Error.cpp"));
}
@Override
public String toInstantiationType(Property p) {
if (p instanceof MapProperty) {
MapProperty ap = (MapProperty) p;
String inner = getSwaggerType(ap.getAdditionalProperties());
return instantiationTypes.get("map");
}
else if (p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
String inner = getSwaggerType(ap.getItems());
return instantiationTypes.get("array");
}
else
return null;
}
@Override
public String getTypeDeclaration(String name) {
if(languageSpecificPrimitives.contains(name) && !foundationClasses.contains(name))
return name;
else
return name + "*";
}
@Override
public String getSwaggerType(Property p) {
String swaggerType = super.getSwaggerType(p);
String type = null;
if(typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType);
if(languageSpecificPrimitives.contains(type) && !foundationClasses.contains(type))
return toModelName(type);
}
else
type = swaggerType;
return toModelName(type);
}
@Override
public String getTypeDeclaration(Property p) {
String swaggerType = getSwaggerType(p);
if(languageSpecificPrimitives.contains(swaggerType) && !foundationClasses.contains(swaggerType))
return toModelName(swaggerType);
else
return swaggerType + "*";
}
@Override
public String toModelName(String type) {
if(typeMapping.keySet().contains(type) ||
typeMapping.values().contains(type) ||
foundationClasses.contains(type) ||
importMapping.values().contains(type) ||
defaultIncludes.contains(type) ||
languageSpecificPrimitives.contains(type)) {
return type;
}
else {
return PREFIX + Character.toUpperCase(type.charAt(0)) + type.substring(1);
}
}
@Override
public String toModelImport(String name) {
if(namespaces.containsKey(name)) {
return "using " + namespaces.get(name) + ";";
}
return "#include \"" + name + ".h\"";
}
@Override
public String toDefaultValue(Property p) {
if(p instanceof StringProperty)
return "new String()";
else if (p instanceof BooleanProperty)
return "new Boolean(false)";
else if(p instanceof DateProperty)
return "new DateTime()";
else if(p instanceof DateTimeProperty)
return "new DateTime()";
else if (p instanceof DoubleProperty)
return "new Double()";
else if (p instanceof FloatProperty)
return "new Float()";
else if (p instanceof IntegerProperty)
return "new Integer()";
else if (p instanceof LongProperty)
return "new Long()";
else if (p instanceof DecimalProperty)
return "new Long()";
else if (p instanceof MapProperty) {
MapProperty ap = (MapProperty) p;
String inner = getSwaggerType(ap.getAdditionalProperties());
return "new HashMap()";
}
else if (p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
String inner = getSwaggerType(ap.getItems());
return "new ArrayList()";
}
// else
if(p instanceof RefProperty) {
RefProperty rp = (RefProperty) p;
return "new " + toModelName(rp.getSimpleRef()) + "()";
}
return "null";
}
@Override
public String apiFileFolder() {
return outputFolder + File.separator + sourceFolder;
}
@Override
public String modelFileFolder() {
return outputFolder + File.separator + sourceFolder;
}
@Override
public String toModelFilename(String name) {
return PREFIX + initialCaps(name);
}
@Override
public String toApiName(String name) {
return PREFIX + initialCaps(name) + "Api";
}
public String toApiFilename(String name) {
return PREFIX + initialCaps(name) + "Api";
}
@Override
public String toVarName(String name) {
String paramName = name.replaceAll("[^a-zA-Z0-9_]","");
paramName = Character.toUpperCase(paramName.charAt(0)) + paramName.substring(1);
return "p" + paramName;
}
public String escapeReservedWord(String name) {
return "_" + name;
}
}

View File

@@ -0,0 +1,34 @@
package config;
import com.google.common.collect.ImmutableMap;
import java.util.HashMap;
import java.util.Map;
public class Config {
private Map<String, String> options;
public Config() {
this.options = new HashMap<String, String>();
}
public Config(Map<String, String> properties) {
this.options = properties;
}
public Map<String, String> getOptions() {
return ImmutableMap.copyOf(options);
}
public boolean hasOption(String opt) {
return options.containsKey(opt);
}
public String getOption(String opt) {
return options.get(opt);
}
public void setOption(String opt, String value) {
options.put(opt, value);
}
}

View File

@@ -0,0 +1,40 @@
package config;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.File;
import java.util.Iterator;
import java.util.Map;
public class ConfigParser {
public static Config read(String location) {
System.out.println("reading config from " + location);
ObjectMapper mapper = new ObjectMapper();
Config config = new Config();
try {
JsonNode rootNode = mapper.readTree(new File(location));
Iterator<Map.Entry<String, JsonNode>> optionNodes = rootNode.fields();
while (optionNodes.hasNext()) {
Map.Entry<String, JsonNode> optionNode = (Map.Entry<String, JsonNode>) optionNodes.next();
if (optionNode.getValue().isValueNode()) {
config.setOption(optionNode.getKey(), optionNode.getValue().asText());
} else {
System.out.println("omitting non-value node " + optionNode.getKey());
}
}
} catch (Exception e) {
System.out.println(e.getMessage());
return null;
}
return config;
}
}

View File

@@ -0,0 +1,90 @@
package io.swagger.codegen;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.util.regex.Pattern;
public abstract class AbstractGenerator {
public File writeToFile(String filename, String contents) throws IOException {
System.out.println("writing file " + filename);
File output = new File(filename);
if (output.getParent() != null && !new File(output.getParent()).exists()) {
File parent = new File(output.getParent());
parent.mkdirs();
}
Writer out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(output), "UTF-8"));
out.write(contents);
out.close();
return output;
}
public String readTemplate(String name) {
try {
Reader reader = getTemplateReader(name);
if (reader == null) {
throw new RuntimeException("no file found");
}
java.util.Scanner s = new java.util.Scanner(reader).useDelimiter("\\A");
return s.hasNext() ? s.next() : "";
} catch (Exception e) {
e.printStackTrace();
}
throw new RuntimeException("can't load template " + name);
}
public Reader getTemplateReader(String name) {
try {
InputStream is = this.getClass().getClassLoader().getResourceAsStream(getCPResourcePath(name));
if (is == null) {
is = new FileInputStream(new File(name));
}
if (is == null) {
throw new RuntimeException("no file found");
}
return new InputStreamReader(is);
} catch (Exception e) {
e.printStackTrace();
}
throw new RuntimeException("can't load template " + name);
}
/**
* Get the template file path with template dir prepended, and use the
* library template if exists.
*/
public String getFullTemplateFile(CodegenConfig config, String templateFile) {
String library = config.getLibrary();
if (library != null && !"".equals(library)) {
String libTemplateFile = config.templateDir() + File.separator +
"libraries" + File.separator + library + File.separator +
templateFile;
if (templateExists(libTemplateFile)) {
return libTemplateFile;
}
}
return config.templateDir() + File.separator + templateFile;
}
public boolean templateExists(String name) {
return this.getClass().getClassLoader().getResource(getCPResourcePath(name)) != null;
}
public String getCPResourcePath(String name) {
if (!"/".equals(File.separator)) {
return name.replaceAll(Pattern.quote(File.separator), "/");
}
return name;
}
}

View File

@@ -0,0 +1,23 @@
package io.swagger.codegen;
public class CliOption {
private final String opt;
private String description;
public CliOption(String opt, String description) {
this.opt = opt;
this.description = description;
}
public String getOpt() {
return opt;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}

View File

@@ -0,0 +1,92 @@
package io.swagger.codegen;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.Swagger;
import io.swagger.models.auth.AuthorizationValue;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
public class ClientOptInput {
protected CodegenConfig config;
private ClientOpts opts;
private Swagger swagger;
private List<AuthorizationValue> auths;
public ClientOptInput swagger(Swagger swagger) {
this.setSwagger(swagger);
return this;
}
public ClientOptInput opts(ClientOpts opts) {
this.setOpts(opts);
return this;
}
public 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 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 List<AuthorizationValue> getAuthorizationValues() {
return auths;
}
public CodegenConfig getConfig() {
return config;
}
public void setConfig(CodegenConfig config) {
this.config = config;
}
public ClientOpts getOpts() {
return opts;
}
public void setOpts(ClientOpts opts) {
this.opts = opts;
}
@ApiModelProperty(dataType = "Object")
public Swagger getSwagger() {
return swagger;
}
public void setSwagger(Swagger swagger) {
this.swagger = swagger;
}
}

View File

@@ -0,0 +1,57 @@
package io.swagger.codegen;
import io.swagger.codegen.auth.AuthMethod;
import java.util.HashMap;
import java.util.Map;
public class ClientOpts {
protected String uri;
protected String target;
protected AuthMethod auth;
protected Map<String, String> properties = new HashMap<String, String>();
protected String outputDirectory;
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getTarget() {
return target;
}
public void setTarget(String target) {
this.target = target;
}
public Map<String, String> getProperties() {
return properties;
}
public void setProperties(Map<String, String> properties) {
this.properties = properties;
}
public String getOutputDirectory() {
return outputDirectory;
}
public void setOutputDirectory(String outputDirectory) {
this.outputDirectory = outputDirectory;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("ClientOpts: {\n");
sb.append(" uri: ").append(uri).append(",");
sb.append(" auth: ").append(auth).append(",");
sb.append(properties);
sb.append("}");
return sb.toString();
}
}

View File

@@ -0,0 +1,148 @@
package io.swagger.codegen;
import io.swagger.models.Swagger;
import io.swagger.parser.SwaggerParser;
import org.apache.commons.cli.BasicParser;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
/**
* @deprecated use instead {@link io.swagger.codegen.DefaultGenerator}
* or cli interface from https://github.com/swagger-api/swagger-codegen/pull/547
*/
@Deprecated
public class Codegen extends DefaultGenerator {
static Map<String, CodegenConfig> configs = new HashMap<String, CodegenConfig>();
static String configString;
static String debugInfoOptions = "\nThe following additional debug options are available for all codegen targets:" +
"\n -DdebugSwagger prints the swagger specification as interpreted by the codegen" +
"\n -DdebugModels prints models passed to the template engine" +
"\n -DdebugOperations prints operations passed to the template engine" +
"\n -DdebugSupportingFiles prints additional data passed to the template engine";
public static void main(String[] args) {
StringBuilder sb = new StringBuilder();
Options options = new Options();
options.addOption("h", "help", false, "shows this message");
options.addOption("l", "lang", true, "client language to generate.\nAvailable languages include:\n\t[" + configString + "]");
options.addOption("o", "output", true, "where to write the generated files");
options.addOption("i", "input-spec", true, "location of the swagger spec, as URL or file");
options.addOption("t", "template-dir", true, "folder containing the template files");
options.addOption("d", "debug-info", false, "prints additional info for debugging");
options.addOption("a", "auth", true, "adds authorization headers when fetching the swagger definitions remotely. Pass in a URL-encoded string of name:header with a comma separating multiple values");
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);
}
}
}
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();
}
}
}

View File

@@ -0,0 +1,120 @@
package io.swagger.codegen;
import io.swagger.models.Model;
import io.swagger.models.Operation;
import io.swagger.models.Swagger;
import io.swagger.models.auth.SecuritySchemeDefinition;
import io.swagger.models.properties.Property;
import java.util.List;
import java.util.Map;
import java.util.Set;
public interface CodegenConfig {
CodegenType getTag();
String getName();
String getHelp();
Map<String, Object> additionalProperties();
String apiPackage();
String apiFileFolder();
String fileSuffix();
String outputFolder();
String templateDir();
String modelFileFolder();
String modelPackage();
String toApiName(String name);
String toApiVarName(String name);
String toModelName(String name);
String toParamName(String name);
String escapeText(String text);
String escapeReservedWord(String name);
String getTypeDeclaration(Property p);
String getTypeDeclaration(String name);
void processOpts();
List<CliOption> cliOptions();
String generateExamplePath(String path, Operation operation);
Set<String> reservedWords();
List<SupportingFile> supportingFiles();
String getOutputDir();
void setOutputDir(String dir);
CodegenModel fromModel(String name, Model model);
CodegenModel fromModel(String name, Model model, Map<String, Model> allDefinitions);
CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, Map<String, Model> definitions);
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);
String apiFilename(String templateName, String tag);
boolean shouldOverwrite(String filename);
boolean isSkipOverwrite();
void setSkipOverwrite(boolean skipOverwrite);
Map<String, String> supportedLibraries();
void setLibrary(String library);
/**
* Library template (sub-template).
*/
String getLibrary();
}

View File

@@ -0,0 +1,18 @@
package io.swagger.codegen;
import io.swagger.models.ExternalDocs;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class CodegenModel {
public String parent;
public String name, classname, description, classVarName, modelJson;
public String defaultValue;
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>();
public Set<String> imports = new HashSet<String>();
public Boolean hasVars, emptyVars, hasMoreModels, hasEnums;
public ExternalDocs externalDocs;
}

View File

@@ -0,0 +1,39 @@
package io.swagger.codegen;
import java.util.HashMap;
import java.util.Map;
public final class CodegenModelFactory {
private static final Map<CodegenModelType, Class<?>> typeMapping = new HashMap<CodegenModelType, Class<?>>();
/**
* Configure a different implementation class.
*
* @param type the type that shall be replaced
* @param implementation the implementation class must extend the default class and must provide a public no-arg constructor
*/
public static void setTypeMapping(CodegenModelType type, Class<?> implementation) {
if (!type.getDefaultImplementation().isAssignableFrom(implementation)) {
throw new IllegalArgumentException(implementation.getSimpleName() + " doesn't extend " + type.getDefaultImplementation().getSimpleName());
}
try {
implementation.newInstance();
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
typeMapping.put(type, implementation);
}
@SuppressWarnings("unchecked")
public static <T> T newInstance(CodegenModelType type) {
Class<?> classType = typeMapping.get(type);
try {
return (T) (classType != null ? classType : type.getDefaultImplementation()).newInstance();
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -0,0 +1,21 @@
package io.swagger.codegen;
public enum CodegenModelType {
MODEL(CodegenModel.class),
OPERATION(CodegenOperation.class),
PARAMETER(CodegenParameter.class),
PROPERTY(CodegenProperty.class),
RESPONSE(CodegenResponse.class),
SECURITY(CodegenSecurity.class);
private final Class<?> defaultImplementation;
private CodegenModelType(Class<?> defaultImplementation) {
this.defaultImplementation = defaultImplementation;
}
public Class<?> getDefaultImplementation() {
return defaultImplementation;
}
}

View File

@@ -0,0 +1,52 @@
package io.swagger.codegen;
import io.swagger.models.ExternalDocs;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class CodegenOperation {
public final List<CodegenProperty> responseHeaders = new ArrayList<CodegenProperty>();
public Boolean hasConsumes, hasProduces, hasParams, returnTypeIsPrimitive,
returnSimpleType, subresourceOperation, isMapContainer, isListContainer,
hasMore = Boolean.TRUE, isMultipart;
public String path, operationId, returnType, httpMethod, returnBaseType,
returnContainer, summary, notes, baseName, defaultResponse;
public List<Map<String, String>> consumes, produces;
public CodegenParameter bodyParam;
public List<CodegenParameter> allParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> bodyParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> pathParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> queryParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> headerParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> formParams = new ArrayList<CodegenParameter>();
public List<CodegenSecurity> authMethods;
public List<String> tags;
public List<CodegenResponse> responses = new ArrayList<CodegenResponse>();
public Set<String> imports = new HashSet<String>();
public List<Map<String, String>> examples;
public ExternalDocs externalDocs;
private boolean nonempty(List<CodegenParameter> params)
{
return params != null && params.size() > 0;
}
public boolean getHasBodyParam() {
return nonempty(bodyParams);
}
public boolean getHasQueryParams() {
return nonempty(bodyParams);
}
public boolean getHasHeaderParams() {
return nonempty(bodyParams);
}
public boolean getHasPathParams() {
return nonempty(bodyParams);
}
// legacy support
public String nickname;
}

View File

@@ -0,0 +1,56 @@
package io.swagger.codegen;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
public class CodegenParameter {
public Boolean isFormParam, isQueryParam, isPathParam, isHeaderParam,
isCookieParam, isBodyParam, isFile, notFile, hasMore, isContainer, secondaryParam;
public String baseName, paramName, dataType, collectionFormat, description, baseType, defaultValue;
public String jsonSchema;
public boolean isEnum;
public List<String> _enum;
public Map<String, Object> allowableValues;
/**
* 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;
output.defaultValue = this.defaultValue;
output.isEnum = this.isEnum;
if (this._enum != null) {
output._enum = new ArrayList<String>(this._enum);
}
if (this.allowableValues != null) {
output.allowableValues = new HashMap<String, Object>(this.allowableValues);
}
return output;
}
}

View File

@@ -0,0 +1,140 @@
package io.swagger.codegen;
import java.util.List;
import java.util.Map;
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;
public Double maximum;
public Boolean exclusiveMinimum;
public Boolean 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;
public CodegenProperty items;
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final CodegenProperty other = (CodegenProperty) obj;
if ((this.baseName == null) ? (other.baseName != null) : !this.baseName.equals(other.baseName)) {
return false;
}
if ((this.complexType == null) ? (other.complexType != null) : !this.complexType.equals(other.complexType)) {
return false;
}
if ((this.getter == null) ? (other.getter != null) : !this.getter.equals(other.getter)) {
return false;
}
if ((this.setter == null) ? (other.setter != null) : !this.setter.equals(other.setter)) {
return false;
}
if ((this.description == null) ? (other.description != null) : !this.description.equals(other.description)) {
return false;
}
if ((this.datatype == null) ? (other.datatype != null) : !this.datatype.equals(other.datatype)) {
return false;
}
if ((this.datatypeWithEnum == null) ? (other.datatypeWithEnum != null) : !this.datatypeWithEnum.equals(other.datatypeWithEnum)) {
return false;
}
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
if ((this.min == null) ? (other.min != null) : !this.min.equals(other.min)) {
return false;
}
if ((this.max == null) ? (other.max != null) : !this.max.equals(other.max)) {
return false;
}
if ((this.defaultValue == null) ? (other.defaultValue != null) : !this.defaultValue.equals(other.defaultValue)) {
return false;
}
if ((this.baseType == null) ? (other.baseType != null) : !this.baseType.equals(other.baseType)) {
return false;
}
if ((this.containerType == null) ? (other.containerType != null) : !this.containerType.equals(other.containerType)) {
return false;
}
if (this.maxLength != other.maxLength && (this.maxLength == null || !this.maxLength.equals(other.maxLength))) {
return false;
}
if (this.minLength != other.minLength && (this.minLength == null || !this.minLength.equals(other.minLength))) {
return false;
}
if ((this.pattern == null) ? (other.pattern != null) : !this.pattern.equals(other.pattern)) {
return false;
}
if ((this.example == null) ? (other.example != null) : !this.example.equals(other.example)) {
return false;
}
if ((this.jsonSchema == null) ? (other.jsonSchema != null) : !this.jsonSchema.equals(other.jsonSchema)) {
return false;
}
if (this.minimum != other.minimum && (this.minimum == null || !this.minimum.equals(other.minimum))) {
return false;
}
if (this.maximum != other.maximum && (this.maximum == null || !this.maximum.equals(other.maximum))) {
return false;
}
if (this.exclusiveMinimum != other.exclusiveMinimum && (this.exclusiveMinimum == null || !this.exclusiveMinimum.equals(other.exclusiveMinimum))) {
return false;
}
if (this.exclusiveMaximum != other.exclusiveMaximum && (this.exclusiveMaximum == null || !this.exclusiveMaximum.equals(other.exclusiveMaximum))) {
return false;
}
if (this.required != other.required && (this.required == null || !this.required.equals(other.required))) {
return false;
}
if (this.secondaryParam != other.secondaryParam && (this.secondaryParam == null || !this.secondaryParam.equals(other.secondaryParam))) {
return false;
}
if (this.isPrimitiveType != other.isPrimitiveType && (this.isPrimitiveType == null || !this.isPrimitiveType.equals(other.isPrimitiveType))) {
return false;
}
if (this.isContainer != other.isContainer && (this.isContainer == null || !this.isContainer.equals(other.isContainer))) {
return false;
}
if (this.isNotContainer != other.isNotContainer && (this.isNotContainer == null || !this.isNotContainer.equals(other.isNotContainer))) {
return false;
}
if (this.isEnum != other.isEnum) {
return false;
}
if (this._enum != other._enum && (this._enum == null || !this._enum.equals(other._enum))) {
return false;
}
if (this.allowableValues != other.allowableValues && (this.allowableValues == null || !this.allowableValues.equals(other.allowableValues))) {
return false;
}
return true;
}
}

View File

@@ -0,0 +1,24 @@
package io.swagger.codegen;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class CodegenResponse {
public final List<CodegenProperty> headers = new ArrayList<CodegenProperty>();
public String code, message;
public Boolean hasMore;
public List<Map<String, Object>> examples;
public String dataType, baseType, containerType;
public Boolean isDefault;
public Boolean simpleType;
public Boolean primitiveType;
public Boolean isMapContainer;
public Boolean isListContainer;
public Object schema;
public String jsonSchema;
public boolean isWildcard() {
return "0".equals(code) || "default".equals(code);
}
}

View File

@@ -0,0 +1,15 @@
package io.swagger.codegen;
import java.util.Set;
public class CodegenSecurity {
public String name;
public String type;
public Boolean hasMore, isBasic, isOAuth, isApiKey;
// ApiKey specific
public String keyParamName;
public Boolean isKeyInQuery, isKeyInHeader;
// Oauth specific
public String flow, authorizationUrl, tokenUrl;
public Set<String> scopes;
}

View File

@@ -0,0 +1,36 @@
package io.swagger.codegen;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.HashMap;
import java.util.Map;
public enum CodegenType {
CLIENT, SERVER, DOCUMENTATION, OTHER;
private static Map<String, CodegenType> names = new HashMap<String, CodegenType>();
@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
}
static {
names.put("client", CLIENT);
names.put("server", SERVER);
names.put("documentation", DOCUMENTATION);
names.put("other", OTHER);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,607 @@
package io.swagger.codegen;
import static org.apache.commons.lang3.StringUtils.capitalize;
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template;
import io.swagger.codegen.languages.CodeGenStatus;
import io.swagger.models.ComposedModel;
import io.swagger.models.Contact;
import io.swagger.models.Info;
import io.swagger.models.License;
import io.swagger.models.Model;
import io.swagger.models.Operation;
import io.swagger.models.Path;
import io.swagger.models.Swagger;
import io.swagger.models.auth.OAuth2Definition;
import io.swagger.models.auth.SecuritySchemeDefinition;
import io.swagger.models.parameters.Parameter;
import io.swagger.util.Json;
import org.apache.commons.io.IOUtils;
import org.joda.time.DateTime;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class DefaultGenerator extends AbstractGenerator implements Generator {
protected CodegenConfig config;
protected ClientOptInput opts = null;
protected Swagger swagger = null;
public CodeGenStatus status = CodeGenStatus.UNRUN;
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();
config.additionalProperties().put("generatedDate", DateTime.now().toString());
config.additionalProperties().put("generatorClass", config.getClass().toString());
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();
String scheme;
if (swagger.getSchemes() != null && swagger.getSchemes().size() > 0) {
scheme = swagger.getSchemes().get(0).toValue();
} else {
scheme = "https";
}
hostBuilder.append(scheme);
hostBuilder.append("://");
if (swagger.getHost() != null) {
hostBuilder.append(swagger.getHost());
} else {
hostBuilder.append("localhost");
}
if (swagger.getBasePath() != null) {
hostBuilder.append(swagger.getBasePath());
}
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) {
List<String> sortedModelKeys = sortModelsByInheritance(definitions);
for (String name : sortedModelKeys) {
Model model = definitions.get(name);
Map<String, Model> modelMap = new HashMap<String, Model>();
modelMap.put(name, model);
Map<String, Object> models = processModels(config, modelMap, definitions);
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;
if (!config.shouldOverwrite(filename)) {
continue;
}
String templateFile = getFullTemplateFile(config, templateName);
String template = readTemplate(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(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));
operation.put("importPath", config.toApiImport(tag));
processMimeTypes(swagger.getConsumes(), operation, "consumes");
processMimeTypes(swagger.getProduces(), operation, "produces");
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 filename = config.apiFilename(templateName, tag);
if (!config.shouldOverwrite(filename) && new File(filename).exists()) {
continue;
}
String templateFile = getFullTemplateFile(config, templateName);
String template = readTemplate(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(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("scheme", scheme);
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());
List<CodegenSecurity> authMethods = config.fromSecurity(swagger.getSecurityDefinitions());
if (authMethods != null && !authMethods.isEmpty()) {
bundle.put("authMethods", authMethods);
bundle.put("hasAuthMethods", true);
}
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 (!config.shouldOverwrite(outputFilename)) {
continue;
}
String templateFile = getFullTemplateFile(config, support.templateFile);
if (templateFile.endsWith("mustache")) {
String template = readTemplate(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(templateFile);
} catch (Exception e) {
// continue
}
if (in == null) {
in = this.getClass().getClassLoader().getResourceAsStream(getCPResourcePath(templateFile));
}
File outputFile = new File(outputFilename);
OutputStream out = new FileOutputStream(outputFile, false);
if (in != null && out != null) {
System.out.println("writing file " + outputFile);
IOUtils.copy(in, out);
} else {
if (in == null) {
System.out.println("can't open " + templateFile + " for input");
}
if (out == null) {
System.out.println("can't open " + outputFile + " for output");
}
}
files.add(outputFile);
}
}
config.processSwagger(swagger);
status = CodeGenStatus.SUCCESSFUL;
} catch (Exception e) {
status = CodeGenStatus.FAILED;
}
return files;
}
private void processMimeTypes(List<String> mimeTypeList, Map<String, Object> operation, String source) {
if (mimeTypeList != null && mimeTypeList.size() > 0) {
List<Map<String, String>> c = new ArrayList<Map<String, String>>();
int count = 0;
for (String key : mimeTypeList) {
Map<String, String> mediaType = new HashMap<String, String>();
mediaType.put("mediaType", key);
count += 1;
if (count < mimeTypeList.size()) {
mediaType.put("hasMore", "true");
} else {
mediaType.put("hasMore", null);
}
c.add(mediaType);
}
operation.put(source, c);
String flagFieldName = "has" + source.substring(0, 1).toUpperCase() + source.substring(1);
operation.put(flagFieldName, true);
}
}
private List<String> sortModelsByInheritance(final Map<String, Model> definitions) {
List<String> sortedModelKeys = new ArrayList<String>(definitions.keySet());
Comparator<String> cmp = new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
Model model1 = definitions.get(o1);
Model model2 = definitions.get(o2);
int model1InheritanceDepth = getInheritanceDepth(model1);
int model2InheritanceDepth = getInheritanceDepth(model2);
if (model1InheritanceDepth == model2InheritanceDepth) {
return 0;
} else if (model1InheritanceDepth > model2InheritanceDepth) {
return 1;
} else {
return -1;
}
}
private int getInheritanceDepth(Model model) {
int inheritanceDepth = 0;
Model parent = getParent(model);
while (parent != null) {
inheritanceDepth++;
parent = getParent(parent);
}
return inheritanceDepth;
}
private Model getParent(Model model) {
if (model instanceof ComposedModel) {
return definitions.get(((ComposedModel) model).getParent().getReference());
}
return null;
}
};
Collections.sort(sortedModelKeys, cmp);
return sortedModelKeys;
}
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, path);
processOperation(resourcePath, "put", path.getPut(), ops, path);
processOperation(resourcePath, "post", path.getPost(), ops, path);
processOperation(resourcePath, "delete", path.getDelete(), ops, path);
processOperation(resourcePath, "patch", path.getPatch(), ops, path);
processOperation(resourcePath, "options", path.getOptions(), ops, path);
}
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, Path path) {
if (operation != null) {
List<String> tags = operation.getTags();
if (tags == null) {
tags = new ArrayList<String>();
tags.add("default");
}
/*
build up a set of parameter "ids" defined at the operation level
per the swagger 2.0 spec "A unique parameter is defined by a combination of a name and location"
i'm assuming "location" == "in"
*/
Set<String> operationParameters = new HashSet<String>();
if (operation.getParameters() != null) {
for (Parameter parameter : operation.getParameters()) {
operationParameters.add(generateParameterId(parameter));
}
}
//need to propagate path level down to the operation
if(path.getParameters() != null) {
for (Parameter parameter : path.getParameters()) {
//skip propagation if a parameter with the same name is already defined at the operation level
if (!operationParameters.contains(generateParameterId(parameter))) {
operation.addParameter(parameter);
}
}
}
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) {
if(securityDefinition instanceof OAuth2Definition) {
OAuth2Definition oauth2Definition = (OAuth2Definition) securityDefinition;
OAuth2Definition oauth2Operation = new OAuth2Definition();
oauth2Operation.setType(oauth2Definition.getType());
oauth2Operation.setAuthorizationUrl(oauth2Definition.getAuthorizationUrl());
oauth2Operation.setFlow(oauth2Definition.getFlow());
oauth2Operation.setTokenUrl(oauth2Definition.getTokenUrl());
for (String scope : security.values().iterator().next()) {
if (oauth2Definition.getScopes().containsKey(scope)) {
oauth2Operation.addScope(scope, oauth2Definition.getScopes().get(scope));
}
}
authMethods.put(securityName, oauth2Operation);
} else {
authMethods.put(securityName, securityDefinition);
}
}
}
if (!authMethods.isEmpty()) {
co.authMethods = config.fromSecurity(authMethods);
}
}
}
}
private String generateParameterId(Parameter parameter) {
return parameter.getName() + ":" + parameter.getIn();
}
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("pathPrefix", config.toApiVarName(tag));
// check for operationId uniqueness
Set<String> opIds = new HashSet<String>();
int counter = 0;
for (CodegenOperation op : ops) {
String opId = op.nickname;
if (opIds.contains(opId)) {
counter++;
op.nickname += "_" + counter;
}
opIds.add(opId);
}
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);
// add a flag to indicate whether there's any {{import}}
if (imports.size() > 0) {
operations.put("hasImport", true);
}
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, Model> allDefinitions) {
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, allDefinitions);
Map<String, Object> mo = new HashMap<String, Object>();
mo.put("model", cm);
mo.put("importPath", config.toModelImport(key));
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;
}
}

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