Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ Method | HTTP request | Description
{{^usePromiseKit}}
{{^useRxSwift}}
{{^useVapor}}
{{^useAsyncAwait}}
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class func {{operationId}}({{#allParams}}{{paramName}}: {{#isEnum}}{{#isContainer}}[{{enumName}}_{{operationId}}]{{/isContainer}}{{^isContainer}}{{enumName}}_{{operationId}}{{/isContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}? = nil{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}completion: @escaping (_ data: {{{returnType}}}{{^returnType}}Void{{/returnType}}?, _ error: Error?) -> Void)
{{/useAsyncAwait}}
{{/useVapor}}
{{/useRxSwift}}
{{/usePromiseKit}}
{{#useAsyncAwait}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: When library=vapor is combined with responseAs=AsyncAwait, the generated client keeps only the EventLoopFuture API, but this template also documents an async method and try/await example. Wrap both new AsyncAwait sections in {{^useVapor}} so Vapor documentation remains on the EventLoopFuture path.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/swift5/api_doc.mustache, line 24:

<comment>When `library=vapor` is combined with `responseAs=AsyncAwait`, the generated client keeps only the EventLoopFuture API, but this template also documents an async method and try/await example. Wrap both new AsyncAwait sections in `{{^useVapor}}` so Vapor documentation remains on the EventLoopFuture path.</comment>

<file context>
@@ -15,10 +15,15 @@ Method | HTTP request | Description
 {{/useVapor}}
 {{/useRxSwift}}
 {{/usePromiseKit}}
+{{#useAsyncAwait}}
+    {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class func {{operationId}}({{#allParams}}{{paramName}}: {{#isEnum}}{{#isContainer}}[{{enumName}}_{{operationId}}]{{/isContainer}}{{^isContainer}}{{enumName}}_{{operationId}}{{/isContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}? = nil{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) async throws{{#returnType}} -> {{{returnType}}}{{#isResponseOptional}}?{{/isResponseOptional}}{{/returnType}}
+{{/useAsyncAwait}}
</file context>

{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class func {{operationId}}({{#allParams}}{{paramName}}: {{#isEnum}}{{#isContainer}}[{{enumName}}_{{operationId}}]{{/isContainer}}{{^isContainer}}{{enumName}}_{{operationId}}{{/isContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}? = nil{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) async throws{{#returnType}} -> {{{returnType}}}{{#isResponseOptional}}?{{/isResponseOptional}}{{/returnType}}
{{/useAsyncAwait}}
{{#usePromiseKit}}
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class func {{operationId}}({{#allParams}} {{paramName}}: {{#isEnum}}{{#isContainer}}[{{enumName}}_{{operationId}}]{{/isContainer}}{{^isContainer}}{{enumName}}_{{operationId}}{{/isContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}? = nil{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Promise<{{{returnType}}}{{^returnType}}Void{{/returnType}}>
{{/usePromiseKit}}
Expand All @@ -45,6 +50,7 @@ import {{{projectName}}}
{{^usePromiseKit}}
{{^useRxSwift}}
{{^useVapor}}
{{^useAsyncAwait}}
{{#summary}}
// {{{.}}}
{{/summary}}
Expand All @@ -58,9 +64,23 @@ import {{{projectName}}}
dump(response)
}
}
{{/useAsyncAwait}}
{{/useVapor}}
{{/useRxSwift}}
{{/usePromiseKit}}
{{#useAsyncAwait}}
{{#summary}}
// {{{.}}}
{{/summary}}
do {
{{#returnType}}let response = {{/returnType}}try await {{classname}}.{{{operationId}}}({{#allParams}}{{paramName}}: {{paramName}}{{^-last}}, {{/-last}}{{/allParams}})
{{#returnType}}
dump(response)
{{/returnType}}
} catch {
print(error)
}
{{/useAsyncAwait}}
{{#usePromiseKit}}
{{#summary}}
// {{{.}}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@ Method | HTTP request | Description
{{^usePromiseKit}}
{{^useRxSwift}}
{{^useVapor}}
{{^useAsyncAwait}}
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class func {{operationId}}({{#allParams}}{{paramName}}: {{#isEnum}}{{#isContainer}}[{{enumName}}_{{operationId}}]{{/isContainer}}{{^isContainer}}{{enumName}}_{{operationId}}{{/isContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}? = nil{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}completion: @escaping (_ data: {{{returnType}}}{{^returnType}}Void{{/returnType}}?, _ error: Error?) -> Void)
{{/useAsyncAwait}}
{{/useVapor}}
{{/useRxSwift}}
{{/usePromiseKit}}
{{^useVapor}}
{{#useAsyncAwait}}
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} {{#apiStaticMethod}}class {{/apiStaticMethod}}func {{operationId}}({{#allParams}}{{paramName}}: {{#isEnum}}{{#isContainer}}[{{enumName}}_{{operationId}}]{{/isContainer}}{{^isContainer}}{{enumName}}_{{operationId}}{{/isContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}? = nil{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#apiStaticMethod}}{{#hasParams}}, {{/hasParams}}apiConfiguration: {{projectName}}APIConfiguration = {{projectName}}APIConfiguration.shared{{/apiStaticMethod}}) async throws(ErrorResponse){{#returnType}} -> {{{returnType}}}{{#isResponseOptional}}?{{/isResponseOptional}}{{/returnType}}
{{/useAsyncAwait}}
{{/useVapor}}
{{#usePromiseKit}}
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class func {{operationId}}({{#allParams}} {{paramName}}: {{#isEnum}}{{#isContainer}}[{{enumName}}_{{operationId}}]{{/isContainer}}{{^isContainer}}{{enumName}}_{{operationId}}{{/isContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}? = nil{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Promise<{{{returnType}}}{{^returnType}}Void{{/returnType}}>
{{/usePromiseKit}}
Expand All @@ -45,6 +52,7 @@ import {{{projectName}}}
{{^usePromiseKit}}
{{^useRxSwift}}
{{^useVapor}}
{{^useAsyncAwait}}
{{#summary}}
// {{{.}}}
{{/summary}}
Expand All @@ -58,9 +66,25 @@ import {{{projectName}}}
dump(response)
}
}
{{/useAsyncAwait}}
{{/useVapor}}
{{/useRxSwift}}
{{/usePromiseKit}}
{{^useVapor}}
{{#useAsyncAwait}}
{{#summary}}
// {{{.}}}
{{/summary}}
do {
{{#returnType}}let response = {{/returnType}}try await {{classname}}{{^apiStaticMethod}}(){{/apiStaticMethod}}.{{{operationId}}}({{#allParams}}{{paramName}}: {{paramName}}{{^-last}}, {{/-last}}{{/allParams}})
{{#returnType}}
dump(response)
{{/returnType}}
} catch {
print(error)
}
{{/useAsyncAwait}}
{{/useVapor}}
{{#usePromiseKit}}
{{#summary}}
// {{{.}}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Method | HTTP request | Description

# **call123testSpecialTags**
```swift
open class func call123testSpecialTags(body: Client, completion: @escaping (_ data: Client?, _ error: Error?) -> Void)
open class func call123testSpecialTags(body: Client) async throws -> Client
```

To test special tags
Expand All @@ -24,15 +24,11 @@ import PetstoreClient
let body = Client(client: "client_example") // Client | client model

// To test special tags
AnotherFakeAPI.call123testSpecialTags(body: body) { (response, error) in
guard error == nil else {
print(error)
return
}

if (response) {
dump(response)
}
do {
let response = try await AnotherFakeAPI.call123testSpecialTags(body: body)
dump(response)
} catch {
print(error)
}
```

Expand Down
Loading
Loading