-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[swift5] Remove optional from body #10938
Conversation
@4brunu |
@@ -160,100 +160,20 @@ private var managerStore = SynchronizedDictionary<String, Alamofire.Session>() | |||
let validatedRequest = request.validate() | |||
|
|||
switch T.self { | |||
case is String.Type: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When response type is void, getNonDecodableBuilder is used
openapi-generator/modules/openapi-generator/src/main/resources/swift5/api.mustache
Line 454 in 126e406
let localVariableRequestBuilder: RequestBuilder<{{{returnType}}}{{^returnType}}Void{{/returnType}}>.Type = {{projectName}}API.requestBuilderFactory.{{#returnType}}getBuilder(){{/returnType}}{{^returnType}}getNonDecodableBuilder(){{/returnType}} openapi-generator/modules/openapi-generator/src/main/resources/swift5/api.mustache
Line 163 in 126e406
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class func {{operationId}}({{#allParams}}{{paramName}}: {{#isEnum}}{{#isContainer}}{{{dataType}}}{{/isContainer}}{{^isContainer}}{{{datatypeWithEnum}}}_{{operationId}}{{/isContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}? = nil{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}apiResponseQueue: DispatchQueue = {{projectName}}API.apiResponseQueue) -> AnyPublisher<{{{returnType}}}{{^returnType}}Void{{/returnType}}, Error> {
Hi @funzin, thanks for creating this PR. |
OK, I will check these places:+1: |
@@ -167,7 +167,7 @@ extension {{projectName}}API { | |||
switch result { | |||
{{#returnType}} | |||
case let .success(response): | |||
promise(.success(response.body!)) | |||
promise(.success(response.body)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@funzin please search and replace all occurrences of response.body!
with response.body
in this class, to fix all the cases. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have already checked response.body!
in swift5
dbdc585
Maybe, CI will be succeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@4brunu
CI ✅
a1a8d2c
to
a802030
Compare
a802030
to
dbdc585
Compare
...pi-generator/src/main/resources/swift5/libraries/alamofire/AlamofireImplementations.mustache
Outdated
Show resolved
Hide resolved
...-generator/src/main/resources/swift5/libraries/urlsession/URLSessionImplementations.mustache
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
Thanks for this PR
Remove optional from
body
When using
getNonDecodableBuilder
, Response body type isVoid
only so we don't need to havebody
as optional.body: T?
tobody: T
we won't have to do any unnecessary unwrapping when using api response.
PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.For Windows users, please run the script in Git BASH.
master
(5.3.0),6.0.x