Compare commits

..

214 Commits

Author SHA1 Message Date
Tony Tam
55bb1f2a76 [maven-release-plugin] prepare release swagger-codegen_2.9.1-2.0.0 2012-10-11 10:54:09 -07:00
Tony Tam
cb534047ee added class for remote urls to avoid Source.io 2012-10-11 10:49:39 -07:00
Tony Tam
735f5c61b3 updated scala plugin 2012-10-11 10:49:27 -07:00
Tony Tam
73a2fc216e added null checks 2012-10-09 17:53:07 -07:00
Tony Tam
46323fae7c updated to new scalatra allowable values 2012-10-09 09:37:49 -07:00
Tony Tam
7fde848680 Merge branch 'master' of github.com:wordnik/swagger-codegen 2012-10-07 09:49:06 -07:00
Tony Tam
aef4190624 added support for copying directories 2012-10-07 09:46:58 -07:00
Tony Tam
4be326152f removed old ref 2012-10-06 05:49:55 -07:00
Tony Tam
51437245e4 removed old refs 2012-10-05 21:12:31 -07:00
Tony Tam
36f4239c93 removed old refs 2012-10-05 21:08:55 -07:00
Tony Tam
87ebc8a7f3 added java-wordnik-api script 2012-10-06 05:57:58 +02:00
Tony Tam
a4afa9bac2 updated to use case classes, removed swagger-core deps 2012-10-06 05:57:21 +02:00
Tony Tam
7af8b0de18 added java sample 2012-10-06 05:56:52 +02:00
Tony Tam
66dd67597c added readme, sample 2012-09-27 11:38:41 -07:00
Tony Tam
f5fae2df48 added readme, sample 2012-09-27 11:36:52 -07:00
Tony Tam
adbadfe500 added tests 2012-09-27 11:29:18 -07:00
Tony Tam
f7b1e25453 removed comments 2012-09-26 22:23:56 -07:00
Tony Tam
a0b0e7bcb7 added wordnik api script 2012-09-26 22:16:41 -07:00
Tony Tam
6aa5b8f089 added license info 2012-09-26 22:16:31 -07:00
Tony Tam
e9ef124f59 removed old file 2012-09-26 22:16:25 -07:00
Tony Tam
5d2ae3d353 formatting 2012-09-26 22:16:09 -07:00
Tony Tam
031dd20072 removed raw 2012-09-26 22:15:52 -07:00
Tony Tam
67ce62c622 added license info 2012-09-26 22:15:28 -07:00
Tony Tam
b4efa892a1 added objc wordnik sample 2012-09-26 22:15:16 -07:00
Tony Tam
ddc94bcb7c removed comments 2012-09-26 22:12:55 -07:00
Tony Tam
bee14e82b2 updated tests 2012-09-26 22:08:51 -07:00
Tony Tam
4765c56b2a removed raw value 2012-09-26 22:07:41 -07:00
Tony Tam
0b7db0ce2d clean up of formatting 2012-09-26 14:01:57 -07:00
Tony Tam
68436f6cbe removed println 2012-09-26 13:52:50 -07:00
Tony Tam
444de037bc Merge branch 'master' of github.com:wordnik/swagger-codegen 2012-09-26 13:43:47 -07:00
Tony Tam
ce1b4ec347 added contianer check to simplify models 2012-09-26 13:43:38 -07:00
fehguy
b65de5466c added objc, ruby to examples 2012-09-26 13:07:57 -07:00
Tony Tam
58cfacc4cf added ruby sample 2012-09-26 13:02:27 -07:00
Tony Tam
cbb61b1002 updated package 2012-09-26 13:01:52 -07:00
Tony Tam
62c3a70843 added tests back 2012-09-26 11:53:39 -07:00
Tony Tam
e0d8a75441 updated settings 2012-09-26 11:51:20 -07:00
Tony Tam
687eff49a5 updated settings 2012-09-26 11:50:03 -07:00
Tony Tam
9f2a90722b added files 2012-09-26 11:33:19 -07:00
Tony Tam
90b5490f00 added test supporting files 2012-09-26 11:32:31 -07:00
Tony Tam
0bdf466e32 restored files 2012-09-26 11:20:56 -07:00
Tony Tam
a8109930ed moved folders 2012-09-26 11:12:12 -07:00
Tony Tam
a3f08e87fd moved folders 2012-09-26 11:10:14 -07:00
Tony Tam
e65e5a730d moved folders 2012-09-26 11:09:40 -07:00
Tony Tam
8d4afdf5ad fixed string escape, comma encoding 2012-09-26 11:09:24 -07:00
Tony Tam
0a7f8f1055 added api file test 2012-09-25 22:32:21 -07:00
Tony Tam
93b11410a9 updated location for writing api invoker 2012-09-25 22:32:06 -07:00
Tony Tam
667b1cf7a5 fixed default values 2012-09-25 22:31:52 -07:00
Tony Tam
93d81b84dc updated location for writing api invoker 2012-09-25 22:31:39 -07:00
Tony Tam
3f55736f33 detabbed 2012-09-25 22:31:20 -07:00
Tony Tam
91c2af2a98 moved template files to base class 2012-09-25 22:31:08 -07:00
Tony Tam
548b86aef1 fixed package 2012-09-25 22:30:47 -07:00
Tony Tam
7baae391eb added objc files 2012-09-25 22:30:35 -07:00
Tony Tam
22783f8f0a updated package 2012-09-25 22:29:49 -07:00
Tony Tam
55d60aca50 added tests 2012-09-25 22:29:18 -07:00
Tony Tam
dd88a6b0ac added apiToMap test 2012-09-25 11:30:33 -07:00
Tony Tam
b0c15d1c9b added wordnik api sample 2012-09-25 09:21:11 -07:00
Tony Tam
7a379a7b40 fixed whitespace 2012-09-24 23:03:32 -07:00
Tony Tam
674fdff35b added objc sample 2012-09-24 22:59:37 -07:00
fehguy
94919895bc added objc script 2012-09-24 22:57:17 -07:00
Tony Tam
c4e2515c8f Merge branch 'master' of github.com:wordnik/swagger-codegen 2012-09-24 22:55:30 -07:00
Tony Tam
85a0a728de added objc sample 2012-09-24 22:55:17 -07:00
Tony Tam
89ec4010e2 moved path util tests into separate file 2012-09-24 22:52:29 -07:00
Tony Tam
b3d5b49e90 added config for model name prefix 2012-09-24 22:51:59 -07:00
fehguy
dbfeb59820 Update README.md 2012-09-23 20:25:17 -07:00
fehguy
3ce7dbd960 Update README.md 2012-09-23 20:24:20 -07:00
fehguy
cef535f380 Update README.md 2012-09-23 20:23:07 -07:00
Tony Tam
3d1678a087 added ingores for server generator 2012-09-23 20:14:33 -07:00
Tony Tam
ac9cff08d4 updated to match templates 2012-09-23 20:13:05 -07:00
Tony Tam
5671bcf746 formatting 2012-09-23 20:12:44 -07:00
Tony Tam
31fa05599e added python3 runnable 2012-09-23 20:12:26 -07:00
Tony Tam
f20748f0d5 moved to client folder 2012-09-23 20:12:13 -07:00
Tony Tam
155251951b formatting 2012-09-23 20:11:20 -07:00
Tony Tam
e2dbe61adf updated to use swagger 1.1.0 2012-09-23 18:43:14 -07:00
Tony Tam
236a9697ad moved to client folder 2012-09-23 18:41:54 -07:00
Tony Tam
2f93e37645 moved to client folder 2012-09-23 18:41:29 -07:00
Tony Tam
56abce3fbd moved to client folder 2012-09-23 18:41:09 -07:00
Tony Tam
b6b80474b7 moved to client folder 2012-09-23 18:40:47 -07:00
Tony Tam
bab5973dd0 moved to client folder 2012-09-23 18:38:27 -07:00
Tony Tam
a29c580205 updated links in readme 2012-09-23 16:38:32 -07:00
Tony Tam
dec7bdfb82 moved to client dir 2012-09-23 16:35:47 -07:00
Tony Tam
b6a85a4b2e moved to client dir 2012-09-23 16:35:19 -07:00
Tony Tam
611cc6075b moved to client dir 2012-09-23 16:34:59 -07:00
Tony Tam
1e8c4668b7 moved to client folder 2012-09-23 16:26:46 -07:00
Tony Tam
84fb24ada5 updated swagger version dep, added json4s 2012-09-23 16:13:22 -07:00
Tony Tam
1077e48e7e moved to client subdirectory 2012-09-23 16:12:56 -07:00
Tony Tam
ad5d44769b updated script location 2012-09-23 16:12:24 -07:00
Tony Tam
e2c383bd80 made more testable, changed to use case classes + native scala lists 2012-09-23 16:11:47 -07:00
Tony Tam
44d018b642 added scala json mapper 2012-09-23 16:11:16 -07:00
Tony Tam
cec3fa5810 refactored to make more testable 2012-09-23 12:18:22 -07:00
Ivan Porto Carrero
d6cf7fc9aa fix the scalatra sample 2012-09-20 23:38:47 -07:00
Ivan Porto Carrero
256e746364 fix the scalatra sample 2012-09-20 23:38:08 -07:00
Tony Tam
0504f68b41 updated defaults 2012-09-20 23:04:52 -07:00
Tony Tam
21265454ab updated files 2012-09-20 23:04:21 -07:00
Tony Tam
cdc1bbc133 split up for testability 2012-09-20 22:13:09 -07:00
Tony Tam
2579ed311a added tests 2012-09-20 18:01:41 -07:00
Tony Tam
cdfbedb0ea implemented tests 2012-09-20 18:01:27 -07:00
Tony Tam
46249530a3 made extraction logic more testable 2012-09-20 18:01:00 -07:00
Tony Tam
7881786fe8 added java codegen test 2012-09-20 16:04:37 -07:00
Tony Tam
5a9979633c added tests 2012-09-20 14:19:58 -07:00
Tony Tam
3d379c82d1 Merge branch 'master' of github.com:wordnik/swagger-codegen 2012-09-20 14:19:27 -07:00
Tony Tam
77141cd55a added default value 2012-09-20 14:16:51 -07:00
Tony Tam
26bcc80ae3 removed unused method 2012-09-20 14:16:34 -07:00
Tony Tam
59cd5380aa added default value for key 2012-09-20 14:16:20 -07:00
Tony Tam
c3b36c6944 removed overridden methods 2012-09-20 14:15:44 -07:00
Tony Tam
f85c06628b removed overridden methods 2012-09-20 14:15:32 -07:00
Gregg
7c55dddf43 fixed a null pointer exception bug 2012-09-20 12:12:54 -07:00
Tony Tam
374c68d8da fixed return type inside containers 2012-09-12 09:52:14 -07:00
Tony Tam
de1ef1dde3 added looking into 2nd-level objects 2012-09-12 09:51:53 -07:00
Tony Tam
f5a69a5a3b removed println 2012-09-12 06:37:09 -07:00
Tony Tam
5afd4b260a formatting 2012-09-12 06:37:00 -07:00
Tony Tam
b648f84980 moved to samples dir 2012-09-12 06:36:45 -07:00
Tony Tam
bc28ee97da moved to samples dir 2012-09-12 06:36:29 -07:00
Tony Tam
a647576c97 moved to samples dir 2012-09-12 06:35:54 -07:00
Tony Tam
45e4c1a53d added null check, override 2012-09-11 21:32:15 -07:00
Tony Tam
6e4e375589 formatting 2012-09-11 21:31:51 -07:00
Tony Tam
3e5e85509d moved override 2012-09-11 21:28:29 -07:00
Tony Tam
92c0fc5afb added override 2012-09-11 21:27:14 -07:00
Tony Tam
5e90e2a24a reduced type specification 2012-09-11 21:26:27 -07:00
Russell Horton
53c612c13b can't pass JAVA_OPTS directly to Scala compiler 2012-09-10 01:56:02 -07:00
Russell Horton
2a1b1817c5 update ignored files to add generated-code, python compilcation results 2012-09-10 01:55:10 -07:00
Russell Horton
e9a8a8d755 add readme to PHP sample app 2012-09-10 01:53:49 -07:00
Russell Horton
9a6392a758 reorganize and update python sample app 2012-09-10 01:53:13 -07:00
Russell Horton
0fbae2736d add README to python sample app 2012-09-10 01:52:11 -07:00
Russell Horton
85a4aacefa add datetime conversion to python 2012-09-10 01:50:54 -07:00
Russell Horton
5189a85966 add JSON header 2012-09-10 00:35:13 -07:00
Russell Horton
4d15674803 Merge branch 'master' of github.com:wordnik/swagger-codegen 2012-09-10 00:28:08 -07:00
Russell Horton
274b9e7c43 added python3 sample app 2012-09-10 00:25:31 -07:00
Russell Horton
cf53a24271 added python3 support 2012-09-09 23:48:30 -07:00
Russell Horton
4c0cd15a40 updated and restructed PHP petstore sample app 2012-09-09 09:01:42 -07:00
fehguy
6829014393 Update samples/server-generator/scalatra/README.md 2012-09-07 14:18:04 -07:00
fehguy
2647f96c81 Update samples/server-generator/sinatra/README.md 2012-09-07 14:17:06 -07:00
Tony Tam
bbcdee8b28 Merge branch 'master' of github.com:wordnik/swagger-codegen 2012-09-07 14:13:56 -07:00
Tony Tam
8d79437c8d added readme 2012-09-07 14:13:46 -07:00
fehguy
a4c9e26018 Update samples/server-generator/sinatra/output/README.md 2012-09-07 07:39:23 -07:00
Russell Horton
a38fc6eb06 Merge branch 'master' of github.com:wordnik/swagger-codegen 2012-09-06 15:16:34 -07:00
Tony Tam
b6a070e604 added gemfile 2012-09-06 09:19:13 -07:00
Tony Tam
e9146234c7 updated sinatra sample 2012-09-06 09:12:11 -07:00
Tony Tam
1e73944722 added ruby generator stub 2012-09-06 09:11:34 -07:00
Tony Tam
f37f284605 updated to make names friendly 2012-09-06 09:09:47 -07:00
Tony Tam
a7156e6f00 removed println 2012-09-06 09:09:28 -07:00
Tony Tam
7c812c2426 updated script 2012-09-06 09:09:12 -07:00
Tony Tam
2dcfebea98 added sinatra samples 2012-09-05 17:48:37 -07:00
Tony Tam
812213164f added sinatra samples 2012-09-05 17:45:07 -07:00
Tony Tam
4b43e70555 added sinatra samples 2012-09-05 17:43:21 -07:00
Tony Tam
5662891d62 added sinatra server generator 2012-09-05 17:25:01 -07:00
Russell Horton
a7f38e40c4 Merge branch 'master' of github.com:wordnik/swagger-codegen 2012-09-01 22:47:19 -07:00
Tony Tam
66f98ebaa8 updated readme 2012-08-29 17:52:40 -07:00
Tony Tam
3c53c13685 added readme 2012-08-29 17:49:50 -07:00
Tony Tam
ae271fb57a reverted basePart injection 2012-08-29 17:26:41 -07:00
Tony Tam
53721239f4 added main app, now validates with 51756c1d8e 2012-08-29 16:57:47 -07:00
Tony Tam
6636acf2d3 updated with dataType in paths, now validates 2012-08-29 16:56:13 -07:00
Tony Tam
b7ed61b8f9 updated sample 2012-08-29 16:55:40 -07:00
Tony Tam
02b5a929ac added main app 2012-08-29 16:54:48 -07:00
Tony Tam
5482cb7822 updated to support raw swagger types 2012-08-29 16:54:14 -07:00
Tony Tam
6113826180 updated versions 2012-08-29 10:40:12 -07:00
Tony Tam
de1a4059b1 updated some formatting 2012-08-29 09:32:12 -07:00
Tony Tam
267ecec8f2 removed unneeded files 2012-08-29 09:28:41 -07:00
Tony Tam
07addb366e added scalatra server generator (WIP) 2012-08-29 09:27:55 -07:00
Tony Tam
21848c3cf3 updated swagger-core version 2012-08-29 09:25:49 -07:00
Tony Tam
45745f6f14 formatting, added more params for server generators 2012-08-29 09:25:30 -07:00
Tony Tam
f7a929bd02 renamed template dir 2012-08-28 16:52:18 -07:00
Tony Tam
cb55d38a38 formatting 2012-08-28 16:31:24 -07:00
Tony Tam
5eb1372e08 updated license 2012-08-28 16:30:51 -07:00
Tony Tam
73b15dce53 excluding default models 2012-08-28 16:30:36 -07:00
Tony Tam
9227d7b046 added null check for item refs 2012-08-28 15:53:12 -07:00
Russell Horton
de0dffe83f cast to string for query param replacements in case ids are submitted as int, long, etc 2012-08-28 15:18:21 -07:00
Russell Horton
3550309544 faciliatate serialization to JSON of deeply nested objects 2012-08-28 15:17:25 -07:00
Russell Horton
153de3077e account for possibly empty / null list-type attributes 2012-08-28 15:16:28 -07:00
Russell Horton
bbb7e7138c added DateTime support to PHP 2012-08-28 15:15:53 -07:00
Russell Horton
c777640f04 add lowercase long field map 2012-08-28 13:55:47 -07:00
Tony Tam
6df5008310 changed to use class instead of script 2012-08-28 01:01:46 -07:00
Tony Tam
37efc32374 changed to use class instead of script 2012-08-28 01:00:24 -07:00
Tony Tam
275098a8ef updated template 2012-08-28 00:58:04 -07:00
Tony Tam
52a9195411 added invoker param 2012-08-28 00:57:49 -07:00
Tony Tam
5f81594f03 updated instructions 2012-08-27 21:15:05 -07:00
Tony Tam
f295fe698a added readme 2012-08-27 21:14:05 -07:00
Tony Tam
8805a7acbb added sample, README 2012-08-27 21:05:03 -07:00
Tony Tam
b4485b1196 added server generator 2012-08-27 20:33:10 -07:00
Tony Tam
a929fce3a0 renamed method 2012-08-27 20:24:58 -07:00
Tony Tam
f4c8dd9dec added invoker package, updated writing supporting files 2012-08-27 17:30:25 -07:00
Tony Tam
79f2be422b made prettier 2012-08-25 18:20:20 -05:00
Tony Tam
b92a84eed8 added notes about generating your own files 2012-08-24 22:41:35 -07:00
Tony Tam
a50f0627f9 updated instructions 2012-08-24 20:42:28 -07:00
Tony Tam
d6f5231e93 updated instructions, package 2012-08-24 20:32:28 -07:00
Tony Tam
6a9ba75640 added package 2012-08-24 20:32:15 -07:00
Tony Tam
95f6b00704 added flash generator 2012-08-24 19:59:19 -07:00
Tony Tam
00fce59737 added php codegen 2012-08-24 19:49:23 -07:00
Tony Tam
384a549807 added python files 2012-08-24 19:39:34 -07:00
Tony Tam
af41b43c56 added validator documentation, script 2012-08-24 19:33:23 -07:00
Tony Tam
b146310c1a fixed path in readme 2012-08-24 19:24:06 -07:00
Tony Tam
7138a3f8c2 fixed path in readme 2012-08-24 19:23:39 -07:00
Tony Tam
038402abb3 added java petstore sample 2012-08-24 19:21:40 -07:00
Tony Tam
52587de715 added license info 2012-08-24 18:37:03 -07:00
Tony Tam
5773626d53 added petstore sample 2012-08-24 18:31:09 -07:00
Tony Tam
2d45c80415 added petstore sample 2012-08-24 18:29:06 -07:00
Tony Tam
432965fa0e changed output directory 2012-08-24 18:22:35 -07:00
Tony Tam
63f2075410 updated invoker for quoted strings 2012-08-24 18:22:24 -07:00
Tony Tam
f1c9e6c64e added file 2012-08-24 15:32:50 -07:00
Tony Tam
05ccb75ebf updated pom.xml 2012-08-24 15:31:49 -07:00
Tony Tam
58ce2a1298 updated to 2.0 2012-08-24 15:29:26 -07:00
Tony Tam
7e823f879e updated to 2.0 2012-08-24 15:27:27 -07:00
Tony Tam
9e3fc6603f updated to 2.0 2012-08-24 15:27:18 -07:00
Tony Tam
aa162b9393 updated to 2.0 2012-08-24 15:27:08 -07:00
fehguy
a33df3ac33 added license info 2012-07-30 09:50:35 -07:00
fehguy
c0aecff3dc Merge pull request #10 from marek-stoj/master
added support for C# (thanks @marek-stoj)
2012-05-14 08:50:14 -07:00
Marek Stój
43d15d4d00 Fixed CSharpDataTypeMappingProvider for string type. 2012-05-12 10:56:59 +02:00
Marek Stój
2633eb77e2 Fix in readme.md. 2012-05-12 09:41:49 +02:00
Marek Stój
094a1f2040 Added support for the C# language. 2012-05-12 09:39:52 +02:00
mrjf
fc7c8c6a8f Merge pull request #9 from gthomas/master
Fix python VersionChecker template
2012-05-08 17:29:09 -07:00
Grant Thomas
404c5ab8c3 Really fix indentation. Github browser-editor fail\! 2012-05-08 07:05:12 -07:00
Grant Thomas
6db5c15037 Ensure correct indentation. 2012-05-08 07:01:48 -07:00
Grant Thomas
94ab81c1a2 Now it is Python! 2012-05-08 06:57:42 -07:00
Tony Tam
e2d8f97e13 removed repositories 2012-04-12 17:50:43 -07:00
Tony Tam
9be7a3f53c [maven-release-plugin] prepare for next development iteration 2012-04-12 17:41:22 -07:00
658 changed files with 44933 additions and 14396 deletions

12
.gitignore vendored
View File

@@ -9,5 +9,17 @@ version.properties
lib/*
build/*
generated-files/*
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

307
README.md
View File

@@ -1,190 +1,171 @@
# Swagger Client Code-Generator
## Overview
This is a project to build the Swagger code-gen library which can be used to automatically
generate client libraries from a Swagger-compliant server. It also contains a testing
framework which allows the client library to query an API server and validate expected results
You can find out more about both the spec and the framework at http://swagger.wordnik.com. For
more information about Wordnik's APIs, please visit http://developer.wordnik.com.
This is the swagger codegen project, which allows generation of client libraries automatically from a
Swagger-compliant server. You can find out more about both the spec and the framework at
http://swagger.wordnik.com. For more information about Wordnik's APIs, please visit http://developer.wordnik.com.
### Prerequisites
You need the following installed and available in your $PATH:
<li>- Java 1.6 or greater (http://java.oracle.com)
* [Java 1.6](http://java.oracle.com)
<li>- Apache ant 1.7 or greater (http://ant.apache.org/)
* [Apache maven 3.0.3 or greater](http://maven.apache.org/)
<li>- Scala 2.x or greater (http://www.scala-lang.org/downloads)
* [Scala](http://www.scala-lang.org)
You also need to set an environment variable for SCALA_HOME:
You also need to add the scala binary to your PATH.
<pre>
export SCALA_HOME={PATH_TO_YOUR_SCALA_DEPLOYMENT}
</pre>
### To generate a sample client library
You can build a client against Wordnik's [petstore](http://petstore.swagger.wordnik.com) API as follows:
```
./bin/scala-petstore.sh
```
This will run the script in [samples/client/petstore/ScalaPetstoreCodegen.scala](https://github.com/wordnik/swagger-codegen/blob/master/samples/client/petstore/scala/ScalaPetstoreCodegen.scala) and create the client. You can then
compile and run the client, as well as unit tests against it:
```
cd samples/client/petstore/scala
mvn package
```
Other languages have petstore samples, too:
```
./bin/flash-petstore.sh
./bin/java-petstore.sh
./bin/objc-petstore.sh
./bin/php-petstore.sh
./bin/python-petstore.sh
./bin/python3-petstore.sh
./bin/ruby-petstore.sh
```
### Generating libraries from your server
It's just as easy--you can either run the default generators:
```
./bin/runscala.sh com.wordnik.swagger.codegen.BasicScalaGenerator http://petstore.swagger.wordnik.com/api/resources.json special-key
```
Replace `Scala` with `Flash`, `Java`, `Objc`, `PHP`, `Python`, `Python3`, `Ruby`.
You will probably want to override some of the defaults--like packages, etc. For doing this, just create a scala
script with the overrides you want. Follow [ScalaPetstoreCodegen](https://github.com/wordnik/swagger-codegen/blob/master/samples/client/petstore/scala/ScalaPetstoreCodegen.scala) as an example:
For example, create `src/main/scala/MyCodegen.scala` with these contents:
```scala
import com.wordnik.swagger.codegen.BasicScalaGenerator
object MyCodegen extends BasicScalaGenerator {
def main(args: Array[String]) = generateClient(args)
// location of templates
override def templateDir = "scala"
// where to write generated code
override def destinationDir = "client/scala/src/main/scala"
// api invoker package
override def invokerPackage = "com.myapi.client"
// package for models
override def modelPackage = Some("com.myapi.client.model")
// package for api classes
override def apiPackage = Some("com.myapi.client.api")
// supporting classes
override def supportingFiles = List(
("apiInvoker.mustache", destinationDir + java.io.File.separator + packageName.replaceAll("\\.", java.io.File.separator), "ApiInvoker.scala"),
("pom.mustache", destinationDir, "pom.xml")
)
}
```
Now you can generate your client like this:
```
./bin/runscala.sh src/main/scala/MyCodegen.scala http://my.api.com/resources.json super-secret-key
```
w00t! Thanks to the scala interpretor, you didn't even need to recompile.
### Modifying the client library format
Don't like the default swagger client syntax? Want a different language supported? No problem! Swagger codegen
processes mustache templates with the [scalate](http://scalate.fusesource.org/) engine. You can modify our templates or
make your own.
You can look at `src/main/resources/${your-language}` for examples. To make your own templates, create your own files
and override the `templateDir` in your script to point to the right place. It actually is that easy.
### Where is Javascript???
See our [javascript library](http://github.com/wordnik/swagger.js)--it's completely dynamic and doesn't require
static code generation.
#### Generating a client from flat files (i.e. no remote server calls)
If you don't want to call your server, you can save the swagger spec files into a directory and pass an argument
to the code generator like this:
```
-DfileMap=/path/to/files
```
Or for example:
```
./bin/java-petstore-filemap.sh
```
Which simple passes `-DfileMap=src/test/resources/petstore` as an argument. Great for creating libraries on your
ci server... or while coding on an airplane.
### Validating your swagger spec
You can use the validation tool to see that your server is creating a proper spec file. If you want to learn
more about the spec file and format, please see [swagger-core](https://github.com/wordnik/swagger-core/wiki). This
tool will read the server and generate a report of any violations of the spec. If there are violations, the
client codegen and ui may not work correctly.
To validate an api and write output to ./swagger-errors.html:
```
./bin/validate.sh http://petstore.swagger.wordnik.com/api/resources.json "" ./swagger-errors.html
```
### To build the codegen library
You can build the client with the following:
This will create the swagger-codegen library from source.
````
```
mvn package
````
```
### Other languages
#### scala
<pre>
./bin/generate-scala-lib.sh http://petstore.swagger.wordnik.com/api "" "client" "generated-files"
</pre>
#### javascript
<pre>
./bin/generate-js-lib.sh http://petstore.swagger.wordnik.com/api "" "" "generated-files"
</pre>
#### actionscript
<pre>
./bin/generate-as3-lib.sh http://petstore.swagger.wordnik.com/api "" "client" "generated-files"
</pre>
#### PHP
<pre>
./bin/generate-php-lib.sh http://petstore.swagger.wordnik.com/api "" "client" "generated-files"
</pre>
#### Python
<pre>
./bin/generate-python-lib.sh http://petstore.swagger.wordnik.com/api "" "client" "generated-files"
</pre>
The main class for the generator is at src/main/java/com/wordnik/swagger/codegen/config/java/JavaLibCodeGen.java
The code-gen uses the antlr string template library for generating the output files, please look at
http://www.stringtemplate.org for details on the antlr framework.
The Wordnik team is working on generating libraries for Ruby, ActionScript 3, Android, PHP and JavaScript, which will be open-sourced in the coming weeks
### The Swagger client test framework
The testing framework helps you to test Swagger generated client libraries using declarative test scripts. The same
scripts can be used to test client libraries in different languages. The framework can be used for client and server
regression testing.
For Example, first build the client library from the sample app:
<pre>
./bin/generate-java-lib.sh http://petstore.swagger.wordnik.com/api/ special-key com.foo.mydriver generated-files
</pre>
Use the sample build script to build a jar from the client files:
<pre>
cp conf/java/sample/*.xml ./generated-files
cd generated-files
ant
</pre>
This creates a complete client library jar. You can now run the tests:
<pre>
./bin/test-java-lib.sh http://petstore.swagger.wordnik.com/api/ special-key conf/java/sample/lib-test-script.json \
conf/java/sample/lib-test-data.json com.foo.mydriver.model.TestData com.foo.mydriver.api \
generated-files/build/swagger-sample-java-lib-1.0.jar
Summary --> Total Test Cases: 9 Failed Test Cases: 0
Details:
1.1 : Create User : passed
1.2 : Login User : passed
1.3 : Find user by name : passed
1.4 : Delete user by name : passed
2.1 : Add pet : passed
2.2 : Find pet by id : passed
2.3 : Find pet by status : passed
3.1 : Find order by id : passed
3.2 : Place order : passed
</pre>
In detail, there are two components in the test framework:
<li>- Test Script
<li>- Test Data
Note! The templates are included in the library generated. If you want to modify the templates, you'll need to
either repackage the library OR modify your codegen script to use a file path!
#### Test script details
### To build a server stub
Test script is written in JSON structure. The JSON consists of following elements:
You can also use the codegen to generate a server for a couple different frameworks. Take a look here:
##### Resources. This is a list of resources considered in the test. Each resource object consists of following properties:
* [javascript node.js Server generator](https://github.com/wordnik/swagger-codegen/tree/master/samples/server-generator/node)
<li>- id: a unique test script ID
* [ruby sinatra generator](https://github.com/wordnik/swagger-codegen/tree/master/samples/server-generator/sinatra)
<li>- name: name of the resource, used in displaying the test result
* [scala sinatra generator](https://github.com/wordnik/swagger-codegen/tree/master/samples/server-generator/scalatra)
<li>- httpMethod: HTTP method used in invoking this resource
License
-------
<li>- path: path of the resource
Copyright 2012 Wordnik, Inc.
<li>- suggested method name: By default this refers to method name of the API in resource classes
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)
##### Test suites. This is a logical way of grouping related test cases. Each test suite consists of following properties:
<li>- id: unique id of the test script, displayed in the test report
<li>- name: name of the test suite. Used in test report
<li>- test cases: List of test cases with in each suite. Each test case consists of following properties:
<li>- id: unique with in the test suite. Used for reporting and tracking output data
<li>- name: Name of the test case
<li>- resource id: references the resource id in the resources section
<li>- input: Input is a JSON object with each property in the object map to query, path or post parameters.
For POST data, the name of the property should be supplied as postData. The value for each property can refer
to input file or output from previous test cases or actual values.
<li>- assertions: list of assertions that needs to be evaluated after test case is executed.
Each assertion contains
<li>- actual output, specified with reference to output of the current test case using syntax similar to object graph navigation language
<li>- condition , support values are equal (==), not equal (!=), less than (<), lesser than or equal (<=), greater than (>), greater than or equal (>=)
<li>- expected output. Specified using actual values or values referring previous outputs or input data file
Test data file is documented using a Test Data Object which is generated as part of Java client library code-gen. This
class provides list getters and setters for each model object available in the resource description. It is called "TestData"
and it is available in model package of the java library code generation output.
Chaining results of test cases:
<li>- Reference to data in input file is done with prefix <pre>${input.</pre>, followed by object graph navigation syntax.
Example: to refer a first user object in test data file use the syntax <pre>${input.userList[0]}</pre>
<li>- To refer a individual property of user object use the syntax <pre>${input.userList[0].username}</pre>
<li>- Reference to output of test cases is done using combination test case path and OGNL. Reference to test cases output
is prefixed with <pre>${output.</pre>
<li>- To refer an output of test case 1 in test suite 2, the syntax will be <pre>${output(1.2)}</pre>. Individual attributes can
be accessed using OGNL syntax. Example: <pre>${output(1.1).username}</pre>
#### Reporting Test Results
A Summary will be reported with each test run. For instance:
<pre>
Sample: "Summary --> Total Test Cases: 9 Failed Test Cases: 0"
</pre>
In detail section each test case and its status (passed/failed) are reported. Failures include an exception trace. Test case path is
combination of test suite id and test case id separated by "."
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.

6
bin/flash-petstore.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
scala $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS -cp $CLASSPATH "$@" samples/client/petstore/flash/FlashPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/resources.json special-key

View File

@@ -1,23 +0,0 @@
#!/bin/bash
if [ $# -ne 4 ]
then
echo "Error in $0 - Invalid Argument Count "
echo "Syntax: $0 location_of_service api_key package_name library_root"
exit
fi
echo "" > classpath.txt
for file in `ls target/lib`;
do echo -n 'target/lib/' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
for file in `ls target/*.jar`;
do echo -n '' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
export CLASSPATH=$(cat classpath.txt)
export JAVA_OPTS="${JAVA_OPTS} -Dproperty=Xmx2g"
java $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS $JAVA_OPTS -cp $CLASSPATH com.wordnik.swagger.codegen.config.as3.As3LibCodeGen "$@"

View File

@@ -1,23 +0,0 @@
#!/bin/bash
if [ $# -ne 4 ]
then
echo "Error in $0 - Invalid Argument Count"
echo "Syntax: $0 location_of_service api_key package_name library_root"
exit
fi
echo "" > classpath.txt
for file in `ls target/lib`;
do echo -n 'target/lib/' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
for file in `ls target/*.jar`;
do echo -n '' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
export CLASSPATH=$(cat classpath.txt)
export JAVA_OPTS="${JAVA_OPTS} -Dproperty=Xmx2g"
java $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS $JAVA_OPTS -cp $CLASSPATH com.wordnik.swagger.codegen.config.java.JavaLibCodeGen "$@"

View File

@@ -1,23 +0,0 @@
#!/bin/bash
if [ $# -ne 3 ]
then
echo "Error in $0 - Invalid Argument Count "
echo "Syntax: $0 location_of_service api_key library_root"
exit
fi
echo "" > classpath.txt
for file in `ls target/lib`;
do echo -n 'target/lib/' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
for file in `ls target/*.jar`;
do echo -n '' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
export CLASSPATH=$(cat classpath.txt)
export JAVA_OPTS="${JAVA_OPTS} -Dproperty=Xmx2g"
java $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS $JAVA_OPTS -cp $CLASSPATH com.wordnik.swagger.codegen.config.js.JSLibCodeGen "$@"

View File

@@ -1,23 +0,0 @@
#!/bin/bash
if [ $# -ne 4 ]
then
echo "Error in $0 - Invalid Argument Count"
echo "Syntax: $0 location_of_service api_key package_name library_root"
exit
fi
echo "" > classpath.txt
for file in `ls target/lib`;
do echo -n 'target/lib/' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
for file in `ls target/*.jar`;
do echo -n '' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
export CLASSPATH=$(cat classpath.txt)
export JAVA_OPTS="${JAVA_OPTS} -Dproperty=Xmx2g"
java $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS $JAVA_OPTS -cp $CLASSPATH com.wordnik.swagger.codegen.config.php.PHPLibCodeGen "$@"

View File

@@ -1,23 +0,0 @@
#!/bin/bash
if [ $# -ne 4 ]
then
echo "Error in $0 - Invalid Argument Count"
echo "Syntax: $0 location_of_service api_key package_name library_root"
exit
fi
echo "" > classpath.txt
for file in `ls target/lib`;
do echo -n 'target/lib/' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
for file in `ls target/*.jar`;
do echo -n '' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
export CLASSPATH=$(cat classpath.txt)
export JAVA_OPTS="${JAVA_OPTS} -Dproperty=Xmx2g"
java $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS $JAVA_OPTS -cp $CLASSPATH com.wordnik.swagger.codegen.config.python.PythonLibCodeGen "$@"

View File

@@ -1,23 +0,0 @@
#!/bin/bash
if [ $# -ne 4 ]
then
echo "Error in $0 - Invalid Argument Count"
echo "Syntax: $0 location_of_service api_key package_name library_root"
exit
fi
echo "" > classpath.txt
for file in `ls target/lib`;
do echo -n 'target/lib/' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
for file in `ls target/*.jar`;
do echo -n '' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
export CLASSPATH=$(cat classpath.txt)
export JAVA_OPTS="${JAVA_OPTS} -Dproperty=Xmx2g"
scala $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS $JAVA_OPTS -cp $CLASSPATH com.wordnik.swagger.codegen.config.scala.ScalaLibCodeGen "$@"

6
bin/java-petstore-filemap.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties -DfileMap=src/test/resources/petstore "
scala $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS -cp $CLASSPATH "$@" samples/client/petstore/java/JavaPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/resources.json special-key

6
bin/java-petstore.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
scala $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS -cp $CLASSPATH "$@" samples/client/petstore/java/JavaPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/resources.json special-key

6
bin/java-wordnik-api.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties -DfileMap=samples/client/wordnik-api/spec-files"
scala $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS -cp $CLASSPATH "$@" samples/client/wordnik-api/java/JavaWordnikApiCodegen.scala http://api.wordnik.com/v4/resources.json

5
bin/objc-petstore.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export CLASSPATH="$DIR/../target/*:$DIR/../target/lib/*"
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
scala $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS -cp $CLASSPATH "$@" samples/client/petstore/objc/ObjcPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/resources.json special-key

6
bin/objc-wordnik-api.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties -DfileMap=samples/client/wordnik-api/spec-files"
scala $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS -cp $CLASSPATH "$@" samples/client/wordnik-api/objc/ObjcWordnikApiCodegen.scala http://api.wordnik.com/v4/resources.json

6
bin/php-petstore.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
scala $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS -cp $CLASSPATH "$@" samples/client/petstore/php/PHPPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/resources.json special-key

6
bin/python-petstore.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
scala $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS -cp $CLASSPATH "$@" samples/client/petstore/python/PythonPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/resources.json special-key

6
bin/python3-petstore.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
scala $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS -cp $CLASSPATH "$@" samples/client/petstore/python3/Python3PetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/resources.json special-key

19
bin/ruby-petstore.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/bash
echo "" > classpath.txt
for file in `ls target/lib`;
do echo -n 'target/lib/' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
for file in `ls target/*.jar`;
do echo -n '' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
export CLASSPATH=$(cat classpath.txt)
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
scala $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS -cp $CLASSPATH "$@" samples/client/petstore/ruby/RubyPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/resources.json special-key

View File

@@ -1,18 +0,0 @@
#!/bin/bash
echo "" > classpath.txt
for file in `ls target/lib`;
do echo -n 'target/lib/' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
for file in `ls target/*.jar`;
do echo -n '' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
echo -n 'build/main/java' >> classpath.txt;
echo -n ':' >> classpath.txt;
#first argument to the command line script give location of the library jar file
export CLASSPATH=$(cat classpath.txt)$2
export JAVA_OPTS="${JAVA_OPTS} -DrulePath=data -Dproperty=Xmx2g -DloggerPath=$BUILD_COMMON/test-config/log4j.properties"
java $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS $JAVA_OPTS -cp $CLASSPATH "$@" com.wordnik.swagger.api ../swagger-sample-app/sdk-libs/bin/AirExecutorApp-app.xml "/Applications/Adobe Flash Builder 4/sdks/4.1.0"

View File

@@ -1,17 +0,0 @@
#!/bin/bash
echo "" > classpath.txt
for file in `ls lib`;
do echo -n 'lib/' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
for file in `ls build`;
do echo -n 'build/' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
export CLASSPATH=$(cat classpath.txt)
export JAVA_OPTS="${JAVA_OPTS} -DrulePath=data -Dproperty=Xmx2g -DloggerPath=$BUILD_COMMON/test-config/log4j.properties"
java $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS $JAVA_OPTS -cp $CLASSPATH "$@"

View File

@@ -1,18 +0,0 @@
#!/bin/bash
echo "" > classpath.txt
echo "" > classpath.txt
for file in `ls target/lib`;
do echo -n 'target/lib/' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
for file in `ls target/*.jar`;
do echo -n '' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
#first argument to the command line script give location of the library jar file
export CLASSPATH=$(cat classpath.txt)$2
export JAVA_OPTS="${JAVA_OPTS} -DrulePath=data -Dproperty=Xmx2g -DloggerPath=$BUILD_COMMON/test-config/log4j.properties"
java $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS $JAVA_OPTS -cp $CLASSPATH "$@"

View File

@@ -1,17 +1,5 @@
#!/bin/bash
echo "" > classpath.txt
for file in `ls lib`;
do echo -n 'lib/' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
for file in `ls build`;
do echo -n 'build/' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
export CLASSPATH=$(cat classpath.txt)
export JAVA_OPTS="${JAVA_OPTS} -DrulePath=data -Dproperty=Xmx2g -DloggerPath=$BUILD_COMMON/test-config/log4j.properties"
scala $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS $JAVA_OPTS -cp $CLASSPATH "$@"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
export JAVA_OPTS="${JAVA_OPTS} -DXmx4096M"
scala $WORDNIK_OPTS -cp $CLASSPATH "$@"

6
bin/scala-petstore.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
scala $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS -cp $CLASSPATH "$@" samples/client/petstore/scala/ScalaPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/resources.json special-key

6
bin/scala-wordnik-api.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties -DfileMap=samples/client/wordnik-api/spec-files"
scala $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS -cp $CLASSPATH "$@" samples/client/wordnik-api/scala/ScalaWordnikApiCodegen.scala http://api.wordnik.com/v4/resources.json

View File

@@ -1,23 +0,0 @@
#!/bin/bash
if [ $# -ne 7 ]
then
echo "Error in $0 - Invalid Argument Count - expected 7 but has "
echo "$#"
echo "Syntax: $0 location_of_service api_key test_script_location test_data_location test_data_class_name api_classes_package_name location_of_client_library"
exit
fi
echo "" > classpath.txt
for file in `ls target/lib`;
do echo -n 'target/lib/' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
for file in `ls target/*.jar`;
do echo -n '' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
export CLASSPATH=$(cat classpath.txt)$7
echo $CLASSPATH
export JAVA_OPTS="${JAVA_OPTS} -Dproperty=Xmx2g "
java $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS $JAVA_OPTS -cp $CLASSPATH com.wordnik.swagger.testframework.APITestRunner "$@" AS3

View File

@@ -1,22 +0,0 @@
#!/bin/bash
if [ $# -ne 7 ]
then
echo "Error in $0 - Invalid Argument Count"
echo "Syntax: $0 location_of_client_library location_of_service api_key test_script_location test_data_location test_data_class_name api_classes_package_name"
exit
fi
echo "" > classpath.txt
for file in `ls target/lib`;
do echo -n 'target/lib/' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
for file in `ls target/*.jar`;
do echo -n '' >> classpath.txt;
echo -n $file >> classpath.txt;
echo -n ':' >> classpath.txt;
done
export CLASSPATH=$(cat classpath.txt)$7
echo $CLASSPATH
export JAVA_OPTS="${JAVA_OPTS} -Dproperty=Xmx2g "
java $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS $JAVA_OPTS -cp $CLASSPATH com.wordnik.swagger.testframework.APITestRunner "$@" JAVA

6
bin/validate.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
scala $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS -cp $CLASSPATH com.wordnik.swagger.codegen.spec.Validator "$@"

View File

@@ -1,27 +0,0 @@
{
"apiUrl":"http://localhost:8002/api/",
"apiKey":"special-key",
"defaultServiceBaseClass":"SwaggerApi",
"defaultModelBaseClass":"Object",
"serviceBaseClasses":{},
"defaultModelImports":[],
"defaultServiceImports":[],
"modelPackageName":"com.wordnik.swagger.model",
"apiPackageName":"com.wordnik.swagger.api",
"ignoreMethods":[],
"ignoreModels":[],
"outputDirectory":"../swagger-sample-app/sdk-libs/src/main/as3/com/wordnik/swagger/",
"libraryHome":"../swagger-sample-app/sdk-libs"
}

View File

@@ -1,42 +0,0 @@
{
"userList":[
{
"username":"testuser1",
"password":"password1",
"email":"test1@dummy.com"
},
{
"username":"testuser2",
"password":"password2",
"email":"test2@dummy.com"
}
],
"petList":[
{
"id":101,
"name":"pet1",
"photoUrls":["url1","url2"],
"tags":[
{
"id":1,
"name":"tag1"
},
{
"id":2,
"name":"tag2"
}
],
"status":"available",
"category":{"id":1,"name":"cat1"}
}
],
"orderList":[
{
"id":101,
"petId":1,
"quantity":1,
"status":"placed",
"shipDate":13456789
}
]
}

View File

@@ -1,265 +0,0 @@
{
"resources" : [
{
"id" : 1,
"name" : "Find Per by Id",
"httpMethod" : "GET",
"path" : "/pet.{format}/{petId}",
"suggestedMethodName" : "getPetById"
},
{
"id" : 2,
"name" : "Find pets by status",
"httpMethod" : "GET",
"path" : "/pet.{format}/findByStatus",
"suggestedMethodName" : "findPetsByStatus"
},
{
"id" : 3,
"name" : "Find pets by tags",
"httpMethod" : "GET",
"path" : "/pet.{format}/findByTags",
"suggestedMethodName" : "findPetsByTags"
},
{
"id" : 4,
"name" : "Add a pet",
"httpMethod" : "POST",
"path" : "/pet.{format}",
"suggestedMethodName" : "addPet"
},
{
"id" : 5,
"name" : "Update a pet",
"httpMethod" : "PUT",
"path" : "/pet.{format}",
"suggestedMethodName" : "updatePet"
},
{
"id" : 6,
"name" : "Create user",
"httpMethod" : "POST",
"path" : "/user.{format}",
"suggestedMethodName" : "createUser"
},
{
"id" : 7,
"name" : "Update user",
"httpMethod" : "PUT",
"path" : "/user.{format}/{username}",
"suggestedMethodName" : "updateUser"
},
{
"id" : 8,
"name" : "Delete user",
"httpMethod" : "DELETE",
"path" : "/user.{format}/{username}",
"suggestedMethodName" : "deleteUser"
},
{
"id" : 9,
"name" : "Get user by user name",
"httpMethod" : "GET",
"path" : "/user.{format}/{username}",
"suggestedMethodName" : "getUserByName"
},
{
"id" : 10,
"name" : "Login",
"httpMethod" : "GET",
"path" : "/user.{format}/login",
"suggestedMethodName" : "loginUser"
},
{
"id" : 11,
"name" : "Logout",
"httpMethod" : "GET",
"path" : "/user.{format}/logout",
"suggestedMethodName" : "logoutUser"
},
{
"id" : 12,
"name" : "Find order by id",
"httpMethod" : "GET",
"path" : "/store.{format}/order/{orderId}",
"suggestedMethodName" : "getOrderById"
},
{
"id" : 13,
"name" : "Delete order by id",
"httpMethod" : "DELETE",
"path" : "/store.{format}/order/{orderId}",
"suggestedMethodName" : "deleteOrder"
},
{
"id" : 14,
"name" : "Create order",
"httpMethod" : "POST",
"path" : "/store.{format}/order",
"suggestedMethodName" : "placeOrder"
}
],
"testSuites" : [
{
"id" : 1,
"name" : "Test User service related APIs",
"testCases" : [
{
"name" : "Create User",
"id" : 1,
"resourceId" : 6,
"input" : {
"postData":"${input.userList[0]}"
},
"assertions" : [
{
"actualOutput" : "${output(1.1)}",
"condition" : "!=",
"expectedOutput" : "EXCEPTION"
}
]
},
{
"name" : "Login User",
"id" : 2,
"resourceId" : 10,
"input" : {
"username":"${input.userList[0].username}",
"password":"${input.userList[0].password}"
},
"assertions" : [
{
"actualOutput" : "${output(1.2)}",
"condition" : "!=",
"expectedOutput" : "EXCEPTION"
}
]
},
{
"name" : "Find user by name",
"id" : 3,
"resourceId" : 9,
"input" : {
"username":"${input.userList[0].username}"
},
"assertions" : [
{
"actualOutput" : "${output(1.3).username}",
"condition" : "==",
"expectedOutput" : "${input.userList[0].username}"
}
]
},
{
"name" : "Delete user by name",
"id" : 4,
"resourceId" : 9,
"input" : {
"username":"${input.userList[0].username}"
},
"assertions" : [
{
"actualOutput" : "${output(1.4)}",
"condition" : "!=",
"expectedOutput" : "EXCEPTION"
}
]
}
]
},
{
"id" : 2,
"name" : "Test Pet service related APIs",
"testCases" : [
{
"name" : "Add pet",
"id" : 1,
"resourceId" : 4,
"input" : {
"postData":"${input.petList[0]}"
},
"assertions" : [
{
"actualOutput" : "${output(2.1)}",
"condition" : "!=",
"expectedOutput" : "EXCEPTION"
}
]
},
{
"name" : "Find pet by id",
"id" : 2,
"resourceId" : 1,
"input" : {
"petId":"1"
},
"assertions" : [
{
"actualOutput" : "${output(2.2)}",
"condition" : "!=",
"expectedOutput" : "NULL"
}
]
},
{
"name" : "Find pet by status",
"id" : 3,
"resourceId" : 2,
"input" : {
"status":"available,sold,pending"
},
"assertions" : [
{
"actualOutput" : "${output(2.3).size}",
"condition" : ">",
"expectedOutput" : "0"
}
]
}
]
},
{
"id" : 3,
"name" : "Test Store service related APIs",
"testCases" : [
{
"name" : "Find order by id",
"id" : 1,
"resourceId" : 12,
"input" : {
"orderId":"1"
},
"assertions" : [
{
"actualOutput" : "${output(3.1)}",
"condition" : "!=",
"expectedOutput" : "NULL"
}
]
},
{
"name" : "Place order",
"id" : 2,
"resourceId" : 14,
"input" : {
"postData":"${input.orderList[0]}"
},
"assertions" : [
{
"actualOutput" : "${output(1.2)}",
"condition" : "!=",
"expectedOutput" : "EXCEPTION"
}
]
}
]
}
]
}

View File

@@ -1,241 +0,0 @@
package com.wordnik.swagger.common
{
import asaxb.xml.bind.ASAXBContext;
import asaxb.xml.bind.Unmarshaller;
import com.wordnik.swagger.event.ApiClientEvent;
import com.wordnik.swagger.event.Response;
import com.wordnik.swagger.common.ApiUserCredentials;
import com.wordnik.swagger.model.LibraryReferences;
import flash.events.EventDispatcher;
import flash.utils.Dictionary;
import flash.utils.describeType;
import flash.xml.XMLDocument;
import flash.xml.XMLNode;
import mx.messaging.ChannelSet;
import mx.messaging.channels.HTTPChannel;
import mx.messaging.messages.HTTPRequestMessage;
import mx.rpc.AsyncToken;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
import mx.rpc.xml.SimpleXMLEncoder;
import mx.utils.ObjectUtil;
public class ApiInvoker extends EventDispatcher
{
private var _apiUsageCredentials:ApiUserCredentials;
internal var _apiProxyServerUrl:String = "";
private var _baseUrl: String = "";
internal var _useProxyServer: Boolean = true;
private var _proxyHostName:String = "";
private var _apiPath: String = "";
public var _apiEventNotifier:EventDispatcher;
public var _apiLibraryReferences:LibraryReferences;
private static const DELETE_DATA_DUMMY:String = "dummyDataRequiredForDeleteOverride";
private static const X_HTTP_OVERRIDE_KEY:String = "X-HTTP-Method-Override";
private static const CONTENT_TYPE_HEADER_KEY:String = "Content-Type";
public function ApiInvoker(apiUsageCredentials: ApiUserCredentials, eventNotifier: EventDispatcher, useProxy: Boolean = true) {
_apiUsageCredentials = apiUsageCredentials;
_useProxyServer = useProxy;
if(_apiUsageCredentials.hostName != null){
_proxyHostName = _apiUsageCredentials.hostName;
}
_apiPath = _apiUsageCredentials.apiPath;
_apiProxyServerUrl = _apiUsageCredentials.apiProxyServerUrl;
_apiEventNotifier = eventNotifier;
}
public function invokeAPI(resourceURL: String, method: String, queryParams: Dictionary, postObject: Object, headerParams: Dictionary): AsyncToken {
//make the communication
if(_useProxyServer) {
resourceURL = resourceURL = _apiProxyServerUrl + resourceURL;
}
else{
resourceURL = resourceURL = "http://"+ _proxyHostName + _apiPath + resourceURL;
}
var counter: int = 0;
var symbol: String = "&";
var paramValue: Object;
for (var paramName:String in queryParams) {
paramValue = queryParams[paramName];
//var key:String = paramName;
// do stuff
symbol = "&";
if(counter == 0){
symbol = "?";
}
resourceURL = resourceURL + symbol + paramName + "=" + paramValue.toString();
counter++;
}
//create a httpservice and invoke the rest url waiting for response
var requestHeader:Object = new Object();
resourceURL = ApiUrlHelper.appendTokenInfo(resourceURL, requestHeader, _apiUsageCredentials);
var bodyData:String = marshal( postObject);//restRequest.postData;
return doRestCall(resourceURL, onApiRequestResult, onApiRequestFault, method, bodyData, requestHeader, "application/xml");
}
private function doRestCall( url : String, resultFunction : Function, faultFunction : Function = null,
restMethod : String = "GET",
bodyData : Object = null, headers: Object = null, contentType:String = "application/xml" ) : AsyncToken
{
var httpService : HTTPService = new HTTPService( );
if(headers == null){
headers = new Object();
}
httpService.method = restMethod;
if ( restMethod.toUpperCase() != HTTPRequestMessage.GET_METHOD )
{
//httpService.method = HTTPRequestMessage.POST_METHOD; - not required as we're using the proxy
if( bodyData == null )
{
bodyData = new Object();
}
if(restMethod == HTTPRequestMessage.DELETE_METHOD){
headers[X_HTTP_OVERRIDE_KEY]= HTTPRequestMessage.DELETE_METHOD;
bodyData = DELETE_DATA_DUMMY;
}
else{
headers[CONTENT_TYPE_HEADER_KEY]= contentType;
}
}
else
{
//if the request type is GET and content type is xml then the Flex HTTPService converts it to a POST ... yeah
contentType = null;
}
httpService.url = url;
httpService.contentType = contentType;
httpService.resultFormat = "e4x";
httpService.headers = headers;
httpService.addEventListener( ResultEvent.RESULT, resultFunction );
if( faultFunction != null )
{
httpService.addEventListener( FaultEvent.FAULT, faultFunction );
}
if(_useProxyServer){
httpService.useProxy = true;
var channelSet: ChannelSet = new ChannelSet();
var httpChannel: HTTPChannel = new HTTPChannel();
httpChannel.uri = ApiUrlHelper.getProxyUrl(_proxyHostName);
channelSet.addChannel(httpChannel);
httpService.channelSet = channelSet;
}
return httpService.send( bodyData );
}
private function onApiRequestResult(event:ResultEvent):void
{
var completionListener: Function = event.token.completionListener;
var result: Object = event.result;
var resultType: Class = event.token.returnType;
var resultObject:Object;
if(resultType != null) {
var context:ASAXBContext = ASAXBContext.newInstance(resultType);
var unmarshaller:Unmarshaller = context.createUnmarshaller();
var resultXML: XML = new XML(event.result);
try{
resultObject = unmarshaller.unmarshal(resultXML);
}
catch(error: TypeError){
var errorResponse: Response = new Response(false, null, "Could not unmarshall response");
if (_apiEventNotifier != null) { //dispatch event via assigned dispatcher
var failureEvent: ApiClientEvent = new ApiClientEvent(event.token.completionEventType);
failureEvent.response = errorResponse;
_apiEventNotifier.dispatchEvent(failureEvent);
}
}
if(resultObject is ListWrapper){
resultObject = ListWrapper(resultObject).getList();
}
}
var response : Response = new Response(true, resultObject);
response.requestId = event.token.requestId;
var successEventType: String = event.token.completionEventType != null ? event.token.completionEventType : ApiClientEvent.SUCCESS_EVENT;
if (_apiEventNotifier != null) { //dispatch event via assigned dispatcher
var successEvent: ApiClientEvent = new ApiClientEvent(successEventType);
successEvent.response = response;
_apiEventNotifier.dispatchEvent(successEvent);
}
}
private function onApiRequestFault(event:FaultEvent):void
{
var completionListener: Function = event.token.completionListener;
if(completionListener != null){
completionListener.call( null, new Response( false, null, event.fault.faultString) );
}
var failureEventType: String = event.token.completionEventType != null ? event.token.completionEventType : ApiClientEvent.FAILURE_EVENT;
if (_apiEventNotifier != null) { //dispatch event via assigned dispatcher
var failureEvent: ApiClientEvent = new ApiClientEvent(failureEventType);
failureEvent.response = new Response( false, null, event.fault.faultString);
_apiEventNotifier.dispatchEvent(failureEvent);
}
}
public function marshal(source:Object):XML
{
var writer:XMLWriter=new XMLWriter();
var objDescriptor:XML=describeType(source);
var property:XML;
var propertyType:String;
var propertyValue:Object;
var qualifiedClassName:String=objDescriptor.@name;
qualifiedClassName=qualifiedClassName.replace("::",".");
var className: String = qualifiedClassName.substring(qualifiedClassName.lastIndexOf(".") + 1);
className = className.charAt().toLowerCase() + className.substring(1);
writer.xml.setName(className);
for each(property in objDescriptor.elements("variable")){
propertyValue=source[property.@name];
if (propertyValue!=null){
if (ObjectUtil.isSimple(propertyValue)){
writer.addProperty(property.@name, propertyValue.toString());
}
else {
writer.addProperty(property.@name, marshal(propertyValue).toXMLString());
}
}
}
for each(property in objDescriptor.elements("accessor")){
if (property.@access=="readonly"){
continue;
}
propertyValue=source[property.@name];
if (source[property.@name]!=null){
if (ObjectUtil.isSimple(propertyValue)){
writer.addProperty(property.@name, propertyValue.toString());
}
else {
writer.addProperty(property.@name, marshal(propertyValue).toXMLString());
}
}
}
return writer.xml;
}
}
}

View File

@@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="runMe()" invoke="onInvoke(event)">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import org.flexunit.listeners.AirCIListener;
import org.flexunit.runner.FlexUnitCore;
import test.TestExecutor;
private var core: FlexUnitCore;
public function runMe(): void{
core = new FlexUnitCore();
core.addListener(new AirCIListener());
core.run(test.TestExecutor);
}
public function onInvoke(event: InvokeEvent): void{
var arguments: Array = event.arguments;
trace(arguments.toString());
}
]]>
</fx:Script>
</s:WindowedApplication>

View File

@@ -1,432 +0,0 @@
package test
{
import com.adobe.serialization.json.JSON;
import com.adobe.utils.DateUtil;
import com.wordnik.swagger.common.ApiInvoker;
import com.wordnik.swagger.common.ApiUserCredentials;
import com.wordnik.swagger.common.SwaggerApi;
import com.wordnik.swagger.event.ApiClientEvent;
import com.wordnik.swagger.event.Response;
import flash.desktop.NativeApplication;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
import flash.events.IOErrorEvent;
import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.system.System;
import flash.utils.describeType;
import flash.utils.getDefinitionByName;
import flexunit.framework.TestCase;
import mx.core.ClassFactory;
import mx.rpc.events.FaultEvent;
import mx.utils.StringUtil;
public class TestExecutor extends TestCase
{
private var urlReq:URLRequest;
private var urlLdr:URLLoader;
private var apiInvoker: ApiInvoker;
private const MODEL_INFO_URL:String ="testData.json";
private const TIME_OUT:int = 5000;
private var testData: Object;
public function testApiMethod():void{
initializeRequest();
urlLdr.addEventListener(Event.COMPLETE, addAsync(executeTest, TIME_OUT));
urlLdr.addEventListener(IOErrorEvent.IO_ERROR, executeTest);
urlLdr.load(urlReq);
}
private function initializeRequest():void {
/* Initialize the URLRequest object with the URL to the file of name/value pairs. */
urlReq = new URLRequest(MODEL_INFO_URL);
/* Initialize the URLLoader object, assign the various event listeners, and load the specified URLRequest object. */
urlLdr = new URLLoader();
}
private function checkAndLoadModelXml(event:Event):Object {
var ldr:URLLoader = urlLdr;//event.currentTarget as URLLoader;
assertTrue("Test data info not found ", ldr.data != null);
var testData:Object = JSON.decode(ldr.data);
//var classList:XML = new XML(ldr.data);
assertTrue("Test data could not be loaded as xml ", testData != null);
return testData;
}
private function executeTest(event:Event):void {
testData = checkAndLoadModelXml(event);
//figure out class and method to execute
var className: String = getServiceName(testData.resource);
var methodName: String = testData.methodName;
var servicePackageName: String = testData.apiPackageName;
var fullClassName: String = servicePackageName + "." + className;
var apiUrl: String = testData.apiUrl;
var apiHostName : String = apiUrl.substring(apiUrl.indexOf("//")+2,
apiUrl.indexOf("/",apiUrl.indexOf("//")+2) );
var apiPath: String = apiUrl.substring(apiUrl.indexOf(apiHostName)+ apiHostName.length,
apiUrl.indexOf("/", apiUrl.indexOf(apiHostName)+ apiHostName.length + 1));
var useProxyServer: Boolean = false;
if(testData.useProxyServer != null){
useProxyServer = testData.useProxyServer == "true" ? true : false;
}
var params: Array;
//execute the test
var classRef:Class;
try{
classRef = getDefinitionByName(fullClassName) as Class;
}
catch(error: ReferenceError){
var classFailure: Response = new Response(false, null, "Api Class not found");
writeToFile( JSON.encode(classFailure) );
}
var apiCredentials: ApiUserCredentials = new ApiUserCredentials(testData.apiKey,
testData.authToken, apiHostName, -1, apiPath, testData.proxyServerUrl);
var apiInstance : * = new classRef(apiCredentials);
apiInstance.useProxyServer(useProxyServer);
apiInstance.addEventListener(methodName, addAsync(onApiCallResponse, TIME_OUT, {} , apiTimeOutHandler) );
apiInstance.addEventListener(ApiClientEvent.FAILURE_EVENT, onApiCallFault );
var queryAndPathParams: Object = new Object();
queryAndPathParams = testData.queryAndPathParams;
params = getArgumentsForTestCaseExecution(methodName, apiInstance,
queryAndPathParams, testData.postData, className, testData.resource);
if(apiInstance.hasOwnProperty(methodName)){
var method:Function = apiInstance[methodName];
var returnValue:* = method.apply(apiInstance, params);
}
else{
//write out error
var failureResponse: Response = new Response(false, null, "Method not found");
writeToFile( JSON.encode(failureResponse) );
}
//write out test data result to json file
}
private function onApiCallResponse(event: ApiClientEvent, tokenObject: Object = null): void{
var result: Response = event.response;
trace("writing to file");
writeToFile( JSON.encode(result) );
}
private function onApiCallFault(event:FaultEvent):void {
var failureResponse: Response = new Response(false, null, "Method invocation failure");
writeToFile( JSON.encode(failureResponse) );
}
private function writeToFile(data: String) : void {
var localFile: File = File.documentsDirectory.resolvePath("testOutput.json");
var localFileStream:FileStream = new FileStream();
localFileStream.open(localFile, FileMode.WRITE);
localFileStream.writeMultiByte( data, "utf-8");
localFileStream.close();
trace(data);
applicationExit();
}
private function apiTimeOutHandler(o: Object):void {
//fail("test timed out");
trace("Execution timed out");
var failureResponse: Response = new Response(false, null, "Method Execution timed out");
writeToFile( JSON.encode(failureResponse) );
}
/**
* Generate name of the service from resource path.
*
* Example: if input is /user.json the generated name for this path will be UserAPI
* If the input is /user.json/{userId}, the service name will still be generated as UserAPI
*
* @param resourcePath
* @return
*/
private function getServiceName(resourcePath: String): String {
var className:String = null;
var index: int = resourcePath.indexOf(".");
if(index >= 0) {
var resourceName: String = resourcePath.substring(1,index);
className = applyClassNamingPolicy(resourceName);
}else{
var paths: Array = resourcePath.split("/");
for each(var path: String in paths) {
if(path != null && path.length > 0) {
className = applyClassNamingPolicy(path);
break;
}
}
}
return className+ "API";
}
private function getArgumentsForTestCaseExecution(methodName: String, apiObject: Object, queryAndPathParameters: Object,
postData: String, className: String, resourcePath: String): Array{
var result: Array;
//get the xml data for the type
var classAsXML: XML = describeType(apiObject);
//get the parameters for the method
var argNamesArray: Array = [];
var argTypesArray: Array = [];
var list: XMLList = classAsXML.method;
var methodXml: XML;
var paramDefn: XML
var currentMethodName: String;
var methodParams: XMLList;
var methodArgumentNames: XMLList;
var argumentNames: String;
for each (methodXml in list) {
//get the names and types for the parameters
currentMethodName = methodXml.@name.toString();
if(methodName == currentMethodName){
methodParams = methodXml.parameter;
for each(paramDefn in methodParams){
argTypesArray.push(paramDefn.@type.toString());
}
methodArgumentNames = methodXml.metadata.(@name == "MethodArgumentNames");
if(methodArgumentNames.length() > 0){
argumentNames = methodArgumentNames.arg[0].@value.toString();
argNamesArray = argNamesArray.concat(argumentNames.split(","));
}
break;
}
}
if(argNamesArray != null && argNamesArray.length > 0){
result = [];
//get the value of the input type parameter
var inputClassName: String = getInputObjectName(className, resourcePath);
var argName: String;
var argType: String;
var argumentValue: Object;
for (var i: Number=0 ; i< argNamesArray.length ; i++){
argName = StringUtil.trim( argNamesArray[i].toString() );
argType = argTypesArray[i].toString();
//if the parameter type is of collated input type
if(argType == inputClassName){
//create an object of type input model and populate it
argumentValue = populateInputModelObject(argTypesArray[i], queryAndPathParameters);
}
//if it is a primitive type then
else if( isPrimitiveType(argType) ){
//get the value from the queryAndPathParameters
argumentValue = queryAndPathParameters[argName] ;
}
//if it is a POST param
else if( argName == "postData"){
//convert from JSON to object ? of type ?
if(postData.charAt(0) == "\"" && postData.charAt(postData.length - 1) == "\""){
postData = postData.slice(1, postData.length);
}
argumentValue = JSON.decode( postData.toString() );
argumentValue = mapToFlexObjects(argumentValue, argType);
}
else if(true){
//???some times input can be list of primitives for supporting multivalued values. however test case sends the input as comma separated values
//???so we need to convert comma separated string into JSON list format
argumentValue = queryAndPathParameters[argName].toString().split(",");
}
result.push(argumentValue);
}
}
return result;
}
/**
* Converts an instance of type 'Object' to a type of 'argType'
*/
private function mapToFlexObjects(obj:Object, argType: String):Object {
var fullClassName: String = argType.replace("::",".");
var classRef:Class;
try{
classRef = getDefinitionByName(fullClassName) as Class;
}
catch(error: ReferenceError){
var classFailure: Response = new Response(false, null, "Api Class not found");
writeToFile( JSON.encode(classFailure) );
}
var returnObject : * = new classRef();
var propertyMap:XML = describeType(returnObject);
var propertyTypeClass:Class;
for each (var property:XML in propertyMap.variable) {
if ((obj as Object).hasOwnProperty(property.@name)) {
propertyTypeClass = getDefinitionByName(property.@type) as Class;
if (obj[property.@name] is (propertyTypeClass)) {
returnObject[property.@name] = obj[property.@name];
}
if(property.@type == "Date"){
var dateValue:Date = DateUtil.parseW3CDTF( obj[property.@name] );
returnObject[property.@name] = dateValue;
}
if( !isPrimitiveType( property.@type )){
try{
var complexTypeObject: Object = mapToFlexObjects( obj[property.@name], property.@type );
returnObject[property.@name] = complexTypeObject;
}
catch(error: Error){
var mapToFlexFailure: Response = new Response(false, null, "Post data object could not be created");
writeToFile( JSON.encode(mapToFlexFailure) );
}
}
}
}
return returnObject;
}
private function isPrimitiveType(type: String): Boolean {
if(type == "String" || type == "int" || type == "integer" || type == "double" ||
type == "boolean" || type == "float" || type == "long" || type == "Number" ){
return true;
}
return false;
}
/**
* Converts the first character of the input into upper case .
* Example: If the input is word, the return value will be Word
* @param input
* @return
*/
private function applyClassNamingPolicy(input: String): String {
if(input != null && input.length > 0) {
return input.substring(0,1).toUpperCase() + input.substring(1);
}else{
throw new Error("Error converting input to first letter caps becuase of null or empty input");
}
}
private function getInputObjectName(serviceName: String, resourcePath: String): String {
//Since service name has API at the end remove that format he name
var inputobjectName: String = serviceName.substring(0, serviceName.length - 3);
var pathElements: Array = resourcePath.split("/");
var urlPath: String = "";
if(pathElements != null){
for each(var pathElement: String in pathElements){
if(pathElement != null && pathElement.length > 0) {
var position: int = pathElement.indexOf("{");
if(position < 0) {
inputobjectName = inputobjectName + applyClassNamingPolicy( pathElement ) + "Input";
}
}
}
}
return inputobjectName;
}
/**
* Populates the swagger input model object.
*
* Input model is created when number of inputs to a method exceed certain limit.
* @param inputDefinitions
* @return
*/
private function populateInputModelObject(swaggerInputClassName: String, inputDefinitions: Object): Object {
var inputModelObjectClass: Class = getDefinitionByName(swaggerInputClassName) as Class;
var inputObject: Object = new inputModelObjectClass();
for(var attributeName: String in inputDefinitions){
if(inputObject.hasOwnProperty(attributeName)){
inputObject[attributeName] = inputDefinitions[attributeName];
}
}
return inputObject;
}
public function applicationExit():void {
var exitingEvent:Event = new Event(Event.EXITING, false, true);
NativeApplication.nativeApplication.dispatchEvent(exitingEvent);
if (!exitingEvent.isDefaultPrevented()) {
NativeApplication.nativeApplication.exit();
}
}
// /**
// * Gets the list of input query and path parameters and post data vlues and covenrt them to arguments that
// * can be used for calling the method. This logic will be different in each driver language depends on how method
// * input arguments are created.
// */
// private function populateArgumentsForTestCaseExecution(methodToExecute: Function, queryAndPathParameters: Object,
// postData: String, serviceName: String, resourcePath: String): Array {
// MethodArgumentNames argNames = methodToExecute.getAnnotation(MethodArgumentNames.class);
// String[] argNamesArray = null;
// if(argNames != null && argNames.value().length() > 0) {
// argNamesArray = argNames.value().split(",");
// }
// Class[] argTypesArray = methodToExecute.getParameterTypes();
// Object output = null;
// String inputClassName = namingPolicyProvider.getInputObjectName(serviceName, resourcePath);
//
// if(argNamesArray != null && argNamesArray.length > 0){
// Object[] arguments = new Object[argNamesArray.length];
//
// for(int i=0; i < argNamesArray.length; i++){
// Object argument = null;
// //if the method takes input model instead of individual arguments, convert individual arguments into input model object
// if(argTypesArray[i].getName().equalsIgnoreCase(inputClassName)){
// argument = populateInputModelObject(argTypesArray[i], queryAndPathParameters);
// }else if(datatypeMppingProvider.isPrimitiveType(argTypesArray[i].getName())){
// argument = queryAndPathParameters.get(argNamesArray[i].trim());
// }else if (argNamesArray[i].trim().equals(APITestRunner.POST_PARAM_NAME)){
// argument = APITestRunner.convertJSONStringToObject(postData, argTypesArray[i]);
// }else{
// //some times input can be list of primitives for supporting multivalued values. however test case sends the input as comma separated values
// //so we need to convert comma separated string into JSON list format
// if(List.class.isAssignableFrom(argTypesArray[i]) && !queryAndPathParameters.get(argNamesArray[i].trim()).startsWith("[")){
// String listInput= "[";
// int x = 0;
// String[] values = queryAndPathParameters.get(argNamesArray[i].trim()).split(",");
// for(String value : values){
// if(x > 0){listInput = listInput + ",";}
// listInput = listInput + "\""+ value + "\"";
// x++;
// }
// listInput = listInput + "]";
// argument = APITestRunner.convertJSONStringToObject(listInput, argTypesArray[i]);
// }else{
// argument = APITestRunner.convertJSONStringToObject(queryAndPathParameters.get(argNamesArray[i].trim()), argTypesArray[i]);
// }
// }
// arguments[i] = argument;
// }
// return arguments;
// }
// return null;
// }
}
}

View File

@@ -1,30 +0,0 @@
package $packageName$;
$imports:{ import |
import $import$;
}$
/**
* $enum.description$
* NOTE: This class is auto generated by the drive code generator program so please do not edit the class manually.
* @author deepak
*
*/
public enum $className$ {
$values: { value | $value.name$($value.value$)};separator=", "$;
final $enumValueType$ value;
$className$($enumValueType$ value) {
this.value = value;
}
public $enumValueType$ getValue() {
return value;
}
@Override public String toString() {
return String.valueOf(this.getValue());
}
};

View File

@@ -1,30 +0,0 @@
package $packageName$ {
$imports:{ import |
import $import$;
}$
/**
* $model.description$
* NOTE: This class is auto generated by the drive code generator program so please do not edit the class manually.
* @author deepak
*
*/
[XmlRootNode(name="$model.name$")]
public class $className$ extends $extends$ {
$fields:{ field |
/**
* $field.description$
* $if(field.required)$@Required$endif$
* $if(field.allowableValues)$[AllowableValues(value="$field.allowedValuesString$"]$endif$
*/
$if(!field.fieldDefinition.collectionItemType)$
[XmlElement(name="$field.fieldDefinition.name$")]$endif$
$if(field.fieldDefinition.collectionItemType)$
[XmlElements(name="$field.fieldDefinition.name$", type="$field.fieldDefinition.collectionItemType$")]$endif$
public var $field.fieldDefinition.name$: $field.fieldDefinition.returnType$ $field.fieldDefinition.initialization$;$\r$}$
}
}

View File

@@ -1,24 +0,0 @@
package $packageName$ {
import com.wordnik.swagger.api.*;
$imports:{ import |
import $import$;
}$
/**
* This class contains references for any classes that might not be directly referenced by the Api classes.
* The AS3 compiler will exclude any class that is not referenced directly somewhere in your code.
* This is an optimization that the compiler applies by design.
* This convenience class prevents the user from having to iclude an import and variable declaration for such classes.
*
* NOTE: This class is auto generated by the drive code generator program so please do not edit the class manually.
* @author deepak
*
*/
public class LibraryReferences {
$fields:{ field |
private var $field.name$: $field.paramType$;$\r$}$
}
}

View File

@@ -1,132 +0,0 @@
package $packageName$ {
import $exceptionPackageName$.ApiErrorCodes;
import $exceptionPackageName$.ApiError;
import $modelPackageName$.*;
import com.wordnik.swagger.common.ApiUserCredentials;
import com.wordnik.swagger.event.Response;
import com.wordnik.swagger.common.SwaggerApi;
import mx.rpc.AsyncToken;
import mx.utils.UIDUtil;
import flash.utils.Dictionary;
import flash.events.EventDispatcher;
$imports:{ import |
import $import$;
}$
/**
* NOTE: This class is auto generated by the drive code generator program so please do not edit the class manually.
* @author deepak
*
*/
public class $resource$ extends $extends$ {
$methods:{ method |
public var event_$method.name$: String = "$method.name$";$\r$}$
/**
* Constructor for the $resource$ api client
* @param apiCredentials Wrapper object for tokens and hostName required towards authentication
* @param eventDispatcher Optional event dispatcher that when provided is used by the SDK to dispatch any Response
*/
public function $resource$(apiCredentials: ApiUserCredentials, eventDispatcher: EventDispatcher = null) {
super(apiCredentials, eventDispatcher);
}
$methods:{ method |
/**
* $method.description$
$method.arguments:{ argument |
* @param $argument.name$ $argument.description$
$if(argument.allowedValues)$
* Allowed values are - $argument.allowedValues$
$endif$}$
*
$if(!method.responseVoid)$
* @return $method.returnValue$ {@link $method.returnClassName$} $endif$
*/
$if(method.hasArguments)$
[MethodArgumentNames(value="$method.argumentNames; separator=", "$")]$endif$
public function $method.name$($method.argumentDefinitions; separator=", "$): String {
$if(method.authToken)$
if(_apiUsageCredentials == null || _apiUsageCredentials.authToken == null || _apiUsageCredentials.authToken.length == 0) {
throw new ApiError(ApiErrorCodes.AUTH_TOKEN_NOT_VALID);
}$endif$
var requestId: String = getUniqueId();
//parse inputs
var resourcePath: String = "$method.resourcePath$";
resourcePath = resourcePath.replace("{format}","xml");
var method: String = "$method.methodType$";
var queryParams:Dictionary = new Dictionary();
var headerParams:Dictionary = new Dictionary();
$if(!method.inputModel)$
$method.queryParameters:{ argument |
if( $argument.name$ != null) {
queryParams["$argument.name$"] = toPathValue($argument.name$);
}
}$
$method.pathParameters:{ argument |
if( $argument.name$ != null) {
resourcePath = resourcePath.replace("{$argument.name$}", $argument.name$);
}
}$
$method.headerParameters:{ argument |
if( $argument.name$ != null) {
headerParams["$argument.name$"] = toPathValue($argument.name$);
}
}$
$endif$
$if(method.inputModel)$
$method.queryParameters:{ argument |
if( $argument.inputModelClassArgument$ != null && $argument.methodNameFromModelClass$ != null) {
queryParams["$argument.name$"] = $argument.methodNameFromModelClass$;
}
}$
$method.pathParameters:{ argument |
if( $argument.inputModelClassArgument$ != null && $argument.methodNameFromModelClass$ != null) {
resourcePath = resourcePath.replace("{$argument.name$}", $argument.methodNameFromModelClass$);
}
}$
$method.headerParameters:{ argument |
if( $argument.inputModelClassArgument$ != null && $argument.methodNameFromModelClass$ != null) {
headerParams["$argument.name$"] = $argument.methodNameFromModelClass$;
}
}$
$endif$
//make the API Call
$if(method.postObject)$
$if(method.authToken)$
var token:AsyncToken = getApiInvoker().invokeAPI(resourcePath, method, queryParams, postData, headerParams);
$endif$
$if(!method.authToken)$
var token:AsyncToken = getApiInvoker().invokeAPI(resourcePath, method, queryParams, postData, headerParams);
$endif$
$endif$
$if(!method.postObject)$
$if(method.authToken)$
var token:AsyncToken = getApiInvoker().invokeAPI(resourcePath, method, queryParams, null, headerParams);
$endif$
$if(!method.authToken)$
var token:AsyncToken = getApiInvoker().invokeAPI(resourcePath, method, queryParams, null, headerParams);
$endif$
$endif$
token.requestId = requestId;
token.completionEventType = "$method.name$";
//create output objects if the response has more than one object
$if(!method.responseVoid)$
token.returnType = $method.returnClassName$;
$endif$
return requestId;
}
}$
}
}

View File

@@ -1,20 +0,0 @@
package $packageName$ {
/**
* Maintains the compatible server version against which the drive is written
* @author deepak
*
*/
public class VersionChecker {
private var compatibleVersion: String = "$apiVersion$";
/**
* Gets the version against which the driver code was written
*/
public function getCompatibleVersion(): String {
return compatibleVersion;
}
}
}

View File

@@ -1,37 +0,0 @@
package $packageName$ {
import com.wordnik.swagger.common.ListWrapper;
$imports:{ import |
import $import$;
}$
/**
* $model.description$
* NOTE: This class is auto generated by the drive code generator program so please do not edit the class manually.
* @author deepak
*
*/
public class $className$ extends $extends$ implements ListWrapper{
$fields:{ field |
/**
* $field.description$
* $if(field.required)$@Required$endif$
* $if(field.allowableValues)$[AllowableValues(value="$field.allowedValuesString$"]$endif$
*/
$if(!field.fieldDefinition.collectionItemType)$
[XmlElement(name="$field.fieldDefinition.name$")]$endif$
$if(field.fieldDefinition.collectionItemType)$
[XmlElements(name="$field.fieldDefinition.collectionItemName$", type="$field.fieldDefinition.collectionItemType$")]$endif$
public var $field.fieldDefinition.name$: $field.fieldDefinition.returnType$ $field.fieldDefinition.initialization$;}$
$fields:{ field |
/**
* Returns the list being wrapped by this wrapper class. There will be a single list item attribute in this class.
*/
$if(field.fieldDefinition.collectionItemType)$
public function getList(): $field.fieldDefinition.returnType${
return $field.fieldDefinition.name$;
}$endif$}$
}
}

View File

@@ -1,111 +0,0 @@
<?xml version="1.0"?>
<project name="swagger-sample-java-lib" xmlns:ivy="antlib:org.apache.ivy.ant" default="build.all" basedir=".">
<property environment="env" />
<property name="version.identifier" value="1.0" />
<property name="artifact.ext" value="jar" />
<property name="organization" value="wordnik" />
<property name="module" value="${ant.project.name}" />
<!-- default dirs for the build -->
<mkdir dir="lib"/>
<mkdir dir="lib/ext"/>
<condition property="scala.home" value="${env.SCALA_HOME}">
<isset property="env.SCALA_HOME" />
</condition>
<path id="scala.classpath">
<fileset dir="${scala.home}/lib">
<include name="scala**.jar" />
</fileset>
</path>
<ivy:settings file="ivysettings.xml" />
<taskdef resource="scala/tools/ant/antlib.xml">
<classpath>
<fileset dir="lib">
<include name="scala**.jar" />
</fileset>
<fileset dir="${scala.home}/lib">
<include name="scala**.jar" />
</fileset>
</classpath>
</taskdef>
<!-- this is the output module -->
<property name="module" value="${ant.project.name}" />
<target name="build.all" depends="clean, resolve, fastcompile" description="builds the module (default target)" />
<target name="clean" description="cleans the project folder">
<mkdir dir="build" />
<echo message="deleting build files" />
<delete quiet="true">
<fileset dir="build">
<include name="*.jar" />
<include name="*.xml" />
</fileset>
</delete>
<delete dir="build/main" quiet="true" />
<delete dir="dist" quiet="true" />
<!-- libraries handled by ivy -->
<echo message="deleting libs handled by ivy" />
<delete>
<fileset dir="lib">
<include name="*.jar" />
<include name="*.zip" />
</fileset>
</delete>
</target>
<!-- copies ONLY the swagger-sample jar to dist-->
<target name="fastdist" depends="fastcompile">
<copy todir="dist/lib">
<fileset dir="build">
<include name="*.jar" />
</fileset>
</copy>
</target>
<!-- copies all dependencies into the lib folder -->
<target name="resolve" description="retreive dependencies with ivy">
<ivy:retrieve pattern="${basedir}/lib/[artifact]-[revision].[ext]" conf="build" />
</target>
<target name="fastcompile" description="builds the module without artifact resolution or cleaning">
<delete quiet="true" file="build/${organization}-${artifact}-*.${artifact.ext}" />
<mkdir dir="build" />
<mkdir dir="build/main" />
<mkdir dir="build/main/java" />
<javac srcdir="src/main/java" debug="true" destdir="build/main/java">
<classpath>
<fileset dir="lib">
<include name="*.jar" />
</fileset>
<fileset dir="lib/ext">
<include name="*.jar" />
</fileset>
<pathelement location="build/main/java" />
</classpath>
</javac>
<jar jarfile="build/${module}-${version.identifier}.${artifact.ext}">
<fileset dir="build/main/java" />
</jar>
</target>
<!-- cleans up the dist -->
<target name="dist.clean" description="cleans the distribution folder">
<delete quiet="true" dir="dist" />
<delete quiet="true" file="dist.zip" />
</target>
<target name="dependency.tree" description="builds a graphml dependency diagram for viewing with yEd">
<ivy:report conf="build" graph="true" todir="." outputpattern="[artifact]-[revision].[ext]" />
</target>
</project>

View File

@@ -1,31 +0,0 @@
<ivy-module version="2.0">
<info organisation="wordnik" module="sample-java-lib"/>
<configurations>
<conf name="build" description="build wordnik-java"/>
<conf name="test" visibility="public"/>
<conf name="source" visibility="public"/>
<conf name="pom" visibility="public"/>
</configurations>
<dependencies>
<!-- jersey dependencies -->
<dependency org="junit" name="junit" rev="4.4" conf="build->default"/>
<dependency org="com.sun.jersey" name="jersey-json" rev="1.4" conf="build->default"/>
<dependency org="com.sun.jersey" name="jersey-client" rev="1.4" conf="build->default"/>
<dependency org="com.sun.jersey" name="jersey-server" rev="1.4" conf="build->default"/>
<dependency org="com.sun.jersey" name="jersey-core" rev="1.4" conf="build->default"/>
<dependency org="asm" name="asm-parent" rev="3.1" conf="build->default"/>
<dependency org="commons-beanutils" name="commons-beanutils" rev="1.8.0" conf="build->default"/>
<dependency org="org.antlr" name="stringtemplate" rev="3.2" conf="build->default"/>
<!-- jackson jars -->
<dependency org="org.codehaus.jackson" name="jackson-jaxrs" rev="1.7.1" conf="build->default"/>
<dependency org="org.codehaus.jackson" name="jackson-xc" rev="1.7.1" conf="build->default"/>
<dependency org="org.codehaus.jackson" name="jackson-mapper-asl" rev="1.7.1" conf="build->default"/>
<dependency org="net.sourceforge.cobertura" name="cobertura" rev="1.9.2" conf="test->default">
<exclude org="asm" name="asm-tree"/>
<exclude org="asm" name="asm"/>
</dependency>
</dependencies>
</ivy-module>

View File

@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ivysettings>
<settings defaultResolver="chained" />
<property name="ivy.checksums" value=""/>
<property name="ivy.local.default.root" value="${ivy.default.ivy.user.dir}/local"
override="false" />
<property name="ivy.local.default.ivy.pattern"
value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]"
override="false" />
<property name="ivy.local.default.artifact.pattern"
value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]"
override="false" />
<resolvers>
<chain name="chained" returnFirst="true">
<filesystem name="local">
<ivy pattern="${ivy.local.default.root}/${ivy.local.default.ivy.pattern}" />
<artifact pattern="${ivy.local.default.root}/${ivy.local.default.artifact.pattern}" />
</filesystem>
<ibiblio name="ibiblio" m2compatible="true" />
<ibiblio name="javanet" root="http://download.java.net/maven/2/" m2compatible="true" />
</chain>
</resolvers>
</ivysettings>

View File

@@ -1,27 +0,0 @@
{
"apiUrl":"http://localhost:8002/api/",
"apiKey":"special-key",
"defaultServiceBaseClass":"Object",
"defaultModelBaseClass":"Object",
"serviceBaseClasses":{},
"defaultModelImports":[],
"defaultServiceImports":[],
"modelPackageName":"com.wordnik.swagger.sample.sdk.java.model",
"apiPackageName":"com.wordnik.swagger.sample.sdk.java.api",
"ignoreMethods":[],
"ignoreModels":[],
"outputDirectory":"../swagger-sample-app/sdk-libs/src/main/java/com/wordnik/swagger/sample/sdk/java",
"libraryHome":"../swagger-sample-app/sdk-libs"
}

View File

@@ -1,47 +0,0 @@
{
"userList":[
{
"username":"testuser1",
"password":"password1",
"email":"test1@dummy.com"
},
{
"username":"testuser2",
"password":"password2",
"email":"test2@dummy.com"
},
{
"username":"user?10",
"password":"password2",
"email":"test2@dummy.com"
}
],
"petList":[
{
"id":101,
"name":"pet1",
"photoUrls":["url1","url2"],
"tags":[
{
"id":1,
"name":"tag1"
},
{
"id":2,
"name":"tag2"
}
],
"status":"available",
"category":{"id":1,"name":"cat1"}
}
],
"orderList":[
{
"id":101,
"petId":1,
"quantity":1,
"status":"placed",
"shipDate":13456789
}
]
}

View File

@@ -1,325 +0,0 @@
{
"resources" : [
{
"id" : 1,
"name" : "Find Per by Id",
"httpMethod" : "GET",
"path" : "/pet.{format}/{petId}",
"suggestedMethodName" : "getPetById"
},
{
"id" : 2,
"name" : "Find pets by status",
"httpMethod" : "GET",
"path" : "/pet.{format}/findByStatus",
"suggestedMethodName" : "findPetsByStatus"
},
{
"id" : 3,
"name" : "Find pets by tags",
"httpMethod" : "GET",
"path" : "/pet.{format}/findByTags",
"suggestedMethodName" : "findPetsByTags"
},
{
"id" : 4,
"name" : "Add a pet",
"httpMethod" : "POST",
"path" : "/pet.{format}",
"suggestedMethodName" : "addPet"
},
{
"id" : 5,
"name" : "Update a pet",
"httpMethod" : "PUT",
"path" : "/pet.{format}",
"suggestedMethodName" : "updatePet"
},
{
"id" : 6,
"name" : "Create user",
"httpMethod" : "POST",
"path" : "/user.{format}",
"suggestedMethodName" : "createUser"
},
{
"id" : 7,
"name" : "Update user",
"httpMethod" : "PUT",
"path" : "/user.{format}/{username}",
"suggestedMethodName" : "updateUser"
},
{
"id" : 8,
"name" : "Delete user",
"httpMethod" : "DELETE",
"path" : "/user.{format}/{username}",
"suggestedMethodName" : "deleteUser"
},
{
"id" : 9,
"name" : "Get user by user name",
"httpMethod" : "GET",
"path" : "/user.{format}/{username}",
"suggestedMethodName" : "getUserByName"
},
{
"id" : 10,
"name" : "Login",
"httpMethod" : "GET",
"path" : "/user.{format}/login",
"suggestedMethodName" : "loginUser"
},
{
"id" : 11,
"name" : "Logout",
"httpMethod" : "GET",
"path" : "/user.{format}/logout",
"suggestedMethodName" : "logoutUser"
},
{
"id" : 12,
"name" : "Find order by id",
"httpMethod" : "GET",
"path" : "/store.{format}/order/{orderId}",
"suggestedMethodName" : "getOrderById"
},
{
"id" : 13,
"name" : "Delete order by id",
"httpMethod" : "DELETE",
"path" : "/store.{format}/order/{orderId}",
"suggestedMethodName" : "deleteOrder"
},
{
"id" : 14,
"name" : "Create order",
"httpMethod" : "POST",
"path" : "/store.{format}/order",
"suggestedMethodName" : "placeOrder"
},
{
"id" : 15,
"name" : "Get users with array input",
"httpMethod" : "POST",
"path" : "/user.{format}/usersWithArray",
"suggestedMethodName" : "getUserByNamesArray"
},
{
"id" : 16,
"name" : "get users with list",
"httpMethod" : "POST",
"path" : "/user.{format}/usersWithList",
"suggestedMethodName" : "getUserByNamesList"
}
],
"testSuites" : [
{
"id" : 1,
"name" : "Test User service related APIs",
"testCases" : [
{
"name" : "Create User",
"id" : 1,
"resourceId" : 6,
"input" : {
"postData":"${input.userList[0]}"
},
"assertions" : [
{
"actualOutput" : "${output(1.1)}",
"condition" : "!=",
"expectedOutput" : "EXCEPTION"
}
]
},
{
"name" : "Login User",
"id" : 2,
"resourceId" : 10,
"input" : {
"username":"${input.userList[0].username}",
"password":"${input.userList[0].password}"
},
"assertions" : [
{
"actualOutput" : "${output(1.2)}",
"condition" : "!=",
"expectedOutput" : "EXCEPTION"
}
]
},
{
"name" : "Find user by name",
"id" : 3,
"resourceId" : 9,
"input" : {
"username":"${input.userList[0].username}"
},
"assertions" : [
{
"actualOutput" : "${output(1.3).username}",
"condition" : "==",
"expectedOutput" : "${input.userList[0].username}"
}
]
},
{
"name" : "Delete user by name",
"id" : 4,
"resourceId" : 9,
"input" : {
"username":"${input.userList[0].username}"
},
"assertions" : [
{
"actualOutput" : "${output(1.4)}",
"condition" : "!=",
"expectedOutput" : "EXCEPTION"
}
]
},
{
"name" : "Find user by name with special characters",
"id" : 5,
"resourceId" : 9,
"input" : {
"username":"${input.userList[2].username}"
},
"assertions" : [
{
"actualOutput" : "${output(1.5).username}",
"condition" : "==",
"expectedOutput" : "${input.userList[2].username}"
}
]
},
{
"name" : "Find users with array of user names",
"id" : 6,
"resourceId" : 15,
"input" : {
"postData":"[\"testuser1\", \"testuser2\"]"
},
"assertions" : [
{
"actualOutput" : "${output(1.6).size}",
"condition" : "==",
"expectedOutput" : "2"
}
]
},
{
"name" : "Find users with list of user names",
"id" : 7,
"resourceId" : 16,
"input" : {
"postData":"[\"testuser1\", \"testuser2\"]"
},
"assertions" : [
{
"actualOutput" : "${output(1.7).size}",
"condition" : "==",
"expectedOutput" : "2"
}
]
}
]
},
{
"id" : 2,
"name" : "Test Pet service related APIs",
"testCases" : [
{
"name" : "Add pet",
"id" : 1,
"resourceId" : 4,
"input" : {
"postData":"${input.petList[0]}"
},
"assertions" : [
{
"actualOutput" : "${output(2.1)}",
"condition" : "!=",
"expectedOutput" : "EXCEPTION"
}
]
},
{
"name" : "Find pet by id",
"id" : 2,
"resourceId" : 1,
"input" : {
"petId":"1"
},
"assertions" : [
{
"actualOutput" : "${output(2.2)}",
"condition" : "!=",
"expectedOutput" : "NULL"
}
]
},
{
"name" : "Find pet by status",
"id" : 3,
"resourceId" : 2,
"input" : {
"status":"available,sold,pending"
},
"assertions" : [
{
"actualOutput" : "${output(2.3).size}",
"condition" : ">",
"expectedOutput" : "0"
}
]
}
]
},
{
"id" : 3,
"name" : "Test Store service related APIs",
"testCases" : [
{
"name" : "Find order by id",
"id" : 1,
"resourceId" : 12,
"input" : {
"orderId":"3"
},
"assertions" : [
{
"actualOutput" : "${output(3.1)}",
"condition" : "!=",
"expectedOutput" : "NULL"
}
]
},
{
"name" : "Place order",
"id" : 2,
"resourceId" : 14,
"input" : {
"postData":"${input.orderList[0]}"
},
"assertions" : [
{
"actualOutput" : "${output(1.2)}",
"condition" : "!=",
"expectedOutput" : "EXCEPTION"
}
]
}
]
}
]
}

View File

@@ -1,46 +0,0 @@
/**
* Copyright 2011 Wordnik, 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 $packageName$;
$imports:{ import |
import $import$;
}$
/**
* $enum.description$
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
* @author deepak
*
*/
public enum $className$ {
$values: { value | $value.name$($value.value$)};separator=", "$;
private $enumValueType$ value;
$className$($enumValueType$ value) {
this.value = value;
}
public $enumValueType$ getValue() {
return value;
}
@Override public String toString() {
return String.valueOf(this.getValue());
}
}

View File

@@ -1,58 +0,0 @@
/**
* Copyright 2011 Wordnik, 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 $packageName$;
import com.wordnik.swagger.runtime.annotations.*;
import java.util.List;
$imports:{ import |
import $import$;
}$
/**
* $model.description$
*
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
*
* @author ramesh
*
*/
public class $className$ extends $extends$ {
$fields:{ field |
/**
* $field.description$
*/
private $field.fieldDefinition.returnType$ $field.fieldDefinition.name$ $field.fieldDefinition.initialization$;$\r$}$
$fields:{ field |
/**
* $field.description$
* $if(field.required)$@Required$endif$
* $if(field.allowableValues)$@AllowableValues(value="$field.allowedValuesString$")$endif$
*/
public $field.fieldDefinition.returnType$ get$field.fieldDefinition.NameForMethod$() {
return $field.fieldDefinition.name$;
}
public void set$field.fieldDefinition.NameForMethod$($field.fieldDefinition.returnType$ $field.fieldDefinition.name$) {
this.$field.fieldDefinition.name$ = $field.fieldDefinition.name$;
}
}$
}

View File

@@ -1,152 +0,0 @@
/**
* Copyright 2011 Wordnik, 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 $packageName$;
import $modelPackageName$.*;
import org.codehaus.jackson.map.DeserializationConfig.Feature;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import com.wordnik.swagger.runtime.annotations.*;
import com.wordnik.swagger.runtime.common.*;
import com.wordnik.swagger.runtime.exception.*;
import java.util.*;
import java.lang.Long;
import java.io.IOException;
$imports:{ import |
import $import$;
}$
/**
*
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
* @author ramesh
*
*/
public class $resource$ extends $extends$ {
private static APIInvoker apiInvoker = null;
$methods:{ method |
/**
* $method.title$
*
$if(method.description)$
* $method.description$
* $endif$
* $method.arguments:{ argument |@param $argument.name$ $argument.description$
* $if(argument.allowedValues)$
* Allowed values are - $argument.allowedValues$ $endif$ }$
$if(!method.responseVoid)$
* @return $method.returnValue$ {@link $method.returnClassName$} $endif$
* @throws APIException $method.exceptionDescription$
*/
$if(method.hasArguments)$
@MethodArgumentNames(value="$method.argumentNames; separator=", "$")
$endif$
public static $method.returnValue$ $method.name$($method.argumentDefinitions; separator=", "$) throws APIException {
//parse inputs
String resourcePath = "$method.resourcePath$";
resourcePath = resourcePath.replace("{format}","json");
String method = "$method.methodType$";
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
$if(!method.inputModel)$
$method.queryParameters:{ argument |
if( $argument.name$ != null) {
queryParams.put("$argument.name$", APIInvoker.toPathValue($argument.name$));
}
}$
$method.pathParameters:{ argument |
if( $argument.name$ != null) {
resourcePath = resourcePath.replace("{$argument.name$}", APIInvoker.toPathValue($argument.name$));
}
}$
$method.headerParameters:{ argument |
if( $argument.name$ != null) {
headerParams.put("$argument.name$", APIInvoker.toPathValue($argument.name$));
}
}$
$endif$
$if(method.inputModel)$
$method.queryParameters:{ argument |
if( $argument.inputModelClassArgument$ != null && $argument.methodNameFromModelClass$ != null) {
queryParams.put("$argument.name$", APIInvoker.toPathValue($argument.methodNameFromModelClass$));
}
}$
$method.pathParameters:{ argument |
if( $argument.inputModelClassArgument$ != null && $argument.methodNameFromModelClass$ != null) {
resourcePath = resourcePath.replace("{$argument.name$}", APIInvoker.toPathValue($argument.methodNameFromModelClass$));
}
}$
$method.headerParameters:{ argument |
if( $argument.inputModelClassArgument$ != null && $argument.methodNameFromModelClass$ != null) {
headerParams.put("$argument.name$", APIInvoker.toPathValue($argument.methodNameFromModelClass$));
}
}$
$endif$
//make the API Call
$if(method.postObject)$
String response = getApiInvoker().invokeAPI(resourcePath, method, queryParams, postData, headerParams);
$endif$
$if(!method.postObject)$
String response = getApiInvoker().invokeAPI(resourcePath, method, queryParams, null, headerParams);
$endif$
$if(!method.responseVoid)$
if(response == null || response.length() == 0){
return null;
}
$if(!method.returnValueList)$
//create output objects if the response has more than one object
$method.returnValue$ responseObject = ($method.returnValue$) getApiInvoker().deserialize(response, $method.returnClassName$.class);
return responseObject;
$endif$
$if(method.returnValueList)$
TypeReference<ArrayList<$method.returnClassName$>> typeRef = new TypeReference<ArrayList<$method.returnClassName$>>() {};
try {
List<$method.returnClassName$> responseObject = (List<$method.returnClassName$>) getApiInvoker().mapper.readValue(response, typeRef);
return responseObject;
} catch (IOException ioe) {
String[] args = new String[]{response, typeRef.toString()};
throw new APIException(APIExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, args, "Error in converting response json value to java object : " + ioe.getMessage(), ioe);
}
$endif$
$endif$
}
}$
public static APIInvoker getApiInvoker() {
if(apiInvoker == null){
apiInvoker = APIInvoker.getApiInvoker();
}
return apiInvoker;
}
public static void setApiInvoker(APIInvoker invoker) {
apiInvoker = invoker;
}
}

View File

@@ -1,27 +0,0 @@
{
"apiUrl":"http://localhost:8002/api/",
"apiKey":"special-key",
"defaultServiceBaseClass":"SwaggerApi",
"defaultModelBaseClass":"Object",
"serviceBaseClasses":{},
"defaultModelImports":[],
"defaultServiceImports":[],
"modelPackageName":"",
"apiPackageName":"",
"ignoreMethods":[],
"ignoreModels":[],
"outputDirectory":"../swagger-sample-app/sdk-libs/src/main/js/",
"libraryHome":"../swagger-sample-app/sdk-libs"
}

File diff suppressed because one or more lines are too long

View File

@@ -1,73 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Swagger Javascript Lib Sandbox</title>
<script src="lib/jquery-1.6.4.min.js" type="text/javascript" charset="utf-8"></script>
<script src="api-lib.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
function log(s) {
if(window.console) console.log(s);
}
function logResponse(event) {
log("-----------------------------");
log(event.type);
log(event);
}
function onUserCreated(event) {
logResponse(event);
// update the created user
var user = new User();
user.lastName = "Sanders Lama";
user.username = "vito";
user.phone = "405-607-8980";
user.email = "vito@sanders.com";
user.userStatus = 1;
user.firstName = "Vito";
user.password = "XXXXX";
UserAPI.updateUser("vito", user);
}
function onUserUpdated(event) {
logResponse(event);
// delete the created user
UserAPI.deleteUser("vito");
}
ApiInvoker.init("http://localhost:8002/api/", null, null, false);
ApiInvoker.addListener(PetAPI.event_getPetById, logResponse);
ApiInvoker.addListener(StoreAPI.event_getOrderById, logResponse);
ApiInvoker.addListener(UserAPI.event_getUserByName, logResponse);
ApiInvoker.addListener(UserAPI.event_loginUser, logResponse);
ApiInvoker.addListener(UserAPI.event_createUser, onUserCreated);
ApiInvoker.addListener(UserAPI.event_updateUser, onUserUpdated);
ApiInvoker.addListener(UserAPI.event_deleteUser, logResponse);
// Get some data
StoreAPI.getOrderById("1");
PetAPI.getPetById("1");
UserAPI.getUserByName("user1");
// login
UserAPI.loginUser("user1", "XXXXXXXXXXX")
// create new user
var user = new User();
user.lastName = "Sanders";
user.username = "vito";
user.phone = "405-607-8980";
user.email = "vito@sanders.com";
user.userStatus = 1;
user.firstName = "Vito";
user.password = "XXXXX";
UserAPI.createUser(user);
</script>
<body>
</body>

View File

@@ -1,233 +0,0 @@
var ApiInvoker = new function() {
this.apiServer = null,
this.authToken = null,
this.apiKey = null,
this.loggingEnabled = false,
this.requestHeader = new Object(),
this.trace = function(obj) {
if (this.loggingEnabled && window.console) console.log(obj);
},
this.error = function(obj) {
if (window.console) console.log(obj);
},
this.init = function(apiServer, apiKey, authToken, loggingEnabled) {
if (apiServer != null && apiServer.length > 0) {
if (apiServer.substring(apiServer.length - 1) == ("/")) {
apiServer = apiServer.substring(0, apiServer.length - 1);
}
this.apiServer = apiServer;
this.apiKey = apiKey;
this.authToken = authToken;
this.loggingEnabled = (loggingEnabled === null) ? false : loggingEnabled;
if(this.apiKey)
this.requestHeader.api_key = this.apiKey;
if(this.authToken)
this.requestHeader.auth_token = this.authToken;
this.trace(this.requestHeader);
}
},
this.invokeAPI = function(authToken, resourceURL, method, queryParams, postObject, completionEvent, requestId, returnType, callback) {
if (this.apiServer == null) {
throw new Error("Please call ApiInvoker.init() to initialize the library");
}
this.trace("authToken = " + authToken);
this.trace("resourceURL = " + resourceURL);
this.trace("method = " + method);
// this.trace("returnType = " + returnType);
this.trace("completionEvent = " + completionEvent);
this.trace("requestId = " + requestId);
this.trace("queryParams:");
this.trace(queryParams);
this.trace("postObject:");
this.trace(postObject);
// create queryParam
var counter = 0;
var symbol = 0;
for (var headerKey in this.requestHeader) {
queryParams[headerKey] = this.requestHeader[headerKey]
}
for (var paramName in queryParams) {
var paramValue = queryParams[paramName];
symbol = "&";
if (counter == 0) {
symbol = "?";
}
resourceURL = resourceURL + symbol + paramName + "=" + paramValue.toString();
counter++;
}
var callURL = this.apiServer + resourceURL;
var responseDataType = (returnType === null || returnType == String) ? "html" : "json";
this.trace("callURL = " + callURL);
this.trace("responseDataType = " + responseDataType);
var ajaxRequest = null;
if (method == "GET") {
// $.get(callURL, postObject,
// function(response) {
// ApiInvoker.fire(completionEvent, returnType, requestId, response, callback);
// }, responseDataType).complete(this.showCompleteStatus).error(this.showErrorStatus);
ajaxRequest = $.ajax({
url: callURL,
data: JSON.stringify(postObject),
type: "GET",
dataType: "jsonp",
contentType: "application/json",
success: function(response) {
ApiInvoker.fire(completionEvent, returnType, requestId, response, callback);
}
}).complete(this.showCompleteStatus).error(this.showErrorStatus);
} else if (method == "POST") {
this.trace("sending post");
this.trace(JSON.stringify(postObject));
ajaxRequest = $.ajax({
url: callURL,
data: JSON.stringify(postObject),
type: "POST",
dataType: "json",
contentType: "application/json",
headers: this.requestHeader,
success: function(response) {
ApiInvoker.fire(completionEvent, returnType, requestId, response, callback);
}
}).complete(this.showCompleteStatus).error(this.showErrorStatus);
} else if (method == "PUT") {
ajaxRequest = $.ajax({
url: callURL,
data: JSON.stringify(postObject),
type: "PUT",
dataType: "json",
contentType: "application/json",
success: function(response) {
ApiInvoker.fire(completionEvent, returnType, requestId, response, callback);
}
}).complete(this.showCompleteStatus).error(this.showErrorStatus);
} else if (method == "DELETE") {
ajaxRequest = $.ajax({
url: callURL,
data: JSON.stringify(postObject),
type: "DELETE",
dataType: "json",
contentType: "application/json",
success: function(response) {
ApiInvoker.fire(completionEvent, returnType, requestId, response, callback);
}
}).complete(this.showCompleteStatus).error(this.showErrorStatus);
}
return ajaxRequest;
},
this.guid = function() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
}).toUpperCase();
},
this._listeners = {},
this.addListener = function(type, listener) {
if (!this._listeners[type]) {
this._listeners[type] = [];
}
this._listeners[type].push(listener);
},
this.fire = function(completionEvent, returnType, requestId, response, callback) {
var event = new Object();
event.type = completionEvent;
event.requestId = requestId;
if (returnType === null || returnType == String) {
event.data = response;
} else {
event.data = eval("new " + returnType);
event.data.parse(response);
}
if (typeof event == "string") {
event = { type: event };
}
if (!event.target) {
event.target = this;
}
if (!event.type) {
throw new Error("Event object must have 'type' property");
}
this.trace(event.data);
if(callback) {
this.trace("invoking callback");
callback(event);
} else {
this.trace("firing event " + event.type);
if (this._listeners[event.type]) {
var listeners = this._listeners[event.type];
for (var i = 0; i < listeners.length; i++) {
listeners[i].call(this, event);
}
}
}
},
this.removeListener = function(type, listener) {
if (this._listeners[type]) {
var listeners = this._listeners[type];
for (var i = 0; i < listeners.length; i++) {
if (listeners[i] === listener) {
listeners.splice(i, 1);
break;
}
}
}
},
this.showErrorStatus = function(data) {
ApiInvoker.trace(data);
if (data.status != 200) {
ApiInvoker.error("ERROR - " + data.status + ": " + data.statusText + " / " + data.responseText);
} else {
ApiInvoker.showStatus(data);
}
},
this.showCompleteStatus = function(data) {
ApiInvoker.trace("complete " + data.status);
// ApiInvoker.showStatus(data);
},
this.showStatus = function(data) {
ApiInvoker.trace(data);
ApiInvoker.trace(data.getAllResponseHeaders());
},
this.toPathValue = function(value) {
if(typeof value == Array){
return this.arrayToPathValue(value);
} else
return value == null ? "" : value.toString();
},
this.arrayToPathValue = function(objects) {
return objects.join(",");
}
};

View File

@@ -1,30 +0,0 @@
package $packageName$;
$imports:{ import |
import $import$;
}$
/**
* $enum.description$
* NOTE: This class is auto generated by the drive code generator program so please do not edit the class manually.
* @author deepak
*
*/
public enum $className$ {
$values: { value | $value.name$($value.value$)};separator=", "$;
final $enumValueType$ value;
$className$($enumValueType$ value) {
this.value = value;
}
public $enumValueType$ getValue() {
return value;
}
@Override public String toString() {
return String.valueOf(this.getValue());
}
};

View File

@@ -1,66 +0,0 @@
/**
* $model.description$
*/
function $className$() {
$fields:{ field |
/**
* $field.description$
* $if(field.required)$@Required$endif$
* $if(field.allowableValues)$[AllowableValues(value="$field.allowedValuesString$"]$endif$
*/
this.$field.fieldDefinition.name$ = null;$\r$}$
this.parse = function(data) {
if(data) {
$fields:{ field |
$! //$field.fieldDefinition.returnType$ (primitive=$field.fieldDefinition.hasPrimitiveType$) !$
$if(field.fieldDefinition.hasListResponse)$
$if(field.fieldDefinition.hasPrimitiveType)$
this.$field.fieldDefinition.name$ = data.$field.fieldDefinition.name$;
$else$
this.$field.fieldDefinition.name$ = $field.fieldDefinition.collectionItemType$Object.parseArray(data.$field.fieldDefinition.name$);
$endif$
$elseif(field.fieldDefinition.hasSetResponse)$
$if(field.fieldDefinition.hasPrimitiveType)$
this.$field.fieldDefinition.name$ = data.$field.fieldDefinition.name$;
$else$
this.$field.fieldDefinition.name$ = $field.fieldDefinition.collectionItemType$Collection.get(data.$field.fieldDefinition.name$);
$endif$
$elseif(field.fieldDefinition.hasMapResponse)$
this.$field.fieldDefinition.name$ = data.$field.fieldDefinition.name$;
$elseif(field.fieldDefinition.hasDateResponse)$
this.$field.fieldDefinition.name$ = new Date(Date.parse(data.$field.fieldDefinition.name$));
$else$
$if(field.fieldDefinition.hasPrimitiveType)$
this.$field.fieldDefinition.name$ = data.$field.fieldDefinition.name$;
$else$
this.$field.fieldDefinition.name$ = new $field.fieldDefinition.returnType$(); this.$field.fieldDefinition.name$.parse(data.$field.fieldDefinition.name$);
$endif$
$endif$
}$
}
}
}
var $className$Object = new function() {
this.parseArray = function(arrayData) {
var responseArray = new Array();
if(arrayData != null && arrayData.length > 0) {
for(var i = 0; i < arrayData.length; i++) {
var o = new $className$();
o.parse(arrayData[i]);
responseArray.push(o);
}
}
return responseArray;
}
}

View File

@@ -1,101 +0,0 @@
/**
* NOTE: This class is auto generated by the drive code generator program so please do not edit the class manually.
*/
var $resource$ = new function() {
$methods:{ method |
this.event_$method.name$ = "$resource$.$method.name$";$\r$}$
// /**
// * Constructor for the $resource$ api client
// * @param apiCredentials Wrapper object for tokens and hostName required towards authentication
// * @param eventDispatcher Optional event dispatcher that when provided is used by the SDK to dispatch any Response
// */
// public function $resource$(apiCredentials: ApiUserCredentials, eventDispatcher: EventDispatcher = null) {
// super(apiCredentials, eventDispatcher);
// }
$methods:{ method |
/**
* $method.description$
$method.arguments:{ argument |
* @param $argument.name$ $argument.description$
$if(argument.allowedValues)$
* Allowed values are - $argument.allowedValues$
$endif$}$
*
$if(!method.responseVoid)$
* @return $method.returnValue$ {@link $method.returnClassName$} $endif$
* $if(method.hasArguments)$ $length(method.argumentNames)$ $endif$
*/
$if(method.hasArguments)$
this.$method.name$ = function($method.argumentNames; separator=", "$, callback)
$else$
this.$method.name$ = function(callback)
$endif$ {
$if(method.authToken)$
if(authToken == null || authToken.length == 0) {
throw new Error(ApiErrorCodes.AUTH_TOKEN_NOT_VALID);
}$endif$
var requestId = ApiInvoker.guid();
//parse inputs
var resourcePath = "$method.resourcePath$";
resourcePath = resourcePath.replace("{format}","json");
var method = "$method.methodType$";
var queryParams = new Object();
$if(!method.inputModel)$
$method.queryParameters:{ argument |
if( $argument.name$ != null) {
queryParams["$argument.name$"] = encodeURIComponent(ApiInvoker.toPathValue($argument.name$));
}
}$
$method.pathParameters:{ argument |
if( $argument.name$ != null) {
resourcePath = resourcePath.replace("{$argument.name$}", encodeURIComponent($argument.name$));
}
}$
$endif$
$if(method.inputModel)$
$method.queryParameters:{ argument |
if( $argument.inputModelClassArgument$ != null && $argument.methodNameFromModelClass$ != null) {
queryParams["$argument.name$"] = encodeURIComponent($argument.methodNameFromModelClass$);
}
}$
$method.pathParameters:{ argument |
if( $argument.inputModelClassArgument$ != null && $argument.methodNameFromModelClass$ != null) {
resourcePath = resourcePath.replace("{$argument.name$}", encodeURIComponent($argument.methodNameFromModelClass$));
}
}$
$endif$
//make the API Call
var eventName = "$resource$.$method.name$";
var returnType = null;
$if(!method.responseVoid)$
returnType = $method.returnClassName$;
$endif$
var ajaxRequest = null;
$if(method.postObject)$
$if(method.authToken)$
ajaxRequest = ApiInvoker.invokeAPI(authToken, resourcePath, method, queryParams, postData, eventName, requestId, returnType, callback);
$endif$
$if(!method.authToken)$
ajaxRequest = ApiInvoker.invokeAPI(null, resourcePath, method, queryParams, postData, eventName, requestId, returnType, callback);
$endif$
$endif$
$if(!method.postObject)$
$if(method.authToken)$
ajaxRequest = ApiInvoker.invokeAPI(authToken, resourcePath, method, queryParams, null, eventName, requestId, returnType, callback);
$endif$
$if(!method.authToken)$
ajaxRequest = ApiInvoker.invokeAPI(null, resourcePath, method, queryParams, null, eventName, requestId, returnType, callback);
$endif$
$endif$
return {"requestId":requestId, "ajaxRequest":ajaxRequest};
}
}$
}

View File

@@ -1,8 +0,0 @@
/**
* Maintains the compatible server version against which the drive is written
*
*/
var VersionChecker = new function() {
this.compatibleVersion = "$apiVersion$";
}

View File

@@ -1,33 +0,0 @@
/**
* $model.description$
* NOTE: This class is auto generated by the drive code generator program so please do not edit the class manually.
* @author deepak
*
*/
function $className$() {
$fields:{ field |
/**
* $field.description$
* $if(field.required)$@Required$endif$
* $if(field.allowableValues)$[AllowableValues(value="$field.allowedValuesString$"]$endif$
*/
this.$field.fieldDefinition.name$ $field.fieldDefinition.initialization$;}$
$fields:{ field |
/**
* Returns the list being wrapped by this wrapper class. There will be a single list item attribute in this class.
*/
$if(field.fieldDefinition.collectionItemType)$
this.getList = function() {
return this.$field.fieldDefinition.name$;
}
this.parse = function(data) {
if(data) {
this.$field.fieldDefinition.name$ = $field.fieldDefinition.collectionItemType$Object.parseArray(data);
}
}
$endif$}$
}

View File

@@ -1,120 +0,0 @@
<?php
/**
* Copyright 2011 Wordnik, 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.
*/
/**
*
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
*/
class $resource$ {
function __construct(\$apiClient) {
\$this->apiClient = \$apiClient;
}
$methods:{ method |
/**
* $method.title$
*
$if(method.description)$
* $method.description$
* $endif$
* $method.arguments:{ argument |@param $argument.name$ $argument.description$
* $if(argument.allowedValues)$
* Allowed values are - $argument.allowedValues$ $endif$ }$
$if(!method.responseVoid)$
* @return $method.returnValue$ {@link $method.returnClassName$} $endif$
* @throws APIException $method.exceptionDescription$
*/
public function $method.name$($method.arguments: { argument | \$$argument.name$}; separator=", "$) {
//parse inputs
\$resourcePath = "$method.resourcePath$";
\$resourcePath = str_replace("{format}", "json", \$resourcePath);
\$method = "$method.methodType$";
\$queryParams = array();
\$headerParams = array();
$if(!method.inputModel)$
$method.queryParameters:{ argument |
if(\$$argument.name$ != null) {
\$queryParams['$argument.name$'] = \$this->apiClient->toPathValue(\$$argument.name$);
}
}$
$method.pathParameters:{ argument |
if(\$$argument.name$ != null) {
\$resourcePath = str_replace("{$argument.name$}", \$$argument.name$, \$resourcePath);
}
}$
$method.headerParameters:{ argument |
if(\$$argument.name$ != null) {
\$headerParams['$argument.name$'] = \$this->apiClient->toPathValue(\$$argument.name$);
}
}$
$endif$
$if(method.inputModel)$
$method.queryParameters:{ argument |
if(\$$argument.inputModelClassArgument$ != null && \$$argument.inputModelClassArgument$->$argument.name$ != null) {
\$queryParams["$argument.name$"] = \$this->apiClient->toPathValue(\$$argument.inputModelClassArgument$->$argument.name$);
}
}$
$method.pathParameters:{ argument |
if(\$$argument.inputModelClassArgument$ != null && \$$argument.inputModelClassArgument$->$argument.name$ != null) {
\$resourcePath = str_replace("{$argument.name$}", \$$argument.inputModelClassArgument$->$argument.name$, \$resourcePath);
}
}$
$method.headerParameters:{ argument |
if(\$$argument.inputModelClassArgument$ != null && \$$argument.inputModelClassArgument$->$argument.name$ != null) {
\$headerParams['$argument.name$'] = \$this->apiClient->toPathValue(\$$argument.inputModelClassArgument$->$argument.name$);
}
}$
$endif$
//make the API Call
$if(method.postObject)$
\$response = \$this->apiClient->callAPI(\$resourcePath, \$method, \$queryParams, \$postData, \$headerParams);
$endif$
$if(!method.postObject)$
\$response = \$this->apiClient->callAPI(\$resourcePath, \$method, \$queryParams, null, \$headerParams);
$endif$
$if(!method.responseVoid)$
if(! \$response){
return null;
}
$if(!method.returnValueList)$
//create output objects if the response has more than one object
\$responseObject = \$this->apiClient->deserialize(\$response, '$method.returnClassName$');
return \$responseObject;
$endif$
$if(method.returnValueList)$
\$responseObjects = array();
foreach (\$response as \$object) {
\$responseObjects[] = \$this->apiClient->deserialize(\$object, '$method.returnClassName$');
}
return \$responseObjects;
$endif$
$endif$
}
}$
}

View File

@@ -1,131 +0,0 @@
#!/usr/bin/env python
"""Wordnik.com's Swagger generic API client. This client handles the client-
server communication, and is invariant across implementations. Specifics of
the methods and models for each application are generated from the Swagger
templates."""
import sys
import os
import re
import urllib
import urllib2
import httplib
import json
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../')
import model
class APIClient:
"""Generic API client for Swagger client library builds"""
def __init__(self, apiKey=None, apiServer=None):
if apiKey == None:
raise Exception('You must pass an apiKey when instantiating the '
'APIClient')
self.apiKey = apiKey
self.apiServer = apiServer
def callAPI(self, resourcePath, method, queryParams, postData,
headerParams=None):
url = self.apiServer + resourcePath
headers = {}
if headerParams:
for param, value in headerParams.iteritems():
headers[param] = value
headers['Content-type'] = 'application/json'
headers['api_key'] = self.apiKey
data = None
if method == 'GET':
if queryParams:
# Need to remove None values, these should not be sent
sentQueryParams = {}
for param, value in queryParams.iteritems():
if value != None:
sentQueryParams[param] = value
url = url + '?' + urllib.urlencode(sentQueryParams)
request = urllib2.Request(url=url, headers=headers)
elif method in ['POST', 'PUT', 'DELETE']:
data = postData
if data:
if type(postData) not in [str, int, float, bool]:
data = json.dumps(postData.__dict__)
request = urllib2.Request(url=url, headers=headers, data=data)
if method in ['PUT', 'DELETE']:
# Monkey patch alert! Urllib2 doesn't really do PUT / DELETE
request.get_method = lambda: method
else:
raise Exception('Method ' + method + ' is not recognized.')
# Make the request
response = urllib2.urlopen(request).read()
try:
data = json.loads(response)
except ValueError: # PUT requests don't return anything
data = None
return data
def toPathValue(self, obj):
"""Serialize a list to a CSV string, if necessary.
Args:
obj -- data object to be serialized
Returns:
string -- json serialization of object
"""
if type(obj) == list:
return ','.join(obj)
else:
return obj
def deserialize(self, obj, objClass):
"""Derialize a JSON string into an object.
Args:
obj -- string or object to be deserialized
objClass -- class literal for deserialzied object, or string
of class name
Returns:
object -- deserialized object"""
# Have to accept objClass as string or actual type. Type could be a
# native Python type, or one of the model classes.
if type(objClass) == str:
try:
objClass = eval(objClass)
except NameError: # not a native type, must be model class
objClass = eval('model.' + objClass + '.' + objClass)
if objClass in [str, int, float, bool]:
return objClass(obj)
instance = objClass()
for attr, attrType in instance.swaggerTypes.iteritems():
if attr in obj:
value = obj[attr]
if attrType in ['str', 'int', 'float', 'bool']:
attrType = eval(attrType)
try:
value = attrType(value)
except UnicodeEncodeError:
value = unicode(value)
setattr(instance, attr, value)
elif 'list<' in attrType:
match = re.match('list<(.*)>', attrType)
subClass = match.group(1)
subValues = []
for subValue in value:
subValues.append(self.deserialize(subValue, subClass))
setattr(instance, attr, subValues)
else:
setattr(instance, attr, self.deserialize(value,
objClass))
return instance

View File

@@ -1,118 +0,0 @@
#!/usr/bin/env python
"""
$resource$.py
Copyright 2011 Wordnik, 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.
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
"""
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../')
import model
class $resource$(object):
def __init__(self, apiClient):
self.apiClient = apiClient
$methods:{ method |
def $method.name$(self, $method.arguments: { argument | $if(argument.required)$$argument.name$, $endif$}$$method.arguments: { argument | $if(! argument.required)$$argument.name$=None, $endif$}$):
"""$method.title$
$if(method.description)$
$method.description$
$endif$
Args:
$method.arguments:{ argument |$argument.name$ -- $argument.description$
$if(argument.allowedValues)$
Allowed values are - $argument.allowedValues$
$endif$}$
$if(!method.responseVoid)$
Return:
$method.returnValue$ -- an instance of $method.returnClassName$
$endif$"""
# Parse inputs
resourcePath = '$method.resourcePath$'
resourcePath = resourcePath.replace('{format}', 'json')
method = '$method.methodType$'
queryParams = {}
headerParams = {}
$if(!method.inputModel)$
$method.queryParameters:{ argument |
queryParams['$argument.name$'] = self.apiClient.toPathValue($argument.name$)
}$
$method.pathParameters:{ argument |
if $argument.name$ != None:
resourcePath = resourcePath.replace('{$argument.name$}', $argument.name$)
}$
$method.headerParameters:{ argument |
if $argument.name$ != None:
headerParams['$argument.name$'] = self.apiClient.toPathValue($argument.name$)
}$
$endif$
$if(method.inputModel)$
$method.queryParameters:{ argument |
if $argument.inputModelClassArgument$ != None and $argument.inputModelClassArgument$.$argument.name$ != None:
queryParams['$argument.name$'] = self.apiClient.toPathValue($argument.inputModelClassArgument$.$argument.name$)
}$
$method.pathParameters:{ argument |
if $argument.inputModelClassArgument$ != None and $argument.inputModelClassArgument$.$argument.name$ != None:
resourcePath = resourcePath.replace('{$argument.name$}', $argument.inputModelClassArgument$.$argument.name$)
}$
$method.headerParameters:{ argument |
if $argument.inputModelClassArgument$ != None and $argument.inputModelClassArgument$.$argument.name$ != None:
headerParams['$argument.name$'] = self.apiClient.toPathValue($argument.inputModelClassArgument$.$argument.name$)
}$
$endif$
# Make the API Call
$if(method.postObject)$
response = self.apiClient.callAPI(resourcePath, method, queryParams,
postData, headerParams)
$endif$
$if(!method.postObject)$
response = self.apiClient.callAPI(resourcePath, method, queryParams,
None, headerParams)
$endif$
$if(!method.responseVoid)$
if not response:
return None
$if(!method.returnValueList)$
# Create output objects if the response has more than one object
responseObject = self.apiClient.deserialize(response,
model.$method.returnClassName$.$method.returnClassName$)
return responseObject
$endif$
$if(method.returnValueList)$
responseObjects = []
for responseObject in response:
responseObjects.append(self.apiClient.deserialize(responseObject,
model.$method.returnClassName$.$method.returnClassName$))
return responseObjects
$endif$
$endif$
}$

View File

@@ -1,128 +0,0 @@
<?xml version="1.0"?>
<project name="swagger-sample-scala-lib" xmlns:ivy="antlib:org.apache.ivy.ant" default="build.all" basedir=".">
<property environment="env" />
<property name="version.identifier" value="1.0" />
<property name="artifact.ext" value="jar" />
<property name="organization" value="wordnik" />
<property name="module" value="${ant.project.name}" />
<!-- default dirs for the build -->
<mkdir dir="lib"/>
<mkdir dir="lib/ext"/>
<condition property="scala.home" value="${env.SCALA_HOME}">
<isset property="env.SCALA_HOME" />
</condition>
<path id="scala.classpath">
<fileset dir="${scala.home}/lib">
<include name="scala**.jar" />
</fileset>
</path>
<ivy:settings file="ivysettings.xml" />
<taskdef resource="scala/tools/ant/antlib.xml">
<classpath>
<fileset dir="lib">
<include name="scala**.jar" />
</fileset>
<fileset dir="${scala.home}/lib">
<include name="scala**.jar" />
</fileset>
</classpath>
</taskdef>
<!-- this is the output module -->
<property name="module" value="${ant.project.name}" />
<target name="build.all" depends="clean, resolve, fastcompile" description="builds the module (default target)" />
<target name="clean" description="cleans the project folder">
<mkdir dir="build" />
<echo message="deleting build files" />
<delete quiet="true">
<fileset dir="build">
<include name="*.jar" />
<include name="*.xml" />
</fileset>
</delete>
<delete dir="build/main" quiet="true" />
<delete dir="dist" quiet="true" />
<!-- libraries handled by ivy -->
<echo message="deleting libs handled by ivy" />
<delete>
<fileset dir="lib">
<include name="*.jar" />
<include name="*.zip" />
</fileset>
</delete>
</target>
<!-- copies ONLY the swagger-sample jar to dist-->
<target name="fastdist" depends="fastcompile">
<copy todir="dist/lib">
<fileset dir="build">
<include name="*.jar" />
</fileset>
</copy>
</target>
<!-- copies all dependencies into the lib folder -->
<target name="resolve" description="retreive dependencies with ivy">
<ivy:retrieve pattern="${basedir}/lib/[artifact]-[revision].[ext]" conf="build" />
</target>
<target name="fastcompile" description="builds the module without artifact resolution or cleaning">
<delete quiet="true" file="build/${organization}-${artifact}-*.${artifact.ext}" />
<mkdir dir="build" />
<mkdir dir="build/main" />
<mkdir dir="build/main/java" />
<javac srcdir="src/main/java" debug="true" destdir="build/main/java">
<classpath>
<fileset dir="lib">
<include name="*.jar" />
</fileset>
<fileset dir="lib/ext">
<include name="*.jar" />
</fileset>
<pathelement location="build/main/java" />
</classpath>
</javac>
<scalac srcdir="src/main/java:src/main/scala" destdir="build/main/java">
<classpath>
<pathelement location="build/main/java" />
<fileset dir="lib">
<include name="*.jar" />
</fileset>
<fileset dir="lib/ext">
<include name="*.jar" />
</fileset>
<fileset dir="${scala.home}/lib"/>
</classpath>
<include name="**/*.scala" />
<include name="**/*.java" />
</scalac>
<jar jarfile="build/${module}-${version.identifier}.${artifact.ext}">
<fileset dir="build/main/java" />
</jar>
</target>
<!-- cleans up the dist -->
<target name="dist.clean" description="cleans the distribution folder">
<delete quiet="true" dir="dist" />
<delete quiet="true" file="dist.zip" />
</target>
<target name="dependency.tree" description="builds a graphml dependency diagram for viewing with yEd">
<ivy:report conf="build" graph="true" todir="." outputpattern="[artifact]-[revision].[ext]" />
</target>
</project>

View File

@@ -1,31 +0,0 @@
<ivy-module version="2.0">
<info organisation="wordnik" module="sample-java-lib"/>
<configurations>
<conf name="build" description="build wordnik-java"/>
<conf name="test" visibility="public"/>
<conf name="source" visibility="public"/>
<conf name="pom" visibility="public"/>
</configurations>
<dependencies>
<!-- jersey dependencies -->
<dependency org="junit" name="junit" rev="4.4" conf="build->default"/>
<dependency org="com.sun.jersey" name="jersey-json" rev="1.4" conf="build->default"/>
<dependency org="com.sun.jersey" name="jersey-client" rev="1.4" conf="build->default"/>
<dependency org="com.sun.jersey" name="jersey-server" rev="1.4" conf="build->default"/>
<dependency org="com.sun.jersey" name="jersey-core" rev="1.4" conf="build->default"/>
<dependency org="asm" name="asm-parent" rev="3.1" conf="build->default"/>
<dependency org="commons-beanutils" name="commons-beanutils" rev="1.8.0" conf="build->default"/>
<dependency org="org.antlr" name="stringtemplate" rev="3.2" conf="build->default"/>
<!-- jackson jars -->
<dependency org="org.codehaus.jackson" name="jackson-jaxrs" rev="1.7.1" conf="build->default"/>
<dependency org="org.codehaus.jackson" name="jackson-xc" rev="1.7.1" conf="build->default"/>
<dependency org="org.codehaus.jackson" name="jackson-mapper-asl" rev="1.7.1" conf="build->default"/>
<dependency org="net.sourceforge.cobertura" name="cobertura" rev="1.9.2" conf="test->default">
<exclude org="asm" name="asm-tree"/>
<exclude org="asm" name="asm"/>
</dependency>
</dependencies>
</ivy-module>

View File

@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ivysettings>
<settings defaultResolver="chained" />
<property name="ivy.checksums" value=""/>
<property name="ivy.local.default.root" value="${ivy.default.ivy.user.dir}/local"
override="false" />
<property name="ivy.local.default.ivy.pattern"
value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]"
override="false" />
<property name="ivy.local.default.artifact.pattern"
value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]"
override="false" />
<resolvers>
<chain name="chained" returnFirst="true">
<filesystem name="local">
<ivy pattern="${ivy.local.default.root}/${ivy.local.default.ivy.pattern}" />
<artifact pattern="${ivy.local.default.root}/${ivy.local.default.artifact.pattern}" />
</filesystem>
<ibiblio name="ibiblio" m2compatible="true" />
<ibiblio name="javanet" root="http://download.java.net/maven/2/" m2compatible="true" />
</chain>
</resolvers>
</ivysettings>

View File

@@ -1,27 +0,0 @@
{
"apiUrl":"http://localhost:8002/api/",
"apiKey":"special-key",
"defaultServiceBaseClass":"Object",
"defaultModelBaseClass":"Object",
"serviceBaseClasses":{},
"defaultModelImports":[],
"defaultServiceImports":[],
"modelPackageName":"com.wordnik.swagger.sample.sdk.java.model",
"apiPackageName":"com.wordnik.swagger.sample.sdk.java.api",
"ignoreMethods":[],
"ignoreModels":[],
"outputDirectory":"../swagger-sample-app/sdk-libs/src/main/java/com/wordnik/swagger/sample/sdk/java",
"libraryHome":"../swagger-sample-app/sdk-libs"
}

View File

@@ -1,42 +0,0 @@
{
"userList":[
{
"username":"testuser1",
"password":"password1",
"email":"test1@dummy.com"
},
{
"username":"testuser2",
"password":"password2",
"email":"test2@dummy.com"
}
],
"petList":[
{
"id":101,
"name":"pet1",
"photoUrls":["url1","url2"],
"tags":[
{
"id":1,
"name":"tag1"
},
{
"id":2,
"name":"tag2"
}
],
"status":"available",
"category":{"id":1,"name":"cat1"}
}
],
"orderList":[
{
"id":101,
"petId":1,
"quantity":1,
"status":"placed",
"shipDate":13456789
}
]
}

View File

@@ -1,265 +0,0 @@
{
"resources" : [
{
"id" : 1,
"name" : "Find Per by Id",
"httpMethod" : "GET",
"path" : "/pet.{format}/{petId}",
"suggestedMethodName" : "getPetById"
},
{
"id" : 2,
"name" : "Find pets by status",
"httpMethod" : "GET",
"path" : "/pet.{format}/findByStatus",
"suggestedMethodName" : "findPetsByStatus"
},
{
"id" : 3,
"name" : "Find pets by tags",
"httpMethod" : "GET",
"path" : "/pet.{format}/findByTags",
"suggestedMethodName" : "findPetsByTags"
},
{
"id" : 4,
"name" : "Add a pet",
"httpMethod" : "POST",
"path" : "/pet.{format}",
"suggestedMethodName" : "addPet"
},
{
"id" : 5,
"name" : "Update a pet",
"httpMethod" : "PUT",
"path" : "/pet.{format}",
"suggestedMethodName" : "updatePet"
},
{
"id" : 6,
"name" : "Create user",
"httpMethod" : "POST",
"path" : "/user.{format}",
"suggestedMethodName" : "createUser"
},
{
"id" : 7,
"name" : "Update user",
"httpMethod" : "PUT",
"path" : "/user.{format}/{username}",
"suggestedMethodName" : "updateUser"
},
{
"id" : 8,
"name" : "Delete user",
"httpMethod" : "DELETE",
"path" : "/user.{format}/{username}",
"suggestedMethodName" : "deleteUser"
},
{
"id" : 9,
"name" : "Get user by user name",
"httpMethod" : "GET",
"path" : "/user.{format}/{username}",
"suggestedMethodName" : "getUserByName"
},
{
"id" : 10,
"name" : "Login",
"httpMethod" : "GET",
"path" : "/user.{format}/login",
"suggestedMethodName" : "loginUser"
},
{
"id" : 11,
"name" : "Logout",
"httpMethod" : "GET",
"path" : "/user.{format}/logout",
"suggestedMethodName" : "logoutUser"
},
{
"id" : 12,
"name" : "Find order by id",
"httpMethod" : "GET",
"path" : "/store.{format}/order/{orderId}",
"suggestedMethodName" : "getOrderById"
},
{
"id" : 13,
"name" : "Delete order by id",
"httpMethod" : "DELETE",
"path" : "/store.{format}/order/{orderId}",
"suggestedMethodName" : "deleteOrder"
},
{
"id" : 14,
"name" : "Create order",
"httpMethod" : "POST",
"path" : "/store.{format}/order",
"suggestedMethodName" : "placeOrder"
}
],
"testSuites" : [
{
"id" : 1,
"name" : "Test User service related APIs",
"testCases" : [
{
"name" : "Create User",
"id" : 1,
"resourceId" : 6,
"input" : {
"postData":"${input.userList[0]}"
},
"assertions" : [
{
"actualOutput" : "${output(1.1)}",
"condition" : "!=",
"expectedOutput" : "EXCEPTION"
}
]
},
{
"name" : "Login User",
"id" : 2,
"resourceId" : 10,
"input" : {
"username":"${input.userList[0].username}",
"password":"${input.userList[0].password}"
},
"assertions" : [
{
"actualOutput" : "${output(1.2)}",
"condition" : "!=",
"expectedOutput" : "EXCEPTION"
}
]
},
{
"name" : "Find user by name",
"id" : 3,
"resourceId" : 9,
"input" : {
"username":"${input.userList[0].username}"
},
"assertions" : [
{
"actualOutput" : "${output(1.3).username}",
"condition" : "==",
"expectedOutput" : "${input.userList[0].username}"
}
]
},
{
"name" : "Delete user by name",
"id" : 4,
"resourceId" : 9,
"input" : {
"username":"${input.userList[0].username}"
},
"assertions" : [
{
"actualOutput" : "${output(1.4)}",
"condition" : "!=",
"expectedOutput" : "EXCEPTION"
}
]
}
]
},
{
"id" : 2,
"name" : "Test Pet service related APIs",
"testCases" : [
{
"name" : "Add pet",
"id" : 1,
"resourceId" : 4,
"input" : {
"postData":"${input.petList[0]}"
},
"assertions" : [
{
"actualOutput" : "${output(2.1)}",
"condition" : "!=",
"expectedOutput" : "EXCEPTION"
}
]
},
{
"name" : "Find pet by id",
"id" : 2,
"resourceId" : 1,
"input" : {
"petId":"1"
},
"assertions" : [
{
"actualOutput" : "${output(2.2)}",
"condition" : "!=",
"expectedOutput" : "NULL"
}
]
},
{
"name" : "Find pet by status",
"id" : 3,
"resourceId" : 2,
"input" : {
"status":"available,sold,pending"
},
"assertions" : [
{
"actualOutput" : "${output(2.3).size}",
"condition" : ">",
"expectedOutput" : "0"
}
]
}
]
},
{
"id" : 3,
"name" : "Test Store service related APIs",
"testCases" : [
{
"name" : "Find order by id",
"id" : 1,
"resourceId" : 12,
"input" : {
"orderId":"1"
},
"assertions" : [
{
"actualOutput" : "${output(3.1)}",
"condition" : "!=",
"expectedOutput" : "NULL"
}
]
},
{
"name" : "Place order",
"id" : 2,
"resourceId" : 14,
"input" : {
"postData":"${input.orderList[0]}"
},
"assertions" : [
{
"actualOutput" : "${output(1.2)}",
"condition" : "!=",
"expectedOutput" : "EXCEPTION"
}
]
}
]
}
]
}

View File

@@ -1 +0,0 @@
# nothing to see yet

View File

@@ -1,21 +0,0 @@
class $className$Model
attr_accessor $fields:{ field | :$field.fieldDefinition.name$};separator=", "$
$fields:{ field |
$if(field.required)$ validate_presence_of :$field.fieldDefinition.name$$endif$
}$
# TODO: move this to base class
def initialize(attributes = {})
attributes.symbolize_and_underscore_keys!
# loop over incoming attributes, only assign to valid attr_accessor props
$fields:{ field |
if(UserModel.respond_to? :$field.fieldDefinition.name$) self.$field.fieldDefinition.name$ = attributes[:$field.fieldDefinition.name$]
}$
# if(UserModel.respond_to? :word) self.word = attributes[:word]
# Zap any whitespace and bad encoding
# attributes[:name] &&= attributes[:name].strip.squeeze(' ').force_encoding('UTF-8')
# super(attributes)
end
end

View File

@@ -1,47 +0,0 @@
module $resource$
$methods:{ method |
def $method.name$(opts={})
$if(method.pathParameters)$ requiredKeys=[:$method.pathParameters:{ param | $param.name$};separator=", "$]$endif$
$if(method.queryParameters)$ queryparamKeys=[:$method.queryParameters:{ param | $param.name$};separator=", "$]$endif$
$if(method.pathParameters)$
#check required options
requiredKeys.each do |key|
raise "#{key} is required" unless options.has_key?(key)
end
$endif$
# set default values and merge with input
options = {
$if(method.arguments)$$method.arguments:{ param | $if(param.defaultValue)$ :$param.name$="$param.defaultValue$"$endif$}$$endif$
}.merge(opts)
#resource path
path = "$method.resourcePath$".sub('{format}', '.json')
$if(method.pathParameters)$
# sub pathparams
$method.pathParameters:{ param |
path.sub!('{$param.name$}', URI.encode(options[:$param.name$]))
}$$endif$
#pull querystring keys from options
queryopts = options.select do |key,value|
queryparamKeys.include? key
end
$if(method.hasResponseValue)$
results = Swagger::request.new(:get, path, queryopts, nil)
$if(method.returnValueList)$
output = results.map {|result| $method.returnValue$.new(result)}
$else$
output = $method.returnValue$.new(result)
$endif$
$else$
Swagger::request.new(:get, path, queryopts, nil)
$endif$
end
}$

View File

@@ -1,5 +0,0 @@
module $resource$
def get_compatible_version(*args)
'$apiVersion$'
end

View File

@@ -1,117 +0,0 @@
<?xml version="1.0"?>
<project name="swagger-sample-scala-lib" xmlns:ivy="antlib:org.apache.ivy.ant" default="build.all" basedir=".">
<property environment="env" />
<property name="version.identifier" value="1.0" />
<property name="artifact.ext" value="jar" />
<property name="organization" value="wordnik" />
<property name="module" value="${ant.project.name}" />
<!-- default dirs for the build -->
<mkdir dir="lib"/>
<mkdir dir="lib/ext"/>
<condition property="scala.home" value="${env.SCALA_HOME}">
<isset property="env.SCALA_HOME" />
</condition>
<path id="scala.classpath">
<fileset dir="${scala.home}/lib">
<include name="scala**.jar" />
</fileset>
</path>
<ivy:settings file="ivysettings.xml" />
<taskdef resource="scala/tools/ant/antlib.xml">
<classpath>
<fileset dir="lib">
<include name="scala**.jar" />
</fileset>
<fileset dir="${scala.home}/lib">
<include name="scala**.jar" />
</fileset>
</classpath>
</taskdef>
<!-- this is the output module -->
<property name="module" value="${ant.project.name}" />
<target name="jar" description="creates jar file " depends="build.all">
<jar jarfile="build/${release.module}-${release.version}.${artifact.ext}">
<fileset dir="build/main/java" />
</jar>
</target>
<target name="build.all" depends="clean, resolve, fastcompile" description="builds the module (default target)" />
<target name="clean" description="cleans the project folder">
<mkdir dir="build" />
<echo message="deleting build files" />
<delete quiet="true">
<fileset dir="build">
<include name="*.jar" />
<include name="*.xml" />
</fileset>
</delete>
<delete dir="build/main" quiet="true" />
<delete dir="dist" quiet="true" />
<!-- libraries handled by ivy -->
<echo message="deleting libs handled by ivy" />
<delete>
<fileset dir="lib">
<include name="*.jar" />
<include name="*.zip" />
</fileset>
</delete>
</target>
<!-- copies all dependencies into the lib folder -->
<target name="resolve" description="retreive dependencies with ivy">
<ivy:retrieve pattern="${basedir}/lib/[artifact]-[revision].[ext]" conf="build" />
</target>
<target name="fastcompile" description="builds the module without artifact resolution or cleaning">
<delete quiet="true" file="build/${organization}-${artifact}-*.${artifact.ext}" />
<mkdir dir="build" />
<mkdir dir="build/main" />
<mkdir dir="build/main/java" />
<javac srcdir="src/main/java" debug="true" destdir="build/main/java">
<classpath>
<fileset dir="lib">
<include name="*.jar" />
</fileset>
<fileset dir="lib/ext">
<include name="*.jar" />
</fileset>
<pathelement location="build/main/java" />
</classpath>
</javac>
<scalac srcdir="src/main/java:src/main/scala" destdir="build/main/java">
<classpath>
<pathelement location="build/main/java" />
<fileset dir="lib">
<include name="*.jar" />
</fileset>
<fileset dir="lib/ext">
<include name="*.jar" />
</fileset>
<fileset dir="${scala.home}/lib"/>
</classpath>
<include name="**/*.scala" />
<include name="**/*.java" />
</scalac>
<jar jarfile="build/${module}-${version.identifier}.${artifact.ext}">
<fileset dir="build/main/java" />
</jar>
</target>
<target name="dependency.tree" description="builds a graphml dependency diagram for viewing with yEd">
<ivy:report conf="build" graph="true" todir="." outputpattern="[artifact]-[revision].[ext]" />
</target>
</project>

View File

@@ -1,31 +0,0 @@
<ivy-module version="2.0">
<info organisation="wordnik" module="sample-java-lib"/>
<configurations>
<conf name="build" description="build wordnik-java"/>
<conf name="test" visibility="public"/>
<conf name="source" visibility="public"/>
<conf name="pom" visibility="public"/>
</configurations>
<dependencies>
<!-- jersey dependencies -->
<dependency org="junit" name="junit" rev="4.4" conf="build->default"/>
<dependency org="com.sun.jersey" name="jersey-json" rev="1.4" conf="build->default"/>
<dependency org="com.sun.jersey" name="jersey-client" rev="1.4" conf="build->default"/>
<dependency org="com.sun.jersey" name="jersey-server" rev="1.4" conf="build->default"/>
<dependency org="com.sun.jersey" name="jersey-core" rev="1.4" conf="build->default"/>
<dependency org="asm" name="asm-parent" rev="3.1" conf="build->default"/>
<dependency org="commons-beanutils" name="commons-beanutils" rev="1.8.0" conf="build->default"/>
<dependency org="org.antlr" name="stringtemplate" rev="3.2" conf="build->default"/>
<!-- jackson jars -->
<dependency org="org.codehaus.jackson" name="jackson-jaxrs" rev="1.7.1" conf="build->default"/>
<dependency org="org.codehaus.jackson" name="jackson-xc" rev="1.7.1" conf="build->default"/>
<dependency org="org.codehaus.jackson" name="jackson-mapper-asl" rev="1.7.1" conf="build->default"/>
<dependency org="net.sourceforge.cobertura" name="cobertura" rev="1.9.2" conf="test->default">
<exclude org="asm" name="asm-tree"/>
<exclude org="asm" name="asm"/>
</dependency>
</dependencies>
</ivy-module>

View File

@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ivysettings>
<settings defaultResolver="chained" />
<property name="ivy.checksums" value=""/>
<property name="ivy.local.default.root" value="${ivy.default.ivy.user.dir}/local"
override="false" />
<property name="ivy.local.default.ivy.pattern"
value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]"
override="false" />
<property name="ivy.local.default.artifact.pattern"
value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]"
override="false" />
<resolvers>
<chain name="chained" returnFirst="true">
<filesystem name="local">
<ivy pattern="${ivy.local.default.root}/${ivy.local.default.ivy.pattern}" />
<artifact pattern="${ivy.local.default.root}/${ivy.local.default.artifact.pattern}" />
</filesystem>
<ibiblio name="ibiblio" m2compatible="true" />
<ibiblio name="javanet" root="http://download.java.net/maven/2/" m2compatible="true" />
</chain>
</resolvers>
</ivysettings>

View File

@@ -1,27 +0,0 @@
{
"apiUrl":"http://localhost:8002/api/",
"apiKey":"special-key",
"defaultServiceBaseClass":"Object",
"defaultModelBaseClass":"Object",
"serviceBaseClasses":{},
"defaultModelImports":[],
"defaultServiceImports":[],
"modelPackageName":"com.wordnik.swagger.sample.sdk.java.model",
"apiPackageName":"com.wordnik.swagger.sample.sdk.java.api",
"ignoreMethods":[],
"ignoreModels":[],
"outputDirectory":"../swagger-sample-app/sdk-libs/src/main/java/com/wordnik/swagger/sample/sdk/java",
"libraryHome":"../swagger-sample-app/sdk-libs"
}

View File

@@ -1,42 +0,0 @@
{
"userList":[
{
"username":"testuser1",
"password":"password1",
"email":"test1@dummy.com"
},
{
"username":"testuser2",
"password":"password2",
"email":"test2@dummy.com"
}
],
"petList":[
{
"id":101,
"name":"pet1",
"photoUrls":["url1","url2"],
"tags":[
{
"id":1,
"name":"tag1"
},
{
"id":2,
"name":"tag2"
}
],
"status":"available",
"category":{"id":1,"name":"cat1"}
}
],
"orderList":[
{
"id":101,
"petId":1,
"quantity":1,
"status":"placed",
"shipDate":13456789
}
]
}

View File

@@ -1,265 +0,0 @@
{
"resources" : [
{
"id" : 1,
"name" : "Find Per by Id",
"httpMethod" : "GET",
"path" : "/pet.{format}/{petId}",
"suggestedMethodName" : "getPetById"
},
{
"id" : 2,
"name" : "Find pets by status",
"httpMethod" : "GET",
"path" : "/pet.{format}/findByStatus",
"suggestedMethodName" : "findPetsByStatus"
},
{
"id" : 3,
"name" : "Find pets by tags",
"httpMethod" : "GET",
"path" : "/pet.{format}/findByTags",
"suggestedMethodName" : "findPetsByTags"
},
{
"id" : 4,
"name" : "Add a pet",
"httpMethod" : "POST",
"path" : "/pet.{format}",
"suggestedMethodName" : "addPet"
},
{
"id" : 5,
"name" : "Update a pet",
"httpMethod" : "PUT",
"path" : "/pet.{format}",
"suggestedMethodName" : "updatePet"
},
{
"id" : 6,
"name" : "Create user",
"httpMethod" : "POST",
"path" : "/user.{format}",
"suggestedMethodName" : "createUser"
},
{
"id" : 7,
"name" : "Update user",
"httpMethod" : "PUT",
"path" : "/user.{format}/{username}",
"suggestedMethodName" : "updateUser"
},
{
"id" : 8,
"name" : "Delete user",
"httpMethod" : "DELETE",
"path" : "/user.{format}/{username}",
"suggestedMethodName" : "deleteUser"
},
{
"id" : 9,
"name" : "Get user by user name",
"httpMethod" : "GET",
"path" : "/user.{format}/{username}",
"suggestedMethodName" : "getUserByName"
},
{
"id" : 10,
"name" : "Login",
"httpMethod" : "GET",
"path" : "/user.{format}/login",
"suggestedMethodName" : "loginUser"
},
{
"id" : 11,
"name" : "Logout",
"httpMethod" : "GET",
"path" : "/user.{format}/logout",
"suggestedMethodName" : "logoutUser"
},
{
"id" : 12,
"name" : "Find order by id",
"httpMethod" : "GET",
"path" : "/store.{format}/order/{orderId}",
"suggestedMethodName" : "getOrderById"
},
{
"id" : 13,
"name" : "Delete order by id",
"httpMethod" : "DELETE",
"path" : "/store.{format}/order/{orderId}",
"suggestedMethodName" : "deleteOrder"
},
{
"id" : 14,
"name" : "Create order",
"httpMethod" : "POST",
"path" : "/store.{format}/order",
"suggestedMethodName" : "placeOrder"
}
],
"testSuites" : [
{
"id" : 1,
"name" : "Test User service related APIs",
"testCases" : [
{
"name" : "Create User",
"id" : 1,
"resourceId" : 6,
"input" : {
"postData":"${input.userList[0]}"
},
"assertions" : [
{
"actualOutput" : "${output(1.1)}",
"condition" : "!=",
"expectedOutput" : "EXCEPTION"
}
]
},
{
"name" : "Login User",
"id" : 2,
"resourceId" : 10,
"input" : {
"username":"${input.userList[0].username}",
"password":"${input.userList[0].password}"
},
"assertions" : [
{
"actualOutput" : "${output(1.2)}",
"condition" : "!=",
"expectedOutput" : "EXCEPTION"
}
]
},
{
"name" : "Find user by name",
"id" : 3,
"resourceId" : 9,
"input" : {
"username":"${input.userList[0].username}"
},
"assertions" : [
{
"actualOutput" : "${output(1.3).username}",
"condition" : "==",
"expectedOutput" : "${input.userList[0].username}"
}
]
},
{
"name" : "Delete user by name",
"id" : 4,
"resourceId" : 9,
"input" : {
"username":"${input.userList[0].username}"
},
"assertions" : [
{
"actualOutput" : "${output(1.4)}",
"condition" : "!=",
"expectedOutput" : "EXCEPTION"
}
]
}
]
},
{
"id" : 2,
"name" : "Test Pet service related APIs",
"testCases" : [
{
"name" : "Add pet",
"id" : 1,
"resourceId" : 4,
"input" : {
"postData":"${input.petList[0]}"
},
"assertions" : [
{
"actualOutput" : "${output(2.1)}",
"condition" : "!=",
"expectedOutput" : "EXCEPTION"
}
]
},
{
"name" : "Find pet by id",
"id" : 2,
"resourceId" : 1,
"input" : {
"petId":"1"
},
"assertions" : [
{
"actualOutput" : "${output(2.2)}",
"condition" : "!=",
"expectedOutput" : "NULL"
}
]
},
{
"name" : "Find pet by status",
"id" : 3,
"resourceId" : 2,
"input" : {
"status":"available,sold,pending"
},
"assertions" : [
{
"actualOutput" : "${output(2.3).size}",
"condition" : ">",
"expectedOutput" : "0"
}
]
}
]
},
{
"id" : 3,
"name" : "Test Store service related APIs",
"testCases" : [
{
"name" : "Find order by id",
"id" : 1,
"resourceId" : 12,
"input" : {
"orderId":"1"
},
"assertions" : [
{
"actualOutput" : "${output(3.1)}",
"condition" : "!=",
"expectedOutput" : "NULL"
}
]
},
{
"name" : "Place order",
"id" : 2,
"resourceId" : 14,
"input" : {
"postData":"${input.orderList[0]}"
},
"assertions" : [
{
"actualOutput" : "${output(1.2)}",
"condition" : "!=",
"expectedOutput" : "EXCEPTION"
}
]
}
]
}
]
}

View File

@@ -1,31 +0,0 @@
/**
* Copyright 2011 Wordnik, 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 $packageName$
$imports:{ import |
import $import$;
}$
/**
* $enum.description$
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
* @author tony
*
*/
object $className$ {
$values: { value | var $value.name$ = $value.value$};separator="\n"$
}

View File

@@ -1,63 +0,0 @@
/**
* Copyright 2011 Wordnik, 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 $packageName$
import com.wordnik.swagger.runtime.annotations._
import scala.reflect.BeanProperty
import scala.collection.JavaConversions._
$imports:{ import |
import $import$
}$
/**
* $model.description$
*
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
*
* @author tony
*
*/
class $className$ extends $extends$ {
$fields:{ field |
/**
* $field.description$
* $if(field.required)$@Required$endif$
* $if(field.allowableValues)$@AllowableValues(value="$field.allowedValuesString$")$endif$
*/
$if(field.fieldDefinition.hasListResponse)$
var $field.fieldDefinition.name$ $field.fieldDefinition.initialization$
def get$field.fieldDefinition.NameForMethod$:java.util.List[$field.fieldDefinition.collectionItemType$] = {
$field.fieldDefinition.name$.toList
}
def set$field.fieldDefinition.NameForMethod$(args:java.util.List[$field.fieldDefinition.collectionItemType$]) = {
$field.fieldDefinition.name$.clear
args.foreach(arg=>$field.fieldDefinition.name$ += arg)
}
$\r$
$else$
@BeanProperty
var $field.fieldDefinition.name$:$field.fieldDefinition.returnType$ $field.fieldDefinition.initialization$$\r\r$
$endif$
}$ override def toString:String = {
"[" +
$fields:{ field | "$field.fieldDefinition.name$:" + $field.fieldDefinition.name$};separator=" + \r "$ + "]"
}
}

View File

@@ -1,177 +0,0 @@
/**
* Copyright 2011 Wordnik, 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 $packageName$
import $modelPackageName$._
import org.codehaus.jackson.map.DeserializationConfig.Feature
import org.codehaus.jackson.map.ObjectMapper
import org.codehaus.jackson.`type`.TypeReference
import com.wordnik.swagger.runtime.annotations._
import com.wordnik.swagger.runtime.common._
import com.wordnik.swagger.runtime.exception._
import java.io.IOException
import scala.collection.mutable._
import scala.collection.JavaConversions._
$imports:{ import |
import $import$
}$
/**
*
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
* @author tony
*
*/
object $resource$ {
var apiInvoker:APIInvoker = null;
$methods:{ method |
/**
* $method.title$
*
$if(method.description)$
* $method.description$
* $endif$
* $method.arguments:{ argument |@param $argument.name$ $argument.description$
$if(argument.allowedValues)$
* Allowed values are - $argument.allowedValues$ $endif$ }$
$if(!method.responseVoid)$
* @return $method.returnValue$ {@link $method.returnClassName$} $endif$
* @throws APIException $method.exceptionDescription$
*/
$if(method.hasArguments)$
@MethodArgumentNames(value="$method.argumentNames; separator=", "$")
$endif$
@throws(classOf[APIException])
def $method.name$($method.argumentDefinitions; separator=", "$)$if(method.hasResponseValue)$: $if(method.returnValueList)$$method.returnValue$$else$Option[$method.returnValue$]$endif$$endif$ = {
//parse inputs
var resourcePath = "$method.resourcePath$".replace("{format}","json")
val method = "$method.methodType$";
var queryParams = new HashMap[String, String]
var headerParams = new HashMap[String, String]
$if(!method.inputModel)$
$method.queryParameters:{ argument |
if(null != $argument.name$) {
queryParams += "$argument.name$" -> APIInvoker.toPathValue($argument.name$)
}
}$
$method.headerParameters:{ argument |
if(null != $argument.name$) {
headerParams += "$argument.name$" -> APIInvoker.toPathValue($argument.name$)
}
}$
$method.pathParameters:{ argument |
if(null != $argument.name$) {
resourcePath = resourcePath.replace("{$argument.name$}", APIInvoker.toPathValue($argument.name$))
}
}$
$endif$
$if(method.inputModel)$
$method.queryParameters:{ argument |
if(null != $argument.inputModelClassArgument$ && null != $argument.methodNameFromModelClass$ ) {
queryParams += "$argument.name$" -> APIInvoker.toPathValue($argument.methodNameFromModelClass$)
}
}$
$method.headerParameters:{ argument |
if(null != $argument.inputModelClassArgument$ && null != $argument.methodNameFromModelClass$ ) {
headerParams += "$argument.name$" -> APIInvoker.toPathValue($argument.methodNameFromModelClass$)
}
}$
$method.pathParameters:{ argument |
if(null != $argument.inputModelClassArgument$ && null != $argument.methodNameFromModelClass$ ) {
resourcePath = resourcePath.replace("{$argument.name$}", APIInvoker.toPathValue($argument.methodNameFromModelClass$))
}
}$
$endif$
//make the API Call
$if(method.hasResponseValue)$
var response: String = null
try {
$if(method.postObject)$
response = apiInvoker.invokeAPI(resourcePath, method, queryParams, postData, headerParams)
$else$
response = apiInvoker.invokeAPI(resourcePath, method, queryParams, null, headerParams)
$endif$
} catch {
case ex: APIException if ex.getCode == 404 =>
$if(method.returnValueList)$ return List()
$else$ return None
$endif$
case ex: APIException => throw ex
}
$else$
$if(method.postObject)$
apiInvoker.invokeAPI(resourcePath, method, queryParams, postData, headerParams)
$else$
apiInvoker.invokeAPI(resourcePath, method, queryParams, null, headerParams)
$endif$
$endif$
$if(!method.responseVoid)$
$if(method.hasResponseValue)$
$if(!method.returnValueList)$
if(null == response){
return None
}
$endif$
$endif$
$if(!method.returnValueList)$
$if(method.hasResponseValue)$
//create output objects if the response has more than one object
val responseObject = APIInvoker.deserialize(response, classOf[$method.returnClassName$]).asInstanceOf[$method.returnValue$]
$if(method.returnValueList)$
responseObject
$else$
Some(responseObject)
$endif$
$endif$
$endif$
$if(method.returnValueList)$
val typeRef = new TypeReference[Array[$method.returnClassName$]] {}
try {
val responseObject = APIInvoker.mapper.readValue(response, typeRef).asInstanceOf[Array[$method.returnClassName$]]
responseObject.toList
} catch {
case ioe:IOException => {
val args = Array(response, typeRef.toString())
throw new APIException(APIExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, args, "Error in converting response json value to java object : " + ioe.getMessage(), ioe)
}
case _ => throw new APIException(APIExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, "Error in converting response json value to java object")
}
$endif$
$endif$
}
}$
def getApiInvoker():APIInvoker = {
if(null == apiInvoker){
apiInvoker = APIInvoker.getApiInvoker();
}
return apiInvoker;
}
def setApiInvoker(invoker:APIInvoker) = {
apiInvoker = invoker;
}
}

View File

@@ -1,33 +0,0 @@
/**
* Copyright 2011 Wordnik, 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 $packageName$
/**
*
* Maintains the compatible server version against which the drive is written
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
* @author tony
*
*/
class VersionChecker {
var compatibleVersion = "$apiVersion$"
/**
* Gets the version against which the library code was written
*/
def getCompatibleVersion():String = compatibleVersion
}

397
pom.xml
View File

@@ -1,10 +1,15 @@
<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>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.wordnik</groupId>
<artifactId>swagger-codegen_2.9.1</artifactId>
<packaging>jar</packaging>
<name>swagger-codegen</name>
<version>1.1</version>
<version>2.0.0</version>
<scm>
<connection>scm:git:git@github.com:wordnik/swagger-codegen.git</connection>
<developerConnection>scm:git:git@github.com:wordnik/swagger-codegen.git</developerConnection>
@@ -13,78 +18,51 @@
<prerequisites>
<maven>2.2.0</maven>
</prerequisites>
<pluginRepositories>
<pluginRepository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</pluginRepository>
</pluginRepositories>
<developers>
<developer>
<id>rpidikiti</id>
<name>Ramesh Pidikiti</name>
<email>ramesh@wordnik.com</email>
</developer>
<developer>
<id>ayush</id>
<name>Ayush Gupts</name>
<email>ayush@glugbot.com</email>
</developer>
<developer>
<id>fehguy</id>
<name>Tony Tam</name>
<email>fehguy@gmail.com</email>
</developer>
</developers>
<issueManagement>
<system>github</system>
<url>https://github.com/wordnik/swagger-codegen/issues</url>
</issueManagement>
<licenses>
<license>
<name>Apache License 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
<distribution>repo</distribution>
</license>
</licenses>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.0</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}/conf</outputDirectory>
<resources>
<resource>
<directory>conf</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-java-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}/conf/java/structure/src/main/java/com/wordnik/swagger/runtime</outputDirectory>
<resources>
<resource>
<directory>src/main/java/com/wordnik/swagger/runtime/</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-scala-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}/conf/scala/structure/src/main/java/com/wordnik/swagger/runtime</outputDirectory>
<resources>
<resource>
<directory>src/main/java/com/wordnik/swagger/runtime/</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<systemProperties>
<property>
<name>loggerPath</name>
<value>conf/log4j.properties</value>
</property>
</systemProperties>
<argLine>-Xms512m -Xmx1500m</argLine>
<parallel>methods</parallel>
<forkMode>pertest</forkMode>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
@@ -100,6 +78,21 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>jar</goal>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
<configuration>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
@@ -131,16 +124,18 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>scala-compile-first</id>
@@ -158,189 +153,48 @@
</goals>
</execution>
</executions>
<configuration>
<jvmArgs>
<jvmArg>-Xms128m</jvmArg>
<jvmArg>-Xmx1500m</jvmArg>
</jvmArgs>
<recompileMode>incremental</recompileMode>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<configuration>
<releaseProfiles>release</releaseProfiles>
<goals>sign</goals>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>release-profile</id>
<properties>
<skipTests>true</skipTests>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration />
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>prepare-package</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/scala</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release-sign-artifacts</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<reporting>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<scalaVersion>${scala-version}</scalaVersion>
</configuration>
</plugin>
</plugins>
</reporting>
<dependencies>
<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>1.4.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-ext</artifactId>
<version>${slf4j-version}</version>
<!--dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-core_2.9.1</artifactId>
<version>${swagger-core-version}</version>
<scope>compile</scope>
</dependency-->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j-version}</version>
<scope>compile</scope>
<groupId>org.fusesource.scalate</groupId>
<artifactId>scalate-wikitext</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>${commons-beanutils-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>${jersey-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>${jersey-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>${jackson-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-xc</artifactId>
<version>${jackson-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>${jackson-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>stringtemplate</artifactId>
<version>${org.antlr-version}</version>
<scope>compile</scope>
<groupId>org.fusesource.scalate</groupId>
<artifactId>scalate-page</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
@@ -355,51 +209,36 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commons-lang-version}</version>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-scala</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>oss.sonatype.org</id>
<url>http://oss.sonatype.org/content/repositories/releases</url>
</repository>
<repository>
<id>oss.sonatype.org-snapshot</id>
<url>http://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
<repository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</repository>
<repository>
<id>jboss</id>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>codehaus</id>
<name>repository.codehaus.org</name>
<url>http://repository.codehaus.org</url>
</repository>
<repository>
<id>codehaus-snapshots</id>
<url>http://snapshots.repository.codehaus.org</url>
</repository>
</repositories>
<properties>
<jackson-version>2.0.4</jackson-version>
<swagger-core-version>1.1.1-SNAPSHOT</swagger-core-version>
<scala-version>2.9.1-1</scala-version>
<scala-test-version>1.6.1</scala-test-version>
<swagger-codegen-version>1.1</swagger-codegen-version>
<servlet-api-version>2.5</servlet-api-version>
<jersey-version>1.7</jersey-version>
<jackson-version>1.7.7</jackson-version>
<junit-version>4.8.1</junit-version>
<maven-plugin.version>1.0.0</maven-plugin.version>
<commons-beanutils-version>1.8.0</commons-beanutils-version>
<commons-lang-version>2.4</commons-lang-version>
<slf4j-version>1.5.8</slf4j-version>
<org.antlr-version>3.2</org.antlr-version>
<scala-test-version>1.6.1</scala-test-version>
</properties>
</project>

View File

@@ -0,0 +1,37 @@
/**
* Copyright 2012 Wordnik, 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.
*/
import com.wordnik.swagger.codegen.BasicFlashCodegen
object FlashPetstoreCodegen extends BasicFlashCodegen {
def main(args: Array[String]) = generateClient(args)
override def packageName = "com.wordnik.client"
override def destinationRoot = "samples/client/petstore/flash"
// where to write generated code
override def destinationDir = destinationRoot + "/src/main/flex"
// package for models
override def modelPackage = Some("com.wordnik.client.model")
// package for api classes
override def apiPackage = Some("com.wordnik.client.api")
// supporting classes
override def supportingFiles = baseSupportingFiles ++ List()
}

View File

@@ -2,11 +2,11 @@
title=Sample app AS3 SDK API Documentation
#Path to the source folder where the .as files are located
sourcepath = ./src/main/as3
sourcepath = ./src/main/flex
# Class-folders you want to search for classes to be included in the docs, seperated by spaces (for example ../com/ ../net/ )
# to include every .as and .mxml file within your project, just state ../
domainextensions = ./src/main/as3
domainextensions = ./src/main/flex
# The Location of deployment library on your Computer (PC/Mac) for compiled SWC file
liboutputfolder = bin
@@ -16,11 +16,12 @@ libpath = lib
# The Location of the output folder for your generated documents
docsoutputfolder = asdoc
# Home directory for flex sdk 3, change this to build for Mac or PC using # as comment
# SDK_HOME = C:/Program Files/Adobe/Flash Builder 4/sdks/3.5.0
# SDK_HOME = /Applications/Adobe Flash Builder 4/sdks/3.5.0
# SDK_HOME = /usr/local/flex_sdk_4.1.0/
# FLEX_HOME = /usr/local/flex_sdk_4.1.0/
# The location of the test sources
testsourcepath = ./src/test/flex
# Home directory for flex sdk, change this to build for Mac or PC using # as comment
FLEX4_SDK_HOME = /usr/local/flex_sdk_4.1.0/
#FLEX4_SDK_HOME = /Applications/Adobe Flash Builder 4/sdks/4.1.0/
# The location of your asdoc.exe, change this to build for Mac or PC using # as comment
#asdoc.exe = C:/Program Files/Adobe/Flash Builder 4/sdks/3.5.0/bin/asdoc.exe

View File

@@ -4,9 +4,9 @@
<!-- import our build properties file -->
<property file="./build.properties"/>
<property environment="env"/>
<property name="FLEX_HOME" value="${FLEX4_SDK_HOME}"/>
<property name="FLEX4_HOME" value="${FLEX4_SDK_HOME}"/>
<property environment="env"/>
<property name="FLEX_HOME" value="${FLEX4_SDK_HOME}"/>
<property name="FLEX4_HOME" value="${FLEX4_SDK_HOME}"/>
<!--<property name="flexunit.swc" value="../lib/ext/flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc" />
<property name="flexunit-uilistener.swc" value="../lib/ext/flexunit-uilistener-4.1.0_RC2-28-flex_3.5.0.12683.swc" />
@@ -38,7 +38,8 @@
-->
<target name="clean" description="DELETE the existing output folder and files and then re-generate the output folder">
<target name="clean"
description="DELETE the existing output folder and files and then re-generate the output folder">
<delete dir="${basedir}/${docsoutputfolder}" failonerror="true" includeemptydirs="true"/>
<delete file="${basedir}/${liboutputfolder}/${liboutputfile}"/>
@@ -46,7 +47,7 @@
<mkdir dir="${basedir}/${docsoutputfolder}"/>
</target>
</target>
<!--
@@ -56,16 +57,16 @@
<target name="docs" description="Run the ASDoc executable and generate the ASDocs to the new output folder">
<exec executable="${env.SDK_HOME}/bin/asdoc" failonerror="true">
<exec executable="${FLEX_HOME}/bin/asdoc" failonerror="true">
<arg line="-doc-sources ${sourcepath}"/>
<arg line="-source-path ${sourcepath}"/>
<arg line="-footer 'Copyright Wordnik'"/>
<arg line="-package com.wordnik.swagger.api 'Contains the apis which are used by clients to make calls to the services deployed'"/>
<arg line="-package com.wordnik.swagger.model 'Contains common classes which encapsulate data elements required'"/>
<arg line="-package com.wordnik.swagger.common 'Contains classes which are used by the api classes to invoke the deployed api like SwaggerApi - a base class, ApiUserCredentials, etc.''"/>
<arg line="-package com.wordnik.swagger.event 'Results of calls made to Wordnik are returned via dispatched events. This package contains such event classes. Right now thats just ApiClientEvent and Response.'"/>
<arg line="-package com.wordnik.swagger.exception 'Contains classes that encapsulate the errors generated'"/>
<arg line="-footer 'Copyright Wordnik'"/>
<arg line="-package com.wordnik.swagger.api 'Contains the apis which are used by clients to make calls to the services deployed'"/>
<arg line="-package com.wordnik.swagger.model 'Contains common classes which encapsulate data elements required'"/>
<arg line="-package com.wordnik.swagger.common 'Contains classes which are used by the api classes to invoke the deployed api like SwaggerApi - a base class, ApiUserCredentials, etc.'"/>
<arg line="-package com.wordnik.swagger.event 'Results of calls made to Wordnik are returned via dispatched events. This package contains such event classes. Right now thats just ApiClientEvent and Response.'"/>
<arg line="-package com.wordnik.swagger.exception 'Contains classes that encapsulate the errors generated'"/>
<arg value="-window-title"/>
<arg value="${title}"/>
@@ -76,7 +77,7 @@
<arg value="-output"/>
<arg value="${basedir}/${docsoutputfolder}"/>
<arg value="-external-library-path"/>
<arg value="-external-library-path"/>
<arg value="${basedir}/${libpath}"/>
</exec>
@@ -92,45 +93,45 @@
-->
<target name="buildSWC" description="Compile the SWC file for the Librayr Project">
<target name="buildSWC" description="Compile the SWC file for the Librayr Project">
<compc output="${basedir}/${liboutputfolder}/${liboutputfile}">
<!--
Include the path to any external SWC files used in the sdk, you may have to place name of SWC (ASAXB-0.1.1.swc) at end of path.
So file path would be file="${basedir}/${libpath}/ASAXB-0.1.1.swc"
-->
<include-libraries file="${basedir}/${libpath}/" />
<source-path path-element="${sourcepath}" />
<compc output="${basedir}/${liboutputfolder}/${liboutputfile}">
<!--
Include the path to any external SWC files used in the sdk, you may have to place name of SWC (ASAXB-0.1.1.swc) at end of path.
So file path would be file="${basedir}/${libpath}/ASAXB-0.1.1.swc"
-->
<include-libraries file="${basedir}/${libpath}/"/>
<source-path path-element="${sourcepath}"/>
<keep-as3-metadata name="XmlRootNode"/>
<keep-as3-metadata name="XmlElement"/>
<keep-as3-metadata name="XmlElements"/>
<!-- include our Class packages into the build (com folder) -->
<include-sources dir="${sourcepath}" includes="*" />
</compc>
<echo>SWC created</echo>
<!-- include our Class packages into the build (com folder) -->
<include-sources dir="${sourcepath}" includes="*"/>
</target>
<target name="dist" depends="clean, buildSWC, docs">
<mkdir dir="${basedir}/dist/lib"/>
<mkdir dir="${basedir}/dist/docs"/>
<mkdir dir="${basedir}/dist/sample"/>
<copy file="${basedir}/${liboutputfolder}/${liboutputfile}" todir="${basedir}/dist/lib/">
</copy>
<copy todir="${basedir}/dist/docs/">
<fileset dir="${basedir}/asdoc"/>
</copy>
</compc>
<zip destfile="sample-as3-sdk.zip" basedir="${basedir}/dist" />
</target>
<echo>SWC created</echo>
</target>
<target name="dist" depends="clean, buildSWC, docs">
<mkdir dir="${basedir}/dist/lib"/>
<mkdir dir="${basedir}/dist/docs"/>
<mkdir dir="${basedir}/dist/sample"/>
<copy file="${basedir}/${liboutputfolder}/${liboutputfile}" todir="${basedir}/dist/lib/">
</copy>
<copy todir="${basedir}/dist/docs/">
<fileset dir="${basedir}/asdoc"/>
</copy>
<zip destfile="sample-as3-sdk.zip" basedir="${basedir}/dist"/>
</target>
<!-- Compiles and creates a test app that can be run using the adl - AIR Debug Launcher from command line
Note: For the output file to be executed an xml file is needed which points to this output swf - this is not
@@ -139,44 +140,53 @@
<target name="compile-test" depends="buildSWC">
<property name="FLEX_HOME" value="${FLEX4_SDK_HOME}"/>
<mxmlc
static-rsls="false"
fork="true"
maxmemory="512m"
file="${testsourcepath}/AirExecutorApp.mxml"
output="${basedir}/${liboutputfolder}/AirExecutorApp.swf"
warnings="false"
configname="air"
locale="en_US">
static-rsls="false"
fork="true"
maxmemory="512m"
file="${testsourcepath}/AirExecutorApp.mxml"
output="${basedir}/${liboutputfolder}/AirExecutorApp.swf"
warnings="false"
configname="air"
locale="en_US">
<load-config filename="${FLEX4_HOME}/frameworks/air-config.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
<compiler.debug>true</compiler.debug>
<source-path path-element="${testsourcepath}" />
<source-path path-element="${testsourcepath}"/>
<!--<source-path path-element="${APP_ROOT}/locale/{locale}" />-->
<library-path dir="${FLEX_HOME}/frameworks/libs" append="true">
<include name="*.swc" />
<include name="*.swc"/>
</library-path>
<library-path dir="${FLEX_HOME}/frameworks/libs/air" append="true">
<include name="*.swc" />
<include name="*.swc"/>
</library-path>
<library-path dir="${FLEX_HOME}/frameworks/locale" append="true">
<include name="{locale}" />
<include name="{locale}"/>
</library-path>
<library-path dir="${basedir}/${libpath}" append="true">
<include name="*.swc" />
<include name="*.swc"/>
</library-path>
<library-path dir="${basedir}/${liboutputfolder}" append="true">
<include name="*.swc" />
<include name="*.swc"/>
</library-path>
<library-path dir="${basedir}/${libpath}/ext" append="true">
<include name="*.swc" />
<include name="*.swc"/>
</library-path>
<verbose-stacktraces>true</verbose-stacktraces>
</mxmlc>
</target>
<target name="do-test">
<exec executable="${FLEX_HOME}/bin/adl" failonerror="true">
<arg value="${basedir}/bin/AirExecutorApp-app.xml"/>
</exec>
</target>
<target name="test" depends="compile-test, do-test">
</target>
</project>

View File

@@ -0,0 +1,160 @@
package com.wordnik.client.api {
import com.wordnik.swagger.common.ApiInvoker;
import com.wordnik.swagger.exception.ApiErrorCodes;
import com.wordnik.swagger.exception.ApiError;
import com.wordnik.swagger.common.ApiUserCredentials;
import com.wordnik.swagger.event.Response;
import com.wordnik.swagger.common.SwaggerApi;
import com.wordnik.client.model.Pet;
import mx.rpc.AsyncToken;
import mx.utils.UIDUtil;
import flash.utils.Dictionary;
import flash.events.EventDispatcher;
public class PetApi extends SwaggerApi {
/**
* Constructor for the PetApi api client
* @param apiCredentials Wrapper object for tokens and hostName required towards authentication
* @param eventDispatcher Optional event dispatcher that when provided is used by the SDK to dispatch any Response
*/
public function PetApi(apiCredentials: ApiUserCredentials, eventDispatcher: EventDispatcher = null) {
super(apiCredentials, eventDispatcher);
}
public static const event_getPetById: String = "getPetById";
public static const event_addPet: String = "addPet";
public static const event_updatePet: String = "updatePet";
public static const event_findPetsByStatus: String = "findPetsByStatus";
public static const event_findPetsByTags: String = "findPetsByTags";
/*
* Returns Pet */
public function getPetById (petId: String): String {
// create path and map variables
var path: String = "/pet.{format}/{petId}".replace(/{format}/g,"xml").replace("{" + "petId" + "}", getApiInvoker().escapeString(petId));
// query params
var queryParams: Dictionary = new Dictionary();
var headerParams: Dictionary = new Dictionary();
// verify required params are set
if(petId == null ) {
throw new ApiError(400, "missing required params");
}
var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams);
var requestId: String = getUniqueId();
token.requestId = requestId;
token.completionEventType = "getPetById";
token.returnType = Pet;
return requestId;
}
/*
* Returns void */
public function addPet (body: Pet): String {
// create path and map variables
var path: String = "/pet.{format}".replace(/{format}/g,"xml");
// query params
var queryParams: Dictionary = new Dictionary();
var headerParams: Dictionary = new Dictionary();
// verify required params are set
if(body == null ) {
throw new ApiError(400, "missing required params");
}
var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, body, headerParams);
var requestId: String = getUniqueId();
token.requestId = requestId;
token.completionEventType = "addPet";
token.returnType = null ;
return requestId;
}
/*
* Returns void */
public function updatePet (body: Pet): String {
// create path and map variables
var path: String = "/pet.{format}".replace(/{format}/g,"xml");
// query params
var queryParams: Dictionary = new Dictionary();
var headerParams: Dictionary = new Dictionary();
// verify required params are set
if(body == null ) {
throw new ApiError(400, "missing required params");
}
var token:AsyncToken = getApiInvoker().invokeAPI(path, "PUT", queryParams, body, headerParams);
var requestId: String = getUniqueId();
token.requestId = requestId;
token.completionEventType = "updatePet";
token.returnType = null ;
return requestId;
}
/*
* Returns com.wordnik.client.model.PetList */
public function findPetsByStatus (status: String= "available"): String {
// create path and map variables
var path: String = "/pet.{format}/findByStatus".replace(/{format}/g,"xml");
// query params
var queryParams: Dictionary = new Dictionary();
var headerParams: Dictionary = new Dictionary();
// verify required params are set
if(status == null ) {
throw new ApiError(400, "missing required params");
}
if("null" != String(status))
queryParams["status"] = toPathValue(status);
var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams);
var requestId: String = getUniqueId();
token.requestId = requestId;
token.completionEventType = "findPetsByStatus";
token.returnType = com.wordnik.client.model.PetList;
return requestId;
}
/*
* Returns com.wordnik.client.model.PetList */
public function findPetsByTags (tags: String): String {
// create path and map variables
var path: String = "/pet.{format}/findByTags".replace(/{format}/g,"xml");
// query params
var queryParams: Dictionary = new Dictionary();
var headerParams: Dictionary = new Dictionary();
// verify required params are set
if(tags == null ) {
throw new ApiError(400, "missing required params");
}
if("null" != String(tags))
queryParams["tags"] = toPathValue(tags);
var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams);
var requestId: String = getUniqueId();
token.requestId = requestId;
token.completionEventType = "findPetsByTags";
token.returnType = com.wordnik.client.model.PetList;
return requestId;
}
}
}

View File

@@ -0,0 +1,104 @@
package com.wordnik.client.api {
import com.wordnik.swagger.common.ApiInvoker;
import com.wordnik.swagger.exception.ApiErrorCodes;
import com.wordnik.swagger.exception.ApiError;
import com.wordnik.swagger.common.ApiUserCredentials;
import com.wordnik.swagger.event.Response;
import com.wordnik.swagger.common.SwaggerApi;
import com.wordnik.client.model.Order;
import mx.rpc.AsyncToken;
import mx.utils.UIDUtil;
import flash.utils.Dictionary;
import flash.events.EventDispatcher;
public class StoreApi extends SwaggerApi {
/**
* Constructor for the StoreApi api client
* @param apiCredentials Wrapper object for tokens and hostName required towards authentication
* @param eventDispatcher Optional event dispatcher that when provided is used by the SDK to dispatch any Response
*/
public function StoreApi(apiCredentials: ApiUserCredentials, eventDispatcher: EventDispatcher = null) {
super(apiCredentials, eventDispatcher);
}
public static const event_getOrderById: String = "getOrderById";
public static const event_deleteOrder: String = "deleteOrder";
public static const event_placeOrder: String = "placeOrder";
/*
* Returns Order */
public function getOrderById (orderId: String): String {
// create path and map variables
var path: String = "/store.{format}/order/{orderId}".replace(/{format}/g,"xml").replace("{" + "orderId" + "}", getApiInvoker().escapeString(orderId));
// query params
var queryParams: Dictionary = new Dictionary();
var headerParams: Dictionary = new Dictionary();
// verify required params are set
if(orderId == null ) {
throw new ApiError(400, "missing required params");
}
var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams);
var requestId: String = getUniqueId();
token.requestId = requestId;
token.completionEventType = "getOrderById";
token.returnType = Order;
return requestId;
}
/*
* Returns void */
public function deleteOrder (orderId: String): String {
// create path and map variables
var path: String = "/store.{format}/order/{orderId}".replace(/{format}/g,"xml").replace("{" + "orderId" + "}", getApiInvoker().escapeString(orderId));
// query params
var queryParams: Dictionary = new Dictionary();
var headerParams: Dictionary = new Dictionary();
// verify required params are set
if(orderId == null ) {
throw new ApiError(400, "missing required params");
}
var token:AsyncToken = getApiInvoker().invokeAPI(path, "DELETE", queryParams, null, headerParams);
var requestId: String = getUniqueId();
token.requestId = requestId;
token.completionEventType = "deleteOrder";
token.returnType = null ;
return requestId;
}
/*
* Returns void */
public function placeOrder (body: Order): String {
// create path and map variables
var path: String = "/store.{format}/order".replace(/{format}/g,"xml");
// query params
var queryParams: Dictionary = new Dictionary();
var headerParams: Dictionary = new Dictionary();
// verify required params are set
if(body == null ) {
throw new ApiError(400, "missing required params");
}
var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, body, headerParams);
var requestId: String = getUniqueId();
token.requestId = requestId;
token.completionEventType = "placeOrder";
token.returnType = null ;
return requestId;
}
}
}

View File

@@ -0,0 +1,234 @@
package com.wordnik.client.api {
import com.wordnik.swagger.common.ApiInvoker;
import com.wordnik.swagger.exception.ApiErrorCodes;
import com.wordnik.swagger.exception.ApiError;
import com.wordnik.swagger.common.ApiUserCredentials;
import com.wordnik.swagger.event.Response;
import com.wordnik.swagger.common.SwaggerApi;
import com.wordnik.client.model.User;
import mx.rpc.AsyncToken;
import mx.utils.UIDUtil;
import flash.utils.Dictionary;
import flash.events.EventDispatcher;
public class UserApi extends SwaggerApi {
/**
* Constructor for the UserApi api client
* @param apiCredentials Wrapper object for tokens and hostName required towards authentication
* @param eventDispatcher Optional event dispatcher that when provided is used by the SDK to dispatch any Response
*/
public function UserApi(apiCredentials: ApiUserCredentials, eventDispatcher: EventDispatcher = null) {
super(apiCredentials, eventDispatcher);
}
public static const event_createUsersWithArrayInput: String = "createUsersWithArrayInput";
public static const event_createUser: String = "createUser";
public static const event_createUsersWithListInput: String = "createUsersWithListInput";
public static const event_updateUser: String = "updateUser";
public static const event_deleteUser: String = "deleteUser";
public static const event_getUserByName: String = "getUserByName";
public static const event_loginUser: String = "loginUser";
public static const event_logoutUser: String = "logoutUser";
/*
* Returns void */
public function createUsersWithArrayInput (body: Array): String {
// create path and map variables
var path: String = "/user.{format}/createWithArray".replace(/{format}/g,"xml");
// query params
var queryParams: Dictionary = new Dictionary();
var headerParams: Dictionary = new Dictionary();
// verify required params are set
if(body == null ) {
throw new ApiError(400, "missing required params");
}
var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, body, headerParams);
var requestId: String = getUniqueId();
token.requestId = requestId;
token.completionEventType = "createUsersWithArrayInput";
token.returnType = null ;
return requestId;
}
/*
* Returns void */
public function createUser (body: User): String {
// create path and map variables
var path: String = "/user.{format}".replace(/{format}/g,"xml");
// query params
var queryParams: Dictionary = new Dictionary();
var headerParams: Dictionary = new Dictionary();
// verify required params are set
if(body == null ) {
throw new ApiError(400, "missing required params");
}
var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, body, headerParams);
var requestId: String = getUniqueId();
token.requestId = requestId;
token.completionEventType = "createUser";
token.returnType = null ;
return requestId;
}
/*
* Returns void */
public function createUsersWithListInput (body: Array): String {
// create path and map variables
var path: String = "/user.{format}/createWithList".replace(/{format}/g,"xml");
// query params
var queryParams: Dictionary = new Dictionary();
var headerParams: Dictionary = new Dictionary();
// verify required params are set
if(body == null ) {
throw new ApiError(400, "missing required params");
}
var token:AsyncToken = getApiInvoker().invokeAPI(path, "POST", queryParams, body, headerParams);
var requestId: String = getUniqueId();
token.requestId = requestId;
token.completionEventType = "createUsersWithListInput";
token.returnType = null ;
return requestId;
}
/*
* Returns void */
public function updateUser (username: String, body: User): String {
// create path and map variables
var path: String = "/user.{format}/{username}".replace(/{format}/g,"xml").replace("{" + "username" + "}", getApiInvoker().escapeString(username));
// query params
var queryParams: Dictionary = new Dictionary();
var headerParams: Dictionary = new Dictionary();
// verify required params are set
if(username == null || body == null ) {
throw new ApiError(400, "missing required params");
}
var token:AsyncToken = getApiInvoker().invokeAPI(path, "PUT", queryParams, body, headerParams);
var requestId: String = getUniqueId();
token.requestId = requestId;
token.completionEventType = "updateUser";
token.returnType = null ;
return requestId;
}
/*
* Returns void */
public function deleteUser (username: String): String {
// create path and map variables
var path: String = "/user.{format}/{username}".replace(/{format}/g,"xml").replace("{" + "username" + "}", getApiInvoker().escapeString(username));
// query params
var queryParams: Dictionary = new Dictionary();
var headerParams: Dictionary = new Dictionary();
// verify required params are set
if(username == null ) {
throw new ApiError(400, "missing required params");
}
var token:AsyncToken = getApiInvoker().invokeAPI(path, "DELETE", queryParams, null, headerParams);
var requestId: String = getUniqueId();
token.requestId = requestId;
token.completionEventType = "deleteUser";
token.returnType = null ;
return requestId;
}
/*
* Returns User */
public function getUserByName (username: String): String {
// create path and map variables
var path: String = "/user.{format}/{username}".replace(/{format}/g,"xml").replace("{" + "username" + "}", getApiInvoker().escapeString(username));
// query params
var queryParams: Dictionary = new Dictionary();
var headerParams: Dictionary = new Dictionary();
// verify required params are set
if(username == null ) {
throw new ApiError(400, "missing required params");
}
var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams);
var requestId: String = getUniqueId();
token.requestId = requestId;
token.completionEventType = "getUserByName";
token.returnType = User;
return requestId;
}
/*
* Returns string */
public function loginUser (username: String, password: String): String {
// create path and map variables
var path: String = "/user.{format}/login".replace(/{format}/g,"xml");
// query params
var queryParams: Dictionary = new Dictionary();
var headerParams: Dictionary = new Dictionary();
// verify required params are set
if(username == null || password == null ) {
throw new ApiError(400, "missing required params");
}
if("null" != String(username))
queryParams["username"] = toPathValue(username);
if("null" != String(password))
queryParams["password"] = toPathValue(password);
var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams);
var requestId: String = getUniqueId();
token.requestId = requestId;
token.completionEventType = "loginUser";
token.returnType = string;
return requestId;
}
/*
* Returns void */
public function logoutUser (): String {
// create path and map variables
var path: String = "/user.{format}/logout".replace(/{format}/g,"xml");
// query params
var queryParams: Dictionary = new Dictionary();
var headerParams: Dictionary = new Dictionary();
var token:AsyncToken = getApiInvoker().invokeAPI(path, "GET", queryParams, null, headerParams);
var requestId: String = getUniqueId();
token.requestId = requestId;
token.completionEventType = "logoutUser";
token.returnType = null ;
return requestId;
}
}
}

View File

@@ -0,0 +1,21 @@
package com.wordnik.client.model {
[XmlRootNode(name="Category")]
public class Category {
[XmlElement(name="id")]
public var id: Number = 0.0;
[XmlElement(name="name")]
public var name: String = null;
public function toString(): String {
var str: String = "Category: ";
str += " (id: " + id + ")";
str += " (name: " + name + ")";
return str;
}
}
}

View File

@@ -0,0 +1,16 @@
package com.wordnik.client.model {
import com.wordnik.swagger.common.ListWrapper;
public class CategoryList implements ListWrapper {
// This declaration below of _Category_obj_class is to force flash compiler to include this class
private var _category_obj_class: com.wordnik.client.model.Category = null;
[XmlElements(name="category", type="com.wordnik.client.model.Category")]
public var category: Array = new Array();
public function getList(): Array{
return category;
}
}
}

View File

@@ -0,0 +1,34 @@
package com.wordnik.client.model {
[XmlRootNode(name="Order")]
public class Order {
[XmlElement(name="id")]
public var id: Number = 0.0;
[XmlElement(name="petId")]
public var petId: Number = 0.0;
/* Order Status */
[XmlElement(name="status")]
public var status: String = null;
[XmlElement(name="quantity")]
public var quantity: Number = 0.0;
[XmlElement(name="shipDate")]
public var shipDate: Date = null;
public function toString(): String {
var str: String = "Order: ";
str += " (id: " + id + ")";
str += " (petId: " + petId + ")";
str += " (status: " + status + ")";
str += " (quantity: " + quantity + ")";
str += " (shipDate: " + shipDate + ")";
return str;
}
}
}

View File

@@ -0,0 +1,16 @@
package com.wordnik.client.model {
import com.wordnik.swagger.common.ListWrapper;
public class OrderList implements ListWrapper {
// This declaration below of _Order_obj_class is to force flash compiler to include this class
private var _order_obj_class: com.wordnik.client.model.Order = null;
[XmlElements(name="order", type="com.wordnik.client.model.Order")]
public var order: Array = new Array();
public function getList(): Array{
return order;
}
}
}

View File

@@ -0,0 +1,46 @@
package com.wordnik.client.model {
import com.wordnik.client.model.Category;
import com.wordnik.client.model.Tag;
[XmlRootNode(name="Pet")]
public class Pet {
[XmlElement(name="id")]
public var id: Number = 0.0;
// This declaration below of _tags_obj_class is to force flash compiler to include this class
private var _tags_obj_class: com.wordnik.client.model.Tag = null;
[XmlElementWrapper(name="tags")]
[XmlElements(name="tag", type="com.wordnik.client.model.Tag")]
public var tags: Array = new Array();
[XmlElement(name="category")]
public var category: Category = null;
/* pet status in the store */
[XmlElement(name="status")]
public var status: String = null;
[XmlElement(name="name")]
public var name: String = null;
// This declaration below of _photoUrls_obj_class is to force flash compiler to include this class
private var _photoUrls_obj_class: com.wordnik.client.model.String = null;
[XmlElementWrapper(name="photoUrls")]
[XmlElements(name="photoUrl", type="com.wordnik.client.model.String")]
public var photoUrls: Array = new Array();
public function toString(): String {
var str: String = "Pet: ";
str += " (id: " + id + ")";
str += " (tags: " + tags + ")";
str += " (category: " + category + ")";
str += " (status: " + status + ")";
str += " (name: " + name + ")";
str += " (photoUrls: " + photoUrls + ")";
return str;
}
}
}

View File

@@ -0,0 +1,18 @@
package com.wordnik.client.model {
import com.wordnik.swagger.common.ListWrapper;
import com.wordnik.client.model.Category;
import com.wordnik.client.model.Tag;
public class PetList implements ListWrapper {
// This declaration below of _Pet_obj_class is to force flash compiler to include this class
private var _pet_obj_class: com.wordnik.client.model.Pet = null;
[XmlElements(name="pet", type="com.wordnik.client.model.Pet")]
public var pet: Array = new Array();
public function getList(): Array{
return pet;
}
}
}

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