forked from loafle/openapi-generator-original
Compare commits
214 Commits
swagger-co
...
swagger-co
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55bb1f2a76 | ||
|
|
cb534047ee | ||
|
|
735f5c61b3 | ||
|
|
73a2fc216e | ||
|
|
46323fae7c | ||
|
|
7fde848680 | ||
|
|
aef4190624 | ||
|
|
4be326152f | ||
|
|
51437245e4 | ||
|
|
36f4239c93 | ||
|
|
87ebc8a7f3 | ||
|
|
a4afa9bac2 | ||
|
|
7af8b0de18 | ||
|
|
66dd67597c | ||
|
|
f5fae2df48 | ||
|
|
adbadfe500 | ||
|
|
f7b1e25453 | ||
|
|
a0b0e7bcb7 | ||
|
|
6aa5b8f089 | ||
|
|
e9ef124f59 | ||
|
|
5d2ae3d353 | ||
|
|
031dd20072 | ||
|
|
67ce62c622 | ||
|
|
b4efa892a1 | ||
|
|
ddc94bcb7c | ||
|
|
bee14e82b2 | ||
|
|
4765c56b2a | ||
|
|
0b7db0ce2d | ||
|
|
68436f6cbe | ||
|
|
444de037bc | ||
|
|
ce1b4ec347 | ||
|
|
b65de5466c | ||
|
|
58cfacc4cf | ||
|
|
cbb61b1002 | ||
|
|
62c3a70843 | ||
|
|
e0d8a75441 | ||
|
|
687eff49a5 | ||
|
|
9f2a90722b | ||
|
|
90b5490f00 | ||
|
|
0bdf466e32 | ||
|
|
a8109930ed | ||
|
|
a3f08e87fd | ||
|
|
e65e5a730d | ||
|
|
8d4afdf5ad | ||
|
|
0a7f8f1055 | ||
|
|
93b11410a9 | ||
|
|
667b1cf7a5 | ||
|
|
93d81b84dc | ||
|
|
3f55736f33 | ||
|
|
91c2af2a98 | ||
|
|
548b86aef1 | ||
|
|
7baae391eb | ||
|
|
22783f8f0a | ||
|
|
55d60aca50 | ||
|
|
dd88a6b0ac | ||
|
|
b0c15d1c9b | ||
|
|
7a379a7b40 | ||
|
|
674fdff35b | ||
|
|
94919895bc | ||
|
|
c4e2515c8f | ||
|
|
85a0a728de | ||
|
|
89ec4010e2 | ||
|
|
b3d5b49e90 | ||
|
|
dbfeb59820 | ||
|
|
3ce7dbd960 | ||
|
|
cef535f380 | ||
|
|
3d1678a087 | ||
|
|
ac9cff08d4 | ||
|
|
5671bcf746 | ||
|
|
31fa05599e | ||
|
|
f20748f0d5 | ||
|
|
155251951b | ||
|
|
e2dbe61adf | ||
|
|
236a9697ad | ||
|
|
2f93e37645 | ||
|
|
56abce3fbd | ||
|
|
b6b80474b7 | ||
|
|
bab5973dd0 | ||
|
|
a29c580205 | ||
|
|
dec7bdfb82 | ||
|
|
b6a85a4b2e | ||
|
|
611cc6075b | ||
|
|
1e8c4668b7 | ||
|
|
84fb24ada5 | ||
|
|
1077e48e7e | ||
|
|
ad5d44769b | ||
|
|
e2c383bd80 | ||
|
|
44d018b642 | ||
|
|
cec3fa5810 | ||
|
|
d6cf7fc9aa | ||
|
|
256e746364 | ||
|
|
0504f68b41 | ||
|
|
21265454ab | ||
|
|
cdc1bbc133 | ||
|
|
2579ed311a | ||
|
|
cdfbedb0ea | ||
|
|
46249530a3 | ||
|
|
7881786fe8 | ||
|
|
5a9979633c | ||
|
|
3d379c82d1 | ||
|
|
77141cd55a | ||
|
|
26bcc80ae3 | ||
|
|
59cd5380aa | ||
|
|
c3b36c6944 | ||
|
|
f85c06628b | ||
|
|
7c55dddf43 | ||
|
|
374c68d8da | ||
|
|
de1ef1dde3 | ||
|
|
f5a69a5a3b | ||
|
|
5afd4b260a | ||
|
|
b648f84980 | ||
|
|
bc28ee97da | ||
|
|
a647576c97 | ||
|
|
45e4c1a53d | ||
|
|
6e4e375589 | ||
|
|
3e5e85509d | ||
|
|
92c0fc5afb | ||
|
|
5e90e2a24a | ||
|
|
53c612c13b | ||
|
|
2a1b1817c5 | ||
|
|
e9a8a8d755 | ||
|
|
9a6392a758 | ||
|
|
0fbae2736d | ||
|
|
85a4aacefa | ||
|
|
5189a85966 | ||
|
|
4d15674803 | ||
|
|
274b9e7c43 | ||
|
|
cf53a24271 | ||
|
|
4c0cd15a40 | ||
|
|
6829014393 | ||
|
|
2647f96c81 | ||
|
|
bbcdee8b28 | ||
|
|
8d79437c8d | ||
|
|
a4c9e26018 | ||
|
|
a38fc6eb06 | ||
|
|
b6a070e604 | ||
|
|
e9146234c7 | ||
|
|
1e73944722 | ||
|
|
f37f284605 | ||
|
|
a7156e6f00 | ||
|
|
7c812c2426 | ||
|
|
2dcfebea98 | ||
|
|
812213164f | ||
|
|
4b43e70555 | ||
|
|
5662891d62 | ||
|
|
a7f38e40c4 | ||
|
|
66f98ebaa8 | ||
|
|
3c53c13685 | ||
|
|
ae271fb57a | ||
|
|
53721239f4 | ||
|
|
6636acf2d3 | ||
|
|
b7ed61b8f9 | ||
|
|
02b5a929ac | ||
|
|
5482cb7822 | ||
|
|
6113826180 | ||
|
|
de1a4059b1 | ||
|
|
267ecec8f2 | ||
|
|
07addb366e | ||
|
|
21848c3cf3 | ||
|
|
45745f6f14 | ||
|
|
f7a929bd02 | ||
|
|
cb55d38a38 | ||
|
|
5eb1372e08 | ||
|
|
73b15dce53 | ||
|
|
9227d7b046 | ||
|
|
de0dffe83f | ||
|
|
3550309544 | ||
|
|
153de3077e | ||
|
|
bbb7e7138c | ||
|
|
c777640f04 | ||
|
|
6df5008310 | ||
|
|
37efc32374 | ||
|
|
275098a8ef | ||
|
|
52a9195411 | ||
|
|
5f81594f03 | ||
|
|
f295fe698a | ||
|
|
8805a7acbb | ||
|
|
b4485b1196 | ||
|
|
a929fce3a0 | ||
|
|
f4c8dd9dec | ||
|
|
79f2be422b | ||
|
|
b92a84eed8 | ||
|
|
a50f0627f9 | ||
|
|
d6f5231e93 | ||
|
|
6a9ba75640 | ||
|
|
95f6b00704 | ||
|
|
00fce59737 | ||
|
|
384a549807 | ||
|
|
af41b43c56 | ||
|
|
b146310c1a | ||
|
|
7138a3f8c2 | ||
|
|
038402abb3 | ||
|
|
52587de715 | ||
|
|
5773626d53 | ||
|
|
2d45c80415 | ||
|
|
432965fa0e | ||
|
|
63f2075410 | ||
|
|
f1c9e6c64e | ||
|
|
05ccb75ebf | ||
|
|
58ce2a1298 | ||
|
|
7e823f879e | ||
|
|
9e3fc6603f | ||
|
|
aa162b9393 | ||
|
|
a33df3ac33 | ||
|
|
c0aecff3dc | ||
|
|
43d15d4d00 | ||
|
|
2633eb77e2 | ||
|
|
094a1f2040 | ||
|
|
fc7c8c6a8f | ||
|
|
404c5ab8c3 | ||
|
|
6db5c15037 | ||
|
|
94ab81c1a2 | ||
|
|
e2d8f97e13 | ||
|
|
9be7a3f53c |
12
.gitignore
vendored
12
.gitignore
vendored
@@ -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
307
README.md
@@ -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
6
bin/flash-petstore.sh
Executable 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
|
||||
@@ -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 "$@"
|
||||
@@ -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 "$@"
|
||||
@@ -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 "$@"
|
||||
@@ -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 "$@"
|
||||
@@ -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 "$@"
|
||||
@@ -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
6
bin/java-petstore-filemap.sh
Executable 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
6
bin/java-petstore.sh
Executable 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
6
bin/java-wordnik-api.sh
Executable 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
5
bin/objc-petstore.sh
Executable 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
6
bin/objc-wordnik-api.sh
Executable 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
6
bin/php-petstore.sh
Executable 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
6
bin/python-petstore.sh
Executable 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
6
bin/python3-petstore.sh
Executable 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
19
bin/ruby-petstore.sh
Executable 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
|
||||
@@ -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"
|
||||
@@ -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 "$@"
|
||||
|
||||
@@ -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 "$@"
|
||||
|
||||
@@ -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
6
bin/scala-petstore.sh
Executable 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
6
bin/scala-wordnik-api.sh
Executable 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
|
||||
@@ -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
|
||||
@@ -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
6
bin/validate.sh
Executable 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 "$@"
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
};
|
||||
@@ -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$}$
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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$}$
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}$
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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$}$
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -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$;
|
||||
}
|
||||
|
||||
}$
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
4
conf/js/structure/lib/jquery-1.6.4.min.js
vendored
4
conf/js/structure/lib/jquery-1.6.4.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -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>
|
||||
@@ -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(",");
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
@@ -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());
|
||||
}
|
||||
};
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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};
|
||||
}
|
||||
}$
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/**
|
||||
* Maintains the compatible server version against which the drive is written
|
||||
*
|
||||
*/
|
||||
var VersionChecker = new function() {
|
||||
this.compatibleVersion = "$apiVersion$";
|
||||
}
|
||||
|
||||
@@ -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$}$
|
||||
}
|
||||
@@ -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$
|
||||
}
|
||||
|
||||
}$
|
||||
|
||||
}
|
||||
@@ -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
|
||||
@@ -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$
|
||||
|
||||
}$
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
# nothing to see yet
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
}$
|
||||
@@ -1,5 +0,0 @@
|
||||
module $resource$
|
||||
def get_compatible_version(*args)
|
||||
'$apiVersion$'
|
||||
end
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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"$
|
||||
}
|
||||
@@ -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 "$ + "]"
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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
397
pom.xml
@@ -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>
|
||||
|
||||
37
samples/client/petstore/flash/FlashPetstoreCodegen.scala
Normal file
37
samples/client/petstore/flash/FlashPetstoreCodegen.scala
Normal 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()
|
||||
}
|
||||
@@ -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
|
||||
@@ -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>
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
Reference in New Issue
Block a user