Compare commits

..

173 Commits

Author SHA1 Message Date
Tony Tam
371a021ef5 Merge pull request #3549 from swagger-api/release-prepare
updated versions for release
2016-08-07 23:02:24 +02:00
Tony Tam
be3a49183e Merge branch 'master' into release-prepare 2016-08-07 18:41:16 +02:00
Tony Tam
5f67ec021d Merge pull request #3551 from wing328/java_fix_okhttp_model
[Java] Fix @JsonCreator annotation issue with Java API clients using gson
2016-08-07 18:40:29 +02:00
wing328
d8cdcbf042 fix jsoncreator annotation issue with java api clients using gson 2016-08-08 00:16:12 +08:00
Tony Tam
c147cfde1b updated release versions 2016-08-07 11:49:01 +02:00
wing328
e8095c6a04 Merge pull request #3543 from guohuang/compile_issue2
[GO] Fixing compilation issue when pathParams  is not presented
2016-08-06 14:07:00 +08:00
wing328
c220dbb2f5 Merge pull request #3541 from expectedbehavior/configuration-misspelling
Fix spelling in ruby ApiClient: Configuraiton -> Configuration
2016-08-06 13:10:46 +08:00
Guo Huang
bef5c74da7 removed unneeded "errors" import 2016-08-05 21:34:04 -07:00
Guo Huang
ab96b318e2 [GO] Fixing compilation issue when pathParams is not presented 2016-08-05 14:53:05 -07:00
Joel Meador
950fb43fdf fix spelling in ruby ApiClient: Configuraiton -> Configuration 2016-08-05 14:36:08 -04:00
Tony Tam
1f58526615 updated to release version of parser 2016-08-05 19:42:21 +02:00
wing328
148a842f3b fix #2538 (#3535) 2016-08-05 18:09:00 +08:00
Tony Tam
b74c1b98a2 updated version 2016-08-05 10:32:06 +02:00
Tony Tam
e6f6e66167 Merge branch 'master' of github.com:swagger-api/swagger-codegen 2016-08-05 10:31:24 +02:00
wing328
47738f6cd6 [Sinatra][Nancyfx] fix enum in Sinatra and nancyfx (#3532)
* fix enum in sintra and nancyfx

* add isContainer check for sinatra allowable value

* fix EOL in nancyfx enum template
2016-08-05 16:30:59 +08:00
Tony Tam
f82d4fa033 updated version 2016-08-05 09:09:45 +02:00
Tony Tam
ce7a5682d5 version update 2016-08-05 08:54:36 +02:00
Tony Tam
125338a081 updated parser 2016-08-05 08:53:13 +02:00
wing328
41ffc70d93 Merge pull request #3531 from wing328/java_test_enum
[Java] add enum test cases for Jackson, Gson
2016-08-05 12:19:24 +08:00
wing328
d76c7cc5e8 add test cases for jersey1 enum 2016-08-05 11:49:34 +08:00
wing328
a2496df401 add test case for okthtp-gson enum 2016-08-05 11:45:51 +08:00
wing328
122af80881 better symbol mapping for enum name 2016-08-05 11:28:07 +08:00
wing328
89fe3403a7 add enum test case for jersey2 2016-08-05 01:57:34 +08:00
wing328
5b4eb96ba1 Merge pull request #3519 from wing328/enum_name_mapping
[Java] better enum naming for symbol
2016-08-04 17:06:46 +08:00
wing328
670f103859 better enum naming for symbol (java) 2016-08-04 16:37:48 +08:00
wing328
d5bf43b824 Merge pull request #3511 from wing328/bug/3355
[Java][Spring] fix models with enum properties
2016-08-03 19:02:18 +08:00
wing328
3238fd2853 ignore 2 test cases in spring cloud client 2016-08-03 18:43:43 +08:00
wing328
0547f0d6d8 fix spring enum model 2016-08-03 16:38:02 +08:00
wing328
3dc31ced8e update https to http for Germin8 2016-08-03 16:37:17 +08:00
wing328
7d8c9dc40a add Germin8 2016-08-03 16:36:08 +08:00
wing328
81f981c54d Merge pull request #3506 from wing328/fix_array_enum
[JaxRS][PHP] Fix issue with enum
2016-08-03 14:50:05 +08:00
wing328
26c33d344d Merge pull request #3507 from chrislewis/gen-readme-typo
s/It's/Its
2016-08-03 12:14:36 +08:00
wing328
5103045246 Merge pull request #3504 from himanshu-mishra/issue-3502
Using baseName in place of paramName in request header. Closes #3502
2016-08-03 10:50:57 +08:00
Chris Lewis
3bd01b988e s/It's/Its 2016-08-02 15:50:25 -04:00
wing328
811b5940eb update jaxrs with better test, fix enum issue, patch operation 2016-08-03 01:36:34 +08:00
wing328
1fde95f997 fix java okhttp (array of enum property) 2016-08-03 01:36:34 +08:00
wing328
25fa3e86f9 add enumName to store the enum prefix 2016-08-03 01:36:13 +08:00
wing328
0b8acb5b0c set allowablevalues of inner enum's allowablevalues 2016-08-03 01:35:58 +08:00
Himanshu Mishra
24d8c621c2 Using baseName in place of paramName in request header. Closes #3502 2016-08-02 21:38:26 +05:30
wing328
bbe422947f Merge pull request #3501 from wing328/revert_3391_2
Revert "Merge branch 'feature/objc-tasks' of https://github.com/wberger/swagger-codegen"
2016-08-02 18:28:15 +08:00
wing328
ed9dea6a89 Revert "Merge branch 'feature/objc-tasks' of https://github.com/wberger/swagger-codegen"
This reverts commit 7c1daab896, reversing
changes made to aa58497247.
2016-08-02 17:49:55 +08:00
wing328
7bd37468bc Merge pull request #3496 from Kvezon/jersey2-byte-array-deserialize
Support byte[] downloading in Java jersey2 client
2016-08-02 16:24:40 +08:00
wing328
390ec38ec7 Merge pull request #3482 from cliffano/master
[Java] Add maven-javadoc-plugin in pom.xml of generated Java client.
2016-08-02 16:19:29 +08:00
wing328
1886abb9f9 Merge pull request #3487 from szantopeter/master
fixing bug of rendering an extra spaces into @FeignClient annotation
2016-08-01 23:12:39 +08:00
Kvezon
ef526422e9 Support byte[] downloading in Java jersey2 client 2016-08-01 16:33:58 +03:00
Peter Szanto
9cc4e1fee0 updated readme.md 2016-08-01 15:16:00 +02:00
Peter Szanto
abd5b3f4de regenerated the spring-cloud sample 2016-08-01 14:50:09 +02:00
wing328
103cc7410b Merge pull request #3494 from osher/patch-1
NodeJS generator - Harken to the the warnings ...
2016-08-01 20:43:18 +08:00
osher
30776d75a9 NodeJS generator - Harken to the the warnings ...
2 types of warnings are emitted in bulk whenever using the nodeJS generator.

I did some guesswork: since JS is a c-type language like C# and Java - I looked there for reference, and followed their example.
2016-08-01 13:40:29 +03:00
wing328
f5e20b4e88 Merge pull request #3493 from arnested/php/Client_properties_validation-3480
[PHP] Fix invalid PHP syntax
2016-08-01 18:06:56 +08:00
Arne Jørgensen
aacc235665 [PHP] Regenerate petstore samples 2016-08-01 11:48:52 +02:00
Arne Jørgensen
cfe8dfc112 [PHP] Fix invalid PHP syntax
Fixes 3480.
2016-08-01 11:46:57 +02:00
wing328
df05295f40 add confluence wiki 2016-08-01 17:35:05 +08:00
wing328
61b86c74fb Merge branch 'jhitchcock-feature/confluencewikidocs' 2016-08-01 17:30:04 +08:00
wing328
c6e6a6560a add shell script for cwiki 2016-08-01 17:29:27 +08:00
wing328
1bdd15c55c Merge branch 'feature/confluencewikidocs' of https://github.com/jhitchcock/swagger-codegen into jhitchcock-feature/confluencewikidocs 2016-08-01 17:25:20 +08:00
wing328
85c8eb3d76 Merge branch 'master' of https://github.com/swagger-api/swagger-codegen 2016-08-01 17:25:13 +08:00
wing328
4895a35200 Merge pull request #3492 from wing328/ruby_optional_validation
[Ruby] fix validation for optional parameters/properties for ruby
2016-08-01 17:12:39 +08:00
wing328
8c357dd1d6 fix validation for optional parameters/properties for ruby 2016-08-01 16:50:11 +08:00
wing328
fa7bd21420 add template owner for html doc 2 2016-08-01 16:17:24 +08:00
wing328
434b4fd359 Merge pull request #3447 from jhitchcock/feature/static-docs-2
[WIP] - Html Docs 2 - API and Client Library Documentation - Feedback / Assistance wanted
2016-08-01 16:13:16 +08:00
Arne Jørgensen
0f8e1f8105 [PHP] Client properties validation #3457 (#3480)
* [PHP] Avoid validation of unset, optional parameters

Fixes #3457.

* [PHP] Regenerate petstore samples
2016-08-01 15:24:47 +08:00
abcsun
d7c959fe42 [PHP] add AbstractPhpCodegen to be as the base class of PHP-related generators (#3310)
* add abstractPhpCodegen

* This base class should provide common functions to PHP-related generators so that the same enhancements or bug fixes can be applied to all clients.

Most source be moved from the PhpClientCodegen.

* change Lumen codegen to use the AbstractPhpCodegen

* remove the composerVendorName/composerProjectName. modify the LumenServerOptionsTest for unit test

* add context path

* reserve the apiDocPath and modelDocPath

* add the templateDir for lumen
2016-08-01 15:23:35 +08:00
wing328
3d7ff26c67 [C#] Add C# Petstore test to AppVeyor (#3489)
* update appveyor.yml to test c# petstore client

* update csproj file

* add docker version test

* add docker version

* add docker

* add cpuid.ps1

* comment out cpuid

* use start process

* remove mvn test

* remove comments related to docker

* fix appveyor to run local petstore, shippable caching turned on

* add comments to ci config

* remove cpuid.ps1

* update C# petstore sample
2016-07-31 22:37:06 +08:00
wing328
2d491dce71 Merge branch 'master' of https://github.com/swagger-api/swagger-codegen 2016-07-31 10:33:47 +08:00
Peter Szanto
c91b004b0b fixing bug of rendering an extra spaces into @FeignClient annotation properties 2016-07-31 04:16:22 +02:00
wing328
75cd4bf437 add shippable badge, update travis badge 2016-07-31 10:07:04 +08:00
wing328
7c1daab896 Merge branch 'feature/objc-tasks' of https://github.com/wberger/swagger-codegen 2016-07-30 16:17:08 +08:00
jhitchcock
c377153336 Confluence Wiki Documentation 2016-07-29 12:09:03 +02:00
wing328
aa58497247 add decentfox 2016-07-29 10:38:51 +08:00
wing328
293096f565 Merge pull request #3476 from philicious/qt5-generator-fixes
Qt5: Added missing datatype handlers for QByteArray for swagger-type "byte"
2016-07-29 09:43:50 +08:00
wing328
4e17221494 Merge pull request #3471 from cbornet/fluent_containers
[JAVA] Add fluent methods to add items to list and put items to maps
2016-07-29 09:33:31 +08:00
wing328
33b33cb384 add Skurt to company list 2016-07-29 08:04:46 +08:00
philicious
a67f168fa6 Qt5: add handling for swagger type-format "byte" to Qt5 generator 2016-07-28 19:34:45 +02:00
philicious
b2cb215741 Qt5: added missing data type handler for QByteArray to SWGHelper 2016-07-28 19:29:33 +02:00
Cliffano Subagio
8d4cfcae78 Add maven-javadoc-plugin in pom.xml of generated Java client. 2016-07-28 23:06:57 +10:00
wing328
46a222088e update go petstore sample 2016-07-28 00:24:36 +08:00
wing328
c8764fe0d0 Merge pull request #3470 from neilotoole/issue-3469-unused-errors-import
[Go] removed unused import
2016-07-28 00:20:24 +08:00
cbornet
3b4465d999 add fluent methods to add items to list and put items to maps 2016-07-27 18:18:48 +02:00
Neil O'Toole
75403f1900 removed unused import 2016-07-27 09:35:04 -06:00
wing328
34137c703b Merge pull request #3467 from wing328/bug/fix_3396
[Haskell] fix casting issue with ModelImpl in Haskell generator
2016-07-27 18:40:49 +08:00
wing328
3cd37bf5e9 fix casting issue with ModelImpl in Haskell 2016-07-27 18:07:35 +08:00
wing328
c23b473636 [Go] update travis config to run Go Petstore tests (#3465)
* update pom to include go ci

* fix pom

* add gopath

* update GOPATH

* reorder pom client, server test sequence

* remove debug echo in travis
2016-07-27 16:19:23 +08:00
wing328
748eaa849e Merge pull request #3463 from neilotoole/issue-3462-caseified-query-param
Issue 3462 caseified query param
2016-07-27 16:18:58 +08:00
wing328
0675f1686e Merge pull request #3460 from neilotoole/issue-3459_bad_required_checking
Issue #3459 removed check for required params
2016-07-27 16:18:49 +08:00
Neil O'Toole
154d0fc9de #3462 using base name in request instead of caseified paramName 2016-07-26 18:11:36 -06:00
Neil O'Toole
39228c7c94 #3459 removed check for required params 2016-07-26 15:07:57 -06:00
wing328
0beb4aa303 Merge pull request #3458 from wing328/go_fix_apikey
[Go] fix API key issue with Go client
2016-07-27 01:17:03 +08:00
wing328
743219aa08 fix apikey issue with go client 2016-07-26 23:05:08 +08:00
wing328
81f5108bac [Scala][Scalatra] Include scalatra pestore in the CI tests (#3456)
* add CI coverage for scalatra server

* move scalatra test to the end
2016-07-26 16:04:54 +08:00
wing328
2b66128954 Merge pull request #3454 from wing328/bug/fix_3223
Clear import mapping for gnereators that do not use it
2016-07-26 15:47:34 +08:00
Yi
b3403015fd fix scalatra path with basepath (#1425) (#3448) 2016-07-26 14:49:33 +08:00
wing328
9489f7d3eb clear import mapping for gnereators that do not use it 2016-07-26 14:40:29 +08:00
wing328
30c2503f9f [C#][NancyFX] Better "Add" for Dictionary and using {{packageName}} for NancyFX (#3449)
* use square bucket for C# dictionary

* use packageName for nancyfx generator, update info to debug for log

* use packageName for nancyfx generator, update info to debug for log
2016-07-26 14:10:48 +08:00
wing328
8184732da2 Merge pull request #3442 from jimschubert/csharp/3441
[C#] RootNamespace/AssemblyName use packageName
2016-07-25 21:50:04 +08:00
jhitchcock
aaba4b9e82 Html Docs 2 - API and Client Library Documentation 2016-07-25 15:36:05 +02:00
Jim Schubert
52cfd0f86f [C#] RootNamespace/AssemblyName use packageName
Uses packageName instead of packageTitle for RootNamespace and
AssemblyName in the C# generate client project. packageTitle is intended
to add additional information to AssemblyInfo.cs, and changing
packageTitle to non-FQN text breaks adding new files to the project.

packageTitle, per CodegenConstants description:

"Specifies an AssemblyTitle for the .NET Framework global assembly
attributes stored in the AssemblyInfo file."
2016-07-24 11:21:06 -04:00
Christian Loitsch
bf17a91275 dart codegen improvements (#3440)
* fix: query params may be ints as well

don't assume query params are Strings or List<String>s

* fix dart: use correct type for QueryParams

type is Iterable, not List

only check params for != null if they haven't been checked already

add some casts to make strong mode happy

update petstore

* feat dart: enable strong mode

* feat dart: generate both browser and vm library

move petstore client into subdirectory and reference
generated libraries using path in pubspec.yaml

* feat dart: refactor petstore test.

The new layout resembles a real project.

petstore test is now strong mode compatible.

* feat: add DateTimerParser transformer

* feat: improved exception reporting

* feat[dart]: handle patch requests

* fix[dart]: typo

* fix dart: remove findPetsByTag test; enable strong-mode

find pets by tag call is deprecated and returns 500

generated library is now strong mode compatible
2016-07-23 23:45:22 +08:00
wing328
a1e7c517d3 add 2.30 and 2.2.1 milestones 2016-07-22 11:23:45 +08:00
Tao Qian
55bf8b1f96 Stop Shortening Underscore in Enum Value (#3401)
* stop shortening underscore

* use 4 space indentation

* remove fake class and use anonymous class instead

* rename
2016-07-21 21:37:54 +08:00
ozialien
d5528e5d2a jmockit-surefire-fix (#3429) 2016-07-21 21:36:56 +08:00
wing328
13ec3dc6bb [C#] fix remaining reference to NUnit 3.2.1 (#3433)
* fix remaining reference to 3.2.1 of nunit

* fix nunit runner path
2016-07-21 21:23:40 +08:00
wing328
f74bf84017 download C# nunit to 2.x (#3432) 2016-07-21 18:17:43 +08:00
wing328
a916696f28 fix #3427 using String() (#3431) 2016-07-21 17:44:10 +08:00
guohuang
f6c523bcd6 fixed all routing to v2 (#3428) 2016-07-21 11:44:43 +08:00
delenius
c888434580 Improve jsdoc for API return values (#3327)
* Add jsdoc for usePromises, add @link for callbacks

* Update petstore samples

* Improve jsdoc for void return type + usePromises

* Add back curly brackets correctly in model template

* Add link to Promise doc in jsdoc comment

* Fix jsdoc annotation for callApi method

The return type annotation was also broken here.
2016-07-20 20:14:51 +08:00
Tao Qian
8818cf9ff4 raise Exception instead of str (#3322) 2016-07-20 20:06:48 +08:00
abcsun
bee6803bcb add context path (#3425) 2016-07-20 19:06:14 +08:00
Chris Jang
9c7710e695 Factory interface for typescript-fetch (#3398)
* Added Factory interface for typescript-fetch

* added tests

* Removed 'this.'

* Added Factory interface for typescript-fetch

* added tests

* Removed 'this.'
2016-07-20 18:00:52 +08:00
Andy
dfe4944552 Fix #3400 - incorrect MinLength and MaxLength on partial_model_generic.mustache template (#3415)
* fix maxLength and Regexp issue

* more fix

* revert some changes
2016-07-20 16:52:07 +08:00
wing328
97855baf83 Merge pull request #3423 from wing328/bug/fix-3418
[PHP][Silex] fix contextpath for index.php
2016-07-20 16:30:47 +08:00
wing328
889549a352 fix contextpath for php silex 2016-07-20 16:13:06 +08:00
wing328
269c657471 Merge pull request #3422 from wing328/bug/fix-3418
[PHP][Slim] Add missing context path
2016-07-20 16:05:25 +08:00
wing328
9fcb8a310d fix #3418 - slim missing contextpath 2016-07-20 15:49:41 +08:00
wing328
d16b761aaf Merge pull request #3407 from lunat/csharp_api_key_header_issue_3295
Csharp api key header issue 3295
2016-07-20 15:29:53 +08:00
wing328
7fbb499ad1 Merge pull request #3266 from ButterflyNetwork/swift-binary
[Swift] Handle binary data types
2016-07-19 23:19:01 +08:00
Jason Gavris
4f0b7dfaed [Swift] Handle binary data types 2016-07-19 11:05:40 -04:00
wing328
ef857176a6 Merge pull request #3397 from ButterflyNetwork/swift-podspec
[Swift] Fix pod authors in podspec
2016-07-19 23:00:52 +08:00
Jason Gavris
9e6896c8f0 [Swift] Fix pod authors in podspec 2016-07-19 10:37:20 -04:00
wing328
72be69d2ed Run petstore.swagger.io locally (#3411)
* update travis to run petstore server locally

* fix docker command

* update travis with addon

* add comment to travis.yml
2016-07-19 22:36:10 +08:00
wing328
5001b54eca update maintainer for spring-related generator 2016-07-19 20:50:22 +08:00
lunat
92e8efde1a Csharp api key header issue 3295 2016-07-19 14:37:03 +02:00
lunat
41bab483e0 Issue #3295
[csharp] header problem due to static method for adding header
2016-07-19 12:45:52 +02:00
wing328
b8f6667f00 Merge pull request #3329 from ant3/JSR310-Clients
[Java] Add support for JSR310 in Jersey Clients (v4)
2016-07-19 17:40:02 +08:00
wing328
ca4a90d64d Merge pull request #3404 from wing328/objc_fix_empty_desc
To set a default description if none is provided
2016-07-19 17:09:01 +08:00
wing328
37404909bf to set a default description if none is provided 2016-07-19 16:55:39 +08:00
wing328
118fd4d84d Merge pull request #3393 from cbornet/java_inheritance
Set supportInheritance to true for java based gens
2016-07-19 16:15:53 +08:00
wing328
207622a8f8 Merge pull request #3402 from wing328/ruby_fix_minlength
[Ruby] Fix minLength, maxLength
2016-07-19 15:58:51 +08:00
wing328
d780e3a5f5 fix #3400 (ruby minLenght, maxLength) 2016-07-19 15:16:07 +08:00
wing328
b9479ae8b7 Merge pull request #3271 from ButterflyNetwork/swift-uuid
[Swift] Add support for NSUUID
2016-07-19 14:16:45 +08:00
wing328
60af9e7a83 Merge pull request #3375 from ButterflyNetwork/swift-progress
[Swift] Expose NSProgress to RequestBuilder
2016-07-19 13:46:50 +08:00
wing328
77097ec76a Merge pull request #3364 from michaelkourlas/michaelkourlas-patch-1
Correct reference to ApiClient default instance
2016-07-19 13:44:52 +08:00
wing328
323c778059 Merge pull request #3378 from ButterflyNetwork/python-flaky-test
[Python] Fix flaky test with id collisions
2016-07-19 13:30:46 +08:00
wing328
b3a6535d1e Merge pull request #3385 from wing328/fix_mvn_warning
Fix maven warning and update maven plug-ins to the latest version
2016-07-19 13:10:49 +08:00
wing328
dc8eb8e8ad Merge pull request #3394 from clasnake/3171/scalatra_petstore_error
Fix the scalatra petstore sample compile error.
2016-07-19 13:10:26 +08:00
Jason Gavris
cd79ae1ab4 [Swift] Add support for NSUUID 2016-07-18 23:30:01 -04:00
Jason Gavris
87b79e5946 [Swift] Expose NSProgress to RequestBuilder 2016-07-18 23:29:29 -04:00
Jason Gavris
be65a26db0 [Python] Fix flaky test with id collisions 2016-07-18 23:29:17 -04:00
wing328
3659767e0a Merge pull request #3399 from cbornet/fix_jetty
Make jersey tests wait that jetty is closed before terminating
2016-07-19 11:18:46 +08:00
cbornet
34d3a5e8d0 make jersey tests wait that jetty is closed before terminating 2016-07-18 23:21:12 +02:00
clasnake
5e4e84ffe7 Fix the scalatra petstore sample compile error. 2016-07-18 23:58:03 +08:00
cbornet
421c462ba9 set supportInheritance to true for java based gens 2016-07-18 16:33:20 +02:00
wing328
0d9878373c Merge pull request #3377 from ButterflyNetwork/maven-cache
[Travis] Cache maven directory
2016-07-18 22:18:00 +08:00
wing328
4da6ecf6a6 Merge pull request #3384 from keithballdotnet/patch-1
[Go] ParameterToString can panic
2016-07-18 22:17:12 +08:00
Wolfgang Berger
d4611e4645 remove custom codegen 2016-07-18 13:05:07 +02:00
Wolfgang Berger
f37bd4ab49 rename ApiClient to ApiSessionManager, return cancellable tasks instead of request IDs which greatly reduces state while offering real cancellation, change to a protocol-based configuration with a default implementation, include a workarount for current JSONModel concurrency issues, add missing super call in QueryParamCollection initWithValuesAndFormat 2016-07-18 13:01:57 +02:00
Wolfgang Berger
e73f2a5c64 Merge branch 'upstream-master' into feature/objc-sessionmanager-integration
* upstream-master:
  update JAR URL to 2.2.0
  updated dev versions
  set interface with discriminator as parent
  null check
  updated readme
  updated versions for release
  update java petstore sample
  derive invoker package name from api/modoel package name
2016-07-18 12:02:32 +02:00
Wolfgang Berger
749a17d292 cleanup 2016-07-18 12:00:22 +02:00
wing328
e6f08df30c update JAR URL to 2.2.0 2016-07-18 17:32:29 +08:00
Wolfgang Berger
07d2e7245e updates iso lib version requirement 2016-07-18 11:20:29 +02:00
Wolfgang Berger
e077e80dcb add missing assignment to task 2016-07-18 10:45:22 +02:00
Tony Tam
39cb6a24db updated dev versions 2016-07-17 15:43:30 -07:00
Wolfgang Berger
d120902e4b integrate latest objc changes into objc-sessionmanager 2016-07-15 15:36:24 +02:00
wing328
9056a5a56c fix mvn warning, update mvn plug-in version 2016-07-15 21:21:58 +08:00
keithballdotnet
cb547c113a ParameterToString can panic
Let the fmt package help convert the obj to a string.  Previously this could panic if the obj was an int.
2016-07-15 14:55:11 +02:00
Wolfgang Berger
fab499e612 Merge branch 'upstream-master' into feature/objc-sessionmanager-integration
* upstream-master:
  add more companies
  added env variable override
  add link to appveyor build
  fix defeault rspec test for ruby, update security petstore
  [Swift] Use ISO-8601 date format
2016-07-15 10:09:15 +02:00
Jason Gavris
4d9b5feb77 [Travis] Cache maven directory 2016-07-14 21:57:24 -04:00
Wolfgang Berger
fb68c6c93d update naming 2016-07-14 15:38:05 +02:00
Wolfgang Berger
f14f4c1e93 Merge branch 'upstream-master' into feature/objc-sessionmanager-master-merge
* upstream-master: (1081 commits)
  improve ts node enum naming
  update ruby samples
  update ruby sample
  Update README to clean on mvn package
  fix csharp enum naming
  fix double hyphen in c# generator
  Remove more Java String comparison using "=="
  Not compare Java String with "=="
  fix csharp code sample
  feat dart: add pubName to all remaining library parts
  fix[ruby]: Problem with List of Enum
  feat dart: add pubName to library name.
  feat dart: mv basePath to ApiClient
  Add more security samples (#3344)
  Leverage Shipable.io to validate mustache templates (#3333)
  fix model name "client" issue
  fix https://github.com/swagger-api/swagger-codegen/pull/3313/files#r70178399
  #3285 replaced setModelNamePrefix by setModelNameSuffix
  doc: explain how to run tests
  feat: improve / fix deserialization by parsing type String
  ...

Conflicts:
	modules/swagger-codegen/src/main/resources/objc/Object-body.mustache
2016-07-14 15:18:08 +02:00
Wolfgang Berger
83e7cdb6a3 Merge branch 'feature/objc-sessionmanager' into feature/objc-sessionmanager-merge
* feature/objc-sessionmanager:
  updates templates with JSONModel workaround
  updates for ISO8601 0.5.1
  updates templates according to https://github.com/NYTimes/objective-c-style-guide
  first version of session manager
2016-07-14 12:28:20 +02:00
Michael Kourlas
a4c589c346 Correct reference to ApiClient default instance 2016-07-13 13:56:43 -04:00
lunat
e6803aed97 Merge pull request #1 from lunat/CSharp-client-header-enhancement
CSharp client header problem
2016-07-11 14:22:11 +02:00
ant3
bf8e1ade56 Added tests to jersey2-java8 sample
These are the tests from the jersey2 sample - but adapted to use the
java8 time classes (rather than Joda time).
2016-07-09 11:31:25 +01:00
ant3
1ea80ab83a Merge remote-tracking branch 'refs/remotes/swagger-api/master' into JSR310-Clients 2016-07-08 23:54:14 +01:00
ant3
836aed999e Merge remote-tracking branch 'refs/remotes/origin/master' into JSR310-Clients 2016-07-08 23:00:04 +01:00
lunat
43d1c5bffc CSharp client header problem
CSharp client may cause an error adding an header because the header
list is static.
Added a check and a function tu set up the ApiKey
2016-07-05 14:42:43 +02:00
ant3
4c1c009bd1 Merge remote-tracking branch 'refs/remotes/swagger-api/master' 2016-06-20 00:25:01 +01:00
ant3
ae67961f60 Merge remote-tracking branch 'refs/remotes/swagger-api/master' 2016-06-15 22:13:56 +01:00
Wolfgang Berger
cd6a805910 updates templates with JSONModel workaround 2016-06-08 13:31:04 +02:00
Wolfgang Berger
e258fb97ca updates for ISO8601 0.5.1 2016-06-06 16:17:39 +02:00
Wolfgang Berger
0259c45b7a Merge branch 'master' into feature/objc-sessionmanager-merge
* master: (682 commits)
  fix, tests for #2500
  added sample files
  rebuilt sample
  changed to use tag sanitization method
  Update doc to support resteasy
  add petstore yaml
  fix typo, update sinatra to use origianl petstore spec (yaml)
  made timestamp generation enabled by default
  rebuilt with generation timestamp disabled
  rebuilt
  added bootstrap sample
  added script
  made generation timestamp optional
  added bootstrap, renamed sample
  added bootstrap
  updated templates
  add new model in csharp
  minor fix to docstring in csharp
  add new files for perl, php, ruby
  add new files for JS
  ...
2016-04-06 11:14:24 +02:00
Wolfgang Berger
0c7bb8b2ca updates templates according to https://github.com/NYTimes/objective-c-style-guide 2016-02-15 10:43:16 +01:00
Wolfgang Berger
6002a983c3 first version of session manager 2016-02-12 16:01:39 +01:00
652 changed files with 19064 additions and 5168 deletions

2
.gitignore vendored
View File

@@ -56,6 +56,8 @@ samples/client/petstore/qt5cpp/PetStore/Makefile
#Java/Android
**/.gradle
samples/client/petstore/java/hello.txt
samples/client/petstore/java/okhttp-gson/hello.txt
samples/client/petstore/java/jersey2-java8/hello.txt
samples/client/petstore/android/default/hello.txt
samples/client/petstore/android/volley/.gradle/
samples/client/petstore/android/volley/build/

View File

@@ -4,16 +4,33 @@ jdk:
- oraclejdk7
- oraclejdk8
cache:
directories:
- $HOME/.m2
services:
- docker
addons:
hosts:
- petstore.swagger.io
before_install:
# required when sudo: required for the Ruby petstore tests
- gem install bundler
- npm install -g typescript
- sudo pip install virtualenv
# to run petstore server locally via docker
- docker pull swaggerapi/petstore
- docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
- docker ps -a
# show host table to confirm petstore.swagger.io is mapped to localhost
- cat /etc/hosts
install:
# Add Godeps dependencies to GOPATH and PATH
- export GOPATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace"
- export PATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace/bin:$PATH"
script:
- mvn verify -Psamples

View File

@@ -1,9 +1,10 @@
# Swagger Code Generator
[![Build Status](https://travis-ci.org/swagger-api/swagger-codegen.svg)](https://travis-ci.org/swagger-api/swagger-codegen)
[![Build Status](https://img.shields.io/travis/swagger-api/swagger-codegen.svg?label=Petstore%20Integration%20Test)](https://travis-ci.org/swagger-api/swagger-codegen)
[![Run Status](https://img.shields.io/shippable/5782588a3be4f4faa56c5bea.svg?label=Mustache%20Template%20Test)](https://app.shippable.com/projects/5782588a3be4f4faa56c5bea)
[![Windows Test](https://ci.appveyor.com/api/projects/status/github/swagger-api/swagger-codegen?branch=master&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/swagger-codegen-wh2wu)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.swagger/swagger-codegen-project/badge.svg?style=plastic)](https://maven-badges.herokuapp.com/maven-central/io.swagger/swagger-codegen-project)
[![PR Stats](http://issuestats.com/github/swagger-api/swagger-codegen/badge/pr)](http://issuestats.com/github/swagger-api/swagger-codegen) [![Issue Stats](http://issuestats.com/github/swagger-api/swagger-codegen/badge/issue)](http://issuestats.com/github/swagger-api/swagger-codegen)
[![Windows Test](https://ci.appveyor.com/api/projects/status/github/swagger-api/swagger-codegen?branch=master&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/swagger-codegen-wh2wu)
:star::star::star: If you would like to contribute, please refer to [guidelines](https://github.com/swagger-api/swagger-codegen/blob/master/CONTRIBUTING.md) and a list of [open tasks](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aopen+is%3Aissue+label%3A%22Need+community+contribution%22).:star::star::star:
@@ -59,8 +60,10 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes
-------------------------- | ------------ | -------------------------- | -----
2.2.0 | 2016-07-15 | 1.0, 1.1, 1.2, 2.0 | [tag v2.2.0](https://github.com/swagger-api/swagger-codegen/tree/v2.2.0)
2.1.6 (**current stable**) | 2016-04-06 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.6](https://github.com/swagger-api/swagger-codegen/tree/v2.1.6)
2.3.0 (upcoming minor release) | TBD | 1.0, 1.1, 1.2, 2.0 | Minor release with breaking changes
2.2.1 (upcoming patch release) | TBD | 1.0, 1.1, 1.2, 2.0 | Patch release with non-breaking changes
2.2.0 (**current stable**) | 2016-07-15 | 1.0, 1.1, 1.2, 2.0 | [tag v2.2.0](https://github.com/swagger-api/swagger-codegen/tree/v2.2.0)
2.1.6 | 2016-04-06 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.6](https://github.com/swagger-api/swagger-codegen/tree/v2.1.6)
2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/v2.0.17)
1.0.4 | 2012-04-12 | 1.0, 1.1 | [tag v1.0.4](https://github.com/swagger-api/swagger-codegen/tree/swagger-codegen_2.9.1-1.1)
@@ -69,7 +72,7 @@ Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes
If you're looking for the latest stable version, you can grab it directly from maven central (you'll need java 7 runtime at a minimum):
```
wget http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.1.6/swagger-codegen-cli-2.1.6.jar -O swagger-codegen-cli.jar
wget http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.2.0/swagger-codegen-cli-2.2.0.jar -O swagger-codegen-cli.jar
java -jar swagger-codegen-cli.jar help
```
@@ -148,7 +151,7 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
```
(if you're on Windows, replace the last command with `java -jar modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l php -o c:\temp\php_api_client`)
You can also download the JAR (latest relesae) directly from [maven.org]( http://central.maven.org/maven2/io/swagger/swagger-codegen/2.1.6/swagger-codegen-2.1.6.jar)
You can also download the JAR (latest relesae) directly from [maven.org]( http://central.maven.org/maven2/io/swagger/swagger-codegen/2.2.0/swagger-codegen-2.2.0.jar)
To get a list of **general** options available, please run `java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar help generate`
@@ -751,7 +754,8 @@ Here are some companies/projects using Swagger Codegen in production. To add you
- [CloudBoost](https://www.CloudBoost.io/)
- [Conplement](http://www.conplement.de/)
- [Cupix](http://www.cupix.com)
- [DBBest Technologies](https://www.dbbest.com)
- [DBBest Technologies](https://www.dbbest.com)
- [DecentFoX](http://decentfox.com/)
- [DocuSign](https://www.docusign.com)
- [Ergon](http://www.ergon.ch/)
- [eureka](http://eure.jp/)
@@ -760,6 +764,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you
- [Finder](http://en.finder.pl/)
- [FH Münster - University of Applied Sciences](http://www.fh-muenster.de)
- [Gear Zero Network](https://www.gearzero.ca)
- [Germin8](http://www.germin8.com)
- [GraphHopper](https://graphhopper.com/)
- [Gravitate Solutions](http://gravitatesolutions.com/)
- [IMS Health](http://www.imshealth.com/en/solution-areas/technology-and-applications)
@@ -784,6 +789,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you
- [Revault Sàrl](http://revault.ch)
- [Royal Bank of Canada (RBC)](http://www.rbc.com/canada.html)
- [SCOOP Software GmbH](http://www.scoop-software.de)
- [Skurt](http://www.skurt.com)
- [SmartRecruiters](https://www.smartrecruiters.com/)
- [StyleRecipe](http://stylerecipe.co.jp)
- [Svenska Spel AB](https://www.svenskaspel.se/)
@@ -810,6 +816,7 @@ Swaagger Codegen core team members are contributors who have been making signfic
| Groovy | |
| Go | @guohuang (2016/05/01) @neilotoole (2016/05/01) |
| Java | @cbornet (2016/05/01) @xhh (2016/05/01) @epaul (2016/06/04) |
| Java (Spring Cloud) | @cbornet (2016/07/19) |
| NodeJS/Javascript | @xhh (2016/05/01) |
| ObjC | @mateuszmackowiak (2016/05/09) |
| Perl | @wing328 (2016/05/01) |
@@ -828,8 +835,8 @@ Swaagger Codegen core team members are contributors who have been making signfic
| C# ASP.NET5 | @jimschubert (2016/05/01) |
| Go Server | @guohuang (2016/06/13) |
| Haskell Servant | |
| Java Spring Boot | |
| Java SpringMVC | @kolyjjj (2016/05/01) |
| Java Spring Boot | @cbornet (2016/07/19) |
| Java Spring MVC | @kolyjjj (2016/05/01) @cbornet (2016/07/19) |
| Java JAX-RS | |
| NancyFX | |
| NodeJS | @kolyjjj (2016/05/01) |
@@ -873,6 +880,9 @@ Here is a list of template creators:
* PHP Lumen: @abcsum
* PHP Slim: @jfastnacht
* Ruby on Rails 5: @zlx
* Documentation
* HTML Doc 2: @jhitchcock
* Confluence Wiki: @jhitchcock
## How to join the core team

View File

@@ -1,7 +1,9 @@
# for CI with appveyor.yml
# Ref: http://www.yegor256.com/2015/01/10/windows-appveyor-maven.html
version: '{build}'
version: '{branch}-{build}'
os: Windows Server 2012
hosts:
petstore.swagger.io: 127.0.0.1
install:
- ps: |
Add-Type -AssemblyName System.IO.Compression.FileSystem
@@ -15,9 +17,16 @@ install:
- cmd: SET PATH=C:\maven\apache-maven-3.2.5\bin;%JAVA_HOME%\bin;%PATH%
- cmd: SET MAVEN_OPTS=-XX:MaxPermSize=2g -Xmx4g
- cmd: SET JAVA_OPTS=-XX:MaxPermSize=2g -Xmx4g
- git clone https://github.com/wing328/swagger-samples
- ps: Start-Process -FilePath 'C:\maven\apache-maven-3.2.5\bin\mvn' -ArgumentList 'jetty:run' -WorkingDirectory "$env:appveyor_build_folder\swagger-samples\java\java-jersey-jaxrs"
build_script:
- nuget restore samples\client\petstore\csharp\SwaggerClient\IO.Swagger.sln
- msbuild samples\client\petstore\csharp\SwaggerClient\IO.Swagger.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- mvn clean install --batch-mode
test_script:
# test c# API client
- nunit-console samples\client\petstore\csharp\SwaggerClient\src\IO.Swagger.Test\bin\Debug\IO.Swagger.Test.dll --result=myresults.xml;format=AppVeyor
# generate all petstore clients
- .\bin\windows\run-all-petstore.cmd
cache:
- C:\maven\

31
bin/cwiki-petstore.sh Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/sh
SCRIPT="$0"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l cwiki -o samples/documentation/cwiki"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -26,9 +26,16 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l dart -o samples/client/petstore/dart"
# for dart vm lib generation:
#ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l dart -o samples/client/petstore/dart --additional-properties browserClient=false"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l dart -o samples/client/petstore/dart/swagger"
# then options to generate the library for vm would be:
#ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l dart -o samples/client/petstore/dart/swagger_vm -DbrowserClient=false -DpubName=swagger_vm"
java $JAVA_OPTS -jar $executable $ags
# There is a proposal to allow importing different libraries depending on the environment:
# https://github.com/munificent/dep-interface-libraries
# When this is implemented there will only be one library.
# The current petstore test will then work for both: the browser library and the vm library.

View File

@@ -26,7 +26,7 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -o samples/client/petstore/java/jersey1 -DhideGenerationTimestamp=true --library=jersey1"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/Java -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -o samples/client/petstore/java/jersey1 -DhideGenerationTimestamp=true --library=jersey1"
echo "Removing files and folders under samples/client/petstore/java/jersey1/src/main"
rm -rf samples/client/petstore/java/jersey1/src/main

View File

@@ -26,7 +26,7 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs -o samples/server/petstore/jaxrs/jersey2 -DhideGenerationTimestamp=true"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l jaxrs -o samples/server/petstore/jaxrs/jersey2 -DhideGenerationTimestamp=true"
echo "Removing files and folders under samples/server/petstore/jaxrs/jersey2/src/main"
rm -rf samples/server/petstore/jaxrs/jersey2/src/main

31
bin/nancyfx-petstore-server.sh Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/sh
SCRIPT="$0"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/nancyfx -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l nancyfx -o samples/server/petstore/nancyfx"
java $JAVA_OPTS -jar $executable $ags

8
bin/objc-petstore-all.sh Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/sh
# default setting
./bin/objc-petstore.sh
# coredata support
./bin/objc-petstore-coredata.sh

7
bin/spring-all-pestore.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/sh
./bin/spring-cloud-feign-petstore.sh
./bin/spring-stubs.sh
./bin/spring-mvc-petstore-j8-async-server.sh
./bin/springboot-petstore-server.sh
./bin/spring-mvc-petstore-server.sh

View File

@@ -5,6 +5,6 @@ If Not Exist %executable% (
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l nancyfx -o samples\server\petstore\nancyfx\
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l nancyfx -o samples\server\petstore\nancyfx\
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-project</artifactId>
<version>2.2.0</version>
<version>2.2.1</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-project</artifactId>
<version>2.2.0</version>
<version>2.2.1</version>
<relativePath>../..</relativePath>
</parent>
<artifactId>swagger-codegen-maven-plugin</artifactId>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-project</artifactId>
<version>2.2.0</version>
<version>2.2.1</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -25,17 +25,17 @@
<extension>
<groupId>org.jvnet.wagon-svn</groupId>
<artifactId>wagon-svn</artifactId>
<version>1.8</version>
<version>1.12</version>
</extension>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh-external</artifactId>
<version>1.0-alpha-6</version>
<version>2.10</version>
</extension>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav</artifactId>
<version>1.0-beta-1</version>
<version>1.0-beta-2</version>
</extension>
</extensions>
<directory>target</directory>
@@ -44,7 +44,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<version>1.5.0</version>
<executions>
<execution>
<goals>
@@ -72,16 +72,16 @@
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<version>3.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<version>3.0.2</version>
<configuration>
<archive>
<manifestEntries>
@@ -92,21 +92,6 @@
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<!-- <version>2.1</version> -->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<goals>
@@ -117,11 +102,13 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
<artifactId>maven-site-plugin</artifactId>
<version>3.5.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
</plugin>
</plugins>
</build>
@@ -166,7 +153,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<version>2.10.4</version>
<configuration>
<aggregate>true</aggregate>
<debug>true</debug>
@@ -180,7 +167,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
<version>2.5</version>
<configuration>
<aggregate>true</aggregate>
</configuration>
@@ -188,7 +175,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.6</version>
<version>2.9</version>
<reportSets>
<reportSet>
<reports>
@@ -200,7 +187,7 @@
</plugins>
</reporting>
<properties>
<diffutils-version>1.2.1</diffutils-version>
<diffutils-version>1.3.0</diffutils-version>
</properties>
<dependencies>
<dependency>

View File

@@ -46,6 +46,8 @@ public class CodegenProperty implements Cloneable {
public Boolean hasValidation; // true if pattern, maximum, etc are set (only used in the mustache template)
public Boolean isInherited;
public String nameInCamelCase; // property name in camel case
// enum name based on the property name, usually use as a prefix (e.g. VAR_NAME) for enum name (e.g. VAR_NAME_VALUE1)
public String enumName;
@Override
public String toString() {
@@ -111,6 +113,7 @@ public class CodegenProperty implements Cloneable {
result = prime * result + ((isListContainer == null) ? 0 : isListContainer.hashCode());
result = prime * result + Objects.hashCode(isInherited);
result = prime * result + Objects.hashCode(nameInCamelCase);
result = prime * result + Objects.hashCode(enumName);
return result;
}
@@ -271,6 +274,9 @@ public class CodegenProperty implements Cloneable {
if (!Objects.equals(this.nameInCamelCase, other.nameInCamelCase)) {
return false;
}
if (!Objects.equals(this.enumName, other.enumName)) {
return false;
}
return true;
}

View File

@@ -106,7 +106,7 @@ public class DefaultCodegen {
// How to encode special characters like $
// They are translated to words like "Dollar" and prefixed with '
// Then translated back during JSON encoding and decoding
protected Map<Character, String> specialCharReplacements = new HashMap<Character, String>();
protected Map<String, String> specialCharReplacements = new HashMap<String, String>();
public List<CliOption> cliOptions() {
return cliOptions;
@@ -789,21 +789,37 @@ public class DefaultCodegen {
*/
protected void initalizeSpecialCharacterMapping() {
// Initialize special characters
specialCharReplacements.put('$', "Dollar");
specialCharReplacements.put('^', "Caret");
specialCharReplacements.put('|', "Pipe");
specialCharReplacements.put('=', "Equal");
specialCharReplacements.put('*', "Star");
specialCharReplacements.put('-', "Minus");
specialCharReplacements.put('&', "Ampersand");
specialCharReplacements.put('%', "Percent");
specialCharReplacements.put('#', "Hash");
specialCharReplacements.put('@', "At");
specialCharReplacements.put('!', "Exclamation");
specialCharReplacements.put('+', "Plus");
specialCharReplacements.put(':', "Colon");
specialCharReplacements.put('>', "GreaterThan");
specialCharReplacements.put('<', "LessThan");
specialCharReplacements.put("$", "Dollar");
specialCharReplacements.put("^", "Caret");
specialCharReplacements.put("|", "Pipe");
specialCharReplacements.put("=", "Equal");
specialCharReplacements.put("*", "Star");
specialCharReplacements.put("-", "Minus");
specialCharReplacements.put("&", "Ampersand");
specialCharReplacements.put("%", "Percent");
specialCharReplacements.put("#", "Hash");
specialCharReplacements.put("@", "At");
specialCharReplacements.put("!", "Exclamation");
specialCharReplacements.put("+", "Plus");
specialCharReplacements.put(":", "Colon");
specialCharReplacements.put(">", "Greater_Than");
specialCharReplacements.put("<", "Less_Than");
specialCharReplacements.put(".", "Period");
specialCharReplacements.put("_", "Underscore");
specialCharReplacements.put("<=", "Less_Than_Or_Equal_To");
specialCharReplacements.put(">=", "Greater_Than_Or_Equal_To");
specialCharReplacements.put("!=", "Not_Equal");
}
/**
* Return the symbol name of a symbol
*
* @param input Symbol (e.g. $)
* @return Symbol name (e.g. Dollar)
*/
protected String getSymbolName(String input) {
return specialCharReplacements.get(input);
}
/**
@@ -1334,7 +1350,7 @@ public class DefaultCodegen {
property.name = toVarName(name);
property.baseName = name;
property.nameInCamelCase = camelize(name, false);
property.nameInCamelCase = camelize(property.name, false);
property.description = escapeText(p.getDescription());
property.unescapedDescription = p.getDescription();
property.getter = "get" + getterAndSetterCapitalize(name);
@@ -1559,6 +1575,7 @@ public class DefaultCodegen {
// this can cause issues for clients which don't support enums
if (property.isEnum) {
property.datatypeWithEnum = toEnumName(property);
property.enumName = toEnumName(property);
} else {
property.datatypeWithEnum = property.datatype;
}
@@ -1606,11 +1623,14 @@ public class DefaultCodegen {
property.items = innerProperty;
// inner item is Enum
if (isPropertyInnerMostEnum(property)) {
// isEnum is set to true when the type is an enum
// or the inner type of an array/map is an enum
property.isEnum = true;
// update datatypeWithEnum and default value for array
// e.g. List<string> => List<StatusEnum>
updateDataTypeWithEnumForArray(property);
// set allowable values to enum values (including array/map of enum)
property.allowableValues = getInnerEnumAllowableValues(property);
}
}
}
@@ -1633,10 +1653,14 @@ public class DefaultCodegen {
property.items = innerProperty;
// inner item is Enum
if (isPropertyInnerMostEnum(property)) {
// isEnum is set to true when the type is an enum
// or the inner type of an array/map is an enum
property.isEnum = true;
// update datatypeWithEnum and default value for map
// e.g. Dictionary<string, string> => Dictionary<string, StatusEnum>
updateDataTypeWithEnumForMap(property);
// set allowable values to enum values (including array/map of enum)
property.allowableValues = getInnerEnumAllowableValues(property);
}
}
@@ -1657,6 +1681,17 @@ public class DefaultCodegen {
return currentProperty.isEnum;
}
protected Map<String, Object> getInnerEnumAllowableValues(CodegenProperty property) {
CodegenProperty currentProperty = property;
while (currentProperty != null && (Boolean.TRUE.equals(currentProperty.isMapContainer)
|| Boolean.TRUE.equals(currentProperty.isListContainer))) {
currentProperty = currentProperty.items;
}
return currentProperty.allowableValues;
}
/**
* Update datatypeWithEnum for array container
* @param property Codegen property
@@ -1670,9 +1705,13 @@ public class DefaultCodegen {
// set both datatype and datetypeWithEnum as only the inner type is enum
property.datatypeWithEnum = property.datatypeWithEnum.replace(baseItem.baseType, toEnumName(baseItem));
// naming the enum with respect to the language enum naming convention
// e.g. remove [], {} from array/map of enum
property.enumName = toEnumName(property);
// set default value for variable with inner enum
if (property.defaultValue != null) {
property.defaultValue = property.defaultValue.replace(property.items.baseType, toEnumName(property.items));
property.defaultValue = property.defaultValue.replace(baseItem.baseType, toEnumName(baseItem));
}
}
@@ -1689,6 +1728,10 @@ public class DefaultCodegen {
// set both datatype and datetypeWithEnum as only the inner type is enum
property.datatypeWithEnum = property.datatypeWithEnum.replace(", " + baseItem.baseType, ", " + toEnumName(baseItem));
// naming the enum with respect to the language enum naming convention
// e.g. remove [], {} from array/map of enum
property.enumName = toEnumName(property);
// set default value for variable with inner enum
if (property.defaultValue != null) {
property.defaultValue = property.defaultValue.replace(", " + property.items.baseType, ", " + toEnumName(property.items));

View File

@@ -17,7 +17,7 @@ import org.slf4j.LoggerFactory;
import java.io.*;
import java.util.*;
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
import org.apache.commons.lang3.StringUtils;
public class DefaultGenerator extends AbstractGenerator implements Generator {
protected Logger LOGGER = LoggerFactory.getLogger(DefaultGenerator.class);
@@ -149,10 +149,16 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
if (info.getVersion() != null) {
config.additionalProperties().put("appVersion", config.escapeText(info.getVersion()));
}
if (info.getDescription() != null) {
if (StringUtils.isEmpty(info.getDescription())) {
// set a default description if none if provided
config.additionalProperties().put("appDescription",
"No descripton provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)");
} else {
config.additionalProperties().put("appDescription",
config.escapeText(info.getDescription()));
}
if (info.getContact() != null) {
Contact contact = info.getContact();
config.additionalProperties().put("infoUrl", config.escapeText(contact.getUrl()));
@@ -274,6 +280,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
try {
//don't generate models that have an import mapping
if(config.importMapping().containsKey(name)) {
LOGGER.info("Model " + name + " not imported due to import mapping");
continue;
}
@@ -522,7 +529,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
for (SupportingFile support : config.supportingFiles()) {
try {
String outputFolder = config.outputFolder();
if (isNotEmpty(support.folder)) {
if (StringUtils.isNotEmpty(support.folder)) {
outputFolder += File.separator + support.folder;
}
File of = new File(outputFolder);

View File

@@ -41,6 +41,9 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
public AbstractCSharpCodegen() {
super();
// C# does not use import mapping
importMapping.clear();
outputFolder = "generated-code" + File.separator + this.getName();
embeddedTemplateDir = templateDir = this.getName();

View File

@@ -1,20 +1,43 @@
package io.swagger.codegen.languages;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.regex.Pattern;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import com.google.common.base.Strings;
import io.swagger.codegen.*;
import io.swagger.codegen.CliOption;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.CodegenModel;
import io.swagger.codegen.CodegenOperation;
import io.swagger.codegen.CodegenParameter;
import io.swagger.codegen.CodegenProperty;
import io.swagger.codegen.DefaultCodegen;
import io.swagger.models.Model;
import io.swagger.models.Operation;
import io.swagger.models.Path;
import io.swagger.models.Swagger;
import io.swagger.models.parameters.FormParameter;
import io.swagger.models.parameters.Parameter;
import io.swagger.models.properties.*;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.util.*;
import java.util.regex.Pattern;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.BooleanProperty;
import io.swagger.models.properties.DoubleProperty;
import io.swagger.models.properties.FloatProperty;
import io.swagger.models.properties.IntegerProperty;
import io.swagger.models.properties.LongProperty;
import io.swagger.models.properties.MapProperty;
import io.swagger.models.properties.Property;
import io.swagger.models.properties.StringProperty;
public abstract class AbstractJavaCodegen extends DefaultCodegen implements CodegenConfig {
@@ -43,6 +66,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
public AbstractJavaCodegen() {
super();
supportsInheritance = true;
modelTemplateFiles.put("model.mustache", ".java");
apiTemplateFiles.put("api.mustache", ".java");
apiTestTemplateFiles.put("api_test.mustache", ".java");
@@ -221,10 +245,14 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
importMapping.put("ApiModelProperty", "io.swagger.annotations.ApiModelProperty");
importMapping.put("ApiModel", "io.swagger.annotations.ApiModel");
importMapping.put("JsonProperty", "com.fasterxml.jackson.annotation.JsonProperty");
importMapping.put("JsonCreator", "com.fasterxml.jackson.annotation.JsonCreator");
importMapping.put("JsonValue", "com.fasterxml.jackson.annotation.JsonValue");
importMapping.put("SerializedName", "com.google.gson.annotations.SerializedName");
importMapping.put("Objects", "java.util.Objects");
importMapping.put("StringUtil", invokerPackage + ".StringUtil");
// import JsonCreator if JsonProperty is imported
// used later in recursive import in postProcessingModels
importMapping.put("com.fasterxml.jackson.annotation.JsonProperty", "com.fasterxml.jackson.annotation.JsonCreator");
if(additionalProperties.containsKey(DATE_LIBRARY)) {
setDateLibrary(additionalProperties.get("dateLibrary").toString());
@@ -615,6 +643,23 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
// recursivly add import for mapping one type to multipe imports
List<Map<String, String>> recursiveImports = (List<Map<String, String>>) objs.get("imports");
if (recursiveImports == null)
return objs;
ListIterator<Map<String, String>> listIterator = recursiveImports.listIterator();
while (listIterator.hasNext()) {
String _import = listIterator.next().get("import");
// if the import package happens to be found in the importMapping (key)
// add the corresponding import package to the list
if (importMapping.containsKey(_import)) {
Map<String, String> newImportMap= new HashMap<String, String>();
newImportMap.put("import", importMapping.get(_import));
listIterator.add(newImportMap);
}
}
return postProcessModelsEnum(objs);
}
@@ -706,6 +751,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
@Override
public String toEnumVarName(String value, String datatype) {
// for symbol, e.g. $, #
if (getSymbolName(value) != null) {
return getSymbolName(value).toUpperCase();
}
// number
if ("Integer".equals(datatype) || "Long".equals(datatype) ||
"Float".equals(datatype) || "Double".equals(datatype)) {
@@ -717,7 +767,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
}
// string
String var = value.replaceAll("\\W+", "_").replaceAll("_+", "_").toUpperCase();
String var = value.replaceAll("\\W+", "_").toUpperCase();
if (var.matches("\\d.*")) {
return "_" + var;
} else {

View File

@@ -0,0 +1,641 @@
package io.swagger.codegen.languages;
import io.swagger.codegen.CliOption;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.CodegenOperation;
import io.swagger.codegen.CodegenParameter;
import io.swagger.codegen.CodegenProperty;
import io.swagger.codegen.CodegenType;
import io.swagger.codegen.DefaultCodegen;
import io.swagger.codegen.SupportingFile;
import io.swagger.models.properties.*;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.HashSet;
import java.util.regex.Matcher;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class AbstractPhpCodegen extends DefaultCodegen implements CodegenConfig {
static Logger LOGGER = LoggerFactory.getLogger(AbstractPhpCodegen.class);
public static final String VARIABLE_NAMING_CONVENTION = "variableNamingConvention";
public static final String PACKAGE_PATH = "packagePath";
public static final String SRC_BASE_PATH = "srcBasePath";
// composerVendorName/composerProjectName has be replaced by gitUserId/gitRepoId. prepare to remove these.
// public static final String COMPOSER_VENDOR_NAME = "composerVendorName";
// public static final String COMPOSER_PROJECT_NAME = "composerProjectName";
// protected String composerVendorName = null;
// protected String composerProjectName = null;
protected String invokerPackage = "php";
protected String packagePath = "php-base";
protected String artifactVersion = null;
protected String srcBasePath = "lib";
protected String testBasePath = "test";
protected String docsBasePath = "docs";
protected String apiDirName = "Api";
protected String modelDirName = "Model";
protected String variableNamingConvention= "snake_case";
protected String apiDocPath = docsBasePath + "/" + apiDirName;
protected String modelDocPath = docsBasePath + "/" + modelDirName;
public AbstractPhpCodegen() {
super();
modelTemplateFiles.put("model.mustache", ".php");
apiTemplateFiles.put("api.mustache", ".php");
apiTestTemplateFiles.put("api_test.mustache", ".php");
modelDocTemplateFiles.put("model_doc.mustache", ".md");
apiDocTemplateFiles.put("api_doc.mustache", ".md");
apiPackage = invokerPackage + "\\" + apiDirName;
modelPackage = invokerPackage + "\\" + modelDirName;
setReservedWordsLowerCase(
Arrays.asList(
// local variables used in api methods (endpoints)
"resourcePath", "httpBody", "queryParams", "headerParams",
"formParams", "_header_accept", "_tempBody",
// PHP reserved words
"__halt_compiler", "abstract", "and", "array", "as", "break", "callable", "case", "catch", "class", "clone", "const", "continue", "declare", "default", "die", "do", "echo", "else", "elseif", "empty", "enddeclare", "endfor", "endforeach", "endif", "endswitch", "endwhile", "eval", "exit", "extends", "final", "for", "foreach", "function", "global", "goto", "if", "implements", "include", "include_once", "instanceof", "insteadof", "interface", "isset", "list", "namespace", "new", "or", "print", "private", "protected", "public", "require", "require_once", "return", "static", "switch", "throw", "trait", "try", "unset", "use", "var", "while", "xor")
);
// ref: http://php.net/manual/en/language.types.intro.php
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList(
"bool",
"boolean",
"int",
"integer",
"double",
"float",
"string",
"object",
"DateTime",
"mixed",
"number",
"void",
"byte")
);
instantiationTypes.put("array", "array");
instantiationTypes.put("map", "map");
// provide primitives to mustache template
String primitives = "'" + StringUtils.join(languageSpecificPrimitives, "', '") + "'";
additionalProperties.put("primitives", primitives);
// ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types
typeMapping = new HashMap<String, String>();
typeMapping.put("integer", "int");
typeMapping.put("long", "int");
typeMapping.put("number", "float");
typeMapping.put("float", "float");
typeMapping.put("double", "double");
typeMapping.put("string", "string");
typeMapping.put("byte", "int");
typeMapping.put("boolean", "bool");
typeMapping.put("Date", "\\DateTime");
typeMapping.put("DateTime", "\\DateTime");
typeMapping.put("file", "\\SplFileObject");
typeMapping.put("map", "map");
typeMapping.put("array", "array");
typeMapping.put("list", "array");
typeMapping.put("object", "object");
typeMapping.put("binary", "string");
typeMapping.put("ByteArray", "string");
typeMapping.put("UUID", "string");
cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
cliOptions.add(new CliOption(VARIABLE_NAMING_CONVENTION, "naming convention of variable name, e.g. camelCase.")
.defaultValue("snake_case"));
cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, "The main namespace to use for all classes. e.g. Yay\\Pets"));
cliOptions.add(new CliOption(PACKAGE_PATH, "The main package name for classes. e.g. GeneratedPetstore"));
cliOptions.add(new CliOption(SRC_BASE_PATH, "The directory under packagePath to serve as source root."));
// cliOptions.add(new CliOption(COMPOSER_VENDOR_NAME, "The vendor name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. yaypets. IMPORTANT NOTE (2016/03): composerVendorName will be deprecated and replaced by gitUserId in the next swagger-codegen release"));
cliOptions.add(new CliOption(CodegenConstants.GIT_USER_ID, CodegenConstants.GIT_USER_ID_DESC));
// cliOptions.add(new CliOption(COMPOSER_PROJECT_NAME, "The project name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. petstore-client. IMPORTANT NOTE (2016/03): composerProjectName will be deprecated and replaced by gitRepoId in the next swagger-codegen release"));
cliOptions.add(new CliOption(CodegenConstants.GIT_REPO_ID, CodegenConstants.GIT_REPO_ID_DESC));
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, "The version to use in the composer package version field. e.g. 1.2.3"));
}
@Override
public void processOpts() {
super.processOpts();
if (additionalProperties.containsKey(PACKAGE_PATH)) {
this.setPackagePath((String) additionalProperties.get(PACKAGE_PATH));
} else {
additionalProperties.put(PACKAGE_PATH, packagePath);
}
if (additionalProperties.containsKey(SRC_BASE_PATH)) {
this.setSrcBasePath((String) additionalProperties.get(SRC_BASE_PATH));
} else {
additionalProperties.put(SRC_BASE_PATH, srcBasePath);
}
if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
} else {
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
}
if (!additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) {
additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage);
}
if (!additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) {
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
}
// if (additionalProperties.containsKey(COMPOSER_PROJECT_NAME)) {
// this.setComposerProjectName((String) additionalProperties.get(COMPOSER_PROJECT_NAME));
// } else {
// additionalProperties.put(COMPOSER_PROJECT_NAME, composerProjectName);
// }
if (additionalProperties.containsKey(CodegenConstants.GIT_USER_ID)) {
this.setGitUserId((String) additionalProperties.get(CodegenConstants.GIT_USER_ID));
} else {
additionalProperties.put(CodegenConstants.GIT_USER_ID, gitUserId);
}
// if (additionalProperties.containsKey(COMPOSER_VENDOR_NAME)) {
// this.setComposerVendorName((String) additionalProperties.get(COMPOSER_VENDOR_NAME));
// } else {
// additionalProperties.put(COMPOSER_VENDOR_NAME, composerVendorName);
// }
if (additionalProperties.containsKey(CodegenConstants.GIT_REPO_ID)) {
this.setGitRepoId((String) additionalProperties.get(CodegenConstants.GIT_REPO_ID));
} else {
additionalProperties.put(CodegenConstants.GIT_REPO_ID, gitRepoId);
}
if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION)) {
this.setArtifactVersion((String) additionalProperties.get(CodegenConstants.ARTIFACT_VERSION));
} else {
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
}
if (additionalProperties.containsKey(VARIABLE_NAMING_CONVENTION)) {
this.setParameterNamingConvention((String) additionalProperties.get(VARIABLE_NAMING_CONVENTION));
}
additionalProperties.put("escapedInvokerPackage", invokerPackage.replace("\\", "\\\\"));
// make api and model doc path available in mustache template
additionalProperties.put("apiDocPath", apiDocPath);
additionalProperties.put("modelDocPath", modelDocPath);
// make test path available in mustache template
additionalProperties.put("testBasePath", testBasePath);
// // apache v2 license
// supportingFiles.add(new SupportingFile("LICENSE", getPackagePath(), "LICENSE"));
}
public String getPackagePath() {
return packagePath;
}
public String toPackagePath(String packageName, String basePath) {
packageName = packageName.replace(invokerPackage, ""); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
if (basePath != null && basePath.length() > 0) {
basePath = basePath.replaceAll("[\\\\/]?$", "") + File.separatorChar; // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
}
String regFirstPathSeparator;
if ("/".equals(File.separator)) { // for mac, linux
regFirstPathSeparator = "^/";
} else { // for windows
regFirstPathSeparator = "^\\\\";
}
String regLastPathSeparator;
if ("/".equals(File.separator)) { // for mac, linux
regLastPathSeparator = "/$";
} else { // for windows
regLastPathSeparator = "\\\\$";
}
return (getPackagePath() + File.separatorChar + basePath
// Replace period, backslash, forward slash with file separator in package name
+ packageName.replaceAll("[\\.\\\\/]", Matcher.quoteReplacement(File.separator))
// Trim prefix file separators from package path
.replaceAll(regFirstPathSeparator, ""))
// Trim trailing file separators from the overall path
.replaceAll(regLastPathSeparator+ "$", "");
}
@Override
public String escapeReservedWord(String name) {
return "_" + name;
}
@Override
public String apiFileFolder() {
return (outputFolder + "/" + toPackagePath(apiPackage, srcBasePath));
}
@Override
public String modelFileFolder() {
return (outputFolder + "/" + toPackagePath(modelPackage, srcBasePath));
}
@Override
public String apiTestFileFolder() {
return (outputFolder + "/" + getPackagePath() + "/" + testBasePath + "/" + apiDirName);
}
@Override
public String modelTestFileFolder() {
return (outputFolder + "/" + getPackagePath() + "/" + testBasePath + "/" + modelDirName);
}
@Override
public String apiDocFileFolder() {
return (outputFolder + "/" + getPackagePath() + "/" + apiDocPath);
}
@Override
public String modelDocFileFolder() {
return (outputFolder + "/" + getPackagePath() + "/" + modelDocPath);
}
@Override
public String toModelDocFilename(String name) {
return toModelName(name);
}
@Override
public String toApiDocFilename(String name) {
return toApiName(name);
}
@Override
public String getTypeDeclaration(Property p) {
if (p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
Property inner = ap.getItems();
return getTypeDeclaration(inner) + "[]";
} else if (p instanceof MapProperty) {
MapProperty mp = (MapProperty) p;
Property inner = mp.getAdditionalProperties();
return getSwaggerType(p) + "[string," + getTypeDeclaration(inner) + "]";
} else if (p instanceof RefProperty) {
String type = super.getTypeDeclaration(p);
return (!languageSpecificPrimitives.contains(type))
? "\\" + modelPackage + "\\" + type : type;
}
return super.getTypeDeclaration(p);
}
@Override
public String getTypeDeclaration(String name) {
if (!languageSpecificPrimitives.contains(name)) {
return "\\" + modelPackage + "\\" + name;
}
return super.getTypeDeclaration(name);
}
@Override
public String getSwaggerType(Property p) {
String swaggerType = super.getSwaggerType(p);
String type = null;
if (typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType);
if (languageSpecificPrimitives.contains(type)) {
return type;
} else if (instantiationTypes.containsKey(type)) {
return type;
}
} else {
type = swaggerType;
}
if (type == null) {
return null;
}
return toModelName(type);
}
public void setInvokerPackage(String invokerPackage) {
this.invokerPackage = invokerPackage;
}
public void setArtifactVersion(String artifactVersion) {
this.artifactVersion = artifactVersion;
}
public void setPackagePath(String packagePath) {
this.packagePath = packagePath;
}
public void setSrcBasePath(String srcBasePath) {
this.srcBasePath = srcBasePath;
}
public void setParameterNamingConvention(String variableNamingConvention) {
this.variableNamingConvention = variableNamingConvention;
}
// public void setComposerVendorName(String composerVendorName) {
// this.composerVendorName = composerVendorName;
// }
// public void setComposerProjectName(String composerProjectName) {
// this.composerProjectName = composerProjectName;
// }
@Override
public String toVarName(String name) {
// sanitize name
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
if ("camelCase".equals(variableNamingConvention)) {
// return the name in camelCase style
// phone_number => phoneNumber
name = camelize(name, true);
} else { // default to snake case
// return the name in underscore style
// PhoneNumber => phone_number
name = underscore(name);
}
// parameter name starting with number won't compile
// need to escape it by appending _ at the beginning
if (name.matches("^\\d.*")) {
name = "_" + name;
}
return name;
}
@Override
public String toParamName(String name) {
// should be the same as variable name
return toVarName(name);
}
@Override
public String toModelName(String name) {
// remove [
name = name.replaceAll("\\]", "");
// Note: backslash ("\\") is allowed for e.g. "\\DateTime"
name = name.replaceAll("[^\\w\\\\]+", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
// remove dollar sign
name = name.replaceAll("$", "");
// model name cannot use reserved keyword
if (isReservedWord(name)) {
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
}
// model name starts with number
if (name.matches("^\\d.*")) {
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
}
// add prefix and/or suffic only if name does not start wth \ (e.g. \DateTime)
if (!name.matches("^\\\\.*")) {
name = modelNamePrefix + name + modelNameSuffix;
}
// camelize the model name
// phone_number => PhoneNumber
return camelize(name);
}
@Override
public String toModelFilename(String name) {
// should be the same as the model name
return toModelName(name);
}
@Override
public String toModelTestFilename(String name) {
// should be the same as the model name
return toModelName(name) + "Test";
}
@Override
public String toOperationId(String operationId) {
// throw exception if method name is empty
if (StringUtils.isEmpty(operationId)) {
throw new RuntimeException("Empty method name (operationId) not allowed");
}
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId), true));
operationId = "call_" + operationId;
}
return camelize(sanitizeName(operationId), true);
}
/**
* Return the default value of the property
*
* @param p Swagger property object
* @return string presentation of the default value of the property
*/
@Override
public String toDefaultValue(Property p) {
if (p instanceof StringProperty) {
StringProperty dp = (StringProperty) p;
if (dp.getDefault() != null) {
return "'" + dp.getDefault().toString() + "'";
}
} else if (p instanceof BooleanProperty) {
BooleanProperty dp = (BooleanProperty) p;
if (dp.getDefault() != null) {
return dp.getDefault().toString();
}
} else if (p instanceof DateProperty) {
// TODO
} else if (p instanceof DateTimeProperty) {
// TODO
} else if (p instanceof DoubleProperty) {
DoubleProperty dp = (DoubleProperty) p;
if (dp.getDefault() != null) {
return dp.getDefault().toString();
}
} else if (p instanceof FloatProperty) {
FloatProperty dp = (FloatProperty) p;
if (dp.getDefault() != null) {
return dp.getDefault().toString();
}
} else if (p instanceof IntegerProperty) {
IntegerProperty dp = (IntegerProperty) p;
if (dp.getDefault() != null) {
return dp.getDefault().toString();
}
} else if (p instanceof LongProperty) {
LongProperty dp = (LongProperty) p;
if (dp.getDefault() != null) {
return dp.getDefault().toString();
}
}
return null;
}
@Override
public void setParameterExampleValue(CodegenParameter p) {
String example;
if (p.defaultValue == null) {
example = p.example;
} else {
example = p.defaultValue;
}
String type = p.baseType;
if (type == null) {
type = p.dataType;
}
if ("String".equalsIgnoreCase(type)) {
if (example == null) {
example = p.paramName + "_example";
}
example = "\"" + escapeText(example) + "\"";
} else if ("Integer".equals(type) || "int".equals(type)) {
if (example == null) {
example = "56";
}
} else if ("Float".equalsIgnoreCase(type) || "Double".equalsIgnoreCase(type)) {
if (example == null) {
example = "3.4";
}
} else if ("BOOLEAN".equalsIgnoreCase(type) || "bool".equalsIgnoreCase(type)) {
if (example == null) {
example = "True";
}
} else if ("\\SplFileObject".equalsIgnoreCase(type)) {
if (example == null) {
example = "/path/to/file";
}
example = "\"" + escapeText(example) + "\"";
} else if ("Date".equalsIgnoreCase(type)) {
if (example == null) {
example = "2013-10-20";
}
example = "new \\DateTime(\"" + escapeText(example) + "\")";
} else if ("DateTime".equalsIgnoreCase(type)) {
if (example == null) {
example = "2013-10-20T19:20:30+01:00";
}
example = "new \\DateTime(\"" + escapeText(example) + "\")";
} else if (!languageSpecificPrimitives.contains(type)) {
// type is a model class, e.g. User
example = "new " + type + "()";
} else {
LOGGER.warn("Type " + type + " not handled properly in setParameterExampleValue");
}
if (example == null) {
example = "NULL";
} else if (Boolean.TRUE.equals(p.isListContainer)) {
example = "array(" + example + ")";
} else if (Boolean.TRUE.equals(p.isMapContainer)) {
example = "array('key' => " + example + ")";
}
p.example = example;
}
@Override
public String toEnumValue(String value, String datatype) {
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
return value;
} else {
return "\'" + escapeText(value) + "\'";
}
}
@Override
public String toEnumDefaultValue(String value, String datatype) {
return datatype + "_" + value;
}
@Override
public String toEnumVarName(String name, String datatype) {
// number
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
String varName = new String(name);
varName = varName.replaceAll("-", "MINUS_");
varName = varName.replaceAll("\\+", "PLUS_");
varName = varName.replaceAll("\\.", "_DOT_");
return varName;
}
// string
String enumName = sanitizeName(underscore(name).toUpperCase());
enumName = enumName.replaceFirst("^_", "");
enumName = enumName.replaceFirst("_$", "");
if (enumName.matches("\\d.*")) { // starts with number
return "_" + enumName;
} else {
return enumName;
}
}
@Override
public String toEnumName(CodegenProperty property) {
String enumName = underscore(toModelName(property.name)).toUpperCase();
if (enumName.matches("\\d.*")) { // starts with number
return "_" + enumName;
} else {
return enumName;
}
}
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
// process enum in models
return postProcessModelsEnum(objs);
}
@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation op : operationList) {
op.vendorExtensions.put("x-testOperationId", camelize(op.operationId));
}
return objs;
}
@Override
public String escapeQuotationMark(String input) {
// remove ' to avoid code injection
return input.replace("'", "");
}
@Override
public String escapeUnsafeCharacters(String input) {
return input.replace("*/", "");
}
}

View File

@@ -26,6 +26,11 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
public AbstractTypeScriptClientCodegen() {
super();
// clear import mapping (from default generator) as TS does not use it
// at the moment
importMapping.clear();
supportsInheritance = true;
setReservedWordsLowerCase(Arrays.asList(
// local variable names used in API methods (endpoints)

View File

@@ -0,0 +1,95 @@
package io.swagger.codegen.languages;
import io.swagger.codegen.*;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.MapProperty;
import io.swagger.models.properties.Property;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
public class ConfluenceWikiGenerator extends DefaultCodegen implements CodegenConfig {
private static final String ALL_OPERATIONS = "";
protected String invokerPackage = "io.swagger.client";
protected String groupId = "io.swagger";
protected String artifactId = "swagger-client";
protected String artifactVersion = "1.0.0";
public ConfluenceWikiGenerator() {
super();
outputFolder = "docs";
embeddedTemplateDir = templateDir = "confluenceWikiDocs";
defaultIncludes = new HashSet<String>();
cliOptions.add(new CliOption("appName", "short name of the application"));
cliOptions.add(new CliOption("appDescription", "description of the application"));
cliOptions.add(new CliOption("infoUrl", "a URL where users can get more information about the application"));
cliOptions.add(new CliOption("infoEmail", "an email address to contact for inquiries about the application"));
cliOptions.add(new CliOption("licenseInfo", "a short description of the license"));
cliOptions.add(new CliOption("licenseUrl", "a URL pointing to the full license"));
cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC));
cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC));
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, CodegenConstants.ARTIFACT_ID_DESC));
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC));
additionalProperties.put("appName", "Swagger Sample");
additionalProperties.put("appDescription", "A sample swagger server");
additionalProperties.put("infoUrl", "https://helloreverb.com");
additionalProperties.put("infoEmail", "hello@helloreverb.com");
additionalProperties.put("licenseInfo", "All rights reserved");
additionalProperties.put("licenseUrl", "http://apache.org/licenses/LICENSE-2.0.html");
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
additionalProperties.put(CodegenConstants.GROUP_ID, groupId);
additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId);
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
supportingFiles.add(new SupportingFile("index.mustache", "", "confluence-markup.txt"));
reservedWords = new HashSet<String>();
languageSpecificPrimitives = new HashSet<String>();
importMapping = new HashMap<String, String>();
}
@Override
public CodegenType getTag() {
return CodegenType.DOCUMENTATION;
}
@Override
public String getName() {
return "cwiki";
}
@Override
public String getHelp() {
return "Generates confluence wiki markup.";
}
@Override
public String getTypeDeclaration(Property p) {
if (p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
Property inner = ap.getItems();
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
} else if (p instanceof MapProperty) {
MapProperty mp = (MapProperty) p;
Property inner = mp.getAdditionalProperties();
return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
}
return super.getTypeDeclaration(p);
}
@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation op : operationList) {
op.httpMethod = op.httpMethod.toLowerCase();
}
return objs;
}
}

View File

@@ -24,6 +24,11 @@ public class CsharpDotNet2ClientCodegen extends DefaultCodegen implements Codege
public CsharpDotNet2ClientCodegen() {
super();
// clear import mapping (from default generator) as C# (2.0) does not use it
// at the moment
importMapping.clear();
outputFolder = "generated-code" + File.separator + "CsharpDotNet2";
modelTemplateFiles.put("model.mustache", ".cs");
apiTemplateFiles.put("api.mustache", ".cs");

View File

@@ -28,6 +28,11 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
public DartClientCodegen() {
super();
// clear import mapping (from default generator) as dart does not use it
// at the moment
importMapping.clear();
outputFolder = "generated-code/dart";
modelTemplateFiles.put("model.mustache", ".dart");
apiTemplateFiles.put("api.mustache", ".dart");
@@ -140,6 +145,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
final String libFolder = sourceFolder + File.separator + "lib";
supportingFiles.add(new SupportingFile("pubspec.mustache", "", "pubspec.yaml"));
supportingFiles.add(new SupportingFile("analysis_options.mustache", "", ".analysis_options"));
supportingFiles.add(new SupportingFile("api_client.mustache", libFolder, "api_client.dart"));
supportingFiles.add(new SupportingFile("api_exception.mustache", libFolder, "api_exception.dart"));
supportingFiles.add(new SupportingFile("api_helper.mustache", libFolder, "api_helper.dart"));

View File

@@ -382,13 +382,21 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
// if the return type is not primitive, import encoding/json
for (CodegenOperation operation : operations) {
if(operation.returnBaseType != null && needToImport(operation.returnBaseType)) {
Map<String, String> customImport = new HashMap<String, String>();
customImport.put("import", "encoding/json");
imports.add(customImport);
imports.add(createMapping("import", "encoding/json"));
break; //just need to import once
}
}
// this will only import "strings" "fmt" if there are items in pathParams
for (CodegenOperation operation : operations) {
if(operation.pathParams != null && operation.pathParams.size() > 0) {
imports.add(createMapping("import", "fmt"));
imports.add(createMapping("import", "strings"));
break; //just need to import once
}
}
// recursivly add import for mapping one type to multipe imports
List<Map<String, String>> recursiveImports = (List<Map<String, String>>) objs.get("imports");
if (recursiveImports == null)
@@ -400,9 +408,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
// if the import package happens to be found in the importMapping (key)
// add the corresponding import package to the list
if (importMapping.containsKey(_import)) {
Map<String, String> newImportMap= new HashMap<String, String>();
newImportMap.put("import", importMapping.get(_import));
listIterator.add(newImportMap);
listIterator.add(createMapping("import", importMapping.get(_import)));
}
}
@@ -432,9 +438,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
// if the import package happens to be found in the importMapping (key)
// add the corresponding import package to the list
if (importMapping.containsKey(_import)) {
Map<String, String> newImportMap= new HashMap<String, String>();
newImportMap.put("import", importMapping.get(_import));
listIterator.add(newImportMap);
listIterator.add(createMapping("import", importMapping.get(_import)));
}
}
@@ -465,4 +469,11 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
public String escapeUnsafeCharacters(String input) {
return input.replace("*/", "*_/").replace("/*", "/_*");
}
public Map<String, String> createMapping(String key, String value){
Map<String, String> customImport = new HashMap<String, String>();
customImport.put(key, value);
return customImport;
}
}

View File

@@ -12,6 +12,10 @@ public class GroovyClientCodegen extends AbstractJavaCodegen {
public GroovyClientCodegen() {
super();
// clear import mapping (from default generator) as groovy does not use it
// at the moment
importMapping.clear();
sourceFolder = projectFolder + File.separator + "groovy";
outputFolder = "generated-code/groovy";
modelTemplateFiles.put("model.mustache", ".groovy");

View File

@@ -49,8 +49,10 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
public HaskellServantCodegen() {
super();
// override the mapping for "-" (Minus) to keep the original mapping in Haskell
specialCharReplacements.put('-', "Dash");
// override the mapping to keep the original mapping in Haskell
specialCharReplacements.put("-", "Dash");
specialCharReplacements.put(">", "GreaterThan");
specialCharReplacements.put("<", "LessThan");
// set the output folder here
outputFolder = "generated-code/haskell-servant";
@@ -203,9 +205,9 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
List<Map<String, Object>> replacements = new ArrayList<>();
Object[] replacementChars = specialCharReplacements.keySet().toArray();
for(int i = 0; i < replacementChars.length; i++) {
Character c = (Character) replacementChars[i];
String c = (String) replacementChars[i];
Map<String, Object> o = new HashMap<>();
o.put("char", Character.toString(c));
o.put("char", c);
o.put("replacement", "'" + specialCharReplacements.get(c));
o.put("hasMore", i != replacementChars.length - 1);
replacements.add(o);
@@ -471,6 +473,11 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
// Create newtypes for things with non-object types
String dataOrNewtype = "data";
// check if it's a ModelImpl before casting
if (!(mod instanceof ModelImpl)) {
return model;
}
String modelType = ((ModelImpl) mod).getType();
if(modelType != "object" && typeMapping.containsKey(modelType)) {
String newtype = typeMapping.get(modelType);

View File

@@ -15,7 +15,6 @@ public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen
public JavaCXFServerCodegen()
{
super();
supportsInheritance = true;
sourceFolder = "gen" + File.separator + "java";
outputFolder = "generated-code/JavaJaxRS-CXF";
apiTestTemplateFiles.clear(); // TODO: add test template

View File

@@ -183,6 +183,11 @@ public class JavaClientCodegen extends AbstractJavaCodegen {
if(additionalProperties.containsKey("gson")) {
model.imports.add("SerializedName");
}
} else { // enum class
//Needed imports for Jackson's JsonCreator
if(additionalProperties.containsKey("jackson")) {
model.imports.add("JsonCreator");
}
}
}

View File

@@ -25,7 +25,6 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen
public JavaJAXRSSpecServerCodegen()
{
super();
supportsInheritance = true;
sourceFolder = "src/main/java";
invokerPackage = "io.swagger.api";
artifactId = "swagger-jaxrs-server";

View File

@@ -762,9 +762,11 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
+ (StringUtils.isEmpty(modelPackage) ? "" : (modelPackage + "/")) + dataType;
}
/*
private String getJSDocTypeWithBraces(CodegenModel cm, CodegenProperty cp) {
return "{" + getJSDocType(cm, cp) + "}";
}
*/
private String getJSDocType(CodegenModel cm, CodegenProperty cp) {
if (Boolean.TRUE.equals(cp.isContainer)) {
@@ -787,9 +789,11 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
return cp.isEnum || !languageSpecificPrimitives.contains(cp.baseType == null ? cp.datatype : cp.baseType);
}
/*
private String getJSDocTypeWithBraces(CodegenParameter cp) {
return "{" + getJSDocType(cp) + "}";
}
*/
private String getJSDocType(CodegenParameter cp) {
String dataType = trimBrackets(cp.dataType);
@@ -808,10 +812,12 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
return cp.isEnum || !languageSpecificPrimitives.contains(cp.baseType == null ? cp.dataType : cp.baseType);
}
/*
private String getJSDocTypeWithBraces(CodegenOperation co) {
String jsDocType = getJSDocType(co);
return jsDocType == null ? null : "{" + jsDocType + "}";
}
*/
private String getJSDocType(CodegenOperation co) {
String returnType = trimBrackets(co.returnType);
@@ -860,10 +866,10 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
// Store JSDoc type specification into vendor-extension: x-jsdoc-type.
for (CodegenParameter cp : operation.allParams) {
String jsdocType = getJSDocTypeWithBraces(cp);
String jsdocType = getJSDocType(cp);
cp.vendorExtensions.put("x-jsdoc-type", jsdocType);
}
String jsdocType = getJSDocTypeWithBraces(operation);
String jsdocType = getJSDocType(operation);
operation.vendorExtensions.put("x-jsdoc-type", jsdocType);
}
}
@@ -889,7 +895,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
for (CodegenProperty var : cm.vars) {
// Add JSDoc @type value for this property.
String jsDocType = getJSDocTypeWithBraces(cm, var);
String jsDocType = getJSDocType(cm, var);
var.vendorExtensions.put("x-jsdoc-type", jsDocType);
if (Boolean.TRUE.equals(var.required)) {

View File

@@ -10,10 +10,9 @@ import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig {
// source folder where to write the files
protected String sourceFolder = "";
public class LumenServerCodegen extends AbstractPhpCodegen
{
@SuppressWarnings("hiding")
protected String apiVersion = "1.0.0";
/**
@@ -43,47 +42,19 @@ public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig
* @return A string value for the help message
*/
public String getHelp() {
return "Generates a LumenServerCodegen client library.";
return "Generates a LumenServerCodegen server library.";
}
public LumenServerCodegen() {
super();
// set the output folder here
outputFolder = "lumen";
String packagePath = "";
embeddedTemplateDir = templateDir = "lumen";
/**
* Models. You can write model files using the modelTemplateFiles map.
* if you want to create one template for file, you can do so here.
* for multiple files for model, just put another entry in the `modelTemplateFiles` with
* a different extension
* packPath
*/
// modelTemplateFiles.put(
// "model.mustache", // the template to use
// ".sample"); // the extension for each file to write
/**
* Api classes. You can write classes for each Api file with the apiTemplateFiles map.
* as with models, add multiple entries with different extensions for multiple files per
* class
*/
// apiTemplateFiles.put(
// "api.mustache", // the template to use
// ".sample"); // the extension for each file to write
// no api files
// apiTemplateFiles.clear();
apiTemplateFiles.put("api.mustache", ".php");
// embeddedTemplateDir = templateDir = "slim";
/**
* Template Location. This is the location which templates will be read from. The generator
* will use the resource stream to attempt to read the templates.
*/
templateDir = "lumen";
invokerPackage = "lumen";
packagePath = "";
/**
* Api Package. Optional, if needed, this can be used in templates
@@ -95,14 +66,11 @@ public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig
*/
modelPackage = "models";
/**
* Reserved words. Override this with reserved words specific to your language
*/
reservedWords = new HashSet<String> (
Arrays.asList(
"sample1", // replace with static values
"sample2")
);
// template files want to be ignored
modelTemplateFiles.clear();
apiTestTemplateFiles.clear();
apiDocTemplateFiles.clear();
modelDocTemplateFiles.clear();
/**
* Additional Properties. These values can be passed to the templates and
@@ -115,55 +83,18 @@ public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig
* entire object tree available. If the input file has a suffix of `.mustache
* it will be processed by the template engine. Otherwise, it will be copied
*/
supportingFiles.add(new SupportingFile("composer.mustache", packagePath, "composer.json"));
supportingFiles.add(new SupportingFile("readme.md", packagePath, "readme.md"));
supportingFiles.add(new SupportingFile("app.php", packagePath + File.separator + "bootstrap", "app.php"));
supportingFiles.add(new SupportingFile("index.php", packagePath + File.separator + "public", "index.php"));
supportingFiles.add(new SupportingFile("User.php", packagePath + File.separator + "app", "User.php"));
supportingFiles.add(new SupportingFile("Kernel.php", packagePath + File.separator + "app" + File.separator + "Console", "Kernel.php"));
supportingFiles.add(new SupportingFile("Handler.php", packagePath + File.separator + "app" + File.separator + "Exceptions", "Handler.php"));
supportingFiles.add(new SupportingFile("routes.mustache", packagePath + File.separator + "app" + File.separator + "Http", "routes.php"));
supportingFiles.add(new SupportingFile("composer.mustache", packagePath + File.separator + srcBasePath, "composer.json"));
supportingFiles.add(new SupportingFile("readme.md", packagePath + File.separator + srcBasePath, "readme.md"));
supportingFiles.add(new SupportingFile("app.php", packagePath + File.separator + srcBasePath + File.separator + "bootstrap", "app.php"));
supportingFiles.add(new SupportingFile("index.php", packagePath + File.separator + srcBasePath + File.separator + "public", "index.php"));
supportingFiles.add(new SupportingFile("User.php", packagePath + File.separator + srcBasePath + File.separator + "app", "User.php"));
supportingFiles.add(new SupportingFile("Kernel.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Console", "Kernel.php"));
supportingFiles.add(new SupportingFile("Handler.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Exceptions", "Handler.php"));
supportingFiles.add(new SupportingFile("routes.mustache", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http", "routes.php"));
supportingFiles.add(new SupportingFile("Controller.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "Controller.php"));
supportingFiles.add(new SupportingFile("Authenticate.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "Authenticate.php"));
supportingFiles.add(new SupportingFile("Controller.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "Controller.php"));
supportingFiles.add(new SupportingFile("Authenticate.php", packagePath + File.separator + srcBasePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "Authenticate.php"));
/**
* Language Specific Primitives. These types will not trigger imports by
* the client generator
*/
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList(
"Type1", // replace these with your types
"Type2")
);
}
/**
* Escapes a reserved word as defined in the `reservedWords` array. Handle escaping
* those terms here. This logic is only called if a variable matches the reseved words
*
* @return the escaped term
*/
@Override
public String escapeReservedWord(String name) {
return "_" + name; // add an underscore to the name
}
/**
* Location to write model files. You can use the modelPackage() as defined when the class is
* instantiated
*/
public String modelFileFolder() {
return outputFolder + "/" + modelPackage().replace('.', File.separatorChar);
}
/**
* Location to write api files. You can use the apiPackage() as defined when the class is
* instantiated
*/
@Override
public String apiFileFolder() {
return outputFolder + "/" + apiPackage().replace('.', File.separatorChar);//"/app/Http/controllers";
}
// override with any special post-processing
@@ -185,57 +116,4 @@ public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig
return objs;
}
/**
* Optional - type declaration. This is a String which is used by the templates to instantiate your
* types. There is typically special handling for different property types
*
* @return a string value used as the `dataType` field for model templates, `returnType` for api templates
*/
@Override
public String getTypeDeclaration(Property p) {
if(p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
Property inner = ap.getItems();
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
}
else if (p instanceof MapProperty) {
MapProperty mp = (MapProperty) p;
Property inner = mp.getAdditionalProperties();
return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
}
return super.getTypeDeclaration(p);
}
/**
* Optional - swagger type conversion. This is used to map swagger types in a `Property` into
* either language specific types via `typeMapping` or into complex models if there is not a mapping.
*
* @return a string value of the type or complex model for this property
* @see io.swagger.models.properties.Property
*/
@Override
public String getSwaggerType(Property p) {
String swaggerType = super.getSwaggerType(p);
String type = null;
if(typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType);
if(languageSpecificPrimitives.contains(type))
return toModelName(type);
}
else
type = swaggerType;
return toModelName(type);
}
@Override
public String escapeQuotationMark(String input) {
// remove ' to avoid code injection
return input.replace("'", "");
}
@Override
public String escapeUnsafeCharacters(String input) {
return input.replace("*/", "*_/").replace("/*", "/_*");
}
}

View File

@@ -222,7 +222,7 @@ public class NancyFXServerCodegen extends AbstractCSharpCodegen {
}
private void postProcessParentModels(final Map<String, Object> models) {
log.info("Processing parents: " + parentModels);
log.debug("Processing parents: " + parentModels);
for (final String parent : parentModels) {
final CodegenModel parentModel = modelByName(parent, models);
parentModel.hasChildren = true;
@@ -301,7 +301,7 @@ public class NancyFXServerCodegen extends AbstractCSharpCodegen {
} else {
result = enumName;
}
log.info(String.format("toEnumVarName('%s', %s) = '%s'", name, datatype, enumName));
log.debug(String.format("toEnumVarName('%s', %s) = '%s'", name, datatype, enumName));
return result;
}
@@ -313,7 +313,7 @@ public class NancyFXServerCodegen extends AbstractCSharpCodegen {
} else {
apiName = capitalize(name);
}
log.info(String.format("toApiName('%s') = '%s'", name, apiName));
log.debug(String.format("toApiName('%s') = '%s'", name, apiName));
return apiName;
}
@@ -334,7 +334,7 @@ public class NancyFXServerCodegen extends AbstractCSharpCodegen {
} else {
result = null;
}
log.info(String.format("toModelImport('%s') = '%s'", name, result));
log.debug(String.format("toModelImport('%s') = '%s'", name, result));
return result;
}

View File

@@ -320,4 +320,14 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
return removeNonNameElementToCamelCase(name, "[-:;#]");
}
@Override
public String escapeUnsafeCharacters(String input) {
return input.replace("*/", "*_/").replace("/*", "/_*");
}
@Override
public String escapeQuotationMark(String input) {
// remove " to avoid code injection
return input.replace("\"", "");
}
}

View File

@@ -703,6 +703,8 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
example = "2013-10-20T19:20:30+01:00";
}
example = "@\"" + escapeText(example) + "\"";
} else if ("NSData".equalsIgnoreCase(type)) {
example = "1234";
} else if (!languageSpecificPrimitives.contains(type)) {
// type is a model class, e.g. User
type = type.replace("*", "");

View File

@@ -42,6 +42,11 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
public PerlClientCodegen() {
super();
// clear import mapping (from default generator) as perl does not use it
// at the moment
importMapping.clear();
modelPackage = File.separatorChar + "Object";
outputFolder = "generated-code" + File.separatorChar + "perl";
modelTemplateFiles.put("object.mustache", ".pm");

View File

@@ -50,6 +50,11 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
public PhpClientCodegen() {
super();
// clear import mapping (from default generator) as php does not use it
// at the moment
importMapping.clear();
supportsInheritance = true;
outputFolder = "generated-code" + File.separator + "php";
modelTemplateFiles.put("model.mustache", ".php");
@@ -640,6 +645,9 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
public String toEnumName(CodegenProperty property) {
String enumName = underscore(toModelName(property.name)).toUpperCase();
// remove [] for array or map of enum
enumName = enumName.replace("[]", "");
if (enumName.matches("\\d.*")) { // starts with number
return "_" + enumName;
} else {

View File

@@ -33,6 +33,10 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
public PythonClientCodegen() {
super();
// clear import mapping (from default generator) as python does not use it
// at the moment
importMapping.clear();
modelPackage = "models";
apiPackage = "api";
outputFolder = "generated-code" + File.separatorChar + "python";

View File

@@ -124,6 +124,7 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
//TODO binary should be mapped to byte array
// mapped to String as a workaround
typeMapping.put("binary", "QString");
typeMapping.put("ByteArray", "QByteArray");
importMapping = new HashMap<String, String>();
@@ -138,6 +139,7 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
systemIncludes.add("QMap");
systemIncludes.add("QDate");
systemIncludes.add("QDateTime");
systemIncludes.add("QByteArray");
}
/**

View File

@@ -54,6 +54,11 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
public RubyClientCodegen() {
super();
// clear import mapping (from default generator) as ruby does not use it
// at the moment
importMapping.clear();
modelPackage = "models";
apiPackage = "api";
outputFolder = "generated-code" + File.separator + "ruby";
@@ -225,7 +230,6 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
// test files should not be overwritten
writeOptional(outputFolder, new SupportingFile("rspec.mustache", "", ".rspec"));

View File

@@ -42,7 +42,7 @@ public class ScalatraServerCodegen extends DefaultCodegen implements CodegenConf
"import", "public", "throws", "case", "enum", "instanceof", "return", "transient",
"catch", "extends", "int", "short", "try", "char", "final", "interface", "static",
"void", "class", "finally", "long", "strictfp", "volatile", "const", "float",
"native", "super", "while")
"native", "super", "while", "type")
);
defaultIncludes = new HashSet<String>(

View File

@@ -30,6 +30,10 @@ public class SlimFrameworkServerCodegen extends DefaultCodegen implements Codege
public SlimFrameworkServerCodegen() {
super();
// clear import mapping (from default generator) as slim does not use it
// at the moment
importMapping.clear();
invokerPackage = camelize("SwaggerServer");
//String packagePath = "SwaggerServer";

View File

@@ -18,6 +18,11 @@ public class StaticDocCodegen extends DefaultCodegen implements CodegenConfig {
public StaticDocCodegen() {
super();
// clear import mapping (from default generator) as this generator does not use it
// at the moment
importMapping.clear();
outputFolder = "docs";
modelTemplateFiles.put("model.mustache", ".html");
apiTemplateFiles.put("operation.mustache", ".html");

View File

@@ -0,0 +1,154 @@
package io.swagger.codegen.languages;
import io.swagger.codegen.*;
import io.swagger.models.Model;
import io.swagger.models.Operation;
import io.swagger.models.Swagger;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.MapProperty;
import io.swagger.models.properties.Property;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfig {
private static final String ALL_OPERATIONS = "";
protected String invokerPackage = "io.swagger.client";
protected String groupId = "io.swagger";
protected String artifactId = "swagger-client";
protected String artifactVersion = "1.0.0";
protected String sourceFolder = "src/main/scala";
public StaticHtml2Generator() {
super();
outputFolder = "docs";
embeddedTemplateDir = templateDir = "htmlDocs2";
defaultIncludes = new HashSet<String>();
cliOptions.add(new CliOption("appName", "short name of the application"));
cliOptions.add(new CliOption("appDescription", "description of the application"));
cliOptions.add(new CliOption("infoUrl", "a URL where users can get more information about the application"));
cliOptions.add(new CliOption("infoEmail", "an email address to contact for inquiries about the application"));
cliOptions.add(new CliOption("licenseInfo", "a short description of the license"));
cliOptions.add(new CliOption("licenseUrl", "a URL pointing to the full license"));
cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC));
cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC));
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, CodegenConstants.ARTIFACT_ID_DESC));
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC));
additionalProperties.put("appName", "Swagger Sample");
additionalProperties.put("appDescription", "A sample swagger server");
additionalProperties.put("infoUrl", "https://helloreverb.com");
additionalProperties.put("infoEmail", "hello@helloreverb.com");
additionalProperties.put("licenseInfo", "All rights reserved");
additionalProperties.put("licenseUrl", "http://apache.org/licenses/LICENSE-2.0.html");
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
additionalProperties.put(CodegenConstants.GROUP_ID, groupId);
additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId);
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
supportingFiles.add(new SupportingFile("index.mustache", "", "index.html"));
reservedWords = new HashSet<String>();
languageSpecificPrimitives = new HashSet<String>();
importMapping = new HashMap<String, String>();
}
@Override
public CodegenType getTag() {
return CodegenType.DOCUMENTATION;
}
@Override
public String getName() {
return "html2";
}
@Override
public String getHelp() {
return "Generates a static HTML file.";
}
@Override
public String getTypeDeclaration(Property p) {
if (p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
Property inner = ap.getItems();
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
} else if (p instanceof MapProperty) {
MapProperty mp = (MapProperty) p;
Property inner = mp.getAdditionalProperties();
return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
}
return super.getTypeDeclaration(p);
}
@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation op : operationList) {
op.httpMethod = op.httpMethod.toLowerCase();
}
return objs;
}
@Override
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map<String, Model> definitions, Swagger swagger) {
CodegenOperation op = super.fromOperation(path, httpMethod, operation, definitions, swagger);
if (op.returnType != null) {
op.returnType = normalizeType(op.returnType);
}
//path is an unescaped variable in the mustache template api.mustache line 82 '<&path>'
op.path = sanitizePath(op.path);
// Set vendor-extension to be used in template:
// x-codegen-hasMoreRequired
// x-codegen-hasMoreOptional
// x-codegen-hasRequiredParams
CodegenParameter lastRequired = null;
CodegenParameter lastOptional = null;
for (CodegenParameter p : op.allParams) {
if (p.required != null && p.required) {
lastRequired = p;
} else {
lastOptional = p;
}
}
for (CodegenParameter p : op.allParams) {
if (p == lastRequired) {
p.vendorExtensions.put("x-codegen-hasMoreRequired", false);
} else if (p == lastOptional) {
p.vendorExtensions.put("x-codegen-hasMoreOptional", false);
} else {
p.vendorExtensions.put("x-codegen-hasMoreRequired", true);
p.vendorExtensions.put("x-codegen-hasMoreOptional", true);
}
}
op.vendorExtensions.put("x-codegen-hasRequiredParams", lastRequired != null);
return op;
}
private String sanitizePath(String p) {
//prefer replace a ', instead of a fuLL URL encode for readability
return p.replaceAll("'", "%27");
}
/**
* Normalize type by wrapping primitive types with single quotes.
*
* @param type Primitive type
* @return Normalized type
*/
public String normalizeType(String type) {
return type.replaceAll("\\b(Boolean|Integer|Number|String|Date)\\b", "'$1'");
}
}

View File

@@ -38,6 +38,7 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
public static final String POD_SCREENSHOTS = "podScreenshots";
public static final String POD_DOCUMENTATION_URL = "podDocumentationURL";
public static final String SWIFT_USE_API_NAMESPACE = "swiftUseApiNamespace";
public static final String DEFAULT_POD_AUTHORS = "Swagger Codegen";
protected static final String LIBRARY_PROMISE_KIT = "PromiseKit";
protected static final String[] RESPONSE_LIBRARIES = { LIBRARY_PROMISE_KIT };
protected String projectName = "SwaggerClient";
@@ -86,8 +87,10 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
);
defaultIncludes = new HashSet<String>(
Arrays.asList(
"NSData",
"NSDate",
"NSURL", // for file
"NSUUID",
"Array",
"Dictionary",
"Set",
@@ -127,10 +130,9 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("double", "Double");
typeMapping.put("object", "AnyObject");
typeMapping.put("file", "NSURL");
//TODO binary should be mapped to byte array
// mapped to String as a workaround
typeMapping.put("binary", "String");
typeMapping.put("ByteArray", "String");
typeMapping.put("binary", "NSData");
typeMapping.put("ByteArray", "NSData");
typeMapping.put("UUID", "NSUUID");
importMapping = new HashMap<String, String>();
@@ -191,6 +193,10 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
}
additionalProperties.put(SWIFT_USE_API_NAMESPACE, swiftUseApiNamespace);
if (!additionalProperties.containsKey(POD_AUTHORS)) {
additionalProperties.put(POD_AUTHORS, DEFAULT_POD_AUTHORS);
}
supportingFiles.add(new SupportingFile("Podspec.mustache", "", projectName + ".podspec"));
supportingFiles.add(new SupportingFile("Cartfile.mustache", "", "Cartfile"));
supportingFiles.add(new SupportingFile("APIHelper.mustache", sourceFolder, "APIHelper.swift"));
@@ -251,6 +257,11 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
return toModelName(type);
}
@Override
public boolean isDataTypeBinary(final String dataType) {
return dataType != null && dataType.equals("NSData");
}
/**
* Output the proper model name (capitalized)
*
@@ -336,10 +347,10 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
List<Map<String, String>> swiftEnums = new ArrayList<Map<String, String>>();
List<String> values = (List<String>) codegenProperty.allowableValues.get("values");
for (String value : values) {
for (Object value : values) {
Map<String, String> map = new HashMap<String, String>();
map.put("enum", toSwiftyEnumName(value));
map.put("raw", value);
map.put("enum", toSwiftyEnumName(String.valueOf(value)));
map.put("raw", String.valueOf(value));
swiftEnums.add(map);
}
codegenProperty.allowableValues.put("values", swiftEnums);

View File

@@ -15,6 +15,11 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
public TypeScriptFetchClientCodegen() {
super();
// clear import mapping (from default generator) as TS does not use it
// at the moment
importMapping.clear();
outputFolder = "generated-code/typescript-fetch";
embeddedTemplateDir = templateDir = "TypeScript-Fetch";
this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package"));

View File

@@ -26,6 +26,11 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
public TypeScriptNodeClientCodegen() {
super();
// clear import mapping (from default generator) as TS does not use it
// at the moment
importMapping.clear();
outputFolder = "generated-code/typescript-node";
embeddedTemplateDir = templateDir = "typescript-node";

View File

@@ -27,7 +27,7 @@ public interface {{classname}} extends ApiClient.Api {
@Headers({
"Content-type: {{vendorExtensions.x-contentType}}",
"Accept: {{vendorExtensions.x-accepts}}",{{#headerParams}}
"{{paramName}}: {{=<% %>=}}{<%paramName%>}<%={{ }}=%>"{{#hasMore}},
"{{baseName}}: {{=<% %>=}}{<%paramName%>}<%={{ }}=%>"{{#hasMore}},
{{/hasMore}}{{/headerParams}}
})
{{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}}({{#allParams}}{{^isBodyParam}}@Param("{{paramName}}") {{/isBodyParam}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});

View File

@@ -498,8 +498,15 @@ public class ApiClient {
* Deserialize response body to Java object according to the Content-Type.
*/
public <T> T deserialize(Response response, GenericType<T> returnType) throws ApiException {
// Handle file downloading.
if (returnType.equals(File.class)) {
if (response == null || returnType == null) {
return null;
}
if ("byte[]".equals(returnType.toString())) {
// Handle binary response (byte array).
return (T) response.readEntity(byte[].class);
} else if (returnType.equals(File.class)) {
// Handle file downloading.
@SuppressWarnings("unchecked")
T file = (T) downloadFileFromResponse(response);
return file;

View File

@@ -1,3 +1,7 @@
{{#jackson}}
import com.fasterxml.jackson.annotation.JsonCreator;
{{/jackson}}
/**
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
*/
@@ -24,4 +28,16 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum
public String toString() {
return String.valueOf(value);
}
{{#jackson}}
@JsonCreator
public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) {
for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
if (String.valueOf(b.value).equals(text)) {
return b;
}
}
return null;
}
{{/jackson}}
}

View File

@@ -30,4 +30,16 @@
public String toString() {
return String.valueOf(value);
}
{{#jackson}}
@JsonCreator
public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) {
for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
if (String.valueOf(b.value).equals(text)) {
return b;
}
}
return null;
}
{{/jackson}}
}

View File

@@ -32,6 +32,20 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
this.{{name}} = {{name}};
return this;
}
{{#isListContainer}}
public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
this.{{name}}.add({{name}}Item);
return this;
}
{{/isListContainer}}
{{#isMapContainer}}
public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
this.{{name}}.put(key, {{name}}Item);
return this;
}
{{/isMapContainer}}
{{/isReadOnly}}
/**

View File

@@ -107,6 +107,11 @@
{{/java8}}
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
</plugin>
</plugins>
</build>
<dependencies>

View File

@@ -5,6 +5,7 @@ import {{package}}.{{classname}}Service;
import {{package}}.factories.{{classname}}ServiceFactory;
import io.swagger.annotations.ApiParam;
import io.swagger.jaxrs.*;
{{#imports}}import {{import}};
{{/imports}}

View File

@@ -1,17 +1,33 @@
/**
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
*/
public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} {
{{#gson}}
{{#allowableValues}}
{{#enumVars}}
@SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}})
{{{name}}}({{{value}}}){{^-last}},
{{/-last}}{{#-last}};{{/-last}}
{{/enumVars}}
{{/allowableValues}}
{{/gson}}
{{^gson}}
{{#allowableValues}}
{{#enumVars}}
{{{name}}}({{{value}}}){{^-last}},
{{/-last}}{{#-last}};{{/-last}}
{{/enumVars}}
{{/allowableValues}}
{{/gson}}
public enum {{{datatypeWithEnum}}} {
{{#allowableValues}}{{#enumVars}}{{{name}}}({{{value}}}){{^-last}},
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
private {{{datatype}}} value;
private String value;
{{{datatypeWithEnum}}}(String value) {
{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}({{{datatype}}} value) {
this.value = value;
}
@Override
@JsonValue
public String toString() {
return value;
return String.valueOf(value);
}
}

View File

@@ -1,3 +1,27 @@
public enum {{classname}} {
{{#allowableValues}}{{.}}{{^-last}}, {{/-last}}{{/allowableValues}}
}
/**
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
*/
public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} {
{{#gson}}
{{#allowableValues}}{{#enumVars}}
@SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}})
{{{name}}}({{{value}}}){{^-last}},
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
{{/gson}}
{{^gson}}
{{#allowableValues}}{{#enumVars}}
{{{name}}}({{{value}}}){{^-last}},
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
{{/gson}}
private {{{dataType}}} value;
{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}({{{dataType}}} value) {
this.value = value;
}
@Override
public String toString() {
return String.valueOf(value);
}
}

View File

@@ -36,6 +36,7 @@
<webAppSourceDirectory>target/${project.artifactId}-${project.version}</webAppSourceDirectory>
<stopPort>8079</stopPort>
<stopKey>stopit</stopKey>
<stopWait>10</stopWait>
<httpConnector>
<port>{{serverPort}}</port>
<idleTimeout>60000</idleTimeout>

View File

@@ -1,53 +1,102 @@
{{#description}}@ApiModel(description = "{{{description}}}"){{/description}}
/**
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
*/{{#description}}
@ApiModel(description = "{{{description}}}"){{/description}}
{{>generatedAnnotation}}
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
{{#vars}}{{#isEnum}}
{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}
{{>enumClass}}{{/items}}{{/items.isEnum}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}}
{{#vars}}
/**{{#description}}
* {{{description}}}{{/description}}{{#minimum}}
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
* maximum: {{maximum}}{{/maximum}}
**/
{{#isEnum}}
{{^isContainer}}
{{>enumClass}}
{{/isContainer}}
{{/isEnum}}
{{#items.isEnum}}
{{#items}}
{{^isContainer}}
{{>enumClass}}
{{/isContainer}}
{{/items}}
{{/items.isEnum}}
{{#jackson}}
@JsonProperty("{{baseName}}")
{{/jackson}}
{{#gson}}
@SerializedName("{{baseName}}")
{{/gson}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};
{{/vars}}
{{#vars}}
{{^isReadOnly}}
public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
return this;
}
{{#isListContainer}}
{{#vendorExtensions.extraAnnotation}}{{vendorExtensions.extraAnnotation}}{{/vendorExtensions.extraAnnotation}}
public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
this.{{name}}.add({{name}}Item);
return this;
}
{{/isListContainer}}
{{#isMapContainer}}
public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
this.{{name}}.put(key, {{name}}Item);
return this;
}
{{/isMapContainer}}
{{/isReadOnly}}
/**
{{#description}}
* {{{description}}}
{{/description}}
{{^description}}
* Get {{name}}
{{/description}}
{{#minimum}}
* minimum: {{minimum}}
{{/minimum}}
{{#maximum}}
* maximum: {{maximum}}
{{/maximum}}
* @return {{name}}
**/
{{#vendorExtensions.extraAnnotation}}
{{vendorExtensions.extraAnnotation}}
{{/vendorExtensions.extraAnnotation}}
@ApiModelProperty({{#example}}example = "{{example}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
@JsonProperty("{{baseName}}")
public {{{datatypeWithEnum}}} {{getter}}() {
return {{name}};
}
{{^isReadOnly}}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
}
{{/isReadOnly}}
{{/vars}}
@Override
public boolean equals(Object o) {
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
{{classname}} {{classVarName}} = ({{classname}}) o;{{#hasVars}}
return {{#vars}}Objects.equals({{name}}, {{classVarName}}.{{name}}){{#hasMore}} &&
{{/hasMore}}{{^hasMore}};{{/hasMore}}{{/vars}}{{/hasVars}}{{^hasVars}}
}{{#hasVars}}
{{classname}} {{classVarName}} = ({{classname}}) o;
return {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} &&
{{/hasMore}}{{/vars}}{{#parent}} &&
super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}}
return true;{{/hasVars}}
}
@Override
public int hashCode() {
return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}});
return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}});
}
@Override
@@ -64,7 +113,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}

View File

@@ -36,6 +36,7 @@
<webAppSourceDirectory>target/${project.artifactId}-${project.version}</webAppSourceDirectory>
<stopPort>8079</stopPort>
<stopKey>stopit</stopKey>
<stopWait>10</stopWait>
<httpConnector>
<port>{{serverPort}}</port>
<idleTimeout>60000</idleTimeout>

View File

@@ -1 +1 @@
{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestBody {{{dataType}}} {{paramName}}{{/isBodyParam}}
{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{^isContainer}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{/isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestBody {{{dataType}}} {{paramName}}{{/isBodyParam}}

View File

@@ -1,17 +1,33 @@
/**
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
*/
public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} {
{{#gson}}
{{#allowableValues}}
{{#enumVars}}
@SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}})
{{{name}}}({{{value}}}){{^-last}},
{{/-last}}{{#-last}};{{/-last}}
{{/enumVars}}
{{/allowableValues}}
{{/gson}}
{{^gson}}
{{#allowableValues}}
{{#enumVars}}
{{{name}}}({{{value}}}){{^-last}},
{{/-last}}{{#-last}};{{/-last}}
{{/enumVars}}
{{/allowableValues}}
{{/gson}}
public enum {{{datatypeWithEnum}}} {
{{#allowableValues}}{{#enumVars}}{{{name}}}({{{value}}}){{^-last}},
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
private {{{datatype}}} value;
private String value;
{{{datatypeWithEnum}}}(String value) {
{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}({{{datatype}}} value) {
this.value = value;
}
@Override
@JsonValue
public String toString() {
return value;
return String.valueOf(value);
}
}

View File

@@ -1,3 +1,27 @@
public enum {{classname}} {
{{#allowableValues}}{{.}}{{^-last}}, {{/-last}}{{/allowableValues}}
}
/**
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
*/
public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} {
{{#gson}}
{{#allowableValues}}{{#enumVars}}
@SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}})
{{{name}}}({{{value}}}){{^-last}},
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
{{/gson}}
{{^gson}}
{{#allowableValues}}{{#enumVars}}
{{{name}}}({{{value}}}){{^-last}},
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
{{/gson}}
private {{{dataType}}} value;
{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}({{{dataType}}} value) {
this.value = value;
}
@Override
public String toString() {
return String.valueOf(value);
}
}

View File

@@ -1 +1 @@
{{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestPart(value="{{paramName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}@ApiParam(value = "file detail") @RequestPart("file") MultipartFile {{baseName}}{{/isFile}}{{/isFormParam}}
{{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{^isContainer}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{/isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestPart(value="{{paramName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}@ApiParam(value = "file detail") @RequestPart("file") MultipartFile {{baseName}}{{/isFile}}{{/isFormParam}}

View File

@@ -1 +1 @@
{{#isHeaderParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestHeader(value="{{baseName}}", required={{#required}}true{{/required}}{{^required}}false{{/required}}) {{{dataType}}} {{paramName}}{{/isHeaderParam}}
{{#isHeaderParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{^isContainer}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{/isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestHeader(value="{{baseName}}", required={{#required}}true{{/required}}{{^required}}false{{/required}}) {{{dataType}}} {{paramName}}{{/isHeaderParam}}

View File

@@ -3,6 +3,8 @@ package {{package}};
import org.springframework.cloud.netflix.feign.FeignClient;
import {{configPackage}}.ClientConfiguration;
@FeignClient(name="${ {{{title}}}.name:{{{title}}}}", url="${ {{{title}}}.url:{{{basePath}}}}", configuration = ClientConfiguration.class)
{{=<% %>=}}
@FeignClient(name="${<%title%>.name:<%title%>}", url="${<%title%>.url:<%basePath%>}", configuration = ClientConfiguration.class)
<%={{ }}=%>
public interface {{classname}}Client extends {{classname}} {
}

View File

@@ -1,53 +1,102 @@
{{#description}}@ApiModel(description = "{{{description}}}"){{/description}}
/**
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
*/{{#description}}
@ApiModel(description = "{{{description}}}"){{/description}}
{{>generatedAnnotation}}
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
{{#vars}}{{#isEnum}}
{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}
{{>enumClass}}{{/items}}{{/items.isEnum}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}}
{{#vars}}
/**{{#description}}
* {{{description}}}{{/description}}{{#minimum}}
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
* maximum: {{maximum}}{{/maximum}}
**/
{{#isEnum}}
{{^isContainer}}
{{>enumClass}}
{{/isContainer}}
{{/isEnum}}
{{#items.isEnum}}
{{#items}}
{{^isContainer}}
{{>enumClass}}
{{/isContainer}}
{{/items}}
{{/items.isEnum}}
{{#jackson}}
@JsonProperty("{{baseName}}")
{{/jackson}}
{{#gson}}
@SerializedName("{{baseName}}")
{{/gson}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};
{{/vars}}
{{#vars}}
{{^isReadOnly}}
public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
return this;
}
{{#isListContainer}}
{{#vendorExtensions.extraAnnotation}}{{vendorExtensions.extraAnnotation}}{{/vendorExtensions.extraAnnotation}}
public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
this.{{name}}.add({{name}}Item);
return this;
}
{{/isListContainer}}
{{#isMapContainer}}
public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
this.{{name}}.put(key, {{name}}Item);
return this;
}
{{/isMapContainer}}
{{/isReadOnly}}
/**
{{#description}}
* {{{description}}}
{{/description}}
{{^description}}
* Get {{name}}
{{/description}}
{{#minimum}}
* minimum: {{minimum}}
{{/minimum}}
{{#maximum}}
* maximum: {{maximum}}
{{/maximum}}
* @return {{name}}
**/
{{#vendorExtensions.extraAnnotation}}
{{vendorExtensions.extraAnnotation}}
{{/vendorExtensions.extraAnnotation}}
@ApiModelProperty({{#example}}example = "{{example}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
@JsonProperty("{{baseName}}")
public {{{datatypeWithEnum}}} {{getter}}() {
return {{name}};
}
{{^isReadOnly}}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
}
{{/isReadOnly}}
{{/vars}}
@Override
public boolean equals(Object o) {
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
{{classname}} {{classVarName}} = ({{classname}}) o;{{#hasVars}}
return {{#vars}}Objects.equals({{name}}, {{classVarName}}.{{name}}){{#hasMore}} &&
{{/hasMore}}{{^hasMore}};{{/hasMore}}{{/vars}}{{/hasVars}}{{^hasVars}}
}{{#hasVars}}
{{classname}} {{classVarName}} = ({{classname}}) o;
return {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} &&
{{/hasMore}}{{/vars}}{{#parent}} &&
super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}}
return true;{{/hasVars}}
}
@Override
public int hashCode() {
return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}});
return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}});
}
@Override
@@ -64,7 +113,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}

View File

@@ -1 +1 @@
{{#isQueryParam}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value = "{{paramName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{{dataType}}} {{paramName}}{{/isQueryParam}}
{{#isQueryParam}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{^isContainer}}{{#allowableValues}}, allowableValues = "{{{allowableValues}}}"{{/allowableValues}}{{/isContainer}}{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value = "{{paramName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{{dataType}}} {{paramName}}{{/isQueryParam}}

View File

@@ -133,7 +133,7 @@
{{#emitJSDoc}} /**
* Checks whether the given parameter value represents file-like content.
* @param param The parameter to check.
* @returns {Boolean} <code>true</code> if <code>param</code> represents a file.
* @returns {Boolean} <code>true</code> if <code>param</code> represents a file.
*/
{{/emitJSDoc}} exports.prototype.isFileParam = function(param) {
// fs.ReadStream in Node.js (but not in runtime like browserify)
@@ -185,7 +185,7 @@
{{#emitJSDoc}} /**
* Enumeration of collection format separator strategies.
* @enum {String}
* @enum {String}
* @readonly
*/
exports.CollectionFormatEnum = {
@@ -330,8 +330,8 @@
* @param {Array.<String>} accepts An array of acceptable response MIME types.
* @param {(String|Array|ObjectFunction)} returnType The required type to return; can be a string for simple types or the
* constructor for a complex type.{{^usePromises}}
* @param {module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}ApiClient~callApiCallback} callback The callback function.
{{/usePromises}} * @returns {{#usePromises}}{Promise} A Promise object{{/usePromises}}{{^usePromises}}{Object} The SuperAgent request object{{/usePromises}}.
* @param {module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}ApiClient~callApiCallback} callback The callback function.{{/usePromises}}
* @returns {{#usePromises}}{Promise} A {@link https://www.promisejs.org/|Promise} object{{/usePromises}}{{^usePromises}}{Object} The SuperAgent request object{{/usePromises}}.
*/
{{/emitJSDoc}} exports.prototype.callApi = function callApi(path, httpMethod, pathParams,
queryParams, headerParams, formParams, bodyParam, authNames, contentTypes, accepts,

View File

@@ -58,7 +58,7 @@ Please follow the [installation](#installation) instruction and execute the foll
```javascript
var {{{moduleName}}} = require('{{{projectName}}}');
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}
var defaultClient = {{{moduleName}}}.ApiClient.default;
var defaultClient = {{{moduleName}}}.ApiClient.instance;
{{#authMethods}}{{#isBasic}}
// Configure HTTP basic authorization: {{{name}}}
var {{{name}}} = defaultClient.authentications['{{{name}}}'];

View File

@@ -38,18 +38,19 @@
* Callback function to receive the result of the <operationId> operation.
* @callback module:<#invokerPackage><invokerPackage>/</invokerPackage><#apiPackage><apiPackage>/</apiPackage><classname>~<operationId>Callback
* @param {String} error Error message, if any.
* @param <#vendorExtensions.x-jsdoc-type><&vendorExtensions.x-jsdoc-type> data The data returned by the service call.</vendorExtensions.x-jsdoc-type><^vendorExtensions.x-jsdoc-type>data This operation does not return a value.</vendorExtensions.x-jsdoc-type>
* @param <#vendorExtensions.x-jsdoc-type>{<&vendorExtensions.x-jsdoc-type>} data The data returned by the service call.</vendorExtensions.x-jsdoc-type><^vendorExtensions.x-jsdoc-type>data This operation does not return a value.</vendorExtensions.x-jsdoc-type>
* @param {String} response The complete HTTP response.
*/</usePromises>
/**<#summary>
* <summary></summary><#notes>
* <notes></notes><#allParams><#required>
* @param <&vendorExtensions.x-jsdoc-type> <paramName> <description></required></allParams><#hasOptionalParams>
* @param {<&vendorExtensions.x-jsdoc-type>} <paramName> <description></required></allParams><#hasOptionalParams>
* @param {Object} opts Optional parameters<#allParams><^required>
* @param <&vendorExtensions.x-jsdoc-type> opts.<paramName> <description><#defaultValue> (default to <.>)</defaultValue></required></allParams></hasOptionalParams><^usePromises>
* @param {module:<#invokerPackage><&invokerPackage>/</invokerPackage><#apiPackage><&apiPackage>/</apiPackage><&classname>~<operationId>Callback} callback The callback function, accepting three arguments: error, data, response</usePromises><#returnType>
* data is of type: <&vendorExtensions.x-jsdoc-type></returnType>
* @param {<&vendorExtensions.x-jsdoc-type>} opts.<paramName> <description><#defaultValue> (default to <.>)</defaultValue></required></allParams></hasOptionalParams><^usePromises>
* @param {module:<#invokerPackage><&invokerPackage>/</invokerPackage><#apiPackage><&apiPackage>/</apiPackage><&classname>~<operationId>Callback} callback The callback function, accepting three arguments: error, data, response<#returnType>
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}</returnType></usePromises><#usePromises>
* @return {Promise} a {@link https://www.promisejs.org/|Promise}<#returnType>, with data of type {@link <&vendorExtensions.x-jsdoc-type>}</returnType></usePromises>
*/
</emitJSDoc> this.<operationId> = function(<vendorExtensions.x-codegen-argList>) {<#hasOptionalParams>
opts = opts || {};</hasOptionalParams>

View File

@@ -14,7 +14,7 @@
* @class{{#useInheritance}}{{#parent}}
* @extends {{#parentModel}}module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{classname}}{{/parentModel}}{{^parentModel}}{{#vendorExtensions.x-isArray}}Array{{/vendorExtensions.x-isArray}}{{#vendorExtensions.x-isMap}}Object{{/vendorExtensions.x-isMap}}{{/parentModel}}{{/parent}}{{#interfaces}}
* @implements module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{modelPackage}}/{{/modelPackage}}{{.}}{{/interfaces}}{{/useInheritance}}{{#vendorExtensions.x-all-required}}
* @param {{name}} {{{vendorExtensions.x-jsdoc-type}}} {{#description}}{{{description}}}{{/description}}{{/vendorExtensions.x-all-required}}
* @param {{name}} {{=< >=}}{<&vendorExtensions.x-jsdoc-type>}<={{ }}=> {{#description}}{{{description}}}{{/description}}{{/vendorExtensions.x-all-required}}
*/
{{/emitJSDoc}}
var exports = function({{#vendorExtensions.x-all-required}}{{name}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-all-required}}) {
@@ -56,7 +56,7 @@
{{#emitJSDoc}}
/**{{#description}}
* {{{description}}}{{/description}}
* @member {{{vendorExtensions.x-jsdoc-type}}} {{baseName}}{{#defaultValue}}
* @member {{=< >=}}{<&vendorExtensions.x-jsdoc-type>}<={{ }}=> {{baseName}}{{#defaultValue}}
* @default {{{defaultValue}}}{{/defaultValue}}
*/
{{/emitJSDoc}}
@@ -66,7 +66,7 @@
{{#emitJSDoc}}
/**{{#description}}
* {{{description}}}{{/description}}
* @member {{{vendorExtensions.x-jsdoc-type}}} {{baseName}}{{#defaultValue}}
* @member {{=< >=}}{<&vendorExtensions.x-jsdoc-type>}<={{ }}=> {{baseName}}{{#defaultValue}}
* @default {{{defaultValue}}}{{/defaultValue}}
*/
{{/emitJSDoc}}
@@ -78,7 +78,7 @@ exports.prototype['{{baseName}}'] = {{#defaultValue}}{{{defaultValue}}}{{/defaul
* Returns {{{description}}}{{/description}}{{#minimum}}
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
* maximum: {{maximum}}{{/maximum}}
* @return {{{vendorExtensions.x-jsdoc-type}}}
* @return {{=< >=}}{<&vendorExtensions.x-jsdoc-type>}<={{ }}=>
*/
{{/emitJSDoc}}
exports.prototype.{{getter}} = function() {
@@ -88,7 +88,7 @@ exports.prototype['{{baseName}}'] = {{#defaultValue}}{{{defaultValue}}}{{/defaul
{{#emitJSDoc}}
/**{{#description}}
* Sets {{{description}}}{{/description}}
* @param {{{vendorExtensions.x-jsdoc-type}}} {{name}}{{#description}} {{{description}}}{{/description}}
* @param {{=< >=}}{<&vendorExtensions.x-jsdoc-type>}<={{ }}=> {{name}}{{#description}} {{{description}}}{{/description}}
*/
{{/emitJSDoc}}
exports.prototype.{{setter}} = function({{name}}) {

View File

@@ -1,6 +1,7 @@
io.swagger.codegen.languages.AndroidClientCodegen
io.swagger.codegen.languages.AspNet5ServerCodegen
io.swagger.codegen.languages.AsyncScalaClientCodegen
io.swagger.codegen.languages.ConfluenceWikiGenerator
io.swagger.codegen.languages.CSharpClientCodegen
io.swagger.codegen.languages.CppRestClientCodegen
io.swagger.codegen.languages.DartClientCodegen
@@ -35,6 +36,7 @@ io.swagger.codegen.languages.SlimFrameworkServerCodegen
io.swagger.codegen.languages.SpringCodegen
io.swagger.codegen.languages.StaticDocCodegen
io.swagger.codegen.languages.StaticHtmlGenerator
io.swagger.codegen.languages.StaticHtml2Generator
io.swagger.codegen.languages.SwaggerGenerator
io.swagger.codegen.languages.SwaggerYamlGenerator
io.swagger.codegen.languages.SwiftCodegen

View File

@@ -161,7 +161,26 @@ export class {{classname}} extends BaseAPI {
return {{classname}}Fp.{{nickname}}({{#hasParams}}params{{/hasParams}})(this.fetch, this.basePath);
}
{{/operation}}
}
};
/**
* {{classname}} - factory interface{{#description}}
* {{&description}}{{/description}}
*/
export const {{classname}}Factory = function (fetch?: FetchAPI, basePath?: string) {
return {
{{#operation}}
/** {{#summary}}
* {{summary}}{{/summary}}{{#notes}}
* {{notes}}{{/notes}}{{#allParams}}
* @param {{paramName}} {{description}}{{/allParams}}
*/
{{nickname}}({{#hasParams}}params: { {{#allParams}} {{paramName}}{{^required}}?{{/required}}: {{{dataType}}};{{/allParams}} }{{/hasParams}}) {
return {{classname}}Fp.{{nickname}}({{#hasParams}}params{{/hasParams}})(fetch, basePath);
},
{{/operation}}
}
};
{{/operations}}
{{/apis}}

View File

@@ -1,7 +1,7 @@
# Swagger Codegen for the {{name}} library
## Overview
This is a boiler-plate project to generate your own client library with Swagger. It's goal is
This is a boiler-plate project to generate your own client library with Swagger. Its goal is
to get you started with the basic plumbing so you can put in your own logic. It won't work without
your changes applied.

View File

@@ -0,0 +1,94 @@
h1. {{{appName}}} {{{appDescription}}}
{{#version}}*Version:* {{{version}}}{{/version}}
----
{toc:printable=true|style=square|minLevel=2|maxLevel=3|type=list|outline=false|include=.*}
h2. Endpoints
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}
h3. {{nickname}}
{status:colour=Yellow|title={{httpMethod}}|subtle=false}
{code}
{{httpMethod}} {{path}}
{code}
*Summary:* {{summary}}
*Description:* {{notes}}
h4. Parameters
{{#hasPathParams}}
h5. Path Parameters
||Name||Description||Required||Default||Pattern||
{{#pathParams}}{{>param}}
{{/pathParams}}
{{/hasPathParams}}
{{#hasBodyParam}}
h5. Body Parameter
||Name||Description||Required||Default||Pattern||
{{#bodyParams}}{{>param}}
{{/bodyParams}}
{{/hasBodyParam}}
{{#hasHeaderParam}}
h5. Header Parameters
||Name||Description||Required||Default||Pattern||
{{#headerParam}}{{>param}}
{{/headerParam}}
{{/hasHeaderParam}}
{{#hasQueryParams}}
h5. Query Parameters
||Name||Description||Required||Default||Pattern||
{{#queryParams}}{{>param}}
{{/queryParams}}
{{/hasQueryParams}}
h4. Responses
{{#responses}}
*Status Code:* {{code}}
*Message:* {{message}}
{code:title=Response Type}
{{{dataType}}}
{code}
See [#models]
{{#hasExamples}}
{{#examples}}
{code:title=Example {{{contentType}}} |collapse=true }
{{{example}}}
{code}
{{/examples}}
{{/hasExamples}}
{code:title=Response Schema |collapse=true}
{{{jsonSchema}}}
{code}
{{#examples}}
{code:title=Example {{{contentType}}} |collapse=true }
{{{example}}}
{code}
{{/examples}}
{{/responses}}
----
{{/operation}}
{{/operations}}
{{/apis}}
{{/apiInfo}}
h2. Models
{{#models}}
{{#model}}
h3. {{classname}}
||Field Name||Required||Type||Description||
{{#vars}} |{{name}} |{{#isNotRequired}}(x){{/isNotRequired}} |{{datatype}} |{{description}} |
{{/vars}}
{{/model}}
{{/models}}

View File

@@ -0,0 +1 @@
|{{paramName}} |{{description}} |{{^required}}(x){{/required}}{{#required}}(/){{/required}} |{{defaultValue}} | {{pattern}} |

View File

@@ -158,7 +158,28 @@ namespace {{packageName}}.Client
/// <returns></returns>
public void AddDefaultHeader(string key, string value)
{
_defaultHeaderMap.Add(key, value);
_defaultHeaderMap[key] = value;
}
/// <summary>
/// Add Api Key Header.
/// </summary>
/// <param name="key">Api Key name.</param>
/// <param name="value">Api Key value.</param>
/// <returns></returns>
public void AddApiKey(string key, string value)
{
ApiKey[key] = value;
}
/// <summary>
/// Sets the API key prefix.
/// </summary>
/// <param name="key">Api Key name.</param>
/// <param name="value">Api Key value.</param>
public void AddApiKeyPrefix(string key, string value)
{
ApiKeyPrefix[key] = value;
}
/// <summary>

View File

@@ -31,8 +31,8 @@ limitations under the License.
<ProjectGuid>{{packageGuid}}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>{{packageTitle}}</RootNamespace>
<AssemblyName>{{packageTitle}}</AssemblyName>
<RootNamespace>{{packageName}}</RootNamespace>
<AssemblyName>{{packageName}}</AssemblyName>
{{^supportsUWP}}
<TargetFrameworkVersion>{{targetFramework}}</TargetFrameworkVersion>
{{/supportsUWP}}

View File

@@ -83,10 +83,10 @@ limitations under the License.
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\RestSharp.105.1.0\lib\{{targetFrameworkNuget}}\RestSharp.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\NUnit.3.2.1\lib\nunit.framework.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\NUnit.3.2.1\lib\nunit.framework.dll</HintPath>
<HintPath Condition="Exists('..\..\packages')">..\..\packages\NUnit.3.2.1\lib\nunit.framework.dll</HintPath>
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\NUnit.3.2.1\lib\nunit.framework.dll</HintPath>
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
<HintPath Condition="Exists('..\..\packages')">..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>

View File

@@ -51,8 +51,8 @@ namespace {{packageName}}.Test
[Test]
public void {{operationId}}InstanceTest()
{
// test 'IsInstanceOfType' {{classname}}
Assert.IsInstanceOfType(typeof({{classname}}), instance, "instance is a {{classname}}");
// TODO uncomment below to test 'IsInstanceOfType' {{classname}}
//Assert.IsInstanceOfType(typeof({{classname}}), instance, "instance is a {{classname}}");
}
{{#operations}}{{#operation}}

View File

@@ -147,39 +147,39 @@ UpgradeLog*.htm
*.swp
*.swo
# svn
.svn
# svn
.svn
# SQL Server files
**/App_Data/*.mdf
**/App_Data/*.ldf
**/App_Data/*.sdf
# SQL Server files
**/App_Data/*.mdf
**/App_Data/*.ldf
**/App_Data/*.sdf
#LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml
#LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml
# =========================
# Windows detritus
# =========================
# =========================
# Windows detritus
# =========================
# Windows image file caches
Thumbs.db
ehthumbs.db
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac desktop service store files
.DS_Store
# Mac desktop service store files
.DS_Store
# SASS Compiler cache
.sass-cache
# SASS Compiler cache
.sass-cache
# Visual Studio 2014 CTP
**/*.sln.ide
# Visual Studio 2014 CTP
**/*.sln.ide

View File

@@ -26,8 +26,8 @@ mozroots --import --sync
mono nuget.exe install src/{{{packageName}}}.Test/packages.config -o packages
echo "[INFO] Install NUnit runners via NuGet"
mono nuget.exe install NUnit.Runners -Version 3.2.1 -OutputDirectory packages
mono nuget.exe install NUnit.Runners -Version 2.6.4 -OutputDirectory packages
echo "[INFO] Build the solution and run the unit test"
xbuild {{{packageName}}}.sln && \
mono ./packages/NUnit.ConsoleRunner.3.2.1/tools/nunit3-console.exe src/{{{packageName}}}.Test/bin/Debug/{{{packageName}}}.Test.dll
mono ./packages/NUnit.Runners.2.6.4/tools/nunit-console.exe src/{{{packageName}}}.Test/bin/Debug/{{{packageName}}}.Test.dll

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="3.2.1" targetFramework="{{targetFrameworkNuget}}" />
<package id="NUnit" version="2.6.4" targetFramework="{{targetFrameworkNuget}}" />
<package id="RestSharp" version="105.1.0" targetFramework="{{targetFrameworkNuget}}" developmentDependency="true" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="{{targetFrameworkNuget}}" developmentDependency="true" />
</packages>

View File

@@ -0,0 +1,2 @@
analyzer:
strong-mode: true

View File

@@ -36,9 +36,13 @@ class {{classname}} {
Map<String, String> headerParams = {};
Map<String, String> formParams = {};
{{#queryParams}}
if("null" != {{paramName}}) {
{{^required}}
if({{paramName}} != null) {
{{/required}}
queryParams.addAll(_convertParametersForCollectionFormat("{{collectionFormat}}", "{{baseName}}", {{paramName}}));
{{^required}}
}
{{/required}}
{{/queryParams}}
{{#headerParams}}headerParams["{{baseName}}"] = {{paramName}};
{{/headerParams}}
@@ -84,7 +88,7 @@ class {{classname}} {
if(response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body);
} else if(response.body != null) {
return {{#returnType}} apiClient.deserialize(response.body, '{{{returnType}}}') {{/returnType}};
return {{#returnType}}apiClient.deserialize(response.body, '{{{returnType}}}') as {{{returnType}}} {{/returnType}};
} else {
return {{#returnType}}null{{/returnType}};
}

View File

@@ -15,7 +15,8 @@ class ApiClient {
Map<String, String> _defaultHeaderMap = {};
Map<String, Authentication> _authentications = {};
final dson = new Dartson.JSON();
final dson = new Dartson.JSON()
..addTransformer(new DateTimeParser(), DateTime);
final DateFormat _dateFormatter = new DateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
final _RegList = new RegExp(r'^List<(.*)>$');
@@ -72,20 +73,18 @@ class ApiClient {
Match match;
if (value is List &&
(match = _RegList.firstMatch(targetType)) != null) {
var valueL = value as List;
var newTargetType = match[1];
return valueL.map((v) => _deserialize(v, newTargetType)).toList();
return value.map((v) => _deserialize(v, newTargetType)).toList();
} else if (value is Map &&
(match = _RegMap.firstMatch(targetType)) != null) {
var valueM = value as Map;
var newTargetType = match[1];
return new Map.fromIterables(valueM.keys,
valueM.values.map((v) => _deserialize(v, newTargetType)));
return new Map.fromIterables(value.keys,
value.values.map((v) => _deserialize(v, newTargetType)));
}
}
}
} catch(e) {
// Just throw the ApiException below
} catch (e, stack) {
throw new ApiException.withInner(500, 'Exception during deserialization.', e, stack);
}
throw new ApiException(500, 'Could not find a suitable class for deserialization');
}
@@ -116,7 +115,7 @@ class ApiClient {
// If collectionFormat is 'multi' a key might appear multiple times.
Future<Response> invokeAPI(String path,
String method,
List<QueryParam> queryParams,
Iterable<QueryParam> queryParams,
Object body,
Map<String, String> headerParams,
Map<String, String> formParams,
@@ -152,6 +151,8 @@ class ApiClient {
return client.put(url, headers: headerParams, body: msgBody);
case "DELETE":
return client.delete(url, headers: headerParams);
case "PATCH":
return client.patch(url, headers: headerParams, body: msgBody);
default:
return client.get(url, headers: headerParams);
}

View File

@@ -3,7 +3,21 @@ part of {{pubName}}.api;
class ApiException implements Exception {
int code = 0;
String message = null;
Exception innerException = null;
StackTrace stackTrace = null;
ApiException(this.code, this.message);
}
ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace);
String toString() {
if (message == null) return "ApiException";
if (innerException == null) {
return "ApiException $code: $message";
}
return "ApiException $code: $message (Inner exception: ${innerException})\n\n" +
stackTrace.toString();
}
}

View File

@@ -3,19 +3,19 @@ part of {{pubName}}.api;
const _delimiters = const {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'};
// port from Java version
List<QueryParam> _convertParametersForCollectionFormat(
Iterable<QueryParam> _convertParametersForCollectionFormat(
String collectionFormat, String name, dynamic value) {
var params = [];
var params = <QueryParam>[];
// preconditions
if (name == null || name.isEmpty || value == null) return params;
if (value is! List) {
params.add(new QueryParam(name, value as String));
params.add(new QueryParam(name, '$value'));
return params;
}
List<String> values = value as List<String>;
List values = value as List;
// get the collection format
collectionFormat = (collectionFormat == null || collectionFormat.isEmpty)
@@ -23,7 +23,7 @@ List<QueryParam> _convertParametersForCollectionFormat(
: collectionFormat; // default: csv
if (collectionFormat == "multi") {
return values.map((v) => new QueryParam(name, v));
return values.map((v) => new QueryParam(name, '$v'));
}
String delimiter = _delimiters[collectionFormat] ?? ",";

View File

@@ -5,6 +5,7 @@ import 'dart:convert';{{#browserClient}}
import 'package:http/browser_client.dart';{{/browserClient}}
import 'package:http/http.dart';
import 'package:dartson/dartson.dart';
import 'package:dartson/transformers/date_time.dart';
import 'package:intl/intl.dart';
part 'api_client.dart';

View File

@@ -40,14 +40,14 @@ var routes = Routes{
Route{
"Index",
"GET",
"/",
"{{basePathWithoutHost}}/",
Index,
},
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}
Route{
"{{operationId}}",
"{{httpMethod}}",
"{{path}}",
"{{basePathWithoutHost}}{{path}}",
{{operationId}},
},
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}

View File

@@ -3,11 +3,8 @@ package {{packageName}}
{{#operations}}
import (
"strings"
"fmt"
"errors"
"net/url"
{{#imports}}"{{import}}"
{{#imports}} "{{import}}"
{{/imports}}
)
@@ -45,11 +42,7 @@ func (a {{{classname}}}) {{{nickname}}}({{#allParams}}{{paramName}} {{{dataType}
// create path and map variables
path := a.Configuration.BasePath + "{{path}}"{{#pathParams}}
path = strings.Replace(path, "{"+"{{baseName}}"+"}", fmt.Sprintf("%v", {{paramName}}), -1){{/pathParams}}
{{#allParams}}{{#required}}
// verify the required parameter '{{paramName}}' is set
if &{{paramName}} == nil {
return {{#returnType}}{{#isListContainer}}*{{/isListContainer}}new({{{returnType}}}), {{/returnType}}nil, errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}")
}{{/required}}{{/allParams}}
headerParams := make(map[string]string)
queryParams := url.Values{}
@@ -58,22 +51,30 @@ func (a {{{classname}}}) {{{nickname}}}({{#allParams}}{{paramName}} {{{dataType}
var fileName string
var fileBytes []byte
{{#authMethods}}
// authentication ({{name}}) required
{{#isApiKey}}{{#isKeyInHeader}}
// authentication '({{name}})' required
{{#isApiKey}}
{{#isKeyInHeader}}
// set key with prefix in header
headerParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}")
{{/isKeyInHeader}}{{#isKeyInQuery}}
// set key with prefix in querystring{{#hasKeyParamName}}
{{/isKeyInHeader}}
{{#isKeyInQuery}}
// set key with prefix in query string
queryParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}")
{{/hasKeyParamName}}{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}
{{/isKeyInQuery}}
{{/isApiKey}}
{{#isBasic}}
// http basic authentication required
if a.Configuration.Username != "" || a.Configuration.Password != ""{
headerParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString()
}{{/isBasic}}{{#isOAuth}}
}
{{/isBasic}}
{{#isOAuth}}
// oauth required
if a.Configuration.AccessToken != ""{
headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken
}{{/isOAuth}}{{/authMethods}}
}
{{/isOAuth}}
{{/authMethods}}
// add default headers if any
for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key]
@@ -84,14 +85,14 @@ func (a {{{classname}}}) {{{nickname}}}({{#allParams}}{{paramName}} {{{dataType}
var collectionFormat = "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}"
if collectionFormat == "multi" {
for _, value := range {{paramName}} {
queryParams.Add("{{paramName}}", value)
queryParams.Add("{{baseName}}", value)
}
} else {
queryParams.Add("{{paramName}}", a.Configuration.APIClient.ParameterToString({{paramName}}, collectionFormat))
queryParams.Add("{{baseName}}", a.Configuration.APIClient.ParameterToString({{paramName}}, collectionFormat))
}
{{/isListContainer}}
{{^isListContainer}}
queryParams.Add("{{paramName}}", a.Configuration.APIClient.ParameterToString({{paramName}}, ""))
queryParams.Add("{{baseName}}", a.Configuration.APIClient.ParameterToString({{paramName}}, ""))
{{/isListContainer}}
{{/queryParams}}{{/hasQueryParams}}

View File

@@ -94,7 +94,7 @@ func (c *APIClient) ParameterToString(obj interface{},collectionFormat string) s
}
}
return obj.(string)
return fmt.Sprintf("%v", obj)
}
func prepareRequest(postBody interface{},

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,101 @@
/* Pretty printing styles. Used with prettify.js. */
/* Vim sunburst theme by David Leibovic */
pre .str {
color: #65B042;
}
/* string - green */
pre .kwd {
color: #E28964;
}
/* keyword - dark pink */
pre .com {
color: #AEAEAE;
font-style: italic;
}
/* comment - gray */
pre .typ {
color: #89bdff;
}
/* type - light blue */
pre .lit {
color: #3387CC;
}
/* literal - blue */
pre .pun {
color: #fff;
}
/* punctuation - white */
pre .pln {
color: #fff;
}
/* plaintext - white */
pre .tag {
color: #89bdff;
}
/* html/xml tag - light blue */
pre .atn {
color: #bdb76b;
}
/* html/xml attribute name - khaki */
pre .atv {
color: #65B042;
}
/* html/xml attribute value - green */
pre .dec {
color: #3387CC;
}
/* decimal - blue */
/* Specify class=linenums on a pre to get line numbering */
ol.linenums {
margin-top: 0;
margin-bottom: 0;
color: #AEAEAE;
}
/* IE indents via margin-left */
li.L0,
li.L1,
li.L2,
li.L3,
li.L5,
li.L6,
li.L7,
li.L8 {
list-style-type: none;
}
/* Alternate shading for lines */
@media print {
pre .str {
color: #060;
}
pre .kwd {
color: #006;
font-weight: bold;
}
pre .com {
color: #600;
font-style: italic;
}
pre .typ {
color: #404;
font-weight: bold;
}
pre .lit {
color: #044;
}
pre .pun {
color: #440;
}
pre .pln {
color: #000;
}
pre .tag {
color: #006;
font-weight: bold;
}
pre .atn {
color: #404;
}
pre .atv {
color: #060;
}
}

View File

@@ -0,0 +1,555 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>{{{appName}}}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8" />
{{>js_jquery}}
{{>js_prettify}}
{{>js_bootstrap}}
<script>
$( document ).ready(function() {
var textFile = null;
/// Function to be used to download a text json schema
function makeTextFile(text) {
var data = new Blob([text], {type: 'text/plain'});
// If we are replacing a previously generated file we need to
// manually revoke the object URL to avoid memory leaks.
if (textFile !== null) {
window.URL.revokeObjectURL(textFile);
}
textFile = window.URL.createObjectURL(data);
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
a.href = textFile;
a.download = 'schema.txt';
a.click();
return textFile;
};
/// TODO: Implement resizing for expanding within iframe
function callResize() {
window.parent.postMessage('resize', "*");
}
// load google web fonts
loadGoogleFontCss();
// Bootstrap Scrollspy
$(this).scrollspy({ target: '#scrollingNav', offset: 18 });
// Content-Scroll on Navigation click.
$('.sidenav').find('a').on('click', function(e) {
e.preventDefault();
var id = $(this).attr('href');
if ($(id).length > 0)
$('html,body').animate({ scrollTop: parseInt($(id).offset().top) }, 400);
window.location.hash = $(this).attr('href');
});
// Quickjump on Pageload to hash position.
if(window.location.hash) {
var id = window.location.hash;
if ($(id).length > 0)
$('html,body').animate({ scrollTop: parseInt($(id).offset().top) }, 0);
}
function initDynamic() {
// tabs
$('.nav-tabs-examples a').click(function (e) {
e.preventDefault();
$(this).tab('show');
});
$('.nav-tabs-examples').find('a:first').tab('show');
// call scrollspy refresh method
$(window).scrollspy('refresh');
}
initDynamic();
// Pre- / Code-Format
prettyPrint();
/**
* Load google fonts.
*/
function loadGoogleFontCss() {
WebFont.load({
active: function() {
// Update scrollspy
$(window).scrollspy('refresh')
},
google: {
families: ['Source Code Pro', 'Source Sans Pro:n4,n6,n7']
}
});
}
});
</script>
<style type="text/css">
{{>css_bootstrap}}
{{>css_prettify}}
{{>styles}}
</style>
</head>
<body>
<script>
// Script section to load models into a JS Var
var defs = {}
{{#models}}
{{#model}}
defs.{{name}} = {{{modelJson}}};
{{/model}}
{{/models}}
</script>
<div class="container-fluid">
<div class="row-fluid">
<div id="sidenav" class="span2">
<nav id="scrollingNav">
<ul class="sidenav nav nav-list">
<!-- Logo Area -->
<!--<div style="width: 80%; background-color: #4c8eca; color: white; padding: 20px; text-align: center; margin-bottom: 20px; ">
API Docs 2
</div>
-->
<li class="nav-fixed nav-header active" data-group="_"><a href="#api-_">API Summary</a></li>
{{#apiInfo}}
{{#apis}}
{{#operations}}
<li class="nav-header" data-group="{{baseName}}"><a href="#api-{{baseName}}">API Methods - {{baseName}}</a></li>
{{#operation}}
<li data-group="{{baseName}}" data-name="{{nickname}}" class="">
<a href="#api-{{baseName}}-{{nickname}}">{{nickname}}</a>
</li>
{{/operation}}
{{/operations}}
{{/apis}}
{{/apiInfo}}
</ul>
</nav>
</div>
<div id="content">
<div id="project">
<div class="pull-left">
<h1>{{{appName}}}</h1>
</div>
<div class="clearfix"></div>
</div>
<div id="header">
<div id="api-_">
<h2 id="welcome-to-apidoc">API and SDK Documentation</h2>
{{#version}}
<div class="app-desc">Version: {{{version}}}</div>
{{/version}}
<hr>
<p>{{{appDescription}}}</p>
</div>
</div>
<div id="sections">
{{#apiInfo}}
{{#apis}}
{{#operations}}
<section id="api-{{baseName}}">
<h1>{{baseName}}</h1>
{{#operation}}
<div id="api-{{baseName}}-{{nickname}}">
<article id="api-{{baseName}}-{{nickname}}-0" data-group="User" data-name="{{nickname}}" data-version="0">
<div class="pull-left">
<h1>{{nickname}}</h1>
</div>
<div class="pull-right">
</div>
<div class="clearfix"></div>
<p></p>
<p>{{notes}}</p>
<p></p>
<br />
<pre class="prettyprint language-html prettyprinted" data-type="{{httpMethod}}"><code><span class="pln">{{path}}</span></code></pre>
<p>
<h3>Usage and SDK Samples</h3>
</p>
<ul class="nav nav-tabs nav-tabs-examples">
<li class="active">
<a href="#examples-{{baseName}}-{{nickname}}-0-curl">Curl</a>
</li>
<li class="">
<a href="#examples-{{baseName}}-{{nickname}}-0-java">Java</a>
</li>
<li class="">
<a href="#examples-{{baseName}}-{{nickname}}-0-android">Android</a>
</li>
<!--<li class="">
<a href="#examples-{{baseName}}-{{nickname}}-0-groovy">Groovy</a>
</li>-->
<li class="">
<a href="#examples-{{baseName}}-{{nickname}}-0-objc">Obj-C</a>
</li>
<li class="">
<a href="#examples-{{baseName}}-{{nickname}}-0-javascript">JavaScript</a>
</li>
<!--<li class="">
<a href="#examples-{{baseName}}-{{nickname}}-0-angular">Angular</a>
</li>-->
<li class="">
<a href="#examples-{{baseName}}-{{nickname}}-0-csharp">C#</a>
</li>
<li class="">
<a href="#examples-{{baseName}}-{{nickname}}-0-php">PHP</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="examples-{{baseName}}-{{nickname}}-0-curl">
<pre class="prettyprint"><code class="language-bsh">
curl -X <span style="text-transform: uppercase;">{{httpMethod}}</span> -H "apiKey: [[apiKey]]" -H "apiSecret: [[apiSecret]]" "{{basePath}}{{path}}{{#hasQueryParams}}?{{#queryParams}}{{^-first}}&{{/-first}}{{paramName}}={{vendorExtensions.x-eg}}{{/queryParams}}{{/hasQueryParams}}"
</code></pre>
</div>
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-java">
<pre class="prettyprint"><code class="language-java">
{{>sample_java}}
</code></pre>
</div>
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-android">
<pre class="prettyprint"><code class="language-java">
{{>sample_android}}
</code></pre>
</div>
<!--
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-groovy">
<pre class="prettyprint language-json prettyprinted" data-type="json"><code>Coming Soon!</code></pre>
</div> -->
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-objc">
<pre class="prettyprint"><code class="language-cpp">
{{>sample_objc}}
</code></pre>
</div>
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-javascript">
<pre class="prettyprint"><code class="language-js">
{{>sample_js}}
</code></pre>
</div>
<!--<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-angular">
<pre class="prettyprint language-json prettyprinted" data-type="json"><code>Coming Soon!</code></pre>
</div>-->
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-csharp">
<pre class="prettyprint"><code class="language-cs">
{{>sample_csharp}}
</code></pre>
</div>
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-php">
<pre class="prettyprint"><code class="language-php">
{{>sample_php}}
</code></pre>
</div>
</div>
<h2>Parameters</h2>
{{#hasPathParams}}
<div class="methodsubtabletitle">Path parameters</div>
<table id="methodsubtable">
<tr>
<th width="150px">Name</th>
<th>Description</th>
</tr>
<!---->
{{#pathParams}}
{{>param}}
{{/pathParams}}
</table>
{{/hasPathParams}}
{{#hasHeaderParams}}
<div class="methodsubtabletitle">Header parameters</div>
<table id="methodsubtable">
<tr>
<th width="150px">Name</th>
<th>Description</th>
</tr>
<!---->
{{#headerParams}}
{{>param}}
{{/headerParams}}
</table>
{{/hasHeaderParams}}
{{#hasBodyParam}}
<div class="methodsubtabletitle">Body parameters</div>
<table id="methodsubtable">
<tr>
<th width="150px">Name</th>
<th>Description</th>
</tr>
<!---->
{{#bodyParams}}
{{>paramB}}
{{/bodyParams}}
</table>
{{/hasBodyParam}}
{{#hasQueryParams}}
<div class="methodsubtabletitle">Query parameters</div>
<table id="methodsubtable">
<tr>
<th width="150px">Name</th>
<th>Description</th>
</tr>
<!---->
{{#queryParams}}
{{>param}}
{{/queryParams}}
</table>
{{/hasQueryParams}}
<h2>Responses</h2>
{{#responses}}
<h3> Status: {{code}} - {{message}} </h3>
<ul class="nav nav-tabs nav-tabs-examples" >
<li class="active">
<a href="#examples-{{baseName}}-{{nickname}}-schema">Schema</a>
</li>
{{#examples}}
<li class="">
<a href="#examples-{{baseName}}-{{nickname}}-example">Response Example</a>
</li>
{{/examples}}
</ul>
<div class="tab-content" style='margin-bottom: 10px;'>
<div class="tab-pane active" id="examples-{{baseName}}-{{nickname}}-schema">
<div id='examples-{{baseName}}-{{nickname}}-schema-{{code}}' style="padding: 30px; border-left: 1px solid #eee; border-right: 1px solid #eee; border-bottom: 1px solid #eee;">
<script>
$(document).ready(function() {
var schemaWrapper = {{{jsonSchema}}};
var schema = schemaWrapper.schema;
schemaWrapper.definitions = defs;
//console.log(JSON.stringify(schema))
JsonRefs.resolveRefs(schemaWrapper, {
"depth": 3,
"resolveRemoteRefs": false,
"resolveFileRefs": false
}, function(err, resolved, metadata) {
//console.log(JSON.stringify(resolved));
var view = new JSONSchemaView(resolved.schema, 3);
$('#examples-{{baseName}}-{{nickname}}-schema-data').val(JSON.stringify(resolved.schema));
var result = $('#examples-{{baseName}}-{{nickname}}-schema-{{code}}');
result.empty();
result.append(view.render());
});
});
</script>
</div>
<input id='examples-{{baseName}}-{{nickname}}-schema-data' type='hidden' value=''></input>
</div>
{{#examples}}
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-example">
<pre class="prettyprint"><code class="json">{{example}}</code></pre>
</div>
{{/examples}}
</div>
{{/responses}}
</article>
</div>
<hr>
{{/operation}}
</section>
{{/operations}}
{{/apis}}
{{/apiInfo}}
</div>
<div id="footer">
<div id="api-_footer">
<p>Suggestions, contact, support and error reporting;
{{#infoUrl}}
<div class="app-desc">Information URL: <a href="{{{infoUrl}}}">{{{infoUrl}}}</a></div>
{{/infoUrl}}
{{#infoEmail}}
<div class="app-desc">Contact Info: <a href="{{{infoEmail}}}">{{{infoEmail}}}</a></div>
{{/infoEmail}}
</p>
{{#licenseInfo}}
<div class="license-info">{{{licenseInfo}}}</div>
{{/licenseInfo}}
{{#licenseUrl}}
<div class="license-url">{{{licenseUrl}}}</div>
{{/licenseUrl}}
</div>
</div>
<div id="generator">
<div class="content">
Generated {{generatedDate}}
</div>
</div>
</div>
</div>
</div>
{{>js_jsonschemaview}}
{{>js_jsonref}}
{{>js_webfontloader}}
<script>
$(document).ready(function () {
$('.nav-tabs-examples').find('a:first').tab('show');
$(this).scrollspy({ target: '#scrollingNav', offset: 18 });
});
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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