Skip to content

[Swift3] Cleaner template of client methods#4552

Merged
wing328 merged 3 commits intoswagger-api:masterfrom
tomekc:swift3_parameters_cleanup
Jan 15, 2017
Merged

[Swift3] Cleaner template of client methods#4552
wing328 merged 3 commits intoswagger-api:masterfrom
tomekc:swift3_parameters_cleanup

Conversation

@tomekc
Copy link
Copy Markdown
Contributor

@tomekc tomekc commented Jan 12, 2017

PR checklist

  • Read the contribution guildelines.
  • Ran the shell/batch script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates)
  • Filed the PR against the correct branch: master for non-breaking changes and 2.3.0 branch for breaking (non-backward compatible) changes.

Description of the PR

Fixed an error which in some cases could lead to generate improper API function, for example not uploading files.

Done a little makeover of api.mustache. Limited capabilities of mustache templates led to extremely convoluted and hardly comprehensible templates.

The template has been reformatted a little, added a couple of newlines, as I believe that readibility of template is much more important than resulting code having a couple extra newlines.

I tested on following use-cases, created privately against httpbin.org:

  • upload a file with one more form param and query params
  • POST an object with query params
  • GET with couple of parameters

@wing328 wing328 added this to the v2.2.2 milestone Jan 13, 2017
@tomekc tomekc changed the title Swift3 parameters cleanup Swift3 Clener template of client methods Jan 13, 2017
@wing328
Copy link
Copy Markdown
Contributor

wing328 commented Jan 13, 2017

@tomekc thanks for the PR. Please run ./bin/swift3-petstore.sh to update Petstore sample (swift3).

@tomekc
Copy link
Copy Markdown
Contributor Author

tomekc commented Jan 13, 2017

@wing328 It is updated, I forgot git push ;-)

BTW Travis checks failed for no reason, and it fixed itself after just updating the PR. I hope it will succeed this time...

@wing328
Copy link
Copy Markdown
Contributor

wing328 commented Jan 13, 2017

@tomekc when I ran the integration test for Swift 3 (default), I got the following errors:

Testing failed:
	Cannot convert value of type 'Error?' to expected argument type 'ErrorResponse?'
** TEST FAILED **


The following build commands failed:
	CompileSwift normal x86_64 /Users/williamcheng/Code/jan2017/swagger-codegen/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/Fake_classname_tags123API.swift
	CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
(2 failures)

Did you get similar error when running the test locally?

(I ran the same test for swift 3 (default) in master and the tests completed without issue)

@tomekc
Copy link
Copy Markdown
Contributor Author

tomekc commented Jan 13, 2017

swagger-codegen/samples/client/petstore/swift3/default/SwaggerClientTests|swift3_parameters_cleanup⚡ $

mvn clean integration-test

Result:

** TEST SUCCEEDED **

Test Suite 'All tests' started at 2017-01-13 20:18:56.337
Test Suite 'SwaggerClientTests.xctest' started at 2017-01-13 20:18:56.337
Test Suite 'PetAPITests' started at 2017-01-13 20:18:56.338
Test Case '-[SwaggerClientTests.PetAPITests test1CreatePet]' started.
Test Case '-[SwaggerClientTests.PetAPITests test1CreatePet]' passed (0.483 seconds).
Test Case '-[SwaggerClientTests.PetAPITests test2GetPet]' started.
Test Case '-[SwaggerClientTests.PetAPITests test2GetPet]' passed (0.282 seconds).
Test Case '-[SwaggerClientTests.PetAPITests test3DeletePet]' started.
Test Case '-[SwaggerClientTests.PetAPITests test3DeletePet]' passed (0.260 seconds).
Test Suite 'PetAPITests' passed at 2017-01-13 20:18:57.363.
	 Executed 3 tests, with 0 failures (0 unexpected) in 1.024 (1.026) seconds
Test Suite 'StoreAPITests' started at 2017-01-13 20:18:57.364
Test Case '-[SwaggerClientTests.StoreAPITests test1PlaceOrder]' started.
Test Case '-[SwaggerClientTests.StoreAPITests test1PlaceOrder]' passed (0.265 seconds).
Test Case '-[SwaggerClientTests.StoreAPITests test2GetOrder]' started.
Test Case '-[SwaggerClientTests.StoreAPITests test2GetOrder]' passed (0.259 seconds).
Test Case '-[SwaggerClientTests.StoreAPITests test3DeleteOrder]' started.
Test Case '-[SwaggerClientTests.StoreAPITests test3DeleteOrder]' passed (0.265 seconds).
Test Case '-[SwaggerClientTests.StoreAPITests testDownloadProgress]' started.
Test Case '-[SwaggerClientTests.StoreAPITests testDownloadProgress]' passed (0.260 seconds).
Test Suite 'StoreAPITests' passed at 2017-01-13 20:18:58.415.
	 Executed 4 tests, with 0 failures (0 unexpected) in 1.050 (1.052) seconds
Test Suite 'UserAPITests' started at 2017-01-13 20:18:58.416
Test Case '-[SwaggerClientTests.UserAPITests test1CreateUser]' started.
Test Case '-[SwaggerClientTests.UserAPITests test1CreateUser]' passed (0.257 seconds).
Test Case '-[SwaggerClientTests.UserAPITests test2GetUser]' started.
Test Case '-[SwaggerClientTests.UserAPITests test2GetUser]' passed (0.264 seconds).
Test Case '-[SwaggerClientTests.UserAPITests test3DeleteUser]' started.
Test Case '-[SwaggerClientTests.UserAPITests test3DeleteUser]' passed (0.257 seconds).
Test Case '-[SwaggerClientTests.UserAPITests testLogin]' started.
Test Case '-[SwaggerClientTests.UserAPITests testLogin]' passed (0.260 seconds).
Test Case '-[SwaggerClientTests.UserAPITests testLogout]' started.
Test Case '-[SwaggerClientTests.UserAPITests testLogout]' passed (0.259 seconds).
Test Suite 'UserAPITests' passed at 2017-01-13 19:06:18.611.
	 Executed 5 tests, with 0 failures (0 unexpected) in 1.364 (1.367) seconds
Test Suite 'SwaggerClientTests.xctest' passed at 2017-01-13 19:06:18.611.
	 Executed 12 tests, with 0 failures (0 unexpected) in 3.372 (3.379) seconds
Test Suite 'All tests' passed at 2017-01-13 19:06:18.612.
	 Executed 12 tests, with 0 failures (0 unexpected) in 3.372 (3.380) seconds
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.253 s
[INFO] Finished at: 2017-01-13T19:06:18+01:00
[INFO] Final Memory: 10M/304M
[INFO] ------------------------------------------------------------------------

@wing328
Copy link
Copy Markdown
Contributor

wing328 commented Jan 14, 2017

@tomekc that's good. Probably issue with my local environment.

cc @jgavris @jaz-ah @Edubits @hexelon

@jaz-ah
Copy link
Copy Markdown
Contributor

jaz-ah commented Jan 14, 2017

+1 @wing328

@wing328
Copy link
Copy Markdown
Contributor

wing328 commented Jan 15, 2017

I did another clone and got good test results:

Test Case '-[SwaggerClientTests.UserAPITests testLogout]' started.
Test Case '-[SwaggerClientTests.UserAPITests testLogout]' passed (0.432 seconds).
Test Suite 'UserAPITests' passed at 2017-01-16 00:00:12.691.
	 Executed 5 tests, with 0 failures (0 unexpected) in 2.176 (2.181) seconds
Test Suite 'SwaggerClientTests.xctest' passed at 2017-01-16 00:00:12.695.
	 Executed 12 tests, with 0 failures (0 unexpected) in 5.876 (5.894) seconds
Test Suite 'All tests' passed at 2017-01-16 00:00:12.697.
	 Executed 12 tests, with 0 failures (0 unexpected) in 5.876 (5.897) seconds
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:12 min
[INFO] Finished at: 2017-01-16T00:00:12+08:00
[INFO] Final Memory: 11M/245M
[INFO] ------------------------------------------------------------------------

@wing328 wing328 merged commit f0cddd2 into swagger-api:master Jan 15, 2017
@wing328 wing328 changed the title Swift3 Clener template of client methods [Swift3] Cleaner template of client methods Feb 20, 2017
davidgri pushed a commit to davidgri/swagger-codegen that referenced this pull request May 11, 2017
* Swift3 template properly uploads files, making mustache template little cleaner

* [swift3] moved URL parameter encoder helper function to APIHelper.swift

* Swift3 - regenerated sample
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants