Compare commits

..

173 Commits

Author SHA1 Message Date
Tony Tam
2ed68c2df8 version 2.0.17 2014-08-26 16:52:26 -07:00
Tony Tam
db1915ec89 Merge pull request #252 from earldouglas/path-not-optional
Drop the 'optional' param for path params
2014-08-26 14:40:14 -07:00
James Earl Douglas
77e9ce5ede Drop the 'optional' param for path params 2014-08-26 14:38:27 -07:00
Tony Tam
013c19eb36 Merge pull request #251 from earldouglas/not-so-required
Set param as 'required' iff required, else set as 'optional'
2014-08-26 14:33:00 -07:00
James Earl Douglas
61c04ddaf1 Set param as 'required' iff required, else set as 'optional' 2014-08-26 14:31:45 -07:00
Tony Tam
b4d361130c Merge pull request #247 from xoom/issues/java_pom
Issues/java pom - remove scala dependencies from Java pom files
2014-08-25 23:05:04 -07:00
Tony Tam
8e7571c34f Merge pull request #248 from xhh/patch-1
Fixes #242 - Ruby model syntax error
2014-08-25 23:03:45 -07:00
xhh
1ba42ef6cc Fixes #242 - Ruby model syntax error 2014-08-26 09:18:54 +08:00
Rob Blair
fc77521d49 Simplify java sample poms.
* remove scala references from the java client pom template files.
* regenerate the petstore sample pom.xml, verify they can build properly.
2014-08-25 17:37:36 -07:00
Rob Blair
1522069281 Regenerate the java code before modifying templates 2014-08-25 17:35:44 -07:00
Tony Tam
a13f46e781 Merge pull request #245 from ganeshs/master
Added import mappings for java.util.Set and java.sql.Timestamp
2014-08-20 23:43:05 -07:00
Ganesh Subramanian
3ad1ecf153 Added import mapping for Timestamp 2014-08-21 12:11:19 +05:30
Ganesh Subramanian
6087181634 Added import mapping for Timestamp 2014-08-21 12:10:14 +05:30
Ganesh Subramanian
c09adc4539 Fix for issue #226 2014-08-21 12:01:44 +05:30
Tony Tam
a626dea181 Update api.mustache 2014-08-11 08:58:45 -07:00
Tony Tam
454ec4b438 fix for #235 2014-08-08 16:38:38 -04:00
Ivan Porto Carrero
c7da910e68 remove sample files again 2014-08-05 10:56:20 -07:00
Ivan Porto Carrero
40d33693cf add typesafe releases resolver, fixes #232 2014-08-05 10:43:28 -07:00
Tony Tam
13eaf2bf63 Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-08-03 09:19:01 -07:00
Tony Tam
d4508ed112 updated resolvers 2014-08-03 09:16:30 -07:00
Tony Tam
c252e9f7c6 added sonatype as resolver 2014-08-03 09:12:16 -07:00
Tony Tam
6690b80b29 Update .travis.yml 2014-08-02 16:32:10 -07:00
Tony Tam
19bb97a725 updated travis to 2.10.4 2014-08-02 16:09:00 -07:00
Tony Tam
62ee62ebd3 Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-08-02 16:04:55 -07:00
Tony Tam
87083034ee Merge pull request #215 from JDiPierro/fix_java_generator_lists
Use config.processResponseClass to determine type of returnContainer
2014-07-24 11:48:19 -07:00
Tony Tam
d9de57da6f Merge pull request #223 from darkcube/master
CSharp: Multipart form submission
2014-07-23 08:43:37 -04:00
Timothy Lusk
d0b0323925 CSharp: Implement multipart form submission 2014-07-22 17:17:54 -04:00
Tony Tam
f592414409 Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-07-18 09:52:57 -06:00
Tony Tam
e1c8f58d28 added 2.10.4 2014-07-18 09:52:53 -06:00
Tony Tam
4870ed7e51 Merge pull request #220 from darkcube/master
CSharp Changes
2014-07-16 16:30:15 -06:00
Timothy Lusk
bbe48814b4 CSharp: Add optional api constructor argument to set the basePath 2014-07-15 15:41:57 -04:00
Timothy Lusk
3b6ffa4a1f CSharp: Close the WebResponse if we throw an ApiException 2014-07-15 15:41:56 -04:00
Tony Tam
527c40b996 Merge pull request #211 from wcandillon/patch-1
Link back to the swagger-js-codegen project
2014-07-13 07:21:22 -07:00
Justin DiPierro
e2a20447df Fixed comment in test 2014-07-10 10:02:18 -04:00
Tony Tam
5d42c8cc5f moved to petstore 2014-07-04 10:19:48 -07:00
Tony Tam
256485ec5b updated template 2014-07-04 10:19:28 -07:00
Tony Tam
7ab0394e76 added node.js instead of jetty 2014-07-04 10:19:09 -07:00
Tony Tam
89b04b2e10 formatting 2014-07-04 10:18:44 -07:00
Tony Tam
a019a438e0 changed to petstore sample 2014-07-04 10:08:54 -07:00
Justin DiPierro
9834059786 Fixed BasicScalaGeneratorTest to expect Some(List) 2014-07-03 11:32:37 -04:00
Justin DiPierro
550fade9e0 Codegen.apiToMap should use config.processResponseClass when setting the returnContainer property. Test passes now 2014-07-03 11:24:05 -04:00
Justin DiPierro
aa1b4fc0fb Wrote failing test for Codegen 2014-07-03 11:23:07 -04:00
Tony Tam
5a659803a8 Merge pull request #212 from darkcube/master
Various csharp codegen fixes
2014-06-29 13:59:21 -07:00
Timothy Lusk
7bc7789e81 CSharp: Invoker should handle WebException and rethrow ApiException 2014-06-27 17:55:10 -04:00
Timothy Lusk
cf0721da73 CSharp: Use nullable primitive types to allow optional parameters 2014-06-27 16:10:45 -04:00
Timothy Lusk
dcbf4d1bfd CSharp: Use the correct model package name 2014-06-27 16:01:24 -04:00
William Candillon
017b578502 Link back to the swagger-js-codegen project 2014-06-26 15:05:33 +02:00
Tony Tam
58bade3b01 Update README.md 2014-06-19 09:33:41 -07:00
Tony Tam
02631e674a Merge pull request #207 from emmekappa/master
Fixing extensions and namespaces for csharp common files.
2014-06-17 10:53:17 -07:00
Michele Cantelli
5f5e534d05 CSharp: renaming the "packages" to follow the .NET style. 2014-06-17 16:22:04 +02:00
Michele Cantelli
51deeb478d Fixing extensions for csharp common files. 2014-06-17 15:18:58 +02:00
Tony Tam
acff8229b3 Merge pull request #206 from xoom/issue/modelsFromStatus
Issue/models from status - utilize the responseModel, if present
2014-06-16 17:03:17 -07:00
Rob Blair
233555790a Regenerate sample java files with example response status codes
* none of existing examples use the responseMessage.responseModel feature, but I have tested it.
* Didn't want to muck with sample json
* update the scripts used to generate both java versions.
* see https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#525-response-message-object
2014-06-16 12:59:53 -07:00
Rob Blair
d5ddac8e7e Update java mustache to show error status codes and models in generated API, in comments.
* I wonder if there is some clever way to make exceptions based on the model thrown, and automatically fill them in with the parsed error models?
* Until then, it's comments, and roll your own.
2014-06-16 12:51:35 -07:00
Rob Blair
e8210cd5e3 allow list of models to be returned in errors
* for example, a list of validation errors with an exceptional status
2014-06-16 12:40:44 -07:00
Rob Blair
2dc6b485e0 Generate classes from the models declared in 'responseModel'
* ResponseMessage has new constructor parameter, an optional string for responseModel
* Make sure we add it to list of models
* make sure the responseModel is part of the error list available to mustache
2014-06-16 12:34:44 -07:00
Tony Tam
11bede2b7d improved validation messages 2014-06-12 00:45:27 -07:00
Tony Tam
ed51dd9dea added files 2014-06-11 06:41:59 -07:00
Tony Tam
218f514005 updated node sample 2014-06-11 06:41:31 -07:00
Tony Tam
209e8e066c Merge pull request #201 from xoom/issue/JavaSafeApiName
coerce API names for classesand files to valid Java names
2014-06-11 06:12:55 -07:00
Tony Tam
7d05b01a56 Merge pull request #202 from gonimar/patch-1
Unused local variable 'json_data'.
2014-06-11 06:12:36 -07:00
Tony Tam
64f6bedc37 Merge branch 'repackage' 2014-06-11 06:12:15 -07:00
Tony Tam
4ae4aa98bb formatting 2014-06-11 06:11:45 -07:00
Tony Tam
db8bda087b made nickname optional 2014-06-11 06:11:31 -07:00
Tony Tam
06eb52118e updated to 2.3.0 release 2014-06-11 06:03:44 -07:00
Tony Tam
63be7d0069 removed println 2014-06-11 05:50:44 -07:00
Tony Tam
c7468125fa added clientName 2014-06-10 20:37:36 -07:00
Tony Tam
7b3d8bf799 added file upload support 2014-06-10 20:37:24 -07:00
Tony Tam
c4913fe583 wrapped in apiInfo 2014-06-10 20:37:08 -07:00
Tony Tam
d3339cb087 fixed string default 2014-06-10 20:36:58 -07:00
Tony Tam
ba4fda12dc added additional params 2014-06-10 20:36:29 -07:00
Tony Tam
7a6d6d27ff enabled logging 2014-06-10 20:36:10 -07:00
Tony Tam
bcabb03225 added support for nickname generation 2014-06-10 20:05:19 -07:00
Tony Tam
a404823c54 updated copyright 2014-06-10 17:23:35 -07:00
Tony Tam
96ea70e3c9 added className key 2014-06-10 17:23:20 -07:00
Tony Tam
9a01331ddd updated copyright 2014-06-10 16:58:43 -07:00
Tony Tam
3bfa468ed1 fixed filemap 2014-06-10 16:57:39 -07:00
Tony Tam
fdf8572535 updated copyright 2014-06-10 16:57:12 -07:00
Tony Tam
cff8b1552d updated copyright 2014-06-10 16:57:01 -07:00
Tony Tam
e73dd0a7c4 updated copyrights 2014-06-10 16:56:06 -07:00
Tony Tam
9c4c2dfd37 updated copyrights 2014-06-10 16:55:57 -07:00
Tony Tam
2f8355c953 regenerated client 2014-06-10 16:55:34 -07:00
Tony Tam
3f480482b6 regenerated client 2014-06-10 16:55:17 -07:00
Tony Tam
8274196999 regenerated client 2014-06-10 16:55:13 -07:00
Tony Tam
4e8c71f754 regenerated client 2014-06-10 16:54:48 -07:00
Tony Tam
57e7b41e9c regenerated client 2014-06-10 16:52:16 -07:00
Tony Tam
58d9894f1f regenerated client 2014-06-10 16:51:41 -07:00
Tony Tam
4b4d4d32cd regenerated client 2014-06-10 16:51:36 -07:00
Tony Tam
6a2ea9f614 regenerated client 2014-06-10 16:51:10 -07:00
Tony Tam
0d6754e167 regenerated client 2014-06-10 16:50:17 -07:00
Tony Tam
cb5c2a9708 regenerated client 2014-06-10 16:48:27 -07:00
Tony Tam
dc8ad7edf5 updated client 2014-06-10 16:48:05 -07:00
Tony Tam
52bc82149f file rename 2014-06-10 16:34:40 -07:00
Tony Tam
f53b5e27e0 updated scalatra version, templates for files, forms 2014-06-10 15:51:15 -07:00
Tony Tam
ce5be3452c added patch class 2014-06-10 15:50:49 -07:00
Tony Tam
ce14c225e5 added patch 2014-06-10 10:36:46 -07:00
Tony Tam
b78721826e regenerated client 2014-06-10 10:36:13 -07:00
Tony Tam
85113df113 regenerated client 2014-06-10 08:41:44 -07:00
Tony Tam
607b56cb87 removed println 2014-06-10 08:40:19 -07:00
Tony Tam
2dbf8b7d41 regenerated 2014-06-10 08:40:03 -07:00
Tony Tam
7d4c10043d updated client 2014-06-10 08:22:40 -07:00
Tony Tam
64604124c9 added array support 2014-06-10 08:22:08 -07:00
Tony Tam
50f20ad836 updated templates 2014-06-10 08:21:51 -07:00
Tony Tam
ac40283501 updated samples 2014-06-10 08:01:53 -07:00
Sergey Gonimar
e03d4fc1a5 Unused local variable 'json_data'.
The value of the variable is not used anywhere.
2014-06-10 19:25:00 +06:00
Rob Blair
05e9443db5 coerce API names of class and file valid Java names
* Swagger allows names of apis to include characters like '-' Java does not like that
* use same replace strings as used in toVarName
2014-06-09 17:04:57 -07:00
Tony Tam
1250cc758f updated version 2014-06-09 16:34:42 -07:00
Tony Tam
a18784da6c updated file maps 2014-06-09 15:05:23 -07:00
Tony Tam
c87d637edd regenerated 2014-06-06 00:27:40 -07:00
Tony Tam
bf4a4e5296 fixed imports, nesting 2014-06-06 00:27:15 -07:00
Tony Tam
4f7b80dad2 added debug, fixed headers 2014-06-05 22:49:09 -07:00
Tony Tam
8a2f9bc7bb compatibility 2014-06-05 20:08:59 -07:00
Tony Tam
b9806c183b fixed case 2014-06-05 20:08:37 -07:00
Tony Tam
5aa4c4c999 made snapshot 2014-05-31 16:04:19 -07:00
Tony Tam
424cfac80f updated config 2014-05-30 16:27:54 -07:00
Ivan Porto Carrero
715913f3b4 Update slightly add some test files 2014-05-30 15:17:53 -07:00
Tony Tam
1c2c4fdcd3 removed function override 2014-05-30 15:03:10 -07:00
Ivan Porto Carrero
2ea6c2a3a7 Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-05-30 14:25:57 -07:00
Tony Tam
d91da857a0 removed unused code 2014-05-30 09:59:27 -07:00
Tony Tam
31e65969b3 removed printlns, cruft 2014-05-30 07:53:27 -07:00
Tony Tam
df250bc056 fixed model mapping, refactoring the processing of apiMap and modelMap so it's executed just once 2014-05-30 07:29:19 -07:00
Tony Tam
1569274684 fixed package 2014-05-20 00:14:01 -07:00
Tony Tam
6d8f751da4 added model package 2014-05-19 23:23:23 -07:00
Tony Tam
c2dd00a4ab fixed return type 2014-05-19 15:08:44 -07:00
Tony Tam
9e6ae6eef8 added opts for input 2014-05-15 08:51:41 -04:00
Tony Tam
58b985ba02 moved packages to address collisions with swagger-core per #145 2014-05-14 18:23:32 -04:00
Tony Tam
b4f3143c8c Merge pull request #159 from yanoosh/php-fix-sanitize
PHP - Improved/fixed serialization and deserialize.
2014-05-01 20:31:13 -07:00
Tony Tam
84ad6b5d50 rebuilt docs 2014-05-01 20:19:40 -07:00
Tony Tam
32c14af5ce added resize 2014-05-01 20:18:23 -07:00
Tony Tam
46023c47f5 Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-05-01 20:17:53 -07:00
Tony Tam
71212e5f68 reverted to artifactVersion 2014-05-01 20:16:46 -07:00
Tony Tam
6d1c34048c fix for #176 2014-05-01 20:16:27 -07:00
Tony Tam
f67006057e updated version 2014-05-01 20:14:41 -07:00
Tony Tam
e1e397a7b5 Merge pull request #179 from j-unior/scala-2.10
Added scala 2.10 support in generated maven profile.
2014-05-01 18:03:22 -07:00
Tony Tam
0f35799a77 fixed start script #188 2014-04-29 09:46:49 -07:00
Tony Tam
be44221d98 Merge pull request #187 from earldouglas/return-generated-files
Return files generated from BasicGenerator#generateClientWithoutExit
2014-04-24 16:06:12 -07:00
James Earl Douglas
94ad254a58 Return files generated from BasicGenerator#generateClientWithoutExit 2014-04-24 15:14:41 -07:00
James Earl Douglas
666a4be1f2 Return files generated from Codegen#writeSupportingClasses 2014-04-24 15:12:11 -07:00
James Earl Douglas
e542fbd0a2 De-duplicate code from Codegen#writeSupportingClasses 2014-04-24 15:07:45 -07:00
Pat
f4b2d13aa4 Update README.md 2014-04-09 10:15:08 -07:00
j-unior
abcae6da96 Added scala 2.10 support in generated maven profile. You can enable it with mvn install -P scala_2.10 on generated client 2014-04-01 16:56:08 +03:00
Tony Tam
1b9b3eaa8e Merge pull request #175 from STEAMULO/master
Filename misprint for Android generation
2014-03-25 11:33:03 -07:00
aansel
0babc4f192 Filename misprint for Android generation 2014-03-25 18:44:05 +01:00
webron
e51ffb37b4 Update README.md 2014-03-23 13:16:02 +02:00
Tony Tam
2fba96713c Merge pull request #172 from giovannibotta/master
Minor change to map used when generating supporting files
2014-03-19 08:27:49 -07:00
giodude
dccf8edc25 Minor change to map used when generating supporting files. 2014-03-19 11:18:23 -04:00
webron
d98aeac818 Create LICENSE 2014-03-19 16:08:55 +02:00
webron
62bfc4ea19 Update README.md
Updated license year.
2014-03-19 16:08:38 +02:00
Tony Tam
8d74029fba Merge pull request #170 from hsanjuan/master
Issue #168: Let runscala.sh run from everywhere without breaking
2014-03-18 18:54:28 -07:00
Hector Sanjuan
809cb5cf1f Issue #168: Let runscala.sh run from everywhere without breaking and correctly
setting the classpath
2014-03-17 16:21:36 +01:00
Tony Tam
a4196609c9 added friendly error message when SSL validation fails 2014-03-06 08:29:02 -08:00
Tony Tam
e7eedcf48d removed printlns 2014-03-05 07:54:12 -08:00
Tony Tam
8bf042b153 updated sample with form param support 2014-03-05 07:54:03 -08:00
Tony Tam
8325a12faf fixed hasMore 2014-03-04 20:05:16 -08:00
Tony Tam
03abccd8e8 fix for #154 2014-03-04 19:48:13 -08:00
Janusz Jablonski
19e79fedb2 Added backslash before DateTime object. 2014-03-03 00:40:45 +01:00
Tony Tam
71eacaa3b1 Merge pull request #160 from yanoosh/php-removed-escape
PHP - Removed escapeReservedWord method.
2014-03-02 13:30:08 -08:00
Janusz Jablonski
7cfa46d838 Removed escapeReservedWord method. 2014-03-02 18:31:35 +01:00
Janusz Jablonski
7989e78460 Improved/fixed serialization and deserialize. 2014-03-02 14:44:46 +01:00
Tony Tam
08466f615f Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-02-25 12:54:12 -08:00
Tony Tam
880d14990f added patch support 2014-02-25 12:53:11 -08:00
Tony Tam
39ac8f6d46 added patch support 2014-02-25 12:52:49 -08:00
Tony Tam
685fc7066f Update README.md 2014-02-22 07:21:13 -08:00
Tony Tam
127600e728 Update README.md 2014-02-21 17:29:22 -08:00
Tony Tam
d764328026 updated readme 2014-02-21 17:22:48 -08:00
Tony Tam
cae8296999 updated readme 2014-02-21 17:21:56 -08:00
Tony Tam
86efb71124 updated readme 2014-02-21 17:21:50 -08:00
Tony Tam
0899b08b8c Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-02-21 17:20:16 -08:00
Tony Tam
a770db9d3e added readme 2014-02-21 17:20:06 -08:00
Tony Tam
87b5c43166 Merge pull request #158 from mkantor/objc-safe-var-names
Prevent ObjC generator from producing invalid var names.
2014-02-21 13:41:26 -08:00
Matt Kantor
d14ab2aeff Prevent ObjC generator from producing invalid var names. 2014-02-21 13:35:13 -08:00
Ivan Porto Carrero
b39a609226 Merge branch 'master' of github.com:wordnik/swagger-codegen 2013-11-09 12:18:42 -08:00
Ivan Porto Carrero
d25f64cca0 change to return transpor client in async scala client 2013-11-09 12:18:20 -08:00
573 changed files with 14026 additions and 15088 deletions

View File

@@ -1,3 +1,3 @@
language: scala
scala:
- 2.10.2
- 2.10.0

11
LICENSE Normal file
View File

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

View File

@@ -4,8 +4,15 @@
## Overview
This is the swagger codegen project, which allows generation of client libraries automatically from a
Swagger-compliant server. You can find out more about both the spec and the framework at
http://swagger.wordnik.com. For more information about Wordnik's APIs, please visit http://developer.wordnik.com.
Swagger-compliant server.
## What's Swagger?
The goal of Swagger™ is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined via Swagger, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interfaces have done for lower-level programming, Swager removes the guesswork in calling the service.
Check out [Swagger-Spec](https://github.com/wordnik/swagger-spec) for additional information about the Swagger project, including additional libraries with support for other languages and more.
### Prerequisites
You need the following installed and available in your $PATH:
@@ -123,13 +130,15 @@ and override the `templateDir` in your script to point to the right place. It a
### Where is Javascript???
See our [javascript library](http://github.com/wordnik/swagger.js)--it's completely dynamic and doesn't require
static code generation.
There is a third-party component called [swagger-js-codegen](https://github.com/wcandillon/swagger-js-codegen) that can generate angularjs or nodejs source code from a swagger specification.
#### Generating a client from flat files (i.e. no remote server calls)
If you don't want to call your server, you can save the swagger spec files into a directory and pass an argument
to the code generator like this:
```
-DfileMap=/path/to/files
-DfileMap=/path/to/resource-listing
```
Or for example:
@@ -224,7 +233,7 @@ either repackage the library OR modify your codegen script to use a file path!
License
-------
Copyright 2013 Wordnik, Inc.
Copyright 2014 Wordnik, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@@ -2,6 +2,7 @@ val version = scala.util.Properties.scalaPropOrElse("version.number", "unknown")
case "2.10.0" => "2.10"
case "2.10.2" => "2.10"
case "2.10.3" => "2.10"
case "2.10.4" => "2.10"
case e: String => e
}
println(version)

View File

@@ -1,7 +1,6 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
@@ -19,6 +18,7 @@ if [ ! -d "${APP_DIR}" ]; then
fi
cd $APP_DIR
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
# if you've executed sbt assembly previously it will use that instead.
@@ -26,7 +26,7 @@ export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/
ags="$@ samples/client/petstore/android-java/AndroidJavaPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
scala -cp $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -1,7 +1,6 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
@@ -19,6 +18,7 @@ if [ ! -d "${APP_DIR}" ]; then
fi
cd $APP_DIR
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
# if you've executed sbt assembly previously it will use that instead.
@@ -26,7 +26,7 @@ export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/
ags="$@ samples/client/petstore/java/JavaPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
scala -cp $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -22,7 +22,7 @@ cd $APP_DIR
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties -DfileMap=samples/client/wordnik-api/spec-files"
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties -DfileMap=samples/client/wordnik-api/spec-files/resources.json"
ags="$@ samples/client/wordnik-api/objc/ObjcWordnikApiCodegen.scala http://api.wordnik.com/v4/resources.json"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then

View File

@@ -1,7 +1,6 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
@@ -19,6 +18,7 @@ if [ ! -d "${APP_DIR}" ]; then
fi
cd $APP_DIR
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
# if you've executed sbt assembly previously it will use that instead.
@@ -26,7 +26,7 @@ export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/
ags="$@"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
scala -cp $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -1,7 +1,7 @@
#!/bin/sh
SCRIPT="$0"
SCALA_RUNNER_VERSION=$(scala ./bin/Version.scala)
SCALA_RUNNER_VERSION=2.10 #$(scala ./bin/Version.scala)
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
@@ -25,7 +25,7 @@ cd $APP_DIR
ags="com.wordnik.swagger.codegen.ScalaAsyncClientGenerator $@"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
java -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -22,8 +22,8 @@ cd $APP_DIR
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties -DfileMap=samples/client/wordnik-api/spec-files"
ags="$@ SwaggerDocGenerator http://developer.wordnik.com/v4/resources.json"
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties "
ags="$@ com.wordnik.swagger.codegen.SwaggerDocGenerator http://petstore.swagger.wordnik.com/api/api-docs"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags

View File

@@ -5,9 +5,7 @@ organization := "com.wordnik"
name := "swagger-codegen"
version := "2.0.13"
scalaVersion := "2.10.1"
version := "2.0.17"
crossVersion := CrossVersion.full
@@ -15,33 +13,38 @@ javacOptions ++= Seq("-target", "1.6", "-source", "1.6", "-Xlint:unchecked", "-X
scalacOptions ++= Seq("-optimize", "-unchecked", "-deprecation", "-Xcheckinit", "-encoding", "utf8")
crossScalaVersions := Seq("2.9.0", "2.9.0-1", "2.9.1", "2.9.1-1", "2.9.2", "2.9.3", "2.10.0", "2.10.1", "2.10.2")
crossScalaVersions := Seq("2.10.0", "2.10.1", "2.10.2", "2.10.3", "2.10.4", "2.11.0", "2.11.1")
scalaVersion := "2.11.1"
libraryDependencies ++= Seq(
"org.json4s" %% "json4s-jackson" % "3.2.5",
"org.json4s" %% "json4s-jackson" % "3.2.10",
"io.backchat.inflector" %% "scala-inflector" % "1.3.5",
"commons-io" % "commons-io" % "2.3",
"ch.qos.logback" % "logback-classic" % "1.0.13" % "provided",
"org.rogach" %% "scallop" % "0.8.1",
"org.rogach" %% "scallop" % "0.9.5",
"junit" % "junit" % "4.11" % "test",
"org.scalatest" %% "scalatest" % "1.9.1" % "test"
"org.scalatest" %% "scalatest" % "2.1.7" % "test"
)
libraryDependencies <+= scalaVersion {
case v if v.startsWith("2.9") =>
"org.fusesource.scalate" % "scalate-core_2.9" % "1.6.1"
case v if v.startsWith("2.10") => {
"org.fusesource.scalate" %% "scalate-core" % "1.6.1"
}
case v if v.startsWith("2.10") =>
"org.scalatra.scalate" %% "scalate-core" % "1.7.0"
case v if v.startsWith("2.11") =>
"org.scalatra.scalate" %% "scalate-core" % "1.7.0"
}
libraryDependencies ++= {
scalaVersion.toString match {
case v if v.startsWith("2.10") => Seq("org.scala-lang" % "scala-reflect" % v)
case v if v.startsWith("2.10") || v.startsWith("2.11") => Seq("org.scala-lang" % "scala-reflect" % v)
case _ => Seq()
}
}
resolvers += "Typesafe releases" at "http://repo.typesafe.com/typesafe/releases"
packageOptions <+= (name, version, organization) map {
(title, version, vendor) =>
Package.ManifestAttributes(
@@ -65,7 +68,7 @@ publishTo <<= (version) { version: String =>
Some("Sonatype Nexus Releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2")
}
//publishTo := Some(Resolver.file("file", new File(Path.userHome.absolutePath+"/.m2/repository")))
// publishTo := Some(Resolver.file("file", new File(Path.userHome.absolutePath+"/.m2/repository")))
artifact in (Compile, assembly) ~= { art =>
art.copy(`classifier` = Some("assembly"))
@@ -130,4 +133,4 @@ pomExtra <<= (pomExtra, name, description) {(pom, name, desc) => pom ++ Group(
assemblySettings
jarName in assembly := "swagger-codegen.jar"
// jarName in assembly := "swagger-codegen.jar"

View File

@@ -1,2 +1,5 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.2")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.9.1")
resolvers += "Sonatype OSS Releases" at "https://oss.sonatype.org/content/repositories/releases"

View File

@@ -1,5 +1,5 @@
/**
* Copyright 2013 Wordnik, Inc.
* Copyright 2014 Wordnik, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,6 +42,7 @@ object AndroidJavaPetstoreCodegen extends BasicAndroidJavaGenerator {
// supporting classes
override def supportingFiles = List(
("apiInvoker.mustache", destinationDir + java.io.File.separator + invokerPackage.get.replace(".", java.io.File.separator) + java.io.File.separator, "ApiInvoker.java"),
("httpPatch.mustache", destinationDir + java.io.File.separator + invokerPackage.get.replace(".", java.io.File.separator) + java.io.File.separator, "HttpPatch.java"),
("jsonUtil.mustache", destinationDir + java.io.File.separator + invokerPackage.get.replace(".", java.io.File.separator) + java.io.File.separator, "JsonUtil.java"),
("apiException.mustache", destinationDir + java.io.File.separator + invokerPackage.get.replace(".", java.io.File.separator) + java.io.File.separator, "ApiException.java"),
("pom.mustache", "samples/client/petstore/android-java", "pom.xml")

View File

@@ -104,55 +104,8 @@
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>${scala-maven-plugin-version}</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<configuration>
<recompileMode>incremental</recompileMode>
</configuration>
<jvmArgs>
<jvmArg>-Xmx384m</jvmArg>
</jvmArgs>
<args>
<arg>-target:jvm-1.5</arg>
<arg>-deprecation</arg>
</args>
<launchers>
<launcher>
<id>run-scalatest</id>
<mainClass>org.scalatest.tools.Runner</mainClass>
<args>
<arg>-p</arg>
<arg>${project.build.testOutputDirectory}</arg>
</args>
<jvmArgs>
<jvmArg>-Xmx512m</jvmArg>
</jvmArgs>
</launcher>
</launchers>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>${scala-maven-plugin-version}</version>
</plugin>
</plugins>
</reporting>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
@@ -180,18 +133,6 @@
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.9.1</artifactId>
<version>${scala-test-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -202,13 +143,10 @@
<properties>
<jackson-version>2.1.4</jackson-version>
<scala-version>2.9.1-1</scala-version>
<junit-version>4.8.1</junit-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<junit-version>4.8.1</junit-version>
<scala-test-version>1.6.1</scala-test-version>
<httpclient-version>4.2.3</httpclient-version>
<scala-maven-plugin-version>3.1.5</scala-maven-plugin-version>
<httpclient-version>4.0</httpclient-version>
</properties>
</project>

View File

@@ -9,11 +9,18 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.apache.http.*;
import org.apache.http.client.*;
import org.apache.http.client.methods.*;
import org.apache.http.conn.*;
import org.apache.http.conn.scheme.*;
import org.apache.http.conn.ssl.*;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.*;
import org.apache.http.impl.conn.*;
import org.apache.http.params.*;
import org.apache.http.util.EntityUtils;
import java.io.File;
import java.net.Socket;
import java.net.UnknownHostException;
import java.net.URLEncoder;
import java.util.Map;
@@ -22,15 +29,50 @@ import java.util.List;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.GeneralSecurityException;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
public class ApiInvoker {
private static ApiInvoker INSTANCE = new ApiInvoker();
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
private HttpClient client = null;
private boolean ignoreSSLCertificates = false;
private ClientConnectionManager ignoreSSLConnectionManager;
public ApiInvoker() {
initConnectionManager();
}
public static ApiInvoker getInstance() {
return INSTANCE;
}
public void ignoreSSLCertificates(boolean ignoreSSLCertificates) {
this.ignoreSSLCertificates = ignoreSSLCertificates;
}
public void addDefaultHeader(String key, String value) {
defaultHeaderMap.put(key, value);
}
@@ -114,8 +156,11 @@ public class ApiInvoker {
}
else if ("POST".equals(method)) {
HttpPost post = new HttpPost(url);
post.setHeader("Content-Type", contentType);
post.setEntity(new StringEntity(serialize(body), "UTF-8"));
if (body != null) {
post.setHeader("Content-Type", contentType);
post.setEntity(new StringEntity(serialize(body), "UTF-8"));
}
for(String key : headers.keySet()) {
post.setHeader(key, headers.get(key));
}
@@ -139,6 +184,18 @@ public class ApiInvoker {
}
response = client.execute(delete);
}
else if ("PATCH".equals(method)) {
HttpPatch patch = new HttpPatch(url);
if (body != null) {
patch.setHeader("Content-Type", contentType);
patch.setEntity(new StringEntity(serialize(body), "UTF-8"));
}
for(String key : headers.keySet()) {
patch.setHeader(key, headers.get(key));
}
response = client.execute(patch);
}
int code = response.getStatusLine().getStatusCode();
String responseString = null;
@@ -167,8 +224,61 @@ public class ApiInvoker {
}
private HttpClient getClient(String host) {
if(client == null)
client = new DefaultHttpClient();
if (client == null) {
if (ignoreSSLCertificates && ignoreSSLConnectionManager != null) {
// Trust self signed certificates
client = new DefaultHttpClient(ignoreSSLConnectionManager, new BasicHttpParams());
} else {
client = new DefaultHttpClient();
}
}
return client;
}
private void initConnectionManager() {
try {
final SSLContext sslContext = SSLContext.getInstance("SSL");
// set up a TrustManager that trusts everything
TrustManager[] trustManagers = new TrustManager[] {
new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] certs, String authType) {}
public void checkServerTrusted(X509Certificate[] certs, String authType) {}
}};
sslContext.init(null, trustManagers, new SecureRandom());
SSLSocketFactory sf = new SSLSocketFactory((KeyStore)null) {
private javax.net.ssl.SSLSocketFactory sslFactory = sslContext.getSocketFactory();
public Socket createSocket(Socket socket, String host, int port, boolean autoClose)
throws IOException, UnknownHostException {
return sslFactory.createSocket(socket, host, port, autoClose);
}
public Socket createSocket() throws IOException {
return sslFactory.createSocket();
}
};
sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
Scheme httpsScheme = new Scheme("https", sf, 443);
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(httpsScheme);
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
ignoreSSLConnectionManager = new SingleClientConnManager(new BasicHttpParams(), schemeRegistry);
} catch (NoSuchAlgorithmException e) {
// This will only be thrown if SSL isn't available for some reason.
} catch (KeyManagementException e) {
// This might be thrown when passing a key into init(), but no key is being passed.
} catch (GeneralSecurityException e) {
// This catches anything else that might go wrong.
// If anything goes wrong we default to the standard connection manager.
}
}
}

View File

@@ -0,0 +1,16 @@
package com.wordnik.client;
import org.apache.http.client.methods.*;
public class HttpPatch extends HttpPost {
public static final String METHOD_PATCH = "PATCH";
public HttpPatch(final String url) {
super(url);
}
@Override
public String getMethod() {
return METHOD_PATCH;
}
}

View File

@@ -2,9 +2,9 @@ package com.wordnik.petstore.api;
import com.wordnik.client.ApiException;
import com.wordnik.client.ApiInvoker;
import java.io.File;
import com.wordnik.petstore.model.Pet;
import java.util.*;
import java.io.File;
public class PetApi {
String basePath = "http://petstore.swagger.wordnik.com/api";
@@ -17,15 +17,17 @@ public class PetApi {
public ApiInvoker getInvoker() {
return apiInvoker;
}
public void setBasePath(String basePath) {
this.basePath = basePath;
}
public String getBasePath() {
return basePath;
}
//error info- code: 400 reason: "Invalid ID supplied" model: <none>
//error info- code: 404 reason: "Pet not found" model: <none>
public Pet getPetById (Long petId) throws ApiException {
// verify required params are set
if(petId == null ) {
@@ -57,68 +59,7 @@ public class PetApi {
}
}
}
public void deletePet (String petId) throws ApiException {
// verify required params are set
if(petId == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return ;
}
else {
throw ex;
}
}
}
public List<Pet> partialUpdate (String petId, Pet body) throws ApiException {
// verify required params are set
if(petId == null || body == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "PATCH", queryParams, body, headerParams, contentType);
if(response != null){
return (List<Pet>) ApiInvoker.deserialize(response, "Array", Pet.class);
}
else {
return null;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return null;
}
else {
throw ex;
}
}
}
//error info- code: 405 reason: "Invalid input" model: <none>
public void updatePetWithForm (String petId, String name, String status) throws ApiException {
// verify required params are set
if(petId == null ) {
@@ -150,9 +91,14 @@ public class PetApi {
}
}
}
public void uploadFile (String additionalMetadata, File body) throws ApiException {
//error info- code: 400 reason: "Invalid pet value" model: <none>
public void deletePet (String petId) throws ApiException {
// verify required params are set
if(petId == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/pet/uploadImage".replaceAll("\\{format\\}","json");
String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
@@ -161,7 +107,7 @@ public class PetApi {
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, contentType);
if(response != null){
return ;
}
@@ -177,6 +123,39 @@ public class PetApi {
}
}
}
//error info- code: 400 reason: "Invalid tag value" model: <none>
public List<Pet> partialUpdate (String petId, Pet body) throws ApiException {
// verify required params are set
if(petId == null || body == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "PATCH", queryParams, body, headerParams, contentType);
if(response != null){
return (List<Pet>) ApiInvoker.deserialize(response, "List", Pet.class);
}
else {
return null;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return null;
}
else {
throw ex;
}
}
}
//error info- code: 405 reason: "Invalid input" model: <none>
public void addPet (Pet body) throws ApiException {
// verify required params are set
if(body == null ) {
@@ -208,6 +187,9 @@ public class PetApi {
}
}
}
//error info- code: 400 reason: "Invalid ID supplied" model: <none>
//error info- code: 404 reason: "Pet not found" model: <none>
//error info- code: 405 reason: "Validation exception" model: <none>
public void updatePet (Pet body) throws ApiException {
// verify required params are set
if(body == null ) {
@@ -239,6 +221,7 @@ public class PetApi {
}
}
}
//error info- code: 400 reason: "Invalid status value" model: <none>
public List<Pet> findPetsByStatus (String status) throws ApiException {
// verify required params are set
if(status == null ) {
@@ -258,7 +241,7 @@ public class PetApi {
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
if(response != null){
return (List<Pet>) ApiInvoker.deserialize(response, "Array", Pet.class);
return (List<Pet>) ApiInvoker.deserialize(response, "List", Pet.class);
}
else {
return null;
@@ -272,6 +255,7 @@ public class PetApi {
}
}
}
//error info- code: 400 reason: "Invalid tag value" model: <none>
public List<Pet> findPetsByTags (String tags) throws ApiException {
// verify required params are set
if(tags == null ) {
@@ -291,7 +275,7 @@ public class PetApi {
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
if(response != null){
return (List<Pet>) ApiInvoker.deserialize(response, "Array", Pet.class);
return (List<Pet>) ApiInvoker.deserialize(response, "List", Pet.class);
}
else {
return null;
@@ -305,5 +289,32 @@ public class PetApi {
}
}
}
public void uploadFile (String additionalMetadata, File file) throws ApiException {
// create path and map variables
String path = "/pet/uploadImage".replaceAll("\\{format\\}","json");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, null, headerParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return ;
}
else {
throw ex;
}
}
}
}

View File

@@ -4,6 +4,7 @@ import com.wordnik.client.ApiException;
import com.wordnik.client.ApiInvoker;
import com.wordnik.petstore.model.Order;
import java.util.*;
import java.io.File;
public class StoreApi {
String basePath = "http://petstore.swagger.wordnik.com/api";
@@ -16,77 +17,16 @@ public class StoreApi {
public ApiInvoker getInvoker() {
return apiInvoker;
}
public void setBasePath(String basePath) {
this.basePath = basePath;
}
public String getBasePath() {
return basePath;
}
public Order getOrderById (String orderId) throws ApiException {
// verify required params are set
if(orderId == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
if(response != null){
return (Order) ApiInvoker.deserialize(response, "", Order.class);
}
else {
return null;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return null;
}
else {
throw ex;
}
}
}
public void deleteOrder (String orderId) throws ApiException {
// verify required params are set
if(orderId == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return ;
}
else {
throw ex;
}
}
}
//error info- code: 400 reason: "Invalid order" model: <none>
public void placeOrder (Order body) throws ApiException {
// verify required params are set
if(body == null ) {
@@ -118,5 +58,71 @@ public class StoreApi {
}
}
}
//error info- code: 400 reason: "Invalid ID supplied" model: <none>
//error info- code: 404 reason: "Order not found" model: <none>
public void deleteOrder (String orderId) throws ApiException {
// verify required params are set
if(orderId == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return ;
}
else {
throw ex;
}
}
}
//error info- code: 400 reason: "Invalid ID supplied" model: <none>
//error info- code: 404 reason: "Order not found" model: <none>
public Order getOrderById (String orderId) throws ApiException {
// verify required params are set
if(orderId == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
if(response != null){
return (Order) ApiInvoker.deserialize(response, "", Order.class);
}
else {
return null;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return null;
}
else {
throw ex;
}
}
}
}

View File

@@ -4,6 +4,7 @@ import com.wordnik.client.ApiException;
import com.wordnik.client.ApiInvoker;
import com.wordnik.petstore.model.User;
import java.util.*;
import java.io.File;
public class UserApi {
String basePath = "http://petstore.swagger.wordnik.com/api";
@@ -16,22 +17,24 @@ public class UserApi {
public ApiInvoker getInvoker() {
return apiInvoker;
}
public void setBasePath(String basePath) {
this.basePath = basePath;
}
public String getBasePath() {
return basePath;
}
public void createUser (User body) throws ApiException {
//error info- code: 400 reason: "Invalid username supplied" model: <none>
//error info- code: 404 reason: "User not found" model: <none>
public void updateUser (String username, User body) throws ApiException {
// verify required params are set
if(body == null ) {
if(username == null || body == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/user".replaceAll("\\{format\\}","json");
String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
@@ -40,7 +43,136 @@ public class UserApi {
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, body, headerParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return ;
}
else {
throw ex;
}
}
}
//error info- code: 400 reason: "Invalid username supplied" model: <none>
//error info- code: 404 reason: "User not found" model: <none>
public void deleteUser (String username) throws ApiException {
// verify required params are set
if(username == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return ;
}
else {
throw ex;
}
}
}
//error info- code: 400 reason: "Invalid username supplied" model: <none>
//error info- code: 404 reason: "User not found" model: <none>
public User getUserByName (String username) throws ApiException {
// verify required params are set
if(username == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
if(response != null){
return (User) ApiInvoker.deserialize(response, "", User.class);
}
else {
return null;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return null;
}
else {
throw ex;
}
}
}
//error info- code: 400 reason: "Invalid username and password combination" model: <none>
public String loginUser (String username, String password) throws ApiException {
// verify required params are set
if(username == null || password == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/user/login".replaceAll("\\{format\\}","json");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
if(!"null".equals(String.valueOf(username)))
queryParams.put("username", String.valueOf(username));
if(!"null".equals(String.valueOf(password)))
queryParams.put("password", String.valueOf(password));
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
if(response != null){
return (String) ApiInvoker.deserialize(response, "", String.class);
}
else {
return null;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return null;
}
else {
throw ex;
}
}
}
public void logoutUser () throws ApiException {
// create path and map variables
String path = "/user/logout".replaceAll("\\{format\\}","json");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
if(response != null){
return ;
}
@@ -118,13 +250,13 @@ public class UserApi {
}
}
}
public void updateUser (String username, User body) throws ApiException {
public void createUser (User body) throws ApiException {
// verify required params are set
if(username == null || body == null ) {
if(body == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString()));
String path = "/user".replaceAll("\\{format\\}","json");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
@@ -133,131 +265,7 @@ public class UserApi {
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, body, headerParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return ;
}
else {
throw ex;
}
}
}
public void deleteUser (String username) throws ApiException {
// verify required params are set
if(username == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return ;
}
else {
throw ex;
}
}
}
public User getUserByName (String username) throws ApiException {
// verify required params are set
if(username == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
if(response != null){
return (User) ApiInvoker.deserialize(response, "", User.class);
}
else {
return null;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return null;
}
else {
throw ex;
}
}
}
public String loginUser (String username, String password) throws ApiException {
// verify required params are set
if(username == null || password == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/user/login".replaceAll("\\{format\\}","json");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
if(!"null".equals(String.valueOf(username)))
queryParams.put("username", String.valueOf(username));
if(!"null".equals(String.valueOf(password)))
queryParams.put("password", String.valueOf(password));
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
if(response != null){
return (String) ApiInvoker.deserialize(response, "", String.class);
}
else {
return null;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return null;
}
else {
throw ex;
}
}
}
public void logoutUser () throws ApiException {
// create path and map variables
String path = "/user/logout".replaceAll("\\{format\\}","json");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams, contentType);
if(response != null){
return ;
}

View File

@@ -3,10 +3,8 @@ package com.wordnik.petstore.model;
import com.fasterxml.jackson.annotation.JsonProperty;
public class Category {
/* Category unique identifier */
@JsonProperty("id")
private Long id = null;
/* Name of the category */
@JsonProperty("name")
private String name = null;
public Long getId() {

View File

@@ -4,19 +4,15 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Date;
public class Order {
/* Unique identifier for the order */
@JsonProperty("id")
private Long id = null;
/* ID of pet being ordered */
@JsonProperty("petId")
private Long petId = null;
/* Number of pets ordered */
@JsonProperty("quantity")
private Integer quantity = null;
/* Status of the order */
/* Order Status */
@JsonProperty("status")
private String status = null;
/* Date shipped, only if it has been */
@JsonProperty("shipDate")
private Date shipDate = null;
public Long getId() {

View File

@@ -6,19 +6,15 @@ import java.util.*;
import com.wordnik.petstore.model.Category;
import com.wordnik.petstore.model.Tag;
public class Pet {
/* Unique identifier for the Pet */
/* unique identifier for the pet */
@JsonProperty("id")
private Long id = null;
/* Category the pet is in */
@JsonProperty("category")
private Category category = null;
/* Friendly name of the pet */
@JsonProperty("name")
private String name = null;
/* Image URLs */
@JsonProperty("photoUrls")
private List<String> photoUrls = new ArrayList<String>();
/* Tags assigned to this pet */
@JsonProperty("tags")
private List<Tag> tags = new ArrayList<Tag>();
/* pet status in the store */

View File

@@ -3,10 +3,8 @@ package com.wordnik.petstore.model;
import com.fasterxml.jackson.annotation.JsonProperty;
public class Tag {
/* Unique identifier for the tag */
@JsonProperty("id")
private Long id = null;
/* Friendly name for the tag */
@JsonProperty("name")
private String name = null;
public Long getId() {

View File

@@ -3,25 +3,18 @@ package com.wordnik.petstore.model;
import com.fasterxml.jackson.annotation.JsonProperty;
public class User {
/* Unique identifier for the user */
@JsonProperty("id")
private Long id = null;
/* Unique username */
@JsonProperty("username")
private String username = null;
/* First name of the user */
@JsonProperty("firstName")
private String firstName = null;
/* Last name of the user */
@JsonProperty("username")
private String username = null;
@JsonProperty("lastName")
private String lastName = null;
/* Email address of the user */
@JsonProperty("email")
private String email = null;
/* Password name of the user */
@JsonProperty("password")
private String password = null;
/* Phone number of the user */
@JsonProperty("phone")
private String phone = null;
/* User Status */
@@ -34,13 +27,6 @@ public class User {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getFirstName() {
return firstName;
}
@@ -48,6 +34,13 @@ public class User {
this.firstName = firstName;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getLastName() {
return lastName;
}
@@ -88,8 +81,8 @@ public class User {
StringBuilder sb = new StringBuilder();
sb.append("class User {\n");
sb.append(" id: ").append(id).append("\n");
sb.append(" username: ").append(username).append("\n");
sb.append(" firstName: ").append(firstName).append("\n");
sb.append(" username: ").append(username).append("\n");
sb.append(" lastName: ").append(lastName).append("\n");
sb.append(" email: ").append(email).append("\n");
sb.append(" password: ").append(password).append("\n");

View File

@@ -1,5 +1,5 @@
/**
* Copyright 2012 Wordnik, Inc.
* Copyright 2014 Wordnik, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -21,38 +21,6 @@
return basePath;
}
/// <summary>
/// uploads an image
/// </summary>
/// <param name="additionalMetadata">Additional data to pass to server</param>
/// <param name="body">file to upload</param>
/// <returns></returns>
public void uploadFile (string additionalMetadata, File body) {
// create path and map variables
var path = "/pet/uploadImage".Replace("{format}","json");
// query params
var queryParams = new Dictionary<String, String>();
var headerParams = new Dictionary<String, String>();
string paramStr = null;
try {
var response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.ErrorCode == 404) {
return ;
}
else {
throw ex;
}
}
}
/// <summary>
/// Find pet by ID Returns a pet based on ID
/// </summary>
@@ -197,6 +165,38 @@
}
}
/// <summary>
/// uploads an image
/// </summary>
/// <param name="additionalMetadata">Additional data to pass to server</param>
/// <param name="body">file to upload</param>
/// <returns></returns>
public void uploadFile (string additionalMetadata, File body) {
// create path and map variables
var path = "/pet/uploadImage".Replace("{format}","json");
// query params
var queryParams = new Dictionary<String, String>();
var headerParams = new Dictionary<String, String>();
string paramStr = null;
try {
var response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.ErrorCode == 404) {
return ;
}
else {
throw ex;
}
}
}
/// <summary>
/// Add a new pet to the store
/// </summary>
/// <param name="body">Pet object that needs to be added to the store</param>

View File

@@ -21,41 +21,6 @@
return basePath;
}
/// <summary>
/// Delete purchase order by ID For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
/// </summary>
/// <param name="orderId">ID of the order that needs to be deleted</param>
/// <returns></returns>
public void deleteOrder (string orderId) {
// create path and map variables
var path = "/store/order/{orderId}".Replace("{format}","json").Replace("{" + "orderId" + "}", apiInvoker.escapeString(orderId.ToString()));
// query params
var queryParams = new Dictionary<String, String>();
var headerParams = new Dictionary<String, String>();
// verify required params are set
if (orderId == null ) {
throw new ApiException(400, "missing required params");
}
string paramStr = null;
try {
var response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.ErrorCode == 404) {
return ;
}
else {
throw ex;
}
}
}
/// <summary>
/// Find purchase order by ID For valid response try integer IDs with value &lt;= 5. Anything above 5 or nonintegers will generate API errors
/// </summary>
@@ -92,6 +57,41 @@
}
}
/// <summary>
/// Delete purchase order by ID For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
/// </summary>
/// <param name="orderId">ID of the order that needs to be deleted</param>
/// <returns></returns>
public void deleteOrder (string orderId) {
// create path and map variables
var path = "/store/order/{orderId}".Replace("{format}","json").Replace("{" + "orderId" + "}", apiInvoker.escapeString(orderId.ToString()));
// query params
var queryParams = new Dictionary<String, String>();
var headerParams = new Dictionary<String, String>();
// verify required params are set
if (orderId == null ) {
throw new ApiException(400, "missing required params");
}
string paramStr = null;
try {
var response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.ErrorCode == 404) {
return ;
}
else {
throw ex;
}
}
}
/// <summary>
/// Place an order for a pet
/// </summary>
/// <param name="body">order placed for purchasing the pet</param>

View File

@@ -21,6 +21,42 @@
return basePath;
}
/// <summary>
/// Updated user This can only be done by the logged in user.
/// </summary>
/// <param name="username">name that need to be deleted</param>
/// <param name="body">Updated user object</param>
/// <returns></returns>
public void updateUser (string username, User body) {
// create path and map variables
var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.escapeString(username.ToString()));
// query params
var queryParams = new Dictionary<String, String>();
var headerParams = new Dictionary<String, String>();
// verify required params are set
if (username == null || body == null ) {
throw new ApiException(400, "missing required params");
}
string paramStr = null;
try {
var response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, body, headerParams);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.ErrorCode == 404) {
return ;
}
else {
throw ex;
}
}
}
/// <summary>
/// Delete user This can only be done by the logged in user.
/// </summary>
@@ -92,42 +128,6 @@
}
}
/// <summary>
/// Updated user This can only be done by the logged in user.
/// </summary>
/// <param name="username">name that need to be deleted</param>
/// <param name="body">Updated user object</param>
/// <returns></returns>
public void updateUser (string username, User body) {
// create path and map variables
var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.escapeString(username.ToString()));
// query params
var queryParams = new Dictionary<String, String>();
var headerParams = new Dictionary<String, String>();
// verify required params are set
if (username == null || body == null ) {
throw new ApiException(400, "missing required params");
}
string paramStr = null;
try {
var response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, body, headerParams);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.ErrorCode == 404) {
return ;
}
else {
throw ex;
}
}
}
/// <summary>
/// Logs user into the system
/// </summary>
/// <param name="username">The user name for login</param>

View File

@@ -61,6 +61,7 @@
var client = WebRequest.Create(host + path + querystring);
client.ContentType = "application/json";
client.Method = method;
foreach (var headerParamsItem in headerParams)
{

View File

@@ -1,5 +1,5 @@
/**
* Copyright 2012 Wordnik, Inc.
* Copyright 2014 Wordnik, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -63,7 +63,7 @@
<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.codegen.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'"/>

View File

@@ -22,91 +22,16 @@ public class UserApi extends SwaggerApi {
super(apiCredentials, eventDispatcher);
}
public static const event_createUser: String = "createUser";
public static const event_createUsersWithArrayInput: String = "createUsersWithArrayInput";
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";
public static const event_createUser: String = "createUser";
public static const event_createUsersWithArrayInput: String = "createUsersWithArrayInput";
public static const event_createUsersWithListInput: String = "createUsersWithListInput";
/*
* Returns void */
public function createUser (body: User): String {
// create path and map variables
var path: String = "/user".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 createUsersWithArrayInput (body: Array): String {
// create path and map variables
var path: String = "/user/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 createUsersWithListInput (body: Array): String {
// create path and map variables
var path: String = "/user/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/{username}".replace(/{format}/g,"xml").replace("{" + "username" + "}", getApiInvoker().escapeString(username));
@@ -229,6 +154,81 @@ public static const event_logoutUser: String = "logoutUser";
token.returnType = null ;
return requestId;
}
/*
* Returns void */
public function createUser (body: User): String {
// create path and map variables
var path: String = "/user".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 createUsersWithArrayInput (body: Array): String {
// create path and map variables
var path: String = "/user/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 createUsersWithListInput (body: Array): String {
// create path and map variables
var path: String = "/user/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;
}
}
}

View File

@@ -2,11 +2,9 @@ package com.wordnik.client.model {
[XmlRootNode(name="Category")]
public class Category {
/* Category unique identifier */
[XmlElement(name="id")]
public var id: Number = 0.0;
/* Name of the category */
[XmlElement(name="name")]
public var name: String = null;

View File

@@ -2,23 +2,19 @@ package com.wordnik.client.model {
[XmlRootNode(name="Order")]
public class Order {
/* Unique identifier for the order */
[XmlElement(name="id")]
public var id: Number = 0.0;
/* ID of pet being ordered */
[XmlElement(name="petId")]
public var petId: Number = 0.0;
/* Number of pets ordered */
[XmlElement(name="quantity")]
public var quantity: Number = 0.0;
/* Status of the order */
/* Order Status */
[XmlElement(name="status")]
public var status: String = null;
/* Date shipped, only if it has been */
[XmlElement(name="shipDate")]
public var shipDate: Date = null;

View File

@@ -4,26 +4,22 @@ import com.wordnik.client.model.Category;
import com.wordnik.client.model.Tag;
[XmlRootNode(name="Pet")]
public class Pet {
/* Unique identifier for the Pet */
/* unique identifier for the pet */
[XmlElement(name="id")]
public var id: Number = 0.0;
/* Category the pet is in */
[XmlElement(name="category")]
public var category: Category = null;
/* Friendly name of the pet */
[XmlElement(name="name")]
public var name: String = null;
/* Image URLs */
// 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();
/* Tags assigned to this pet */
// 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")]

View File

@@ -2,11 +2,9 @@ package com.wordnik.client.model {
[XmlRootNode(name="Tag")]
public class Tag {
/* Unique identifier for the tag */
[XmlElement(name="id")]
public var id: Number = 0.0;
/* Friendly name for the tag */
[XmlElement(name="name")]
public var name: String = null;

View File

@@ -2,31 +2,24 @@ package com.wordnik.client.model {
[XmlRootNode(name="User")]
public class User {
/* Unique identifier for the user */
[XmlElement(name="id")]
public var id: Number = 0.0;
/* Unique username */
[XmlElement(name="username")]
public var username: String = null;
/* First name of the user */
[XmlElement(name="firstName")]
public var firstName: String = null;
/* Last name of the user */
[XmlElement(name="username")]
public var username: String = null;
[XmlElement(name="lastName")]
public var lastName: String = null;
/* Email address of the user */
[XmlElement(name="email")]
public var email: String = null;
/* Password name of the user */
[XmlElement(name="password")]
public var password: String = null;
/* Phone number of the user */
[XmlElement(name="phone")]
public var phone: String = null;
@@ -37,8 +30,8 @@ package com.wordnik.client.model {
public function toString(): String {
var str: String = "User: ";
str += " (id: " + id + ")";
str += " (username: " + username + ")";
str += " (firstName: " + firstName + ")";
str += " (username: " + username + ")";
str += " (lastName: " + lastName + ")";
str += " (email: " + email + ")";
str += " (password: " + password + ")";

View File

@@ -1,5 +1,5 @@
/**
* Copyright 2013 Wordnik, Inc.
* Copyright 2014 Wordnik, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ object JavaPetstoreCodegen extends BasicJavaGenerator {
def main(args: Array[String]) = generateClient(args)
// location of templates
override def templateDir = "Java"
override def templateDir = "src/main/resources/Java"
// where to write generated code
override def destinationDir = "samples/client/petstore/java/src/main/java"

View File

@@ -1,10 +1,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.wordnik.client</groupId>
<artifactId>api-client</artifactId>
<groupId>com.wordnik</groupId>
<artifactId>swagger-petstore</artifactId>
<packaging>jar</packaging>
<name>api-client</name>
<name>swagger-petstore</name>
<version>1.0.0</version>
<scm>
<connection>scm:git:git@github.com:wordnik/swagger-mustache.git</connection>
@@ -104,55 +104,8 @@
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>${scala-maven-plugin-version}</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<configuration>
<recompileMode>incremental</recompileMode>
</configuration>
<jvmArgs>
<jvmArg>-Xmx384m</jvmArg>
</jvmArgs>
<args>
<arg>-target:jvm-1.5</arg>
<arg>-deprecation</arg>
</args>
<launchers>
<launcher>
<id>run-scalatest</id>
<mainClass>org.scalatest.tools.Runner</mainClass>
<args>
<arg>-p</arg>
<arg>${project.build.testOutputDirectory}</arg>
</args>
<jvmArgs>
<jvmArg>-Xmx512m</jvmArg>
</jvmArgs>
</launcher>
</launchers>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>${scala-maven-plugin-version}</version>
</plugin>
</plugins>
</reporting>
<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
@@ -160,6 +113,12 @@
<version>${jersey-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
<version>${jersey-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
@@ -178,20 +137,19 @@
<version>${jackson-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>2.1.5</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${jodatime-version}</version>
<scope>compile</scope>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.9.1</artifactId>
<version>${scala-test-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -203,12 +161,10 @@
<properties>
<jersey-version>1.7</jersey-version>
<jackson-version>2.1.4</jackson-version>
<scala-version>2.9.1-1</scala-version>
<jodatime-version>2.3</jodatime-version>
<junit-version>4.8.1</junit-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<junit-version>4.8.1</junit-version>
<scala-test-version>1.6.1</scala-test-version>
<scala-maven-plugin-version>3.1.5</scala-maven-plugin-version>
</properties>
</project>

View File

@@ -11,6 +11,7 @@ import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.client.filter.LoggingFilter;
import com.sun.jersey.api.client.WebResource.Builder;
import com.sun.jersey.multipart.FormDataMultiPart;
import javax.ws.rs.core.Response.Status.Family;
import javax.ws.rs.core.MediaType;
@@ -19,11 +20,18 @@ import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.io.IOException;
import java.net.URLEncoder;
import java.io.UnsupportedEncodingException;
public class ApiInvoker {
private static ApiInvoker INSTANCE = new ApiInvoker();
private Map<String, Client> hostMap = new HashMap<String, Client>();
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
private boolean isDebug = false;
public void enableDebug() {
isDebug = true;
}
public static ApiInvoker getInstance() {
return INSTANCE;
@@ -34,7 +42,12 @@ public class ApiInvoker {
}
public String escapeString(String str) {
return str;
try{
return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20");
}
catch(UnsupportedEncodingException e) {
return str;
}
}
public static Object deserialize(String json, String containerType, Class cls) throws ApiException {
@@ -71,7 +84,7 @@ public class ApiInvoker {
}
}
public String invokeAPI(String host, String path, String method, Map<String, String> queryParams, Object body, Map<String, String> headerParams, String contentType) throws ApiException {
public String invokeAPI(String host, String path, String method, Map<String, String> queryParams, Object body, Map<String, String> headerParams, Map<String, String> formParams, String contentType) throws ApiException {
Client client = getClient(host);
StringBuilder b = new StringBuilder();
@@ -105,21 +118,46 @@ public class ApiInvoker {
}
else if ("POST".equals(method)) {
if(body == null)
response = builder.post(ClientResponse.class, serialize(body));
response = builder.post(ClientResponse.class, null);
else if(body instanceof FormDataMultiPart) {
response = builder.type(contentType).post(ClientResponse.class, body);
}
else
response = builder.type("application/json").post(ClientResponse.class, serialize(body));
response = builder.type(contentType).post(ClientResponse.class, serialize(body));
}
else if ("PUT".equals(method)) {
if(body == null)
response = builder.put(ClientResponse.class, serialize(body));
else
response = builder.type("application/json").put(ClientResponse.class, serialize(body));
else {
if("application/x-www-form-urlencoded".equals(contentType)) {
StringBuilder formParamBuilder = new StringBuilder();
// encode the form params
for(String key : formParams.keySet()) {
String value = formParams.get(key);
if(value != null && !"".equals(value.trim())) {
if(formParamBuilder.length() > 0) {
formParamBuilder.append("&");
}
try {
formParamBuilder.append(URLEncoder.encode(key, "utf8")).append("=").append(URLEncoder.encode(value, "utf8"));
}
catch (Exception e) {
// move on to next
}
}
}
response = builder.type(contentType).put(ClientResponse.class, formParamBuilder.toString());
}
else
response = builder.type(contentType).put(ClientResponse.class, serialize(body));
}
}
else if ("DELETE".equals(method)) {
if(body == null)
response = builder.delete(ClientResponse.class, serialize(body));
else
response = builder.type("application/json").delete(ClientResponse.class, serialize(body));
response = builder.type(contentType).delete(ClientResponse.class, serialize(body));
}
else {
throw new ApiException(500, "unknown method type " + method);
@@ -140,7 +178,8 @@ public class ApiInvoker {
private Client getClient(String host) {
if(!hostMap.containsKey(host)) {
Client client = Client.create();
client.addFilter(new LoggingFilter());
if(isDebug)
client.addFilter(new LoggingFilter());
hostMap.put(host, client);
}
return hostMap.get(host);

View File

@@ -5,6 +5,8 @@ import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.core.JsonGenerator.Feature;
import com.fasterxml.jackson.datatype.joda.*;
public class JsonUtil {
public static ObjectMapper mapper;
@@ -12,6 +14,7 @@ public class JsonUtil {
mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.registerModule(new JodaModule());
}
public static ObjectMapper getJsonMapper() {

View File

@@ -2,8 +2,13 @@ package com.wordnik.petstore.api;
import com.wordnik.client.ApiException;
import com.wordnik.client.ApiInvoker;
import java.io.File;
import com.wordnik.petstore.model.Pet;
import com.sun.jersey.multipart.FormDataMultiPart;
import javax.ws.rs.core.MediaType;
import java.io.File;
import java.util.*;
public class PetApi {
@@ -22,34 +27,10 @@ public class PetApi {
return basePath;
}
public void uploadFile (String additionalMetadata, File body) throws ApiException {
// create path and map variables
String path = "/pet/uploadImage".replaceAll("\\{format\\}","json");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return ;
}
else {
throw ex;
}
}
}
//error info- code: 400 reason: "Invalid ID supplied" model: <none>
//error info- code: 404 reason: "Pet not found" model: <none>
public Pet getPetById (Long petId) throws ApiException {
Object postBody = null;
// verify required params are set
if(petId == null ) {
throw new ApiException(400, "missing required params");
@@ -60,11 +41,24 @@ public class PetApi {
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
String contentType = "application/json";
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return (Pet) ApiInvoker.deserialize(response, "", Pet.class);
}
@@ -80,7 +74,9 @@ public class PetApi {
}
}
}
public void deletePet (String petId) throws ApiException {
//error info- code: 405 reason: "Invalid input" model: <none>
public void updatePetWithForm (String petId, String name, String status) throws ApiException {
Object postBody = null;
// verify required params are set
if(petId == null ) {
throw new ApiException(400, "missing required params");
@@ -91,11 +87,28 @@ public class PetApi {
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
String contentType = "application/json";
String[] contentTypes = {
"application/x-www-form-urlencoded"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
hasFields = true;
mp.field("name", name, MediaType.MULTIPART_FORM_DATA_TYPE);
hasFields = true;
mp.field("status", status, MediaType.MULTIPART_FORM_DATA_TYPE);
if(hasFields)
postBody = mp;
}
else {
formParams.put("name", name);formParams.put("status", status);}
try {
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
@@ -111,7 +124,55 @@ public class PetApi {
}
}
}
//error info- code: 400 reason: "Invalid pet value" model: <none>
public void deletePet (String petId) throws ApiException {
Object postBody = null;
// verify required params are set
if(petId == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return ;
}
else {
throw ex;
}
}
}
//error info- code: 400 reason: "Invalid tag value" model: <none>
public List<Pet> partialUpdate (String petId, Pet body) throws ApiException {
Object postBody = body;
// verify required params are set
if(petId == null || body == null ) {
throw new ApiException(400, "missing required params");
@@ -122,13 +183,26 @@ public class PetApi {
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
String contentType = "application/json";
String[] contentTypes = {
"application/json","application/xml"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "PATCH", queryParams, body, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "PATCH", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return (List<Pet>) ApiInvoker.deserialize(response, "Array", Pet.class);
return (List<Pet>) ApiInvoker.deserialize(response, "List", Pet.class);
}
else {
return null;
@@ -142,38 +216,9 @@ public class PetApi {
}
}
}
public void updatePetWithForm (String petId, String name, String status) throws ApiException {
// verify required params are set
if(petId == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, null, headerParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return ;
}
else {
throw ex;
}
}
}
//error info- code: 405 reason: "Invalid input" model: <none>
public void addPet (Pet body) throws ApiException {
Object postBody = body;
// verify required params are set
if(body == null ) {
throw new ApiException(400, "missing required params");
@@ -184,11 +229,24 @@ public class PetApi {
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
String contentType = "application/json";
String[] contentTypes = {
"application/json","application/xml"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
@@ -204,7 +262,11 @@ public class PetApi {
}
}
}
//error info- code: 400 reason: "Invalid ID supplied" model: <none>
//error info- code: 404 reason: "Pet not found" model: <none>
//error info- code: 405 reason: "Validation exception" model: <none>
public void updatePet (Pet body) throws ApiException {
Object postBody = body;
// verify required params are set
if(body == null ) {
throw new ApiException(400, "missing required params");
@@ -215,11 +277,24 @@ public class PetApi {
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
String contentType = "application/json";
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, body, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
@@ -235,7 +310,9 @@ public class PetApi {
}
}
}
//error info- code: 400 reason: "Invalid status value" model: <none>
public List<Pet> findPetsByStatus (String status) throws ApiException {
Object postBody = null;
// verify required params are set
if(status == null ) {
throw new ApiException(400, "missing required params");
@@ -246,15 +323,28 @@ public class PetApi {
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
if(!"null".equals(String.valueOf(status)))
queryParams.put("status", String.valueOf(status));
String contentType = "application/json";
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return (List<Pet>) ApiInvoker.deserialize(response, "Array", Pet.class);
return (List<Pet>) ApiInvoker.deserialize(response, "List", Pet.class);
}
else {
return null;
@@ -268,7 +358,9 @@ public class PetApi {
}
}
}
//error info- code: 400 reason: "Invalid tag value" model: <none>
public List<Pet> findPetsByTags (String tags) throws ApiException {
Object postBody = null;
// verify required params are set
if(tags == null ) {
throw new ApiException(400, "missing required params");
@@ -279,15 +371,28 @@ public class PetApi {
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
if(!"null".equals(String.valueOf(tags)))
queryParams.put("tags", String.valueOf(tags));
String contentType = "application/json";
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return (List<Pet>) ApiInvoker.deserialize(response, "Array", Pet.class);
return (List<Pet>) ApiInvoker.deserialize(response, "List", Pet.class);
}
else {
return null;
@@ -301,5 +406,50 @@ public class PetApi {
}
}
}
public void uploadFile (String additionalMetadata, File file) throws ApiException {
Object postBody = null;
// create path and map variables
String path = "/pet/uploadImage".replaceAll("\\{format\\}","json");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = {
"multipart/form-data"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
hasFields = true;
mp.field("additionalMetadata", additionalMetadata, MediaType.MULTIPART_FORM_DATA_TYPE);
hasFields = true;
mp.field("file", file, MediaType.MULTIPART_FORM_DATA_TYPE);
if(hasFields)
postBody = mp;
}
else {
formParams.put("additionalMetadata", additionalMetadata);}
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return ;
}
else {
throw ex;
}
}
}
}

View File

@@ -2,7 +2,13 @@ package com.wordnik.petstore.api;
import com.wordnik.client.ApiException;
import com.wordnik.client.ApiInvoker;
import com.wordnik.petstore.model.Order;
import com.sun.jersey.multipart.FormDataMultiPart;
import javax.ws.rs.core.MediaType;
import java.io.File;
import java.util.*;
public class StoreApi {
@@ -21,22 +27,37 @@ public class StoreApi {
return basePath;
}
public void deleteOrder (String orderId) throws ApiException {
//error info- code: 400 reason: "Invalid order" model: <none>
public void placeOrder (Order body) throws ApiException {
Object postBody = body;
// verify required params are set
if(orderId == null ) {
if(body == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString()));
String path = "/store/order".replaceAll("\\{format\\}","json");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
String contentType = "application/json";
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
@@ -52,7 +73,10 @@ public class StoreApi {
}
}
}
public Order getOrderById (String orderId) throws ApiException {
//error info- code: 400 reason: "Invalid ID supplied" model: <none>
//error info- code: 404 reason: "Order not found" model: <none>
public void deleteOrder (String orderId) throws ApiException {
Object postBody = null;
// verify required params are set
if(orderId == null ) {
throw new ApiException(400, "missing required params");
@@ -63,11 +87,71 @@ public class StoreApi {
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
String contentType = "application/json";
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return ;
}
else {
throw ex;
}
}
}
//error info- code: 400 reason: "Invalid ID supplied" model: <none>
//error info- code: 404 reason: "Order not found" model: <none>
public Order getOrderById (String orderId) throws ApiException {
Object postBody = null;
// verify required params are set
if(orderId == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return (Order) ApiInvoker.deserialize(response, "", Order.class);
}
@@ -83,36 +167,5 @@ public class StoreApi {
}
}
}
public void placeOrder (Order body) throws ApiException {
// verify required params are set
if(body == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/store/order".replaceAll("\\{format\\}","json");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return ;
}
else {
throw ex;
}
}
}
}

View File

@@ -2,7 +2,13 @@ package com.wordnik.petstore.api;
import com.wordnik.client.ApiException;
import com.wordnik.client.ApiInvoker;
import com.wordnik.petstore.model.User;
import com.sun.jersey.multipart.FormDataMultiPart;
import javax.ws.rs.core.MediaType;
import java.io.File;
import java.util.*;
public class UserApi {
@@ -21,9 +27,12 @@ public class UserApi {
return basePath;
}
public void deleteUser (String username) throws ApiException {
//error info- code: 400 reason: "Invalid username supplied" model: <none>
//error info- code: 404 reason: "User not found" model: <none>
public void updateUser (String username, User body) throws ApiException {
Object postBody = body;
// verify required params are set
if(username == null ) {
if(username == null || body == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
@@ -32,11 +41,24 @@ public class UserApi {
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
String contentType = "application/json";
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
@@ -52,7 +74,10 @@ public class UserApi {
}
}
}
public User getUserByName (String username) throws ApiException {
//error info- code: 400 reason: "Invalid username supplied" model: <none>
//error info- code: 404 reason: "User not found" model: <none>
public void deleteUser (String username) throws ApiException {
Object postBody = null;
// verify required params are set
if(username == null ) {
throw new ApiException(400, "missing required params");
@@ -63,11 +88,71 @@ public class UserApi {
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
String contentType = "application/json";
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return ;
}
else {
throw ex;
}
}
}
//error info- code: 400 reason: "Invalid username supplied" model: <none>
//error info- code: 404 reason: "User not found" model: <none>
public User getUserByName (String username) throws ApiException {
Object postBody = null;
// verify required params are set
if(username == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return (User) ApiInvoker.deserialize(response, "", User.class);
}
@@ -83,38 +168,9 @@ public class UserApi {
}
}
}
public void updateUser (String username, User body) throws ApiException {
// verify required params are set
if(username == null || body == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString()));
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, body, headerParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return ;
}
else {
throw ex;
}
}
}
//error info- code: 400 reason: "Invalid username and password combination" model: <none>
public String loginUser (String username, String password) throws ApiException {
Object postBody = null;
// verify required params are set
if(username == null || password == null ) {
throw new ApiException(400, "missing required params");
@@ -125,15 +181,28 @@ public class UserApi {
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
if(!"null".equals(String.valueOf(username)))
queryParams.put("username", String.valueOf(username));
if(!"null".equals(String.valueOf(password)))
queryParams.put("password", String.valueOf(password));
String contentType = "application/json";
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return (String) ApiInvoker.deserialize(response, "", String.class);
}
@@ -150,48 +219,31 @@ public class UserApi {
}
}
public void logoutUser () throws ApiException {
Object postBody = null;
// create path and map variables
String path = "/user/logout".replaceAll("\\{format\\}","json");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
String contentType = "application/json";
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return ;
}
else {
throw ex;
}
}
}
public void createUser (User body) throws ApiException {
// verify required params are set
if(body == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/user".replaceAll("\\{format\\}","json");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
@@ -208,6 +260,7 @@ public class UserApi {
}
}
public void createUsersWithArrayInput (List<User> body) throws ApiException {
Object postBody = body;
// verify required params are set
if(body == null ) {
throw new ApiException(400, "missing required params");
@@ -218,11 +271,24 @@ public class UserApi {
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
String contentType = "application/json";
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
@@ -239,6 +305,7 @@ public class UserApi {
}
}
public void createUsersWithListInput (List<User> body) throws ApiException {
Object postBody = body;
// verify required params are set
if(body == null ) {
throw new ApiException(400, "missing required params");
@@ -249,11 +316,69 @@ public class UserApi {
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
String contentType = "application/json";
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return ;
}
else {
throw ex;
}
}
}
public void createUser (User body) throws ApiException {
Object postBody = body;
// verify required params are set
if(body == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/user".replaceAll("\\{format\\}","json");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if(hasFields)
postBody = mp;
}
else {
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return ;
}

View File

@@ -1,5 +1,5 @@
/**
* Copyright 2012 Wordnik, Inc.
* Copyright 2014 Wordnik, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@ object ObjcPetstoreCodegen extends BasicObjcGenerator {
val outputFolder = "samples/client/petstore/objc/"
override def destinationDir = outputFolder + java.io.File.separator + "client"
// to avoid recompiling ...
override def templateDir = "objc"
additionalParams ++= Map("projectName" -> "PetstoreClient")

View File

@@ -280,7 +280,7 @@ static bool loggingEnabled = false;
}
if(body != nil) {
if([body isKindOfClass:[NSDictionary class]]){
if([body isKindOfClass:[NSDictionary class]] || [body isKindOfClass:[NSArray class]]){
[request setValue:requestContentType forHTTPHeaderField:@"Content-Type"];
}
else if ([body isKindOfClass:[SWGFile class]]) {}

View File

@@ -1,11 +1,12 @@
#import <Foundation/Foundation.h>
#import "SWGObject.h"
@interface SWGCategory : SWGObject
@property(nonatomic) NSNumber* _id; /* Category unique identifier [optional]*/
@property(nonatomic) NSNumber* _id;
@property(nonatomic) NSString* name; /* Name of the category [optional]*/
@property(nonatomic) NSString* name;
- (id) _id: (NSNumber*) _id
name: (NSString*) name;

View File

@@ -2,17 +2,18 @@
#import "SWGObject.h"
#import "SWGDate.h"
@interface SWGOrder : SWGObject
@property(nonatomic) NSNumber* _id; /* Unique identifier for the order [optional]*/
@property(nonatomic) NSNumber* _id;
@property(nonatomic) NSNumber* petId; /* ID of pet being ordered [optional]*/
@property(nonatomic) NSNumber* petId;
@property(nonatomic) NSNumber* quantity; /* Number of pets ordered [optional]*/
@property(nonatomic) NSNumber* quantity;
@property(nonatomic) NSString* status; /* Status of the order [optional]*/
@property(nonatomic) NSString* status; /* Order Status [optional]*/
@property(nonatomic) SWGDate* shipDate; /* Date shipped, only if it has been [optional]*/
@property(nonatomic) SWGDate* shipDate;
- (id) _id: (NSNumber*) _id
petId: (NSNumber*) petId

View File

@@ -3,17 +3,18 @@
#import "SWGCategory.h"
#import "SWGTag.h"
@interface SWGPet : SWGObject
@property(nonatomic) NSNumber* _id; /* Unique identifier for the Pet */
@property(nonatomic) NSNumber* _id; /* unique identifier for the pet */
@property(nonatomic) SWGCategory* category; /* Category the pet is in [optional]*/
@property(nonatomic) SWGCategory* category;
@property(nonatomic) NSString* name; /* Friendly name of the pet */
@property(nonatomic) NSString* name;
@property(nonatomic) NSArray* photoUrls; /* Image URLs [optional]*/
@property(nonatomic) NSArray* photoUrls;
@property(nonatomic) NSArray* tags; /* Tags assigned to this pet [optional]*/
@property(nonatomic) NSArray* tags;
@property(nonatomic) NSString* status; /* pet status in the store [optional]*/

View File

@@ -3,6 +3,7 @@
#import "SWGFile.h"
@interface SWGPetApi: NSObject
-(void) addHeader:(NSString*)value forKey:(NSString*)key;

View File

@@ -6,6 +6,7 @@
@implementation SWGPetApi
static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
@@ -561,4 +562,5 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
}
@end

View File

@@ -2,6 +2,7 @@
#import "SWGOrder.h"
@interface SWGStoreApi: NSObject
-(void) addHeader:(NSString*)value forKey:(NSString*)key;

View File

@@ -5,6 +5,7 @@
@implementation SWGStoreApi
static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
@@ -202,4 +203,5 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
}
@end

View File

@@ -1,11 +1,12 @@
#import <Foundation/Foundation.h>
#import "SWGObject.h"
@interface SWGTag : SWGObject
@property(nonatomic) NSNumber* _id; /* Unique identifier for the tag [optional]*/
@property(nonatomic) NSNumber* _id;
@property(nonatomic) NSString* name; /* Friendly name for the tag [optional]*/
@property(nonatomic) NSString* name;
- (id) _id: (NSNumber*) _id
name: (NSString*) name;

View File

@@ -1,27 +1,28 @@
#import <Foundation/Foundation.h>
#import "SWGObject.h"
@interface SWGUser : SWGObject
@property(nonatomic) NSNumber* _id; /* Unique identifier for the user [optional]*/
@property(nonatomic) NSNumber* _id;
@property(nonatomic) NSString* username; /* Unique username [optional]*/
@property(nonatomic) NSString* firstName;
@property(nonatomic) NSString* firstName; /* First name of the user [optional]*/
@property(nonatomic) NSString* username;
@property(nonatomic) NSString* lastName; /* Last name of the user [optional]*/
@property(nonatomic) NSString* lastName;
@property(nonatomic) NSString* email; /* Email address of the user [optional]*/
@property(nonatomic) NSString* email;
@property(nonatomic) NSString* password; /* Password name of the user [optional]*/
@property(nonatomic) NSString* password;
@property(nonatomic) NSString* phone; /* Phone number of the user [optional]*/
@property(nonatomic) NSString* phone;
@property(nonatomic) NSNumber* userStatus; /* User Status [optional]*/
- (id) _id: (NSNumber*) _id
username: (NSString*) username
firstName: (NSString*) firstName
username: (NSString*) username
lastName: (NSString*) lastName
email: (NSString*) email
password: (NSString*) password

View File

@@ -4,8 +4,8 @@
@implementation SWGUser
-(id)_id: (NSNumber*) _id
username: (NSString*) username
firstName: (NSString*) firstName
username: (NSString*) username
lastName: (NSString*) lastName
email: (NSString*) email
password: (NSString*) password
@@ -13,8 +13,8 @@
userStatus: (NSNumber*) userStatus
{
__id = _id;
_username = username;
_firstName = firstName;
_username = username;
_lastName = lastName;
_email = email;
_password = password;
@@ -28,8 +28,8 @@
self = [super init];
if(self) {
__id = dict[@"id"];
_username = dict[@"username"];
_firstName = dict[@"firstName"];
_username = dict[@"username"];
_lastName = dict[@"lastName"];
_email = dict[@"email"];
_password = dict[@"password"];
@@ -44,8 +44,8 @@
-(NSDictionary*) asDictionary {
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
if(__id != nil) dict[@"id"] = __id ;
if(_username != nil) dict[@"username"] = _username ;
if(_firstName != nil) dict[@"firstName"] = _firstName ;
if(_username != nil) dict[@"username"] = _username ;
if(_lastName != nil) dict[@"lastName"] = _lastName ;
if(_email != nil) dict[@"email"] = _email ;
if(_password != nil) dict[@"password"] = _password ;

View File

@@ -2,6 +2,7 @@
#import "SWGUser.h"
@interface SWGUserApi: NSObject
-(void) addHeader:(NSString*)value forKey:(NSString*)key;
@@ -9,33 +10,6 @@
+(SWGUserApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key;
+(void) setBasePath:(NSString*)basePath;
+(NSString*) getBasePath;
/**
Create user
This can only be done by the logged in user.
@param body Created user object
*/
-(NSNumber*) createUserWithCompletionBlock :(SWGUser*) body
completionHandler: (void (^)(NSError* error))completionBlock;
/**
Creates list of users with given input array
@param body List of user object
*/
-(NSNumber*) createUsersWithArrayInputWithCompletionBlock :(NSArray*) body
completionHandler: (void (^)(NSError* error))completionBlock;
/**
Creates list of users with given list input
@param body List of user object
*/
-(NSNumber*) createUsersWithListInputWithCompletionBlock :(NSArray*) body
completionHandler: (void (^)(NSError* error))completionBlock;
/**
Updated user
@@ -83,4 +57,31 @@
*/
-(NSNumber*) logoutUserWithCompletionBlock :(void (^)(NSError* error))completionBlock;
/**
Create user
This can only be done by the logged in user.
@param body Created user object
*/
-(NSNumber*) createUserWithCompletionBlock :(SWGUser*) body
completionHandler: (void (^)(NSError* error))completionBlock;
/**
Creates list of users with given input array
@param body List of user object
*/
-(NSNumber*) createUsersWithArrayInputWithCompletionBlock :(NSArray*) body
completionHandler: (void (^)(NSError* error))completionBlock;
/**
Creates list of users with given list input
@param body List of user object
*/
-(NSNumber*) createUsersWithListInputWithCompletionBlock :(NSArray*) body
completionHandler: (void (^)(NSError* error))completionBlock;
@end

View File

@@ -5,6 +5,7 @@
@implementation SWGUserApi
static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
@@ -50,219 +51,6 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
}
-(NSNumber*) createUserWithCompletionBlock:(SWGUser*) body
completionHandler: (void (^)(NSError* error))completionBlock{
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user", basePath];
// remove format in URL if needed
if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
NSString* requestContentType = @"application/json";
NSString* responseContentType = @"application/json";
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
id bodyDictionary = nil;
if(body != nil && [body isKindOfClass:[NSArray class]]){
NSMutableArray * objs = [[NSMutableArray alloc] init];
for (id dict in (NSArray*)body) {
if([dict respondsToSelector:@selector(asDictionary)]) {
[objs addObject:[(SWGObject*)dict asDictionary]];
}
else{
[objs addObject:dict];
}
}
bodyDictionary = objs;
}
else if([body respondsToSelector:@selector(asDictionary)]) {
bodyDictionary = [(SWGObject*)body asDictionary];
}
else if([body isKindOfClass:[NSString class]]) {
// convert it to a dictionary
NSError * error;
NSString * str = (NSString*)body;
NSDictionary *JSON =
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
options:NSJSONReadingMutableContainers
error:&error];
bodyDictionary = JSON;
}
else if([body isKindOfClass: [SWGFile class]]) {
requestContentType = @"form-data";
bodyDictionary = body;
}
else{
NSLog(@"don't know what to do with %@", body);
}
if(body == nil) {
// error
}
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
return [client stringWithCompletionBlock:requestUrl
method:@"POST"
queryParams:queryParams
body:bodyDictionary
headerParams:headerParams
requestContentType: requestContentType
responseContentType: responseContentType
completionBlock:^(NSString *data, NSError *error) {
if (error) {
completionBlock(error);
return;
}
completionBlock(nil);
}];
}
-(NSNumber*) createUsersWithArrayInputWithCompletionBlock:(NSArray*) body
completionHandler: (void (^)(NSError* error))completionBlock{
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/createWithArray", basePath];
// remove format in URL if needed
if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
NSString* requestContentType = @"application/json";
NSString* responseContentType = @"application/json";
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
id bodyDictionary = nil;
if(body != nil && [body isKindOfClass:[NSArray class]]){
NSMutableArray * objs = [[NSMutableArray alloc] init];
for (id dict in (NSArray*)body) {
if([dict respondsToSelector:@selector(asDictionary)]) {
[objs addObject:[(SWGObject*)dict asDictionary]];
}
else{
[objs addObject:dict];
}
}
bodyDictionary = objs;
}
else if([body respondsToSelector:@selector(asDictionary)]) {
bodyDictionary = [(SWGObject*)body asDictionary];
}
else if([body isKindOfClass:[NSString class]]) {
// convert it to a dictionary
NSError * error;
NSString * str = (NSString*)body;
NSDictionary *JSON =
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
options:NSJSONReadingMutableContainers
error:&error];
bodyDictionary = JSON;
}
else if([body isKindOfClass: [SWGFile class]]) {
requestContentType = @"form-data";
bodyDictionary = body;
}
else{
NSLog(@"don't know what to do with %@", body);
}
if(body == nil) {
// error
}
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
return [client stringWithCompletionBlock:requestUrl
method:@"POST"
queryParams:queryParams
body:bodyDictionary
headerParams:headerParams
requestContentType: requestContentType
responseContentType: responseContentType
completionBlock:^(NSString *data, NSError *error) {
if (error) {
completionBlock(error);
return;
}
completionBlock(nil);
}];
}
-(NSNumber*) createUsersWithListInputWithCompletionBlock:(NSArray*) body
completionHandler: (void (^)(NSError* error))completionBlock{
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/createWithList", basePath];
// remove format in URL if needed
if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
NSString* requestContentType = @"application/json";
NSString* responseContentType = @"application/json";
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
id bodyDictionary = nil;
if(body != nil && [body isKindOfClass:[NSArray class]]){
NSMutableArray * objs = [[NSMutableArray alloc] init];
for (id dict in (NSArray*)body) {
if([dict respondsToSelector:@selector(asDictionary)]) {
[objs addObject:[(SWGObject*)dict asDictionary]];
}
else{
[objs addObject:dict];
}
}
bodyDictionary = objs;
}
else if([body respondsToSelector:@selector(asDictionary)]) {
bodyDictionary = [(SWGObject*)body asDictionary];
}
else if([body isKindOfClass:[NSString class]]) {
// convert it to a dictionary
NSError * error;
NSString * str = (NSString*)body;
NSDictionary *JSON =
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
options:NSJSONReadingMutableContainers
error:&error];
bodyDictionary = JSON;
}
else if([body isKindOfClass: [SWGFile class]]) {
requestContentType = @"form-data";
bodyDictionary = body;
}
else{
NSLog(@"don't know what to do with %@", body);
}
if(body == nil) {
// error
}
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
return [client stringWithCompletionBlock:requestUrl
method:@"POST"
queryParams:queryParams
body:bodyDictionary
headerParams:headerParams
requestContentType: requestContentType
responseContentType: responseContentType
completionBlock:^(NSString *data, NSError *error) {
if (error) {
completionBlock(error);
return;
}
completionBlock(nil);
}];
}
-(NSNumber*) updateUserWithCompletionBlock:(NSString*) username
body:(SWGUser*) body
completionHandler: (void (^)(NSError* error))completionBlock{
@@ -500,5 +288,219 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
}
-(NSNumber*) createUserWithCompletionBlock:(SWGUser*) body
completionHandler: (void (^)(NSError* error))completionBlock{
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user", basePath];
// remove format in URL if needed
if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
NSString* requestContentType = @"application/json";
NSString* responseContentType = @"application/json";
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
id bodyDictionary = nil;
if(body != nil && [body isKindOfClass:[NSArray class]]){
NSMutableArray * objs = [[NSMutableArray alloc] init];
for (id dict in (NSArray*)body) {
if([dict respondsToSelector:@selector(asDictionary)]) {
[objs addObject:[(SWGObject*)dict asDictionary]];
}
else{
[objs addObject:dict];
}
}
bodyDictionary = objs;
}
else if([body respondsToSelector:@selector(asDictionary)]) {
bodyDictionary = [(SWGObject*)body asDictionary];
}
else if([body isKindOfClass:[NSString class]]) {
// convert it to a dictionary
NSError * error;
NSString * str = (NSString*)body;
NSDictionary *JSON =
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
options:NSJSONReadingMutableContainers
error:&error];
bodyDictionary = JSON;
}
else if([body isKindOfClass: [SWGFile class]]) {
requestContentType = @"form-data";
bodyDictionary = body;
}
else{
NSLog(@"don't know what to do with %@", body);
}
if(body == nil) {
// error
}
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
return [client stringWithCompletionBlock:requestUrl
method:@"POST"
queryParams:queryParams
body:bodyDictionary
headerParams:headerParams
requestContentType: requestContentType
responseContentType: responseContentType
completionBlock:^(NSString *data, NSError *error) {
if (error) {
completionBlock(error);
return;
}
completionBlock(nil);
}];
}
-(NSNumber*) createUsersWithArrayInputWithCompletionBlock:(NSArray*) body
completionHandler: (void (^)(NSError* error))completionBlock{
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/createWithArray", basePath];
// remove format in URL if needed
if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
NSString* requestContentType = @"application/json";
NSString* responseContentType = @"application/json";
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
id bodyDictionary = nil;
if(body != nil && [body isKindOfClass:[NSArray class]]){
NSMutableArray * objs = [[NSMutableArray alloc] init];
for (id dict in (NSArray*)body) {
if([dict respondsToSelector:@selector(asDictionary)]) {
[objs addObject:[(SWGObject*)dict asDictionary]];
}
else{
[objs addObject:dict];
}
}
bodyDictionary = objs;
}
else if([body respondsToSelector:@selector(asDictionary)]) {
bodyDictionary = [(SWGObject*)body asDictionary];
}
else if([body isKindOfClass:[NSString class]]) {
// convert it to a dictionary
NSError * error;
NSString * str = (NSString*)body;
NSDictionary *JSON =
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
options:NSJSONReadingMutableContainers
error:&error];
bodyDictionary = JSON;
}
else if([body isKindOfClass: [SWGFile class]]) {
requestContentType = @"form-data";
bodyDictionary = body;
}
else{
NSLog(@"don't know what to do with %@", body);
}
if(body == nil) {
// error
}
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
return [client stringWithCompletionBlock:requestUrl
method:@"POST"
queryParams:queryParams
body:bodyDictionary
headerParams:headerParams
requestContentType: requestContentType
responseContentType: responseContentType
completionBlock:^(NSString *data, NSError *error) {
if (error) {
completionBlock(error);
return;
}
completionBlock(nil);
}];
}
-(NSNumber*) createUsersWithListInputWithCompletionBlock:(NSArray*) body
completionHandler: (void (^)(NSError* error))completionBlock{
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/createWithList", basePath];
// remove format in URL if needed
if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
NSString* requestContentType = @"application/json";
NSString* responseContentType = @"application/json";
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
id bodyDictionary = nil;
if(body != nil && [body isKindOfClass:[NSArray class]]){
NSMutableArray * objs = [[NSMutableArray alloc] init];
for (id dict in (NSArray*)body) {
if([dict respondsToSelector:@selector(asDictionary)]) {
[objs addObject:[(SWGObject*)dict asDictionary]];
}
else{
[objs addObject:dict];
}
}
bodyDictionary = objs;
}
else if([body respondsToSelector:@selector(asDictionary)]) {
bodyDictionary = [(SWGObject*)body asDictionary];
}
else if([body isKindOfClass:[NSString class]]) {
// convert it to a dictionary
NSError * error;
NSString * str = (NSString*)body;
NSDictionary *JSON =
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
options:NSJSONReadingMutableContainers
error:&error];
bodyDictionary = JSON;
}
else if([body isKindOfClass: [SWGFile class]]) {
requestContentType = @"form-data";
bodyDictionary = body;
}
else{
NSLog(@"don't know what to do with %@", body);
}
if(body == nil) {
// error
}
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
return [client stringWithCompletionBlock:requestUrl
method:@"POST"
queryParams:queryParams
body:bodyDictionary
headerParams:headerParams
requestContentType: requestContentType
responseContentType: responseContentType
completionBlock:^(NSString *data, NSError *error) {
if (error) {
completionBlock(error);
return;
}
completionBlock(nil);
}];
}
@end

View File

@@ -1,5 +1,5 @@
/**
* Copyright 2012 Wordnik, Inc.
* Copyright 2014 Wordnik, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -29,6 +29,7 @@ class PetApi {
* getPetById
* Find pet by ID
* petId, int: ID of pet that needs to be fetched (required)
* @return Pet
*/
@@ -40,6 +41,8 @@ class PetApi {
$method = "GET";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($petId != null) {
$resourcePath = str_replace("{" . "petId" . "}",
@@ -67,6 +70,7 @@ class PetApi {
* deletePet
* Deletes a pet
* petId, string: Pet id to delete (required)
* @return
*/
@@ -78,6 +82,8 @@ class PetApi {
$method = "DELETE";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($petId != null) {
$resourcePath = str_replace("{" . "petId" . "}",
@@ -97,7 +103,9 @@ class PetApi {
* partialUpdate
* partial updates to a pet
* petId, string: ID of pet that needs to be fetched (required)
* body, Pet: Pet object that needs to be added to the store (required)
* @return Array[Pet]
*/
@@ -109,6 +117,8 @@ class PetApi {
$method = "PATCH";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json,application/xml';
$headerParams['Content-Type'] = 'application/json,application/xml';
if($petId != null) {
$resourcePath = str_replace("{" . "petId" . "}",
@@ -136,8 +146,11 @@ class PetApi {
* updatePetWithForm
* Updates a pet in the store with form data
* petId, string: ID of pet that needs to be updated (required)
* name, string: Updated name of the pet (optional)
* status, string: Updated status of the pet (optional)
* @return
*/
@@ -149,6 +162,8 @@ class PetApi {
$method = "POST";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
if($petId != null) {
$resourcePath = str_replace("{" . "petId" . "}",
@@ -168,7 +183,9 @@ class PetApi {
* uploadFile
* uploads an image
* additionalMetadata, string: Additional data to pass to server (optional)
* body, File: file to upload (optional)
* @return
*/
@@ -180,6 +197,8 @@ class PetApi {
$method = "POST";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'multipart/form-data';
//make the API Call
if (! isset($body)) {
@@ -195,6 +214,7 @@ class PetApi {
* addPet
* Add a new pet to the store
* body, Pet: Pet object that needs to be added to the store (required)
* @return
*/
@@ -206,6 +226,8 @@ class PetApi {
$method = "POST";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json,application/xml';
//make the API Call
if (! isset($body)) {
@@ -221,6 +243,7 @@ class PetApi {
* updatePet
* Update an existing pet
* body, Pet: Pet object that needs to be updated in the store (required)
* @return
*/
@@ -232,6 +255,8 @@ class PetApi {
$method = "PUT";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
//make the API Call
if (! isset($body)) {
@@ -247,6 +272,7 @@ class PetApi {
* findPetsByStatus
* Finds Pets by status
* status, string: Status values that need to be considered for filter (required)
* @return Array[Pet]
*/
@@ -258,6 +284,8 @@ class PetApi {
$method = "GET";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($status != null) {
$queryParams['status'] = $this->apiClient->toQueryValue($status);
@@ -284,6 +312,7 @@ class PetApi {
* findPetsByTags
* Finds Pets by tags
* tags, string: Tags to filter by (required)
* @return Array[Pet]
*/
@@ -295,6 +324,8 @@ class PetApi {
$method = "GET";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($tags != null) {
$queryParams['tags'] = $this->apiClient->toQueryValue($tags);
@@ -318,5 +349,6 @@ class PetApi {
}
}

View File

@@ -29,6 +29,7 @@ class StoreApi {
* getOrderById
* Find purchase order by ID
* orderId, string: ID of pet that needs to be fetched (required)
* @return Order
*/
@@ -40,6 +41,8 @@ class StoreApi {
$method = "GET";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($orderId != null) {
$resourcePath = str_replace("{" . "orderId" . "}",
@@ -67,6 +70,7 @@ class StoreApi {
* deleteOrder
* Delete purchase order by ID
* orderId, string: ID of the order that needs to be deleted (required)
* @return
*/
@@ -78,6 +82,8 @@ class StoreApi {
$method = "DELETE";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($orderId != null) {
$resourcePath = str_replace("{" . "orderId" . "}",
@@ -97,6 +103,7 @@ class StoreApi {
* placeOrder
* Place an order for a pet
* body, Order: order placed for purchasing the pet (required)
* @return
*/
@@ -108,6 +115,8 @@ class StoreApi {
$method = "POST";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
//make the API Call
if (! isset($body)) {
@@ -120,5 +129,6 @@ class StoreApi {
}
}

View File

@@ -44,13 +44,12 @@ class APIClient {
* @param array $queryParams parameters to be place in query URL
* @param array $postData parameters to be placed in POST body
* @param array $headerParams parameters to be place in request header
* @return unknown
* @return mixed
*/
public function callAPI($resourcePath, $method, $queryParams, $postData,
$headerParams) {
$headers = array();
$headers[] = "Content-type: application/json";
# Allow API key from $headerParams to override default
$added_api_key = False;
@@ -67,7 +66,7 @@ class APIClient {
}
if (is_object($postData) or is_array($postData)) {
$postData = json_encode(self::sanitizeForSerialization($postData));
$postData = json_encode($this->sanitizeForSerialization($postData));
}
$url = $this->apiServer . $resourcePath;
@@ -118,21 +117,35 @@ class APIClient {
$response_info['http_code']);
}
return $data;
}
/**
* Build a JSON POST object
*/
public static function sanitizeForSerialization($postData) {
foreach ($postData as $key => $value) {
if (is_a($value, "DateTime")) {
$postData->{$key} = $value->format(DateTime::ISO8601);
}
}
return $postData;
}
protected function sanitizeForSerialization($data)
{
if (is_scalar($data) || null === $data) {
$sanitized = $data;
} else if ($data instanceof \DateTime) {
$sanitized = $data->format(\DateTime::ISO8601);
} else if (is_array($data)) {
foreach ($data as $property => $value) {
$data[$property] = $this->sanitizeForSerialization($value);
}
$sanitized = $data;
} else if (is_object($data)) {
$values = array();
foreach (array_keys($data::$swaggerTypes) as $property) {
$values[$property] = $this->sanitizeForSerialization($data->$property);
}
$sanitized = $values;
} else {
$sanitized = (string)$data;
}
return $sanitized;
}
/**
* Take value and turn it into a string suitable for inclusion in
@@ -170,73 +183,43 @@ class APIClient {
return $value;
}
/**
* Deserialize a JSON string into an object
*
* @param object $object object or primitive to be deserialized
* @param string $class class name is passed as a string
* @return object an instance of $class
*/
public static function deserialize($object, $class) {
/**
* Deserialize a JSON string into an object
*
* @param object $object object or primitive to be deserialized
* @param string $class class name is passed as a string
* @return object an instance of $class
*/
if (gettype($object) == "NULL") {
return $object;
}
if (substr($class, 0, 6) == 'array[') {
$sub_class = substr($class, 6, -1);
$sub_objects = array();
foreach ($object as $sub_object) {
$sub_objects[] = self::deserialize($sub_object,
$sub_class);
public static function deserialize($data, $class)
{
if (null === $data) {
$deserialized = null;
} else if (substr($class, 0, 6) == 'array[') {
$subClass = substr($class, 6, -1);
$values = array();
foreach ($data as $value) {
$values[] = self::deserialize($value, $subClass);
}
return $sub_objects;
$deserialized = $values;
} elseif ($class == 'DateTime') {
return new DateTime($object);
} elseif (in_array($class, array('string', 'int', 'float', 'bool'))) {
settype($object, $class);
return $object;
} else {
$instance = new $class(); // this instantiates class named $class
$classVars = get_class_vars($class);
}
$deserialized = new \DateTime($data);
} elseif (in_array($class, array('string', 'int', 'float', 'bool'))) {
settype($data, $class);
$deserialized = $data;
} else {
$instance = new $class();
foreach ($instance::$swaggerTypes as $property => $type) {
if (isset($data->$property)) {
$instance->$property = self::deserialize($data->$property, $type);
}
}
$deserialized = $instance;
}
foreach ($object as $property => $value) {
return $deserialized;
}
// Need to handle possible pluralization differences
$true_property = $property;
if (! property_exists($class, $true_property)) {
if (substr($property, -1) == 's') {
$true_property = substr($property, 0, -1);
}
}
if (array_key_exists($true_property, $classVars['swaggerTypes'])) {
$type = $classVars['swaggerTypes'][$true_property];
} else {
$type = 'string';
}
if (in_array($type, array('string', 'int', 'float', 'bool'))) {
settype($value, $type);
$instance->{$true_property} = $value;
} elseif (preg_match("/array<(.*)>/", $type, $matches)) {
$sub_class = $matches[1];
$instance->{$true_property} = array();
foreach ($value as $sub_property => $sub_value) {
$instance->{$true_property}[] = self::deserialize($sub_value,
$sub_class);
}
} else {
$instance->{$true_property} = self::deserialize($value, $type);
}
}
return $instance;
}
}
?>

View File

@@ -25,89 +25,13 @@ class UserApi {
$this->apiClient = $apiClient;
}
/**
* createUser
* Create user
* body, User: Created user object (required)
* @return
*/
public function createUser($body) {
//parse inputs
$resourcePath = "/user";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$queryParams = array();
$headerParams = array();
//make the API Call
if (! isset($body)) {
$body = null;
}
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
}
/**
* createUsersWithArrayInput
* Creates list of users with given input array
* body, array[User]: List of user object (required)
* @return
*/
public function createUsersWithArrayInput($body) {
//parse inputs
$resourcePath = "/user/createWithArray";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$queryParams = array();
$headerParams = array();
//make the API Call
if (! isset($body)) {
$body = null;
}
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
}
/**
* createUsersWithListInput
* Creates list of users with given list input
* body, array[User]: List of user object (required)
* @return
*/
public function createUsersWithListInput($body) {
//parse inputs
$resourcePath = "/user/createWithList";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$queryParams = array();
$headerParams = array();
//make the API Call
if (! isset($body)) {
$body = null;
}
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
}
/**
* updateUser
* Updated user
* username, string: name that need to be deleted (required)
* body, User: Updated user object (required)
* @return
*/
@@ -119,6 +43,8 @@ class UserApi {
$method = "PUT";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($username != null) {
$resourcePath = str_replace("{" . "username" . "}",
@@ -138,6 +64,7 @@ class UserApi {
* deleteUser
* Delete user
* username, string: The name that needs to be deleted (required)
* @return
*/
@@ -149,6 +76,8 @@ class UserApi {
$method = "DELETE";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($username != null) {
$resourcePath = str_replace("{" . "username" . "}",
@@ -168,6 +97,7 @@ class UserApi {
* getUserByName
* Get user by user name
* username, string: The name that needs to be fetched. Use user1 for testing. (required)
* @return User
*/
@@ -179,6 +109,8 @@ class UserApi {
$method = "GET";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($username != null) {
$resourcePath = str_replace("{" . "username" . "}",
@@ -206,7 +138,9 @@ class UserApi {
* loginUser
* Logs user into the system
* username, string: The user name for login (required)
* password, string: The password for login in clear text (required)
* @return string
*/
@@ -218,6 +152,8 @@ class UserApi {
$method = "GET";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
if($username != null) {
$queryParams['username'] = $this->apiClient->toQueryValue($username);
@@ -257,6 +193,95 @@ class UserApi {
$method = "GET";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
//make the API Call
if (! isset($body)) {
$body = null;
}
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
}
/**
* createUser
* Create user
* body, User: Created user object (required)
* @return
*/
public function createUser($body) {
//parse inputs
$resourcePath = "/user";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
//make the API Call
if (! isset($body)) {
$body = null;
}
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
}
/**
* createUsersWithArrayInput
* Creates list of users with given input array
* body, array[User]: List of user object (required)
* @return
*/
public function createUsersWithArrayInput($body) {
//parse inputs
$resourcePath = "/user/createWithArray";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
//make the API Call
if (! isset($body)) {
$body = null;
}
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
}
/**
* createUsersWithListInput
* Creates list of users with given list input
* body, array[User]: List of user object (required)
* @return
*/
public function createUsersWithListInput($body) {
//parse inputs
$resourcePath = "/user/createWithList";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$queryParams = array();
$headerParams = array();
$headerParams['Accept'] = 'application/json';
$headerParams['Content-Type'] = 'application/json';
//make the API Call
if (! isset($body)) {
@@ -269,5 +294,6 @@ class UserApi {
}
}

View File

@@ -29,13 +29,7 @@ class Category {
);
/**
* Category unique identifier
*/
public $id; // int
/**
* Name of the category
*/
public $name; // string
}

View File

@@ -32,25 +32,13 @@ class Order {
);
/**
* Unique identifier for the order
*/
public $id; // int
/**
* ID of pet being ordered
*/
public $petId; // int
/**
* Number of pets ordered
*/
public $quantity; // int
/**
* Status of the order
* Order Status
*/
public $status; // string
/**
* Date shipped, only if it has been
*/
public $shipDate; // DateTime
}

View File

@@ -34,24 +34,12 @@ class Pet {
);
/**
* Unique identifier for the Pet
* unique identifier for the pet
*/
public $id; // int
/**
* Category the pet is in
*/
public $category; // Category
/**
* Friendly name of the pet
*/
public $name; // string
/**
* Image URLs
*/
public $photoUrls; // array[string]
/**
* Tags assigned to this pet
*/
public $tags; // array[Tag]
/**
* pet status in the store

View File

@@ -29,13 +29,7 @@ class Tag {
);
/**
* Unique identifier for the tag
*/
public $id; // int
/**
* Friendly name for the tag
*/
public $name; // string
}

View File

@@ -25,8 +25,8 @@ class User {
static $swaggerTypes = array(
'id' => 'int',
'username' => 'string',
'firstName' => 'string',
'username' => 'string',
'lastName' => 'string',
'email' => 'string',
'password' => 'string',
@@ -35,33 +35,12 @@ class User {
);
/**
* Unique identifier for the user
*/
public $id; // int
/**
* Unique username
*/
public $username; // string
/**
* First name of the user
*/
public $firstName; // string
/**
* Last name of the user
*/
public $username; // string
public $lastName; // string
/**
* Email address of the user
*/
public $email; // string
/**
* Password name of the user
*/
public $password; // string
/**
* Phone number of the user
*/
public $phone; // string
/**
* User Status

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python
"""
WordAPI.py
Copyright 2012 Wordnik, Inc.
Copyright 2014 Wordnik, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -29,12 +29,15 @@ class PetApi(object):
self.apiClient = apiClient
def getPetById(self, petId, **kwargs):
"""Find pet by ID
Args:
petId, long: ID of pet that needs to be fetched (required)
Returns: Pet
"""
@@ -69,13 +72,17 @@ class PetApi(object):
responseObject = self.apiClient.deserialize(response, 'Pet')
return responseObject
def deletePet(self, petId, **kwargs):
"""Deletes a pet
Args:
petId, str: Pet id to delete (required)
Returns:
"""
@@ -105,14 +112,19 @@ class PetApi(object):
postData, headerParams)
def partialUpdate(self, petId, body, **kwargs):
"""partial updates to a pet
Args:
petId, str: ID of pet that needs to be fetched (required)
body, Pet: Pet object that needs to be added to the store (required)
Returns: Array[Pet]
"""
@@ -147,15 +159,21 @@ class PetApi(object):
responseObject = self.apiClient.deserialize(response, 'Array[Pet]')
return responseObject
def updatePetWithForm(self, petId, **kwargs):
"""Updates a pet in the store with form data
Args:
petId, str: ID of pet that needs to be updated (required)
name, str: Updated name of the pet (optional)
status, str: Updated status of the pet (optional)
Returns:
"""
@@ -185,14 +203,19 @@ class PetApi(object):
postData, headerParams)
def uploadFile(self, **kwargs):
"""uploads an image
Args:
additionalMetadata, str: Additional data to pass to server (optional)
body, File: file to upload (optional)
Returns:
"""
@@ -218,13 +241,17 @@ class PetApi(object):
postData, headerParams)
def addPet(self, body, **kwargs):
"""Add a new pet to the store
Args:
body, Pet: Pet object that needs to be added to the store (required)
Returns:
"""
@@ -250,13 +277,17 @@ class PetApi(object):
postData, headerParams)
def updatePet(self, body, **kwargs):
"""Update an existing pet
Args:
body, Pet: Pet object that needs to be updated in the store (required)
Returns:
"""
@@ -282,13 +313,17 @@ class PetApi(object):
postData, headerParams)
def findPetsByStatus(self, status= None, **kwargs):
"""Finds Pets by status
Args:
status, str: Status values that need to be considered for filter (required)
Returns: Array[Pet]
"""
@@ -321,13 +356,17 @@ class PetApi(object):
responseObject = self.apiClient.deserialize(response, 'Array[Pet]')
return responseObject
def findPetsByTags(self, tags, **kwargs):
"""Finds Pets by tags
Args:
tags, str: Tags to filter by (required)
Returns: Array[Pet]
"""
@@ -360,7 +399,11 @@ class PetApi(object):
responseObject = self.apiClient.deserialize(response, 'Array[Pet]')
return responseObject

View File

@@ -1,5 +1,5 @@
/**
* Copyright 2012 Wordnik, Inc.
* Copyright 2014 Wordnik, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python
"""
WordAPI.py
Copyright 2012 Wordnik, Inc.
Copyright 2014 Wordnik, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -29,12 +29,15 @@ class StoreApi(object):
self.apiClient = apiClient
def getOrderById(self, orderId, **kwargs):
"""Find purchase order by ID
Args:
orderId, str: ID of pet that needs to be fetched (required)
Returns: Order
"""
@@ -69,13 +72,17 @@ class StoreApi(object):
responseObject = self.apiClient.deserialize(response, 'Order')
return responseObject
def deleteOrder(self, orderId, **kwargs):
"""Delete purchase order by ID
Args:
orderId, str: ID of the order that needs to be deleted (required)
Returns:
"""
@@ -105,13 +112,17 @@ class StoreApi(object):
postData, headerParams)
def placeOrder(self, body, **kwargs):
"""Place an order for a pet
Args:
body, Order: order placed for purchasing the pet (required)
Returns:
"""
@@ -137,7 +148,11 @@ class StoreApi(object):
postData, headerParams)

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python
"""
WordAPI.py
Copyright 2012 Wordnik, Inc.
Copyright 2014 Wordnik, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -29,109 +29,17 @@ class UserApi(object):
self.apiClient = apiClient
def createUser(self, body, **kwargs):
"""Create user
Args:
body, User: Created user object (required)
Returns:
"""
allParams = ['body']
params = locals()
for (key, val) in params['kwargs'].iteritems():
if key not in allParams:
raise TypeError("Got an unexpected keyword argument '%s' to method createUser" % key)
params[key] = val
del params['kwargs']
resourcePath = '/user'
resourcePath = resourcePath.replace('{format}', 'json')
method = 'POST'
queryParams = {}
headerParams = {}
postData = (params['body'] if 'body' in params else None)
response = self.apiClient.callAPI(resourcePath, method, queryParams,
postData, headerParams)
def createUsersWithArrayInput(self, body, **kwargs):
"""Creates list of users with given input array
Args:
body, list[User]: List of user object (required)
Returns:
"""
allParams = ['body']
params = locals()
for (key, val) in params['kwargs'].iteritems():
if key not in allParams:
raise TypeError("Got an unexpected keyword argument '%s' to method createUsersWithArrayInput" % key)
params[key] = val
del params['kwargs']
resourcePath = '/user/createWithArray'
resourcePath = resourcePath.replace('{format}', 'json')
method = 'POST'
queryParams = {}
headerParams = {}
postData = (params['body'] if 'body' in params else None)
response = self.apiClient.callAPI(resourcePath, method, queryParams,
postData, headerParams)
def createUsersWithListInput(self, body, **kwargs):
"""Creates list of users with given list input
Args:
body, list[User]: List of user object (required)
Returns:
"""
allParams = ['body']
params = locals()
for (key, val) in params['kwargs'].iteritems():
if key not in allParams:
raise TypeError("Got an unexpected keyword argument '%s' to method createUsersWithListInput" % key)
params[key] = val
del params['kwargs']
resourcePath = '/user/createWithList'
resourcePath = resourcePath.replace('{format}', 'json')
method = 'POST'
queryParams = {}
headerParams = {}
postData = (params['body'] if 'body' in params else None)
response = self.apiClient.callAPI(resourcePath, method, queryParams,
postData, headerParams)
def updateUser(self, username, body, **kwargs):
"""Updated user
Args:
username, str: name that need to be deleted (required)
body, User: Updated user object (required)
Returns:
"""
@@ -161,13 +69,17 @@ class UserApi(object):
postData, headerParams)
def deleteUser(self, username, **kwargs):
"""Delete user
Args:
username, str: The name that needs to be deleted (required)
Returns:
"""
@@ -197,13 +109,17 @@ class UserApi(object):
postData, headerParams)
def getUserByName(self, username, **kwargs):
"""Get user by user name
Args:
username, str: The name that needs to be fetched. Use user1 for testing. (required)
Returns: User
"""
@@ -238,14 +154,19 @@ class UserApi(object):
responseObject = self.apiClient.deserialize(response, 'User')
return responseObject
def loginUser(self, username, password, **kwargs):
"""Logs user into the system
Args:
username, str: The user name for login (required)
password, str: The password for login in clear text (required)
Returns: str
"""
@@ -280,12 +201,15 @@ class UserApi(object):
responseObject = self.apiClient.deserialize(response, 'str')
return responseObject
def logoutUser(self, **kwargs):
"""Logs out current logged in user session
Args:
Returns:
"""
@@ -311,7 +235,119 @@ class UserApi(object):
postData, headerParams)
def createUser(self, body, **kwargs):
"""Create user
Args:
body, User: Created user object (required)
Returns:
"""
allParams = ['body']
params = locals()
for (key, val) in params['kwargs'].iteritems():
if key not in allParams:
raise TypeError("Got an unexpected keyword argument '%s' to method createUser" % key)
params[key] = val
del params['kwargs']
resourcePath = '/user'
resourcePath = resourcePath.replace('{format}', 'json')
method = 'POST'
queryParams = {}
headerParams = {}
postData = (params['body'] if 'body' in params else None)
response = self.apiClient.callAPI(resourcePath, method, queryParams,
postData, headerParams)
def createUsersWithArrayInput(self, body, **kwargs):
"""Creates list of users with given input array
Args:
body, list[User]: List of user object (required)
Returns:
"""
allParams = ['body']
params = locals()
for (key, val) in params['kwargs'].iteritems():
if key not in allParams:
raise TypeError("Got an unexpected keyword argument '%s' to method createUsersWithArrayInput" % key)
params[key] = val
del params['kwargs']
resourcePath = '/user/createWithArray'
resourcePath = resourcePath.replace('{format}', 'json')
method = 'POST'
queryParams = {}
headerParams = {}
postData = (params['body'] if 'body' in params else None)
response = self.apiClient.callAPI(resourcePath, method, queryParams,
postData, headerParams)
def createUsersWithListInput(self, body, **kwargs):
"""Creates list of users with given list input
Args:
body, list[User]: List of user object (required)
Returns:
"""
allParams = ['body']
params = locals()
for (key, val) in params['kwargs'].iteritems():
if key not in allParams:
raise TypeError("Got an unexpected keyword argument '%s' to method createUsersWithListInput" % key)
params[key] = val
del params['kwargs']
resourcePath = '/user/createWithList'
resourcePath = resourcePath.replace('{format}', 'json')
method = 'POST'
queryParams = {}
headerParams = {}
postData = (params['body'] if 'body' in params else None)
response = self.apiClient.callAPI(resourcePath, method, queryParams,
postData, headerParams)

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python
"""
Copyright 2012 Wordnik, Inc.
Copyright 2014 Wordnik, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -27,8 +27,6 @@ class Category:
}
#Category unique identifier
self.id = None # long
#Name of the category
self.name = None # str

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python
"""
Copyright 2012 Wordnik, Inc.
Copyright 2014 Wordnik, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -30,14 +30,10 @@ class Order:
}
#Unique identifier for the order
self.id = None # long
#ID of pet being ordered
self.petId = None # long
#Number of pets ordered
self.quantity = None # int
#Status of the order
#Order Status
self.status = None # str
#Date shipped, only if it has been
self.shipDate = None # datetime

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python
"""
Copyright 2012 Wordnik, Inc.
Copyright 2014 Wordnik, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -31,15 +31,11 @@ class Pet:
}
#Unique identifier for the Pet
#unique identifier for the pet
self.id = None # long
#Category the pet is in
self.category = None # Category
#Friendly name of the pet
self.name = None # str
#Image URLs
self.photoUrls = None # list[str]
#Tags assigned to this pet
self.tags = None # list[Tag]
#pet status in the store
self.status = None # str

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python
"""
Copyright 2012 Wordnik, Inc.
Copyright 2014 Wordnik, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -27,8 +27,6 @@ class Tag:
}
#Unique identifier for the tag
self.id = None # long
#Friendly name for the tag
self.name = None # str

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python
"""
Copyright 2012 Wordnik, Inc.
Copyright 2014 Wordnik, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -22,8 +22,8 @@ class User:
def __init__(self):
self.swaggerTypes = {
'id': 'long',
'username': 'str',
'firstName': 'str',
'username': 'str',
'lastName': 'str',
'email': 'str',
'password': 'str',
@@ -33,19 +33,12 @@ class User:
}
#Unique identifier for the user
self.id = None # long
#Unique username
self.username = None # str
#First name of the user
self.firstName = None # str
#Last name of the user
self.username = None # str
self.lastName = None # str
#Email address of the user
self.email = None # str
#Password name of the user
self.password = None # str
#Phone number of the user
self.phone = None # str
#User Status
self.userStatus = None # int

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python
"""
WordAPI.py
Copyright 2012 Wordnik, Inc.
Copyright 2014 Wordnik, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -29,12 +29,15 @@ class PetApi(object):
self.apiClient = apiClient
def getPetById(self, petId, **kwargs):
"""Find pet by ID
Args:
petId, int: ID of pet that needs to be fetched (required)
Returns: Pet
"""
@@ -69,13 +72,17 @@ class PetApi(object):
responseObject = self.apiClient.deserialize(response, 'Pet')
return responseObject
def deletePet(self, petId, **kwargs):
"""Deletes a pet
Args:
petId, str: Pet id to delete (required)
Returns:
"""
@@ -105,14 +112,19 @@ class PetApi(object):
postData, headerParams)
def partialUpdate(self, petId, body, **kwargs):
"""partial updates to a pet
Args:
petId, str: ID of pet that needs to be fetched (required)
body, Pet: Pet object that needs to be added to the store (required)
Returns: Array[Pet]
"""
@@ -147,15 +159,21 @@ class PetApi(object):
responseObject = self.apiClient.deserialize(response, 'Array[Pet]')
return responseObject
def updatePetWithForm(self, petId, **kwargs):
"""Updates a pet in the store with form data
Args:
petId, str: ID of pet that needs to be updated (required)
name, str: Updated name of the pet (optional)
status, str: Updated status of the pet (optional)
Returns:
"""
@@ -185,14 +203,19 @@ class PetApi(object):
postData, headerParams)
def uploadFile(self, **kwargs):
"""uploads an image
Args:
additionalMetadata, str: Additional data to pass to server (optional)
body, File: file to upload (optional)
Returns:
"""
@@ -218,13 +241,17 @@ class PetApi(object):
postData, headerParams)
def addPet(self, body, **kwargs):
"""Add a new pet to the store
Args:
body, Pet: Pet object that needs to be added to the store (required)
Returns:
"""
@@ -250,13 +277,17 @@ class PetApi(object):
postData, headerParams)
def updatePet(self, body, **kwargs):
"""Update an existing pet
Args:
body, Pet: Pet object that needs to be updated in the store (required)
Returns:
"""
@@ -282,13 +313,17 @@ class PetApi(object):
postData, headerParams)
def findPetsByStatus(self, status= None, **kwargs):
"""Finds Pets by status
Args:
status, str: Status values that need to be considered for filter (required)
Returns: Array[Pet]
"""
@@ -321,13 +356,17 @@ class PetApi(object):
responseObject = self.apiClient.deserialize(response, 'Array[Pet]')
return responseObject
def findPetsByTags(self, tags, **kwargs):
"""Finds Pets by tags
Args:
tags, str: Tags to filter by (required)
Returns: Array[Pet]
"""
@@ -360,7 +399,11 @@ class PetApi(object):
responseObject = self.apiClient.deserialize(response, 'Array[Pet]')
return responseObject

View File

@@ -1,5 +1,5 @@
/**
* Copyright 2012 Wordnik, Inc.
* Copyright 2014 Wordnik, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python
"""
WordAPI.py
Copyright 2012 Wordnik, Inc.
Copyright 2014 Wordnik, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -29,12 +29,15 @@ class StoreApi(object):
self.apiClient = apiClient
def getOrderById(self, orderId, **kwargs):
"""Find purchase order by ID
Args:
orderId, str: ID of pet that needs to be fetched (required)
Returns: Order
"""
@@ -69,13 +72,17 @@ class StoreApi(object):
responseObject = self.apiClient.deserialize(response, 'Order')
return responseObject
def deleteOrder(self, orderId, **kwargs):
"""Delete purchase order by ID
Args:
orderId, str: ID of the order that needs to be deleted (required)
Returns:
"""
@@ -105,13 +112,17 @@ class StoreApi(object):
postData, headerParams)
def placeOrder(self, body, **kwargs):
"""Place an order for a pet
Args:
body, Order: order placed for purchasing the pet (required)
Returns:
"""
@@ -137,7 +148,11 @@ class StoreApi(object):
postData, headerParams)

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python
"""
WordAPI.py
Copyright 2012 Wordnik, Inc.
Copyright 2014 Wordnik, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -29,109 +29,17 @@ class UserApi(object):
self.apiClient = apiClient
def createUser(self, body, **kwargs):
"""Create user
Args:
body, User: Created user object (required)
Returns:
"""
allParams = ['body']
params = locals()
for (key, val) in params['kwargs'].items():
if key not in allParams:
raise TypeError("Got an unexpected keyword argument '%s' to method createUser" % key)
params[key] = val
del params['kwargs']
resourcePath = '/user'
resourcePath = resourcePath.replace('{format}', 'json')
method = 'POST'
queryParams = {}
headerParams = {}
postData = (params['body'] if 'body' in params else None)
response = self.apiClient.callAPI(resourcePath, method, queryParams,
postData, headerParams)
def createUsersWithArrayInput(self, body, **kwargs):
"""Creates list of users with given input array
Args:
body, list[User]: List of user object (required)
Returns:
"""
allParams = ['body']
params = locals()
for (key, val) in params['kwargs'].items():
if key not in allParams:
raise TypeError("Got an unexpected keyword argument '%s' to method createUsersWithArrayInput" % key)
params[key] = val
del params['kwargs']
resourcePath = '/user/createWithArray'
resourcePath = resourcePath.replace('{format}', 'json')
method = 'POST'
queryParams = {}
headerParams = {}
postData = (params['body'] if 'body' in params else None)
response = self.apiClient.callAPI(resourcePath, method, queryParams,
postData, headerParams)
def createUsersWithListInput(self, body, **kwargs):
"""Creates list of users with given list input
Args:
body, list[User]: List of user object (required)
Returns:
"""
allParams = ['body']
params = locals()
for (key, val) in params['kwargs'].items():
if key not in allParams:
raise TypeError("Got an unexpected keyword argument '%s' to method createUsersWithListInput" % key)
params[key] = val
del params['kwargs']
resourcePath = '/user/createWithList'
resourcePath = resourcePath.replace('{format}', 'json')
method = 'POST'
queryParams = {}
headerParams = {}
postData = (params['body'] if 'body' in params else None)
response = self.apiClient.callAPI(resourcePath, method, queryParams,
postData, headerParams)
def updateUser(self, username, body, **kwargs):
"""Updated user
Args:
username, str: name that need to be deleted (required)
body, User: Updated user object (required)
Returns:
"""
@@ -161,13 +69,17 @@ class UserApi(object):
postData, headerParams)
def deleteUser(self, username, **kwargs):
"""Delete user
Args:
username, str: The name that needs to be deleted (required)
Returns:
"""
@@ -197,13 +109,17 @@ class UserApi(object):
postData, headerParams)
def getUserByName(self, username, **kwargs):
"""Get user by user name
Args:
username, str: The name that needs to be fetched. Use user1 for testing. (required)
Returns: User
"""
@@ -238,14 +154,19 @@ class UserApi(object):
responseObject = self.apiClient.deserialize(response, 'User')
return responseObject
def loginUser(self, username, password, **kwargs):
"""Logs user into the system
Args:
username, str: The user name for login (required)
password, str: The password for login in clear text (required)
Returns: str
"""
@@ -280,12 +201,15 @@ class UserApi(object):
responseObject = self.apiClient.deserialize(response, 'str')
return responseObject
def logoutUser(self, **kwargs):
"""Logs out current logged in user session
Args:
Returns:
"""
@@ -311,7 +235,119 @@ class UserApi(object):
postData, headerParams)
def createUser(self, body, **kwargs):
"""Create user
Args:
body, User: Created user object (required)
Returns:
"""
allParams = ['body']
params = locals()
for (key, val) in params['kwargs'].items():
if key not in allParams:
raise TypeError("Got an unexpected keyword argument '%s' to method createUser" % key)
params[key] = val
del params['kwargs']
resourcePath = '/user'
resourcePath = resourcePath.replace('{format}', 'json')
method = 'POST'
queryParams = {}
headerParams = {}
postData = (params['body'] if 'body' in params else None)
response = self.apiClient.callAPI(resourcePath, method, queryParams,
postData, headerParams)
def createUsersWithArrayInput(self, body, **kwargs):
"""Creates list of users with given input array
Args:
body, list[User]: List of user object (required)
Returns:
"""
allParams = ['body']
params = locals()
for (key, val) in params['kwargs'].items():
if key not in allParams:
raise TypeError("Got an unexpected keyword argument '%s' to method createUsersWithArrayInput" % key)
params[key] = val
del params['kwargs']
resourcePath = '/user/createWithArray'
resourcePath = resourcePath.replace('{format}', 'json')
method = 'POST'
queryParams = {}
headerParams = {}
postData = (params['body'] if 'body' in params else None)
response = self.apiClient.callAPI(resourcePath, method, queryParams,
postData, headerParams)
def createUsersWithListInput(self, body, **kwargs):
"""Creates list of users with given list input
Args:
body, list[User]: List of user object (required)
Returns:
"""
allParams = ['body']
params = locals()
for (key, val) in params['kwargs'].items():
if key not in allParams:
raise TypeError("Got an unexpected keyword argument '%s' to method createUsersWithListInput" % key)
params[key] = val
del params['kwargs']
resourcePath = '/user/createWithList'
resourcePath = resourcePath.replace('{format}', 'json')
method = 'POST'
queryParams = {}
headerParams = {}
postData = (params['body'] if 'body' in params else None)
response = self.apiClient.callAPI(resourcePath, method, queryParams,
postData, headerParams)

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python
"""
Copyright 2012 Wordnik, Inc.
Copyright 2014 Wordnik, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -27,8 +27,6 @@ class Category:
}
#Category unique identifier
self.id = None # int
#Name of the category
self.name = None # str

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python
"""
Copyright 2012 Wordnik, Inc.
Copyright 2014 Wordnik, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -30,14 +30,10 @@ class Order:
}
#Unique identifier for the order
self.id = None # int
#ID of pet being ordered
self.petId = None # int
#Number of pets ordered
self.quantity = None # int
#Status of the order
#Order Status
self.status = None # str
#Date shipped, only if it has been
self.shipDate = None # datetime

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python
"""
Copyright 2012 Wordnik, Inc.
Copyright 2014 Wordnik, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -31,15 +31,11 @@ class Pet:
}
#Unique identifier for the Pet
#unique identifier for the pet
self.id = None # int
#Category the pet is in
self.category = None # Category
#Friendly name of the pet
self.name = None # str
#Image URLs
self.photoUrls = None # list[str]
#Tags assigned to this pet
self.tags = None # list[Tag]
#pet status in the store
self.status = None # str

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python
"""
Copyright 2012 Wordnik, Inc.
Copyright 2014 Wordnik, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -27,8 +27,6 @@ class Tag:
}
#Unique identifier for the tag
self.id = None # int
#Friendly name for the tag
self.name = None # str

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python
"""
Copyright 2012 Wordnik, Inc.
Copyright 2014 Wordnik, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -22,8 +22,8 @@ class User:
def __init__(self):
self.swaggerTypes = {
'id': 'int',
'username': 'str',
'firstName': 'str',
'username': 'str',
'lastName': 'str',
'email': 'str',
'password': 'str',
@@ -33,19 +33,12 @@ class User:
}
#Unique identifier for the user
self.id = None # int
#Unique username
self.username = None # str
#First name of the user
self.firstName = None # str
#Last name of the user
self.username = None # str
self.lastName = None # str
#Email address of the user
self.email = None # str
#Password name of the user
self.password = None # str
#Phone number of the user
self.phone = None # str
#User Status
self.userStatus = None # int

View File

@@ -1,5 +1,5 @@
/**
* Copyright 2012 Wordnik, Inc.
* Copyright 2014 Wordnik, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -20,6 +20,7 @@ class Pet_api
#resource path
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
# pull querystring keys from options
queryopts = options.select do |key,value|
@@ -30,6 +31,7 @@ class Pet_api
post_body = nil
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
Pet.new(response)
end
def self.delete_pet (pet_id,opts={})
@@ -44,6 +46,7 @@ def self.delete_pet (pet_id,opts={})
#resource path
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
# pull querystring keys from options
queryopts = options.select do |key,value|
@@ -54,6 +57,7 @@ def self.delete_pet (pet_id,opts={})
post_body = nil
Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
end
def self.partial_update (pet_id,body,opts={})
@@ -70,6 +74,7 @@ def self.partial_update (pet_id,body,opts={})
#resource path
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
# pull querystring keys from options
queryopts = options.select do |key,value|
@@ -100,6 +105,7 @@ def self.partial_update (pet_id,body,opts={})
end
response = Swagger::Request.new(:PATCH, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
response.map {|response|Pet.new(response)}
end
def self.update_pet_with_form (pet_id,name,status,opts={})
@@ -116,6 +122,7 @@ def self.update_pet_with_form (pet_id,name,status,opts={})
#resource path
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
# pull querystring keys from options
queryopts = options.select do |key,value|
@@ -126,6 +133,7 @@ def self.update_pet_with_form (pet_id,name,status,opts={})
post_body = nil
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
end
def self.upload_file (additional_metadata,body,opts={})
@@ -138,6 +146,7 @@ def self.upload_file (additional_metadata,body,opts={})
#resource path
path = "/pet/uploadImage".sub('{format}','json')
# pull querystring keys from options
queryopts = options.select do |key,value|
@@ -168,6 +177,7 @@ def self.upload_file (additional_metadata,body,opts={})
end
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
end
def self.add_pet (body,opts={})
@@ -181,6 +191,7 @@ def self.add_pet (body,opts={})
#resource path
path = "/pet".sub('{format}','json')
# pull querystring keys from options
queryopts = options.select do |key,value|
@@ -211,6 +222,7 @@ def self.add_pet (body,opts={})
end
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
end
def self.update_pet (body,opts={})
@@ -224,6 +236,7 @@ def self.update_pet (body,opts={})
#resource path
path = "/pet".sub('{format}','json')
# pull querystring keys from options
queryopts = options.select do |key,value|
@@ -254,6 +267,7 @@ def self.update_pet (body,opts={})
end
Swagger::Request.new(:PUT, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
end
def self.find_pets_by_status (status= "available",opts={})
@@ -267,6 +281,7 @@ def self.find_pets_by_status (status= "available",opts={})
#resource path
path = "/pet/findByStatus".sub('{format}','json')
# pull querystring keys from options
queryopts = options.select do |key,value|
@@ -277,6 +292,7 @@ def self.find_pets_by_status (status= "available",opts={})
post_body = nil
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
response.map {|response|Pet.new(response)}
end
def self.find_pets_by_tags (tags,opts={})
@@ -290,6 +306,7 @@ def self.find_pets_by_tags (tags,opts={})
#resource path
path = "/pet/findByTags".sub('{format}','json')
# pull querystring keys from options
queryopts = options.select do |key,value|
@@ -300,6 +317,7 @@ def self.find_pets_by_tags (tags,opts={})
post_body = nil
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
response.map {|response|Pet.new(response)}
end
end

View File

@@ -20,6 +20,7 @@ class Store_api
#resource path
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(order_id))
# pull querystring keys from options
queryopts = options.select do |key,value|
@@ -30,6 +31,7 @@ class Store_api
post_body = nil
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
Order.new(response)
end
def self.delete_order (order_id,opts={})
@@ -44,6 +46,7 @@ def self.delete_order (order_id,opts={})
#resource path
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(order_id))
# pull querystring keys from options
queryopts = options.select do |key,value|
@@ -54,6 +57,7 @@ def self.delete_order (order_id,opts={})
post_body = nil
Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
end
def self.place_order (body,opts={})
@@ -67,6 +71,7 @@ def self.place_order (body,opts={})
#resource path
path = "/store/order".sub('{format}','json')
# pull querystring keys from options
queryopts = options.select do |key,value|
@@ -97,6 +102,7 @@ def self.place_order (body,opts={})
end
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
end
end

View File

@@ -8,136 +8,7 @@ class User_api
URI.encode(string.to_s)
end
def self.create_user (body,opts={})
query_param_keys = []
# verify existence of params
raise "body is required" if body.nil?
# set default values and merge with input
options = {
:body => body}.merge(opts)
#resource path
path = "/user".sub('{format}','json')
# pull querystring keys from options
queryopts = options.select do |key,value|
query_param_keys.include? key
end
headers = nil
post_body = nil
if body != nil
if body.is_a?(Array)
array = Array.new
body.each do |item|
if item.respond_to?("to_body".to_sym)
array.push item.to_body
else
array.push item
end
end
post_body = array
else
if body.respond_to?("to_body".to_sym)
post_body = body.to_body
else
post_body = body
end
end
end
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
end
def self.create_users_with_array_input (body,opts={})
query_param_keys = []
# verify existence of params
raise "body is required" if body.nil?
# set default values and merge with input
options = {
:body => body}.merge(opts)
#resource path
path = "/user/createWithArray".sub('{format}','json')
# pull querystring keys from options
queryopts = options.select do |key,value|
query_param_keys.include? key
end
headers = nil
post_body = nil
if body != nil
if body.is_a?(Array)
array = Array.new
body.each do |item|
if item.respond_to?("to_body".to_sym)
array.push item.to_body
else
array.push item
end
end
post_body = array
else
if body.respond_to?("to_body".to_sym)
post_body = body.to_body
else
post_body = body
end
end
end
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
end
def self.create_users_with_list_input (body,opts={})
query_param_keys = []
# verify existence of params
raise "body is required" if body.nil?
# set default values and merge with input
options = {
:body => body}.merge(opts)
#resource path
path = "/user/createWithList".sub('{format}','json')
# pull querystring keys from options
queryopts = options.select do |key,value|
query_param_keys.include? key
end
headers = nil
post_body = nil
if body != nil
if body.is_a?(Array)
array = Array.new
body.each do |item|
if item.respond_to?("to_body".to_sym)
array.push item.to_body
else
array.push item
end
end
post_body = array
else
if body.respond_to?("to_body".to_sym)
post_body = body.to_body
else
post_body = body
end
end
end
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
end
def self.update_user (username,body,opts={})
def self.update_user (username,body,opts={})
query_param_keys = []
# verify existence of params
@@ -151,6 +22,7 @@ def self.update_user (username,body,opts={})
#resource path
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', escapeString(username))
# pull querystring keys from options
queryopts = options.select do |key,value|
@@ -181,6 +53,7 @@ def self.update_user (username,body,opts={})
end
Swagger::Request.new(:PUT, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
end
def self.delete_user (username,opts={})
@@ -195,6 +68,7 @@ def self.delete_user (username,opts={})
#resource path
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', escapeString(username))
# pull querystring keys from options
queryopts = options.select do |key,value|
@@ -205,6 +79,7 @@ def self.delete_user (username,opts={})
post_body = nil
Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
end
def self.get_user_by_name (username,opts={})
@@ -219,6 +94,7 @@ def self.get_user_by_name (username,opts={})
#resource path
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', escapeString(username))
# pull querystring keys from options
queryopts = options.select do |key,value|
@@ -229,6 +105,7 @@ def self.get_user_by_name (username,opts={})
post_body = nil
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
User.new(response)
end
def self.login_user (username,password,opts={})
@@ -244,6 +121,7 @@ def self.login_user (username,password,opts={})
#resource path
path = "/user/login".sub('{format}','json')
# pull querystring keys from options
queryopts = options.select do |key,value|
@@ -254,6 +132,7 @@ def self.login_user (username,password,opts={})
post_body = nil
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
string.new(response)
end
def self.logout_user (opts={})
@@ -265,6 +144,7 @@ def self.logout_user (opts={})
#resource path
path = "/user/logout".sub('{format}','json')
# pull querystring keys from options
queryopts = options.select do |key,value|
@@ -275,6 +155,142 @@ def self.logout_user (opts={})
post_body = nil
Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
end
def self.create_user (body,opts={})
query_param_keys = []
# verify existence of params
raise "body is required" if body.nil?
# set default values and merge with input
options = {
:body => body}.merge(opts)
#resource path
path = "/user".sub('{format}','json')
# pull querystring keys from options
queryopts = options.select do |key,value|
query_param_keys.include? key
end
headers = nil
post_body = nil
if body != nil
if body.is_a?(Array)
array = Array.new
body.each do |item|
if item.respond_to?("to_body".to_sym)
array.push item.to_body
else
array.push item
end
end
post_body = array
else
if body.respond_to?("to_body".to_sym)
post_body = body.to_body
else
post_body = body
end
end
end
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
end
def self.create_users_with_array_input (body,opts={})
query_param_keys = []
# verify existence of params
raise "body is required" if body.nil?
# set default values and merge with input
options = {
:body => body}.merge(opts)
#resource path
path = "/user/createWithArray".sub('{format}','json')
# pull querystring keys from options
queryopts = options.select do |key,value|
query_param_keys.include? key
end
headers = nil
post_body = nil
if body != nil
if body.is_a?(Array)
array = Array.new
body.each do |item|
if item.respond_to?("to_body".to_sym)
array.push item.to_body
else
array.push item
end
end
post_body = array
else
if body.respond_to?("to_body".to_sym)
post_body = body.to_body
else
post_body = body
end
end
end
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
end
def self.create_users_with_list_input (body,opts={})
query_param_keys = []
# verify existence of params
raise "body is required" if body.nil?
# set default values and merge with input
options = {
:body => body}.merge(opts)
#resource path
path = "/user/createWithList".sub('{format}','json')
# pull querystring keys from options
queryopts = options.select do |key,value|
query_param_keys.include? key
end
headers = nil
post_body = nil
if body != nil
if body.is_a?(Array)
array = Array.new
body.each do |item|
if item.respond_to?("to_body".to_sym)
array.push item.to_body
else
array.push item
end
end
post_body = array
else
if body.respond_to?("to_body".to_sym)
post_body = body.to_body
else
post_body = body
end
end
end
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
end
end

View File

@@ -3,8 +3,7 @@ module Swagger
class Configuration
require 'swagger/version'
attr_accessor :format, :api_key, :username, :password, :auth_token, :scheme, :host, :base_path,
:user_agent, :logger, :inject_format
attr_accessor :format, :api_key, :username, :password, :auth_token, :scheme, :host, :base_path, :user_agent, :logger, :inject_format, :force_ending_format, :camelize_params
# Defaults go in here..
def initialize
@@ -14,9 +13,10 @@ module Swagger
@base_path = '/v4'
@user_agent = "ruby-#{Swagger::VERSION}"
@inject_format = true
@force_ending_format = false
@camelize_params = true
end
end
end

View File

@@ -87,6 +87,15 @@ module Swagger
end
end
# Stick a .{format} placeholder on the end of the path if there isn't
# one already or an actual format like json or xml
# e.g. /words/blah => /words/blah.{format}
if Swagger.configuration.force_ending_format
unless ['.json', '.xml', '{format}'].any? {|s| p.downcase.include? s }
p = "#{p}.#{format}"
end
end
p = p.sub("{format}", self.format.to_s)
URI.encode [Swagger.configuration.base_path, p].join("/").gsub(/\/+/, '/')
@@ -121,7 +130,9 @@ module Swagger
self.params.each_pair do |key, value|
next if self.path.include? "{#{key}}" # skip path params
next if value.blank? && value.class != FalseClass # skip empties
key = key.to_s.camelize(:lower).to_sym unless key.to_sym == :api_key # api_key is not a camelCased param
if Swagger.configuration.camelize_params
key = key.to_s.camelize(:lower).to_sym unless key.to_sym == :api_key # api_key is not a camelCased param
end
query_values[key] = value.to_s
end
@@ -186,4 +197,3 @@ module Swagger
end
end

View File

@@ -1,12 +1,12 @@
class User
attr_accessor :id, :username, :first_name, :last_name, :email, :password, :phone, :user_status
attr_accessor :id, :first_name, :username, :last_name, :email, :password, :phone, :user_status
# :internal => :external
def self.attribute_map
{
:id => :id,
:username => :username,
:first_name => :firstName,
:username => :username,
:last_name => :lastName,
:email => :email,
:password => :password,
@@ -22,12 +22,12 @@ class User
if self.class.attribute_map[:"id"]
@id = attributes["id"]
end
if self.class.attribute_map[:"username"]
@username = attributes["username"]
end
if self.class.attribute_map[:"first_name"]
@first_name = attributes["firstName"]
end
if self.class.attribute_map[:"username"]
@username = attributes["username"]
end
if self.class.attribute_map[:"last_name"]
@last_name = attributes["lastName"]
end

View File

@@ -1,5 +1,5 @@
/**
* Copyright 2012 Wordnik, Inc.
* Copyright 2014 Wordnik, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -2,10 +2,10 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.wordnik</groupId>
<artifactId>swagger-client</artifactId>
<artifactId>scala-client</artifactId>
<packaging>jar</packaging>
<name>swagger-client</name>
<version>1.0</version>
<name>scala-client</name>
<version>1.0.0</version>
<prerequisites>
<maven>2.2.0</maven>
</prerequisites>
@@ -170,13 +170,13 @@
</dependency>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-core_2.9.1</artifactId>
<artifactId>swagger-core_${scala-short-version}</artifactId>
<version>${swagger-core-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.9.1</artifactId>
<artifactId>scalatest_${scala-short-version}</artifactId>
<version>${scala-test-version}</version>
<scope>test</scope>
</dependency>
@@ -187,15 +187,34 @@
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>scala_2.10</id>
<properties>
<scala-version>2.10.3</scala-version>
<scala-short-version>2.10</scala-short-version>
<swagger-core-version>1.3.2</swagger-core-version>
<scala-test-version>2.1.2</scala-test-version>
</properties>
</profile>
<profile>
<id>scala_2.9.1</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<scala-version>2.9.1-1</scala-version>
<scala-short-version>2.9.1</scala-short-version>
<swagger-core-version>1.1.0</swagger-core-version>
<scala-test-version>1.6.1</scala-test-version>
</properties>
</profile>
</profiles>
<properties>
<jersey-version>1.7</jersey-version>
<swagger-core-version>1.1.0</swagger-core-version>
<scala-version>2.9.1-1</scala-version>
<junit-version>4.8.1</junit-version>
<maven-plugin.version>1.0.0</maven-plugin.version>
<scala-test-version>1.6.1</scala-test-version>
<junit-version>4.8.1</junit-version>
<scala-test-version>1.6.1</scala-test-version>
<scala-maven-plugin-version>3.1.5</scala-maven-plugin-version>
</properties>
</project>

View File

@@ -44,8 +44,6 @@ object ApiInvoker {
URLEncoder.encode(value, "utf-8").replaceAll("\\+", "%20")
}
def addHeader(key: String, value: String) = defaultHeaders += key -> value
def escape(value: Long): String = value.toString
def escape(value: Double): String = value.toString
def escape(value: Float): String = value.toString

View File

@@ -1,6 +1,5 @@
package com.wordnik.petstore.api
import java.io.File
import com.wordnik.petstore.model.Pet
import com.wordnik.client.ApiInvoker
import com.wordnik.client.ApiException
@@ -21,6 +20,7 @@ class PetApi {
val path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId))
val contentType = {
"application/json"}
@@ -49,6 +49,7 @@ class PetApi {
val path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId))
val contentType = {
"application/json"}
@@ -76,6 +77,7 @@ class PetApi {
val path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId))
val contentType = {
if(body != null && body.isInstanceOf[File] )
"multipart/form-data"
@@ -107,6 +109,7 @@ class PetApi {
val path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId))
val contentType = {
"application/json"}
@@ -132,6 +135,7 @@ class PetApi {
def uploadFile (additionalMetadata: String, body: File) = {
// create path and map variables
val path = "/pet/uploadImage".replaceAll("\\{format\\}","json")
val contentType = {
if(body != null && body.isInstanceOf[File] )
"multipart/form-data"
@@ -155,6 +159,7 @@ class PetApi {
def addPet (body: Pet) = {
// create path and map variables
val path = "/pet".replaceAll("\\{format\\}","json")
val contentType = {
if(body != null && body.isInstanceOf[File] )
"multipart/form-data"
@@ -183,6 +188,7 @@ class PetApi {
def updatePet (body: Pet) = {
// create path and map variables
val path = "/pet".replaceAll("\\{format\\}","json")
val contentType = {
if(body != null && body.isInstanceOf[File] )
"multipart/form-data"
@@ -211,6 +217,7 @@ class PetApi {
def findPetsByStatus (status: String= "available") : Option[List[Pet]]= {
// create path and map variables
val path = "/pet/findByStatus".replaceAll("\\{format\\}","json")
val contentType = {
"application/json"}
@@ -238,6 +245,7 @@ class PetApi {
def findPetsByTags (tags: String) : Option[List[Pet]]= {
// create path and map variables
val path = "/pet/findByTags".replaceAll("\\{format\\}","json")
val contentType = {
"application/json"}

View File

@@ -20,6 +20,7 @@ class StoreApi {
val path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}",apiInvoker.escape(orderId))
val contentType = {
"application/json"}
@@ -48,6 +49,7 @@ class StoreApi {
val path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}",apiInvoker.escape(orderId))
val contentType = {
"application/json"}
@@ -73,6 +75,7 @@ class StoreApi {
def placeOrder (body: Order) = {
// create path and map variables
val path = "/store/order".replaceAll("\\{format\\}","json")
val contentType = {
if(body != null && body.isInstanceOf[File] )
"multipart/form-data"

View File

@@ -15,95 +15,12 @@ class UserApi {
def addHeader(key: String, value: String) = apiInvoker.defaultHeaders += key -> value
def createUser (body: User) = {
// create path and map variables
val path = "/user".replaceAll("\\{format\\}","json")
val contentType = {
if(body != null && body.isInstanceOf[File] )
"multipart/form-data"
else "application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
// verify required params are set
(List(body).filter(_ != null)).size match {
case 1 => // all required values set
case _ => throw new Exception("missing required params")
}
try {
apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match {
case s: String =>
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
def createUsersWithArrayInput (body: List[User]) = {
// create path and map variables
val path = "/user/createWithArray".replaceAll("\\{format\\}","json")
val contentType = {
if(body != null && body.isInstanceOf[File] )
"multipart/form-data"
else "application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
// verify required params are set
(List(body).filter(_ != null)).size match {
case 1 => // all required values set
case _ => throw new Exception("missing required params")
}
try {
apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match {
case s: String =>
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
def createUsersWithListInput (body: List[User]) = {
// create path and map variables
val path = "/user/createWithList".replaceAll("\\{format\\}","json")
val contentType = {
if(body != null && body.isInstanceOf[File] )
"multipart/form-data"
else "application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
// verify required params are set
(List(body).filter(_ != null)).size match {
case 1 => // all required values set
case _ => throw new Exception("missing required params")
}
try {
apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match {
case s: String =>
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
def updateUser (username: String, body: User) = {
// create path and map variables
val path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}",apiInvoker.escape(username))
val contentType = {
if(body != null && body.isInstanceOf[File] )
"multipart/form-data"
@@ -134,6 +51,7 @@ class UserApi {
val path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}",apiInvoker.escape(username))
val contentType = {
"application/json"}
@@ -161,6 +79,7 @@ class UserApi {
val path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}",apiInvoker.escape(username))
val contentType = {
"application/json"}
@@ -187,6 +106,7 @@ class UserApi {
def loginUser (username: String, password: String) : Option[String]= {
// create path and map variables
val path = "/user/login".replaceAll("\\{format\\}","json")
val contentType = {
"application/json"}
@@ -215,6 +135,7 @@ class UserApi {
def logoutUser () = {
// create path and map variables
val path = "/user/logout".replaceAll("\\{format\\}","json")
val contentType = {
"application/json"}
@@ -232,5 +153,92 @@ class UserApi {
case ex: ApiException => throw ex
}
}
def createUser (body: User) = {
// create path and map variables
val path = "/user".replaceAll("\\{format\\}","json")
val contentType = {
if(body != null && body.isInstanceOf[File] )
"multipart/form-data"
else "application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
// verify required params are set
(List(body).filter(_ != null)).size match {
case 1 => // all required values set
case _ => throw new Exception("missing required params")
}
try {
apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match {
case s: String =>
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
def createUsersWithArrayInput (body: List[User]) = {
// create path and map variables
val path = "/user/createWithArray".replaceAll("\\{format\\}","json")
val contentType = {
if(body != null && body.isInstanceOf[File] )
"multipart/form-data"
else "application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
// verify required params are set
(List(body).filter(_ != null)).size match {
case 1 => // all required values set
case _ => throw new Exception("missing required params")
}
try {
apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match {
case s: String =>
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
def createUsersWithListInput (body: List[User]) = {
// create path and map variables
val path = "/user/createWithList".replaceAll("\\{format\\}","json")
val contentType = {
if(body != null && body.isInstanceOf[File] )
"multipart/form-data"
else "application/json"
}
// query params
val queryParams = new HashMap[String, String]
val headerParams = new HashMap[String, String]
// verify required params are set
(List(body).filter(_ != null)).size match {
case 1 => // all required values set
case _ => throw new Exception("missing required params")
}
try {
apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match {
case s: String =>
case _ => None
}
} catch {
case ex: ApiException if ex.code == 404 => None
case ex: ApiException => throw ex
}
}
}

View File

@@ -1,8 +1,6 @@
package com.wordnik.petstore.model
case class Category (
/* Category unique identifier */
id: Long,
/* Name of the category */
name: String)

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