Compare commits

..

264 Commits

Author SHA1 Message Date
Tony Tam
ece072aee3 Merge pull request #418 from lucamilanesio/scala-async-http-support
Support for HTTP Async client transport for Jersey on Scala (legacy master)
2015-02-09 13:43:07 -08:00
Luca Milanesio
2386e394ae Support for HTTP Async client transport for Jersey on Scala
When generating Scala client, the ApiInvoker is a class with
overridable options, avoiding the need of public vars to be
manually modified.

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

NOTE: Support for Scala 2.10.0-3 removed as largely obsolete
2015-02-09 19:36:28 +00:00
Tony Tam
f55d9eaa68 Merge pull request #412 from FindTheBest/master
Python/PHP Multipart-Form request support
2015-02-06 10:47:10 -08:00
James Ebentier
0f041dae90 MultipartForm: adding support for php 2015-02-04 12:48:00 -08:00
James Ebentier
6c97a9c6c7 MultipartForm: some more fixing of formating 2015-02-04 10:54:55 -08:00
James Ebentier
257d67346c MultipartForm: fixing some spacing issues 2015-02-04 10:41:25 -08:00
James Ebentier
e955c9dcfd MultipartForm: getting the file uploading working 2015-02-04 09:56:10 -08:00
James Ebentier
63bb20238b MultipartForm: fixing syntax error 2015-02-03 19:01:31 -08:00
James Ebentier
55575541d8 MultipartForm: better formatting 2015-02-03 18:28:56 -08:00
James Ebentier
33e6105822 MultipartForm: adding in basic support for multipart form submissions on python bindings 2015-02-03 18:03:20 -08:00
Tony Tam
87be442ad9 Merge pull request #409 from ethanjcohen/master
Fix "properties" name in node server example template
2015-02-02 22:42:56 -08:00
Ethan Cohen
65b3b594e3 Renamed the "params" operation property to "parameters" to conform to the swagger spec 2015-02-01 16:02:27 -06:00
Ethan Cohen
94ceb504b8 Changed the "params" operation property to "parameters" to conform to the swagger spec 2015-02-01 15:54:47 -06:00
Tony Tam
f914f26f3b Merge pull request #400 from FindTheBest/master
Fixing curl $postData for php bindings
2015-01-28 22:06:23 -08:00
James Ebentier
4a6e719d6a APIClient: making the cURL timeout able to be variably set for better dynamic api calls 2015-01-28 16:04:11 -08:00
James Ebentier
61ea9564f8 building a fix for postData that will pass TravisCI build 2015-01-27 13:48:59 -08:00
James Ebentier
bfc14938d0 Fixing curl $postData for php bindings 2015-01-27 13:16:20 -08:00
Tony Tam
c98a78062f Merge pull request #398 from FindTheBest/master
Fixing issue with deserialization in PHP
2015-01-27 12:50:24 -08:00
James Ebentier
fd128cbab0 Update Swagger.mustache 2015-01-27 12:28:28 -08:00
James Ebentier
59568915de Fixing minor typo 2015-01-27 12:08:41 -08:00
James Ebentier
bff2515bf2 Fixing issue with deserialization in PHP
No longer will deserialize throw errors when converting a json response to a string
2015-01-27 11:48:20 -08:00
Tony Tam
dcaf639bec Merge branch 'STRML-fixPHPFormParams' 2015-01-21 23:19:19 -08:00
Tony Tam
2f6bf95fa2 merged 2015-01-21 23:19:13 -08:00
Tony Tam
154c28b062 Merge pull request #385 from STRML/fixPHPComments
Rework generated PHP function comments.
2015-01-21 22:10:20 -08:00
Samuel Reed
8106de95dc Rework PHP function comments to match PHPDoc style.
Also eliminated bad newline.
2015-01-21 10:58:57 +01:00
Samuel Reed
7c342a060a Add missing formParams to PHP api.mustache. Fixes #383.
Also fixed mixed tabs and spaces in template.
2015-01-21 10:01:41 +01:00
Tony Tam
3abc42eee9 Merge pull request #368 from amandaducrou/master
Adding first and hasRequiredParams parameters to Codegen
2015-01-09 10:26:50 -08:00
Amanda Ducrou
2d81c71b52 Adding first and hasRequiredParams parameters to Codegen 2015-01-09 10:59:21 +10:00
Tony Tam
2d193a0e92 Merge pull request #218 from JDiPierro/output_resource_path_for_no_models_found
Output the resourcePath when no models are found rather than the basePath
2014-12-23 22:23:14 -08:00
Tony Tam
09e7bd9c43 Merge pull request #286 from jebentier/master
Java binding comment creation issue fixed
2014-12-23 22:17:35 -08:00
Tony Tam
0ece4a084f Merge pull request #303 from butlermh/master
Can't run ./bin/scala-petstore.sh as instructed at README
2014-12-23 22:16:35 -08:00
Tony Tam
0821d1859b Merge pull request #321 from Laurent-Sarrazin/patch-doc
Fix a typo
2014-12-23 22:14:39 -08:00
Tony Tam
25aef5fd6e Merge pull request #240 from GerardSoleCa/master
Edit line 76 to place pom.xml correctly and dependency-jar generation
2014-12-23 20:31:26 -08:00
webron
3a77287f8b Update README.md 2014-12-23 17:29:49 +02:00
webron
d2111a8e68 Merge pull request #352 from FMJaguar/patch-2
Update README.md
2014-12-23 17:28:59 +02:00
Rich DeLauder
3c0d639d0e Update README.md 2014-12-19 13:10:02 -08:00
Tony Tam
1f30c65464 Update README.md 2014-12-12 12:47:30 -08:00
webron
1b68671e98 Update README.md 2014-12-04 16:27:44 +02:00
Tony Tam
586420b919 Merge pull request #335 from wing328/master
update deserialize to handle both array(primitive) and Array(model)
2014-12-02 22:07:24 -08:00
Tony Tam
43a5ece5b3 Merge pull request #312 from idosh/master
add support to multipart form data and urlencoded for android client
2014-12-02 20:40:02 -08:00
William Cheng
9f6d883e68 update deserialize to handle both array(primitive) and Array(model) 2014-11-29 18:23:44 +08:00
webron
524497a606 Merge pull request #332 from mhurne/patch-1
Fix spelling errors and improve sentence in Compatibility section
2014-11-24 22:13:29 +02:00
Matt Hurne
665ba22c7a Fix spelling errors and improve sentence in Compatibility section 2014-11-24 15:11:38 -05:00
Ido Shamun
0614d1b221 update pom.xml with dependencies
fix Codegen.scala to support file as a param type
2014-11-08 01:19:53 +02:00
Ido Shamun
fb3f331e3c Merge remote-tracking branch 'upstream/master'
merge fork with master
2014-11-07 18:27:58 +02:00
Tony Tam
4e9378965b Merge pull request #324 from FindTheBest/pull_request
Adding the casting of integer -> int for python generated code
2014-11-05 15:47:44 -08:00
James Ebentier
d1fe146522 Adding the casting of integer -> int for python generated code 2014-11-05 15:37:22 -08:00
Tony Tam
b9758107c3 Merge pull request #322 from Laurent-Sarrazin/patch-php-server-generator
Add a basic PHP server-generator example
2014-10-31 09:32:08 -07:00
Laurent Sarrazin
06332e5dce Add a basic PHP server-generator example 2014-10-31 17:00:34 +01:00
Laurent Sarrazin
aa262f6021 Fix a typo 2014-10-30 14:30:55 +01:00
Tony Tam
88692ec42d updated references 2014-10-22 15:45:21 -07:00
Ivan Porto Carrero
a656ea301e updates the codegen to also include the project name for sbt 2014-10-21 10:59:35 -07:00
Ido Shamun
5e4e838a48 add support to multipart form data and urlencoded for android client 2014-10-21 01:58:31 +03:00
Ivan Porto Carrero
f3dc69a7e7 update dependencies in async scala project 2014-10-20 15:42:10 -07:00
Tony Tam
12eba440ae Update README.md 2014-10-18 17:14:00 -07:00
webron
4676c4cdf7 Merge pull request #307 from catherinedodge/master
Fixed broken link in README.md
2014-10-13 16:58:22 +03:00
catherinedodge
d5674c9a7b Fixed broken link in README.md 2014-10-13 09:48:29 -04:00
Mark H. Butler
c8dac4a3cf Reverting these files, they don't need to change 2014-10-08 08:25:23 -07:00
Mark H. Butler
6f30a6d65a Modifying the pom.xml template because it defaults to building with Scala 2.9.1, but that is broken because BeanProperty moved, so instead use 2.10 as the default but add the option of using Scala 2.11 2014-10-08 08:20:02 -07:00
Mark H. Butler
9d1f0bf568 Adding ignore for gedit files (Linux) 2014-10-08 08:19:08 -07:00
Tony Tam
643c211d72 Merge pull request #296 from lloydmeta/update/fix_deprecations
Update deprecated method calls
2014-10-07 21:42:13 -07:00
Tony Tam
fb84985e9b Merge pull request #298 from dreamfactorysoftware/master
adding a space in call to completionHandler to kill latest Xcode parse errors
2014-10-02 16:45:38 -07:00
Jason Sykes
afb34b4f2f adding a space in call to completionHandler to kill latest Xcode parse errors 2014-10-02 12:20:17 -04:00
Lloyd
1734ac2e18 Update deprecated method calls
1. Update specs to inherit via `with Matchers`
2. Update `URLEncoder.encode` to pass "UTF-8" as charset
2014-10-02 10:49:20 +09:00
James Ebentier
72bef1fb68 fixing the java comments above the api calls to allow for multiline comments in the swagger docs 2014-09-29 17:53:53 -07:00
Tony Tam
ec99bef893 Merge pull request #266 from FindTheBest/pull_request
Python binding generation pull request
2014-09-20 13:39:07 -07:00
Tony Tam
2fd29d74f2 Merge pull request #263 from wordnik/basic-auth
Adds Basic auth as an authentication mechanism
2014-09-20 08:43:30 -07:00
Tony Tam
033a9a4b97 Merge pull request #262 from xhh/patch-1
Fixes #260 convert form parameters to string for Java client
2014-09-20 08:41:33 -07:00
Tony Tam
885e463bcb added compatibility table 2014-09-19 11:50:20 -07:00
James Ebentier
b8f3201dba fixing a minor generation issue in api.mustashe to make sure that python scripts are as clean as possible for apis 2014-09-19 10:53:03 -07:00
James Ebentier
983edbd85b Adding in the ability to post forms using swagger codegen generate bindings for python 2014-09-19 10:52:57 -07:00
Ivan Porto Carrero
86d56b978a also work on java 7 2014-09-16 20:52:07 -07:00
Ivan Porto Carrero
ed86bfb79b adds basic auth support 2014-09-16 20:41:32 -07:00
Ivan Porto Carrero
44a73c32fa more lenient Version.scala 2014-09-16 20:15:09 -07:00
Xu Hui Hui
39662e45b1 Fixes #260 convert form parameters to string for Java client 2014-09-16 18:58:17 +08:00
webron
998bf633d8 Merge pull request #261 from czenker/patch-1
Fix typo in README.md
2014-09-12 15:48:22 +03:00
Christian Zenker
b927ffbd53 Fix typo in README.md 2014-09-12 14:26:15 +02:00
Tony Tam
1ff47393ed Merge pull request #255 from martoe/master
Issue 244 - checkout on windows fails due to special chars
2014-09-07 23:59:01 -07:00
isf
a6ecc7a65b Issue 244 - checkout on windows fails due to special chars 2014-09-08 08:50:35 +02:00
Tony Tam
dbf04a9563 updated scripts 2014-08-27 01:09:28 -07:00
Tony Tam
d1603ba25e updated scalatest 2014-08-27 01:04:02 -07:00
Tony Tam
d4ce57bd15 added bigdecimal support 2014-08-27 01:03:49 -07:00
Tony Tam
5e56346dc9 updated scripts to use only assembly 2014-08-27 01:03:32 -07:00
Tony Tam
05db83a067 set to petstore 2014-08-27 00:17:45 -07:00
Tony Tam
707ee1c85b set version to 2.10.4 2014-08-27 00:17:33 -07:00
Tony Tam
a54adb925f added big decimal support 2014-08-27 00:16:12 -07:00
Tony Tam
8c53837802 updated scripts for assembly 2014-08-27 00:15:26 -07:00
Tony Tam
3625b89a15 updated to snapshot build 2014-08-26 16:53:52 -07:00
Tony Tam
2ed68c2df8 version 2.0.17 2014-08-26 16:52:26 -07:00
Tony Tam
db1915ec89 Merge pull request #252 from earldouglas/path-not-optional
Drop the 'optional' param for path params
2014-08-26 14:40:14 -07:00
James Earl Douglas
77e9ce5ede Drop the 'optional' param for path params 2014-08-26 14:38:27 -07:00
Tony Tam
013c19eb36 Merge pull request #251 from earldouglas/not-so-required
Set param as 'required' iff required, else set as 'optional'
2014-08-26 14:33:00 -07:00
James Earl Douglas
61c04ddaf1 Set param as 'required' iff required, else set as 'optional' 2014-08-26 14:31:45 -07:00
Tony Tam
b4d361130c Merge pull request #247 from xoom/issues/java_pom
Issues/java pom - remove scala dependencies from Java pom files
2014-08-25 23:05:04 -07:00
Tony Tam
8e7571c34f Merge pull request #248 from xhh/patch-1
Fixes #242 - Ruby model syntax error
2014-08-25 23:03:45 -07:00
xhh
1ba42ef6cc Fixes #242 - Ruby model syntax error 2014-08-26 09:18:54 +08:00
Rob Blair
fc77521d49 Simplify java sample poms.
* remove scala references from the java client pom template files.
* regenerate the petstore sample pom.xml, verify they can build properly.
2014-08-25 17:37:36 -07:00
Rob Blair
1522069281 Regenerate the java code before modifying templates 2014-08-25 17:35:44 -07:00
Tony Tam
a13f46e781 Merge pull request #245 from ganeshs/master
Added import mappings for java.util.Set and java.sql.Timestamp
2014-08-20 23:43:05 -07:00
Ganesh Subramanian
3ad1ecf153 Added import mapping for Timestamp 2014-08-21 12:11:19 +05:30
Ganesh Subramanian
6087181634 Added import mapping for Timestamp 2014-08-21 12:10:14 +05:30
Ganesh Subramanian
c09adc4539 Fix for issue #226 2014-08-21 12:01:44 +05:30
Tony Tam
a626dea181 Update api.mustache 2014-08-11 08:58:45 -07:00
Tony Tam
454ec4b438 fix for #235 2014-08-08 16:38:38 -04:00
Gerard Solé
4a64d602a0 Add plugin to build a jar with dependencies 2014-08-07 12:17:05 -07:00
Gerard Solé
f294656073 Edit line 76 to place pom.xml correctly 2014-08-07 11:28:08 -07:00
Ivan Porto Carrero
c7da910e68 remove sample files again 2014-08-05 10:56:20 -07:00
Ivan Porto Carrero
40d33693cf add typesafe releases resolver, fixes #232 2014-08-05 10:43:28 -07:00
Tony Tam
13eaf2bf63 Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-08-03 09:19:01 -07:00
Tony Tam
d4508ed112 updated resolvers 2014-08-03 09:16:30 -07:00
Tony Tam
c252e9f7c6 added sonatype as resolver 2014-08-03 09:12:16 -07:00
Tony Tam
6690b80b29 Update .travis.yml 2014-08-02 16:32:10 -07:00
Tony Tam
19bb97a725 updated travis to 2.10.4 2014-08-02 16:09:00 -07:00
Tony Tam
62ee62ebd3 Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-08-02 16:04:55 -07:00
Tony Tam
87083034ee Merge pull request #215 from JDiPierro/fix_java_generator_lists
Use config.processResponseClass to determine type of returnContainer
2014-07-24 11:48:19 -07:00
Tony Tam
d9de57da6f Merge pull request #223 from darkcube/master
CSharp: Multipart form submission
2014-07-23 08:43:37 -04:00
Timothy Lusk
d0b0323925 CSharp: Implement multipart form submission 2014-07-22 17:17:54 -04:00
Tony Tam
f592414409 Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-07-18 09:52:57 -06:00
Tony Tam
e1c8f58d28 added 2.10.4 2014-07-18 09:52:53 -06:00
Tony Tam
4870ed7e51 Merge pull request #220 from darkcube/master
CSharp Changes
2014-07-16 16:30:15 -06:00
Timothy Lusk
bbe48814b4 CSharp: Add optional api constructor argument to set the basePath 2014-07-15 15:41:57 -04:00
Timothy Lusk
3b6ffa4a1f CSharp: Close the WebResponse if we throw an ApiException 2014-07-15 15:41:56 -04:00
Tony Tam
527c40b996 Merge pull request #211 from wcandillon/patch-1
Link back to the swagger-js-codegen project
2014-07-13 07:21:22 -07:00
Justin DiPierro
3aa2c86991 Output the resourcePath when no models are found rather than the basePath 2014-07-10 10:14:22 -04:00
Justin DiPierro
e2a20447df Fixed comment in test 2014-07-10 10:02:18 -04:00
Tony Tam
5d42c8cc5f moved to petstore 2014-07-04 10:19:48 -07:00
Tony Tam
256485ec5b updated template 2014-07-04 10:19:28 -07:00
Tony Tam
7ab0394e76 added node.js instead of jetty 2014-07-04 10:19:09 -07:00
Tony Tam
89b04b2e10 formatting 2014-07-04 10:18:44 -07:00
Tony Tam
a019a438e0 changed to petstore sample 2014-07-04 10:08:54 -07:00
Justin DiPierro
9834059786 Fixed BasicScalaGeneratorTest to expect Some(List) 2014-07-03 11:32:37 -04:00
Justin DiPierro
550fade9e0 Codegen.apiToMap should use config.processResponseClass when setting the returnContainer property. Test passes now 2014-07-03 11:24:05 -04:00
Justin DiPierro
aa1b4fc0fb Wrote failing test for Codegen 2014-07-03 11:23:07 -04:00
Tony Tam
5a659803a8 Merge pull request #212 from darkcube/master
Various csharp codegen fixes
2014-06-29 13:59:21 -07:00
Timothy Lusk
7bc7789e81 CSharp: Invoker should handle WebException and rethrow ApiException 2014-06-27 17:55:10 -04:00
Timothy Lusk
cf0721da73 CSharp: Use nullable primitive types to allow optional parameters 2014-06-27 16:10:45 -04:00
Timothy Lusk
dcbf4d1bfd CSharp: Use the correct model package name 2014-06-27 16:01:24 -04:00
William Candillon
017b578502 Link back to the swagger-js-codegen project 2014-06-26 15:05:33 +02:00
Tony Tam
58bade3b01 Update README.md 2014-06-19 09:33:41 -07:00
Tony Tam
02631e674a Merge pull request #207 from emmekappa/master
Fixing extensions and namespaces for csharp common files.
2014-06-17 10:53:17 -07:00
Michele Cantelli
5f5e534d05 CSharp: renaming the "packages" to follow the .NET style. 2014-06-17 16:22:04 +02:00
Michele Cantelli
51deeb478d Fixing extensions for csharp common files. 2014-06-17 15:18:58 +02:00
Tony Tam
acff8229b3 Merge pull request #206 from xoom/issue/modelsFromStatus
Issue/models from status - utilize the responseModel, if present
2014-06-16 17:03:17 -07:00
Rob Blair
233555790a Regenerate sample java files with example response status codes
* none of existing examples use the responseMessage.responseModel feature, but I have tested it.
* Didn't want to muck with sample json
* update the scripts used to generate both java versions.
* see https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#525-response-message-object
2014-06-16 12:59:53 -07:00
Rob Blair
d5ddac8e7e Update java mustache to show error status codes and models in generated API, in comments.
* I wonder if there is some clever way to make exceptions based on the model thrown, and automatically fill them in with the parsed error models?
* Until then, it's comments, and roll your own.
2014-06-16 12:51:35 -07:00
Rob Blair
e8210cd5e3 allow list of models to be returned in errors
* for example, a list of validation errors with an exceptional status
2014-06-16 12:40:44 -07:00
Rob Blair
2dc6b485e0 Generate classes from the models declared in 'responseModel'
* ResponseMessage has new constructor parameter, an optional string for responseModel
* Make sure we add it to list of models
* make sure the responseModel is part of the error list available to mustache
2014-06-16 12:34:44 -07:00
Tony Tam
11bede2b7d improved validation messages 2014-06-12 00:45:27 -07:00
Tony Tam
ed51dd9dea added files 2014-06-11 06:41:59 -07:00
Tony Tam
218f514005 updated node sample 2014-06-11 06:41:31 -07:00
Tony Tam
209e8e066c Merge pull request #201 from xoom/issue/JavaSafeApiName
coerce API names for classesand files to valid Java names
2014-06-11 06:12:55 -07:00
Tony Tam
7d05b01a56 Merge pull request #202 from gonimar/patch-1
Unused local variable 'json_data'.
2014-06-11 06:12:36 -07:00
Tony Tam
64f6bedc37 Merge branch 'repackage' 2014-06-11 06:12:15 -07:00
Tony Tam
4ae4aa98bb formatting 2014-06-11 06:11:45 -07:00
Tony Tam
db8bda087b made nickname optional 2014-06-11 06:11:31 -07:00
Tony Tam
06eb52118e updated to 2.3.0 release 2014-06-11 06:03:44 -07:00
Tony Tam
63be7d0069 removed println 2014-06-11 05:50:44 -07:00
Tony Tam
c7468125fa added clientName 2014-06-10 20:37:36 -07:00
Tony Tam
7b3d8bf799 added file upload support 2014-06-10 20:37:24 -07:00
Tony Tam
c4913fe583 wrapped in apiInfo 2014-06-10 20:37:08 -07:00
Tony Tam
d3339cb087 fixed string default 2014-06-10 20:36:58 -07:00
Tony Tam
ba4fda12dc added additional params 2014-06-10 20:36:29 -07:00
Tony Tam
7a6d6d27ff enabled logging 2014-06-10 20:36:10 -07:00
Tony Tam
bcabb03225 added support for nickname generation 2014-06-10 20:05:19 -07:00
Tony Tam
a404823c54 updated copyright 2014-06-10 17:23:35 -07:00
Tony Tam
96ea70e3c9 added className key 2014-06-10 17:23:20 -07:00
Tony Tam
9a01331ddd updated copyright 2014-06-10 16:58:43 -07:00
Tony Tam
3bfa468ed1 fixed filemap 2014-06-10 16:57:39 -07:00
Tony Tam
fdf8572535 updated copyright 2014-06-10 16:57:12 -07:00
Tony Tam
cff8b1552d updated copyright 2014-06-10 16:57:01 -07:00
Tony Tam
e73dd0a7c4 updated copyrights 2014-06-10 16:56:06 -07:00
Tony Tam
9c4c2dfd37 updated copyrights 2014-06-10 16:55:57 -07:00
Tony Tam
2f8355c953 regenerated client 2014-06-10 16:55:34 -07:00
Tony Tam
3f480482b6 regenerated client 2014-06-10 16:55:17 -07:00
Tony Tam
8274196999 regenerated client 2014-06-10 16:55:13 -07:00
Tony Tam
4e8c71f754 regenerated client 2014-06-10 16:54:48 -07:00
Tony Tam
57e7b41e9c regenerated client 2014-06-10 16:52:16 -07:00
Tony Tam
58d9894f1f regenerated client 2014-06-10 16:51:41 -07:00
Tony Tam
4b4d4d32cd regenerated client 2014-06-10 16:51:36 -07:00
Tony Tam
6a2ea9f614 regenerated client 2014-06-10 16:51:10 -07:00
Tony Tam
0d6754e167 regenerated client 2014-06-10 16:50:17 -07:00
Tony Tam
cb5c2a9708 regenerated client 2014-06-10 16:48:27 -07:00
Tony Tam
dc8ad7edf5 updated client 2014-06-10 16:48:05 -07:00
Tony Tam
52bc82149f file rename 2014-06-10 16:34:40 -07:00
Tony Tam
f53b5e27e0 updated scalatra version, templates for files, forms 2014-06-10 15:51:15 -07:00
Tony Tam
ce5be3452c added patch class 2014-06-10 15:50:49 -07:00
Tony Tam
ce14c225e5 added patch 2014-06-10 10:36:46 -07:00
Tony Tam
b78721826e regenerated client 2014-06-10 10:36:13 -07:00
Tony Tam
85113df113 regenerated client 2014-06-10 08:41:44 -07:00
Tony Tam
607b56cb87 removed println 2014-06-10 08:40:19 -07:00
Tony Tam
2dbf8b7d41 regenerated 2014-06-10 08:40:03 -07:00
Tony Tam
7d4c10043d updated client 2014-06-10 08:22:40 -07:00
Tony Tam
64604124c9 added array support 2014-06-10 08:22:08 -07:00
Tony Tam
50f20ad836 updated templates 2014-06-10 08:21:51 -07:00
Tony Tam
ac40283501 updated samples 2014-06-10 08:01:53 -07:00
Sergey Gonimar
e03d4fc1a5 Unused local variable 'json_data'.
The value of the variable is not used anywhere.
2014-06-10 19:25:00 +06:00
Rob Blair
05e9443db5 coerce API names of class and file valid Java names
* Swagger allows names of apis to include characters like '-' Java does not like that
* use same replace strings as used in toVarName
2014-06-09 17:04:57 -07:00
Tony Tam
1250cc758f updated version 2014-06-09 16:34:42 -07:00
Tony Tam
a18784da6c updated file maps 2014-06-09 15:05:23 -07:00
Tony Tam
c87d637edd regenerated 2014-06-06 00:27:40 -07:00
Tony Tam
bf4a4e5296 fixed imports, nesting 2014-06-06 00:27:15 -07:00
Tony Tam
4f7b80dad2 added debug, fixed headers 2014-06-05 22:49:09 -07:00
Tony Tam
8a2f9bc7bb compatibility 2014-06-05 20:08:59 -07:00
Tony Tam
b9806c183b fixed case 2014-06-05 20:08:37 -07:00
Tony Tam
5aa4c4c999 made snapshot 2014-05-31 16:04:19 -07:00
Tony Tam
424cfac80f updated config 2014-05-30 16:27:54 -07:00
Ivan Porto Carrero
715913f3b4 Update slightly add some test files 2014-05-30 15:17:53 -07:00
Tony Tam
1c2c4fdcd3 removed function override 2014-05-30 15:03:10 -07:00
Ivan Porto Carrero
2ea6c2a3a7 Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-05-30 14:25:57 -07:00
Tony Tam
d91da857a0 removed unused code 2014-05-30 09:59:27 -07:00
Tony Tam
31e65969b3 removed printlns, cruft 2014-05-30 07:53:27 -07:00
Tony Tam
df250bc056 fixed model mapping, refactoring the processing of apiMap and modelMap so it's executed just once 2014-05-30 07:29:19 -07:00
Tony Tam
1569274684 fixed package 2014-05-20 00:14:01 -07:00
Tony Tam
6d8f751da4 added model package 2014-05-19 23:23:23 -07:00
Tony Tam
c2dd00a4ab fixed return type 2014-05-19 15:08:44 -07:00
Tony Tam
9e6ae6eef8 added opts for input 2014-05-15 08:51:41 -04:00
Tony Tam
58b985ba02 moved packages to address collisions with swagger-core per #145 2014-05-14 18:23:32 -04:00
Tony Tam
b4f3143c8c Merge pull request #159 from yanoosh/php-fix-sanitize
PHP - Improved/fixed serialization and deserialize.
2014-05-01 20:31:13 -07:00
Tony Tam
84ad6b5d50 rebuilt docs 2014-05-01 20:19:40 -07:00
Tony Tam
32c14af5ce added resize 2014-05-01 20:18:23 -07:00
Tony Tam
46023c47f5 Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-05-01 20:17:53 -07:00
Tony Tam
71212e5f68 reverted to artifactVersion 2014-05-01 20:16:46 -07:00
Tony Tam
6d1c34048c fix for #176 2014-05-01 20:16:27 -07:00
Tony Tam
f67006057e updated version 2014-05-01 20:14:41 -07:00
Tony Tam
e1e397a7b5 Merge pull request #179 from j-unior/scala-2.10
Added scala 2.10 support in generated maven profile.
2014-05-01 18:03:22 -07:00
Tony Tam
0f35799a77 fixed start script #188 2014-04-29 09:46:49 -07:00
Tony Tam
be44221d98 Merge pull request #187 from earldouglas/return-generated-files
Return files generated from BasicGenerator#generateClientWithoutExit
2014-04-24 16:06:12 -07:00
James Earl Douglas
94ad254a58 Return files generated from BasicGenerator#generateClientWithoutExit 2014-04-24 15:14:41 -07:00
James Earl Douglas
666a4be1f2 Return files generated from Codegen#writeSupportingClasses 2014-04-24 15:12:11 -07:00
James Earl Douglas
e542fbd0a2 De-duplicate code from Codegen#writeSupportingClasses 2014-04-24 15:07:45 -07:00
Pat
f4b2d13aa4 Update README.md 2014-04-09 10:15:08 -07:00
j-unior
abcae6da96 Added scala 2.10 support in generated maven profile. You can enable it with mvn install -P scala_2.10 on generated client 2014-04-01 16:56:08 +03:00
Tony Tam
1b9b3eaa8e Merge pull request #175 from STEAMULO/master
Filename misprint for Android generation
2014-03-25 11:33:03 -07:00
aansel
0babc4f192 Filename misprint for Android generation 2014-03-25 18:44:05 +01:00
webron
e51ffb37b4 Update README.md 2014-03-23 13:16:02 +02:00
Tony Tam
2fba96713c Merge pull request #172 from giovannibotta/master
Minor change to map used when generating supporting files
2014-03-19 08:27:49 -07:00
giodude
dccf8edc25 Minor change to map used when generating supporting files. 2014-03-19 11:18:23 -04:00
webron
d98aeac818 Create LICENSE 2014-03-19 16:08:55 +02:00
webron
62bfc4ea19 Update README.md
Updated license year.
2014-03-19 16:08:38 +02:00
Tony Tam
8d74029fba Merge pull request #170 from hsanjuan/master
Issue #168: Let runscala.sh run from everywhere without breaking
2014-03-18 18:54:28 -07:00
Hector Sanjuan
809cb5cf1f Issue #168: Let runscala.sh run from everywhere without breaking and correctly
setting the classpath
2014-03-17 16:21:36 +01:00
Tony Tam
a4196609c9 added friendly error message when SSL validation fails 2014-03-06 08:29:02 -08:00
Tony Tam
e7eedcf48d removed printlns 2014-03-05 07:54:12 -08:00
Tony Tam
8bf042b153 updated sample with form param support 2014-03-05 07:54:03 -08:00
Tony Tam
8325a12faf fixed hasMore 2014-03-04 20:05:16 -08:00
Tony Tam
03abccd8e8 fix for #154 2014-03-04 19:48:13 -08:00
Janusz Jablonski
19e79fedb2 Added backslash before DateTime object. 2014-03-03 00:40:45 +01:00
Tony Tam
71eacaa3b1 Merge pull request #160 from yanoosh/php-removed-escape
PHP - Removed escapeReservedWord method.
2014-03-02 13:30:08 -08:00
Janusz Jablonski
7cfa46d838 Removed escapeReservedWord method. 2014-03-02 18:31:35 +01:00
Janusz Jablonski
7989e78460 Improved/fixed serialization and deserialize. 2014-03-02 14:44:46 +01:00
Tony Tam
08466f615f Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-02-25 12:54:12 -08:00
Tony Tam
880d14990f added patch support 2014-02-25 12:53:11 -08:00
Tony Tam
39ac8f6d46 added patch support 2014-02-25 12:52:49 -08:00
Tony Tam
685fc7066f Update README.md 2014-02-22 07:21:13 -08:00
Tony Tam
127600e728 Update README.md 2014-02-21 17:29:22 -08:00
Tony Tam
d764328026 updated readme 2014-02-21 17:22:48 -08:00
Tony Tam
cae8296999 updated readme 2014-02-21 17:21:56 -08:00
Tony Tam
86efb71124 updated readme 2014-02-21 17:21:50 -08:00
Tony Tam
0899b08b8c Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-02-21 17:20:16 -08:00
Tony Tam
a770db9d3e added readme 2014-02-21 17:20:06 -08:00
Tony Tam
87b5c43166 Merge pull request #158 from mkantor/objc-safe-var-names
Prevent ObjC generator from producing invalid var names.
2014-02-21 13:41:26 -08:00
Matt Kantor
d14ab2aeff Prevent ObjC generator from producing invalid var names. 2014-02-21 13:35:13 -08:00
Ivan Porto Carrero
b39a609226 Merge branch 'master' of github.com:wordnik/swagger-codegen 2013-11-09 12:18:42 -08:00
Ivan Porto Carrero
d25f64cca0 change to return transpor client in async scala client 2013-11-09 12:18:20 -08:00
609 changed files with 15402 additions and 15350 deletions

1
.gitignore vendored
View File

@@ -28,3 +28,4 @@ target
.lib
atlassian-ide-plugin.xml
.DS_Store
*~

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

@@ -1,11 +1,28 @@
# Swagger Code Generator
[![Build Status](https://travis-ci.org/wordnik/swagger-codegen.png)](https://travis-ci.org/wordnik/swagger-codegen)
[![Build Status](https://travis-ci.org/swagger-api/swagger-codegen.png)](https://travis-ci.org/swagger-api/swagger-codegen)
## Overview
This is the swagger codegen project, which allows generation of client libraries automatically from a
Swagger-compliant server. You can find out more about both the spec and the framework at
http://swagger.wordnik.com. For more information about Wordnik's APIs, please visit http://developer.wordnik.com.
Swagger-compliant server.
## What's Swagger?
The goal of Swagger™ is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined via Swagger, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interfaces have done for lower-level programming, Swagger removes the guesswork in calling the service.
Check out [Swagger-Spec](https://github.com/swagger-api/swagger-spec) for additional information about the Swagger project, including additional libraries with support for other languages and more.
## Compatibility
The Swagger Specification has undergone 3 revisions since initial creation in 2010. Compatibility between swagger-codegen and the Swagger specification is as follows:
Swagger Codegen Version | Release Date | Swagger Spec compatibility | Notes
----------------------- | ------------ | -------------------------- | -----
2.1.0 (in development) | n/a | 1.0, 1.1, 1.2, 2.0 | [branch develop_2.0](https://github.com/swagger-api/swagger-codegen/tree/develop_2.0)
2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/2.0.17)
1.0.4 | 2012-04-12 | 1.0, 1.1 | [tag v1.0.4](https://github.com/swagger-api/swagger-codegen/tree/swagger-codegen_2.9.1-1.1)
### Prerequisites
You need the following installed and available in your $PATH:
@@ -16,7 +33,7 @@ Note! Some folks have had issues with OOM errors with java version "1.6.0_51".
* [Apache maven 3.0.3 or greater](http://maven.apache.org/)
* [Scala 2.9.1](http://www.scala-lang.org)
* [Scala 2.10.4](http://www.scala-lang.org)
* [sbt (only download if you're building on Windows)](http://www.scala-sbt.org/)
@@ -42,7 +59,7 @@ You can build a client against Wordnik's [petstore](http://petstore.swagger.word
./bin/scala-petstore.sh
```
This will run the script in [samples/client/petstore/ScalaPetstoreCodegen.scala](https://github.com/wordnik/swagger-codegen/blob/master/samples/client/petstore/scala/ScalaPetstoreCodegen.scala) and create the client. You can then
This will run the script in [samples/client/petstore/ScalaPetstoreCodegen.scala](https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/scala/ScalaPetstoreCodegen.scala) and create the client. You can then
compile and run the client, as well as unit tests against it:
```
@@ -71,7 +88,7 @@ It's just as easy--you can either run the default generators:
Replace `Scala` with `Flash`, `Java`, `Objc`, `PHP`, `Python`, `Python3`, `Ruby`.
You will probably want to override some of the defaults--like packages, etc. For doing this, just create a scala
script with the overrides you want. Follow [ScalaPetstoreCodegen](https://github.com/wordnik/swagger-codegen/blob/master/samples/client/petstore/scala/ScalaPetstoreCodegen.scala) as an example:
script with the overrides you want. Follow [ScalaPetstoreCodegen](https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/scala/ScalaPetstoreCodegen.scala) as an example:
For example, create `src/main/scala/MyCodegen.scala` with these contents:
@@ -121,15 +138,17 @@ You can look at `src/main/resources/${your-language}` for examples. To make you
and override the `templateDir` in your script to point to the right place. It actually is that easy.
### Where is Javascript???
See our [javascript library](http://github.com/wordnik/swagger.js)--it's completely dynamic and doesn't require
See our [javascript library](http://github.com/swagger-api/swagger-js)--it's completely dynamic and doesn't require
static code generation.
There is a third-party component called [swagger-js-codegen](https://github.com/wcandillon/swagger-js-codegen) that can generate angularjs or nodejs source code from a swagger specification.
#### Generating a client from flat files (i.e. no remote server calls)
If you don't want to call your server, you can save the swagger spec files into a directory and pass an argument
to the code generator like this:
```
-DfileMap=/path/to/files
-DfileMap=/path/to/resource-listing
```
Or for example:
@@ -142,7 +161,7 @@ ci server... or while coding on an airplane.
### Validating your swagger spec
You can use the validation tool to see that your server is creating a proper spec file. If you want to learn
more about the spec file and format, please see [swagger-core](https://github.com/wordnik/swagger-core/wiki). This
more about the spec file and format, please see [swagger-spec](https://github.com/swagger-api/swagger-spec). This
tool will read the server and generate a report of any violations of the spec. If there are violations, the
client codegen and ui may not work correctly.
@@ -162,35 +181,35 @@ If you need to make static pages or don't want the sandbox of the swagger-ui, yo
Will produce the output here:
```
https://github.com/wordnik/swagger-codegen/tree/master/samples/docs/swagger-static-docs
https://github.com/swagger-api/swagger-codegen/tree/master/samples/swagger-static-docs/docs
```
which is based on these templates:
```
https://github.com/wordnik/swagger-codegen/tree/master/src/main/resources/swagger-static
https://github.com/swagger-api/swagger-codegen/tree/master/src/main/resources/swagger-static
```
and looks like this
![Image](https://raw.github.com/wordnik/swagger-codegen/master/samples/docs/swagger-static-docs/static-docs.png)
![Image](https://raw.github.com/swagger-api/swagger-codegen/master/samples/docs/swagger-static-docs/static-docs.png)
### To build a server stub
You can also use the codegen to generate a server for a couple different frameworks. Take a look here:
* [javascript node.js Server generator](https://github.com/wordnik/swagger-codegen/tree/master/samples/server-generator/node)
* [javascript node.js Server generator](https://github.com/swagger-api/swagger-codegen/tree/master/samples/server-generator/node)
* [ruby sinatra generator](https://github.com/wordnik/swagger-codegen/tree/master/samples/server-generator/sinatra)
* [ruby sinatra generator](https://github.com/swagger-api/swagger-codegen/tree/master/samples/server-generator/sinatra)
* [scala scalatra generator](https://github.com/wordnik/swagger-codegen/tree/master/samples/server-generator/scalatra)
* [scala scalatra generator](https://github.com/swagger-api/swagger-codegen/tree/master/samples/server-generator/scalatra)
* [java jax-rs generator](https://github.com/wordnik/swagger-codegen/tree/master/samples/server-generator/java-jaxrs)
* [java jax-rs generator](https://github.com/swagger-api/swagger-codegen/tree/master/samples/server-generator/java-jaxrs)
### Migrating from Swagger 1.1 to 1.2 format
If you've spent time hand-crafting your swagger spec files, you can use the [SpecConverter](https://github.com/wordnik/swagger-codegen/blob/master/src/main/scala/com/wordnik/swagger/codegen/SpecConverter.scala) to do the dirty work. For example:
If you've spent time hand-crafting your swagger spec files, you can use the [SpecConverter](https://github.com/swagger-api/swagger-codegen/blob/master/src/main/scala/com/wordnik/swagger/codegen/SpecConverter.scala) to do the dirty work. For example:
```bash
$ ./bin/update-spec.sh http://developer.wordnik.com/v4/resources.json wordnik-developer
@@ -224,7 +243,7 @@ either repackage the library OR modify your codegen script to use a file path!
License
-------
Copyright 2013 Wordnik, Inc.
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.

View File

@@ -1,7 +1,6 @@
val version = scala.util.Properties.scalaPropOrElse("version.number", "unknown").toString match {
case "2.10.0" => "2.10"
case "2.10.2" => "2.10"
case "2.10.3" => "2.10"
case s if s startsWith "2.10" => "2.10"
case s if s startsWith "2.11" => "2.11"
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,14 +18,15 @@ 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.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ samples/client/petstore/android-java/AndroidJavaPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -25,8 +25,8 @@ cd $APP_DIR
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ samples/client/petstore/android-java/AndroidJavaPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -25,8 +25,8 @@ cd $APP_DIR
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ samples/client/petstore/csharp/CsharpPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -25,8 +25,8 @@ cd $APP_DIR
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties "
ags="$@ samples/client/petstore/flash/FlashPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -22,11 +22,11 @@ cd $APP_DIR
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DfileMap=src/test/resources/petstore-1.1/resources.json -DloggerPath=conf/log4j.properties"
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DfileMap=src/test/resources/petstore-1.2/api-docs -DloggerPath=conf/log4j.properties"
ags="$@ samples/client/petstore/java/JavaPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -25,8 +25,8 @@ cd $APP_DIR
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ samples/client/petstore/java/JavaPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -25,8 +25,8 @@ cd $APP_DIR
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties -DfileMap=samples/client/wordnik-api/spec-files/resources.json"
ags="$@ samples/client/wordnik-api/java/JavaWordnikApiCodegen.scala http://api.wordnik.com/v4/resources.json"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -27,8 +27,8 @@ cd $APP_DIR
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ samples/client/petstore/objc/ObjcPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -22,11 +22,11 @@ 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
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -25,8 +25,8 @@ cd $APP_DIR
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ samples/client/petstore/php/PHPPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -25,8 +25,8 @@ cd $APP_DIR
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties -DfileMap=samples/client/wordnik-api/spec-files/resources.json"
ags="$@ samples/client/wordnik-api/php/PHPWordnikApiCodegen.scala http://api.wordnik.com/v4/resources.json"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -25,8 +25,8 @@ cd $APP_DIR
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ samples/client/petstore/python/PythonPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -25,8 +25,8 @@ cd $APP_DIR
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties -DfileMap=samples/client/wordnik-api/spec-files/resources.json"
ags="$@ samples/client/wordnik-api/python/PythonWordnikApiCodegen.scala http://api.wordnik.com/v4/resources.json"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -25,8 +25,8 @@ cd $APP_DIR
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ samples/client/petstore/python3/Python3PetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -25,8 +25,8 @@ cd $APP_DIR
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties -DfileMap=samples/client/wordnik-api/spec-files/resources.json"
ags="$@ samples/client/wordnik-api/python3/Python3WordnikApiCodegen.scala http://api.wordnik.com/v4/resources.json"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -25,8 +25,8 @@ cd $APP_DIR
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ samples/client/petstore/ruby/RubyPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/*assembly*.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,14 +18,15 @@ 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.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
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
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.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"`
@@ -24,8 +24,8 @@ cd $APP_DIR
# if you've executed sbt assembly previously it will use that instead.
ags="com.wordnik.swagger.codegen.ScalaAsyncClientGenerator $@"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
java -cp target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -25,8 +25,8 @@ cd $APP_DIR
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ samples/client/petstore/scala/ScalaPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -25,8 +25,8 @@ cd $APP_DIR
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties -DfileMap=samples/client/wordnik-api/spec-files/resources.json"
ags="$@ samples/client/wordnik-api/scala/ScalaWordnikApiCodegen.scala http://api.wordnik.com/v4/resources.json"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -22,11 +22,11 @@ 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
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -24,8 +24,8 @@ cd $APP_DIR
# if you've executed sbt assembly previously it will use that instead.
ags="com.wordnik.swagger.codegen.SpecConverter $@"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -24,8 +24,8 @@ cd $APP_DIR
# if you've executed sbt assembly previously it will use that instead.
ags="com.wordnik.swagger.codegen.spec.Validator $@"
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/swagger-codegen.jar $ags
if [ -f $APP_DIR/target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar ]; then
scala -cp target/scala-$SCALA_RUNNER_VERSION/*assembly*.jar $ags
else
echo "Please set scalaVersion := \"$SCALA_RUNNER_VERSION\" in build.sbt and run ./sbt assembly"
fi

View File

@@ -5,9 +5,7 @@ organization := "com.wordnik"
name := "swagger-codegen"
version := "2.0.13"
scalaVersion := "2.10.1"
version := "2.0.18-SNAPSHOT"
crossVersion := CrossVersion.full
@@ -15,33 +13,39 @@ 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.4", "2.11.0", "2.11.1")
scalaVersion := "2.10.4"
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",
"net.iharder" % "base64" % "2.3.8",
"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 +69,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 +134,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 +1 @@
sbt.version=0.13.0
sbt.version=0.13.5

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>
@@ -178,20 +131,26 @@
<version>${httpclient-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>${httpclient-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>${httpclient-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</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>
@@ -202,13 +161,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.3</httpclient-version>
</properties>
</project>

View File

@@ -9,11 +9,20 @@ 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.mime.*;
import org.apache.http.entity.StringEntity;
import org.apache.http.client.entity.UrlEncodedFormEntity;
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 +31,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 +158,24 @@ 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) {
if("application/x-www-form-urlencoded".equals(contentType)) {
post.setHeader("Content-Type", contentType);
post.setEntity(new UrlEncodedFormEntity((List<NameValuePair>)body));
}
else if("multipart/form-data".equals(contentType)) {
String boundary = "-------------" + System.currentTimeMillis();
post.setHeader("Content-type", "multipart/form-data; boundary="+boundary);
MultipartEntityBuilder builder = (MultipartEntityBuilder)body;
builder.setBoundary(boundary);
post.setEntity(builder.build());
}
else {
post.setHeader("Content-Type", contentType);
post.setEntity(new StringEntity(serialize(body), "UTF-8"));
}
}
for(String key : headers.keySet()) {
post.setHeader(key, headers.get(key));
}
@@ -124,8 +184,21 @@ public class ApiInvoker {
else if ("PUT".equals(method)) {
HttpPut put = new HttpPut(url);
if(body != null) {
put.setHeader("Content-Type", contentType);
put.setEntity(new StringEntity(serialize(body), "UTF-8"));
if("application/x-www-form-urlencoded".equals(contentType)) {
put.setHeader("Content-Type", contentType);
put.setEntity(new UrlEncodedFormEntity((List<NameValuePair>)body));
}
else if("multipart/form-data".equals(contentType)) {
String boundary = "-------------" + System.currentTimeMillis();
put.setHeader("Content-type", "multipart/form-data; boundary="+boundary);
MultipartEntityBuilder builder = (MultipartEntityBuilder)body;
builder.setBoundary(boundary);
put.setEntity(builder.build());
}
else {
put.setHeader("Content-Type", contentType);
put.setEntity(new StringEntity(serialize(body), "UTF-8"));
}
}
for(String key : headers.keySet()) {
put.setHeader(key, headers.get(key));
@@ -139,6 +212,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 +252,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,17 @@ 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;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.entity.mime.*;
import org.apache.http.entity.mime.content.*;
import org.apache.http.entity.ContentType;
import android.webkit.MimeTypeMap;
public class PetApi {
String basePath = "http://petstore.swagger.wordnik.com/api";
@@ -17,16 +25,243 @@ public class PetApi {
public ApiInvoker getInvoker() {
return apiInvoker;
}
public void setBasePath(String basePath) {
this.basePath = basePath;
}
public String getBasePath() {
return basePath;
}
public Pet getPetById (Long petId) throws ApiException {
private static String getMimeType(File file) {
MimeTypeMap mime = MimeTypeMap.getSingleton();
int index = file.getName().lastIndexOf('.')+1;
String ext = file.getName().substring(index).toLowerCase();
return mime.getMimeTypeFromExtension(ext);
}
//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");
}
// create path and map variables
String path = "/pet".replaceAll("\\{format\\}","json");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("application/x-www-form-urlencoded")) {
boolean hasFields = false;
List<NameValuePair> mp = new ArrayList<NameValuePair>();
if(hasFields)
postBody = mp;
}
else if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(hasFields)
postBody = builder;
}
else {
postBody = body;
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, postBody, 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");
}
// create path and map variables
String path = "/pet".replaceAll("\\{format\\}","json");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String[] contentTypes = {
"application/json","application/xml"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("application/x-www-form-urlencoded")) {
boolean hasFields = false;
List<NameValuePair> mp = new ArrayList<NameValuePair>();
if(hasFields)
postBody = mp;
}
else if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(hasFields)
postBody = builder;
}
else {
postBody = body;
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, 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 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");
}
// create path and map variables
String path = "/pet/findByStatus".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(status)))
queryParams.put("status", String.valueOf(status));
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("application/x-www-form-urlencoded")) {
boolean hasFields = false;
List<NameValuePair> mp = new ArrayList<NameValuePair>();
if(hasFields)
postBody = mp;
}
else if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(hasFields)
postBody = builder;
}
else {
postBody = null;
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, 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: 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");
}
// create path and map variables
String path = "/pet/findByTags".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(tags)))
queryParams.put("tags", String.valueOf(tags));
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("application/x-www-form-urlencoded")) {
boolean hasFields = false;
List<NameValuePair> mp = new ArrayList<NameValuePair>();
if(hasFields)
postBody = mp;
}
else if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(hasFields)
postBody = builder;
}
else {
postBody = null;
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, 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 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");
@@ -38,10 +273,92 @@ public class PetApi {
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = 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("application/x-www-form-urlencoded")) {
boolean hasFields = false;
List<NameValuePair> mp = new ArrayList<NameValuePair>();
hasFields = true;
mp.add(new BasicNameValuePair("name", name));
hasFields = true;
mp.add(new BasicNameValuePair("status", status));
if(hasFields)
postBody = mp;
}
else if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
hasFields = true;
builder.addTextBody("name", name.toString());
hasFields = true;
builder.addTextBody("status", status.toString());
if(hasFields)
postBody = builder;
}
else {
postBody = null;
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, 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");
}
// 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[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("application/x-www-form-urlencoded")) {
boolean hasFields = false;
List<NameValuePair> mp = new ArrayList<NameValuePair>();
if(hasFields)
postBody = mp;
}
else if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(hasFields)
postBody = builder;
}
else {
postBody = null;
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, contentType);
if(response != null){
return (Pet) ApiInvoker.deserialize(response, "", Pet.class);
}
@@ -57,7 +374,9 @@ 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");
@@ -69,10 +388,30 @@ public class PetApi {
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("application/x-www-form-urlencoded")) {
boolean hasFields = false;
List<NameValuePair> mp = new ArrayList<NameValuePair>();
if(hasFields)
postBody = mp;
}
else if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(hasFields)
postBody = builder;
}
else {
postBody = null;
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, postBody, headerParams, contentType);
if(response != null){
return ;
}
@@ -88,7 +427,9 @@ public class PetApi {
}
}
}
//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");
@@ -100,12 +441,32 @@ public class PetApi {
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = 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("application/x-www-form-urlencoded")) {
boolean hasFields = false;
List<NameValuePair> mp = new ArrayList<NameValuePair>();
if(hasFields)
postBody = mp;
}
else if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(hasFields)
postBody = builder;
}
else {
postBody = body;
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "PATCH", queryParams, body, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "PATCH", queryParams, postBody, 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;
@@ -119,38 +480,8 @@ 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;
}
}
}
public void uploadFile (String additionalMetadata, File body) throws ApiException {
public void uploadFile (String additionalMetadata, File file) throws ApiException {
Object postBody = null;
// create path and map variables
String path = "/pet/uploadImage".replaceAll("\\{format\\}","json");
@@ -158,10 +489,36 @@ public class PetApi {
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
String[] contentTypes = {
"multipart/form-data"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("application/x-www-form-urlencoded")) {
boolean hasFields = false;
List<NameValuePair> mp = new ArrayList<NameValuePair>();
hasFields = true;
mp.add(new BasicNameValuePair("additionalMetadata", additionalMetadata));
if(hasFields)
postBody = mp;
}
else if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
hasFields = true;
builder.addTextBody("additionalMetadata", additionalMetadata.toString());
hasFields = true;
builder.addBinaryBody("file", file, ContentType.create(getMimeType(file)), file.getName());
if(hasFields)
postBody = builder;
}
else {
postBody = null;
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, contentType);
if(response != null){
return ;
}
@@ -177,133 +534,5 @@ public class PetApi {
}
}
}
public void addPet (Pet 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 = "/pet".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;
}
}
}
public void updatePet (Pet 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 = "/pet".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, "PUT", queryParams, body, headerParams, contentType);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return ;
}
else {
throw ex;
}
}
}
public List<Pet> findPetsByStatus (String status) throws ApiException {
// verify required params are set
if(status == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/pet/findByStatus".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(status)))
queryParams.put("status", String.valueOf(status));
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, 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;
}
}
}
public List<Pet> findPetsByTags (String tags) throws ApiException {
// verify required params are set
if(tags == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String path = "/pet/findByTags".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(tags)))
queryParams.put("tags", String.valueOf(tags));
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, 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;
}
}
}
}

View File

@@ -4,6 +4,15 @@ import com.wordnik.client.ApiException;
import com.wordnik.client.ApiInvoker;
import com.wordnik.petstore.model.Order;
import java.util.*;
import java.io.File;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.entity.mime.*;
import org.apache.http.entity.mime.content.*;
import org.apache.http.entity.ContentType;
import android.webkit.MimeTypeMap;
public class StoreApi {
String basePath = "http://petstore.swagger.wordnik.com/api";
@@ -16,16 +25,79 @@ 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 {
private static String getMimeType(File file) {
MimeTypeMap mime = MimeTypeMap.getSingleton();
int index = file.getName().lastIndexOf('.')+1;
String ext = file.getName().substring(index).toLowerCase();
return mime.getMimeTypeFromExtension(ext);
}
//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(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[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("application/x-www-form-urlencoded")) {
boolean hasFields = false;
List<NameValuePair> mp = new ArrayList<NameValuePair>();
if(hasFields)
postBody = mp;
}
else if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(hasFields)
postBody = builder;
}
else {
postBody = body;
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, 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 void deleteOrder (String orderId) throws ApiException {
Object postBody = null;
// verify required params are set
if(orderId == null ) {
throw new ApiException(400, "missing required params");
@@ -37,10 +109,84 @@ public class StoreApi {
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("application/x-www-form-urlencoded")) {
boolean hasFields = false;
List<NameValuePair> mp = new ArrayList<NameValuePair>();
if(hasFields)
postBody = mp;
}
else if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(hasFields)
postBody = builder;
}
else {
postBody = null;
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, postBody, 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 {
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>();
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("application/x-www-form-urlencoded")) {
boolean hasFields = false;
List<NameValuePair> mp = new ArrayList<NameValuePair>();
if(hasFields)
postBody = mp;
}
else if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(hasFields)
postBody = builder;
}
else {
postBody = null;
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, contentType);
if(response != null){
return (Order) ApiInvoker.deserialize(response, "", Order.class);
}
@@ -56,67 +202,5 @@ public class StoreApi {
}
}
}
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;
}
}
}
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

@@ -4,6 +4,15 @@ import com.wordnik.client.ApiException;
import com.wordnik.client.ApiInvoker;
import com.wordnik.petstore.model.User;
import java.util.*;
import java.io.File;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.entity.mime.*;
import org.apache.http.entity.mime.content.*;
import org.apache.http.entity.ContentType;
import android.webkit.MimeTypeMap;
public class UserApi {
String basePath = "http://petstore.swagger.wordnik.com/api";
@@ -16,47 +25,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 {
// 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);
if(response != null){
return ;
}
else {
return ;
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return ;
}
else {
throw ex;
}
}
private static String getMimeType(File file) {
MimeTypeMap mime = MimeTypeMap.getSingleton();
int index = file.getName().lastIndexOf('.')+1;
String ext = file.getName().substring(index).toLowerCase();
return mime.getMimeTypeFromExtension(ext);
}
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");
@@ -68,10 +54,30 @@ public class UserApi {
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("application/x-www-form-urlencoded")) {
boolean hasFields = false;
List<NameValuePair> mp = new ArrayList<NameValuePair>();
if(hasFields)
postBody = mp;
}
else if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(hasFields)
postBody = builder;
}
else {
postBody = body;
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, contentType);
if(response != null){
return ;
}
@@ -88,6 +94,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");
@@ -99,10 +106,30 @@ public class UserApi {
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("application/x-www-form-urlencoded")) {
boolean hasFields = false;
List<NameValuePair> mp = new ArrayList<NameValuePair>();
if(hasFields)
postBody = mp;
}
else if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(hasFields)
postBody = builder;
}
else {
postBody = body;
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, contentType);
if(response != null){
return ;
}
@@ -118,7 +145,10 @@ public class UserApi {
}
}
}
//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 || body == null ) {
throw new ApiException(400, "missing required params");
@@ -130,10 +160,30 @@ public class UserApi {
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("application/x-www-form-urlencoded")) {
boolean hasFields = false;
List<NameValuePair> mp = new ArrayList<NameValuePair>();
if(hasFields)
postBody = mp;
}
else if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(hasFields)
postBody = builder;
}
else {
postBody = body;
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, body, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, postBody, headerParams, contentType);
if(response != null){
return ;
}
@@ -149,7 +199,10 @@ public class UserApi {
}
}
}
//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");
@@ -161,10 +214,30 @@ public class UserApi {
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("application/x-www-form-urlencoded")) {
boolean hasFields = false;
List<NameValuePair> mp = new ArrayList<NameValuePair>();
if(hasFields)
postBody = mp;
}
else if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(hasFields)
postBody = builder;
}
else {
postBody = null;
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, postBody, headerParams, contentType);
if(response != null){
return ;
}
@@ -180,7 +253,10 @@ public class UserApi {
}
}
}
//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");
@@ -192,10 +268,30 @@ public class UserApi {
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("application/x-www-form-urlencoded")) {
boolean hasFields = false;
List<NameValuePair> mp = new ArrayList<NameValuePair>();
if(hasFields)
postBody = mp;
}
else if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(hasFields)
postBody = builder;
}
else {
postBody = null;
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, contentType);
if(response != null){
return (User) ApiInvoker.deserialize(response, "", User.class);
}
@@ -211,7 +307,9 @@ public class UserApi {
}
}
}
//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");
@@ -227,10 +325,30 @@ public class UserApi {
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("application/x-www-form-urlencoded")) {
boolean hasFields = false;
List<NameValuePair> mp = new ArrayList<NameValuePair>();
if(hasFields)
postBody = mp;
}
else if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(hasFields)
postBody = builder;
}
else {
postBody = null;
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, contentType);
if(response != null){
return (String) ApiInvoker.deserialize(response, "", String.class);
}
@@ -247,6 +365,7 @@ public class UserApi {
}
}
public void logoutUser () throws ApiException {
Object postBody = null;
// create path and map variables
String path = "/user/logout".replaceAll("\\{format\\}","json");
@@ -254,10 +373,82 @@ public class UserApi {
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
String contentType = "application/json";
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("application/x-www-form-urlencoded")) {
boolean hasFields = false;
List<NameValuePair> mp = new ArrayList<NameValuePair>();
if(hasFields)
postBody = mp;
}
else if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(hasFields)
postBody = builder;
}
else {
postBody = null;
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, 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 {
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>();
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("application/x-www-form-urlencoded")) {
boolean hasFields = false;
List<NameValuePair> mp = new ArrayList<NameValuePair>();
if(hasFields)
postBody = mp;
}
else if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(hasFields)
postBody = builder;
}
else {
postBody = body;
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, 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

@@ -4,21 +4,16 @@ import com.fasterxml.jackson.annotation.JsonProperty;
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)

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