From 42d635b463f1b3795535c73d0867635e74c22181 Mon Sep 17 00:00:00 2001 From: Bruno Coelho <4brunu@users.noreply.github.com> Date: Fri, 17 Dec 2021 02:19:41 +0000 Subject: [PATCH] [swift5][client] improve code formatting (#11124) * [swift][client] improve code formatting with multiple response as * [kotlin][vertx] update sample project --- .../src/main/resources/swift5/api.mustache | 13 ++++--- .../PetstoreClient/APIs/AnotherFakeAPI.swift | 1 - .../Sources/PetstoreClient/APIs/FakeAPI.swift | 14 -------- .../APIs/FakeClassnameTags123API.swift | 1 - .../Sources/PetstoreClient/APIs/PetAPI.swift | 9 ----- .../PetstoreClient/APIs/StoreAPI.swift | 4 --- .../Sources/PetstoreClient/APIs/UserAPI.swift | 8 ----- .../server/api/model/ApiResponse.kt | 34 ------------------- 8 files changed, 9 insertions(+), 75 deletions(-) delete mode 100644 samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/ApiResponse.kt diff --git a/modules/openapi-generator/src/main/resources/swift5/api.mustache b/modules/openapi-generator/src/main/resources/swift5/api.mustache index 2351c74fd9b..e5cd7ea4490 100644 --- a/modules/openapi-generator/src/main/resources/swift5/api.mustache +++ b/modules/openapi-generator/src/main/resources/swift5/api.mustache @@ -23,9 +23,9 @@ extension {{projectName}}API { /** {{{.}}} */{{/description}} {{#objcCompatible}}@objc {{/objcCompatible}}{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class {{classname}}{{#objcCompatible}} : NSObject{{/objcCompatible}} { {{#operation}} - {{#allParams}} {{#isEnum}} + /** * enum for parameter {{paramName}} */ @@ -36,7 +36,6 @@ extension {{projectName}}API { {{/enumVars}} {{/allowableValues}} } - {{/isEnum}} {{/allParams}} {{^useVapor}} @@ -45,6 +44,7 @@ extension {{projectName}}API { {{^useResult}} {{^useCombine}} {{^useAsyncAwait}} + /** {{#summary}} {{{.}}} @@ -80,6 +80,7 @@ extension {{projectName}}API { {{/usePromiseKit}} {{/useVapor}} {{#usePromiseKit}} + /** {{#summary}} {{{.}}} @@ -111,6 +112,7 @@ extension {{projectName}}API { } {{/usePromiseKit}} {{#useRxSwift}} + /** {{#summary}} {{{.}}} @@ -147,6 +149,7 @@ extension {{projectName}}API { } {{/useRxSwift}} {{#useCombine}} + /** {{#summary}} {{{.}}} @@ -186,6 +189,7 @@ extension {{projectName}}API { #endif {{/useCombine}} {{#useAsyncAwait}} + /** {{#summary}} {{{.}}} @@ -229,6 +233,7 @@ extension {{projectName}}API { } {{/useAsyncAwait}} {{#useResult}} + /** {{#summary}} {{{.}}} @@ -241,7 +246,7 @@ extension {{projectName}}API { @available(*, deprecated, message: "This operation is deprecated.") {{/isDeprecated}} @discardableResult - open 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}}apiResponseQueue: DispatchQueue = {{projectName}}API.apiResponseQueue, completion: @escaping ((_ result: Swift.Result<{{{returnType}}}{{^returnType}}Void{{/returnType}}, ErrorResponse>) -> Void)) -> RequestTask { + {{#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}}apiResponseQueue: DispatchQueue = {{projectName}}API.apiResponseQueue, completion: @escaping ((_ result: Swift.Result<{{{returnType}}}{{^returnType}}Void{{/returnType}}, ErrorResponse>) -> Void)) -> RequestTask { return {{operationId}}WithRequestBuilder({{#allParams}}{{paramName}}: {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}).execute(apiResponseQueue) { result in switch result { {{#returnType}} @@ -259,6 +264,7 @@ extension {{projectName}}API { } {{/useResult}} {{#useVapor}} + /** {{#summary}} {{{.}}} @@ -380,7 +386,6 @@ extension {{projectName}}API { } } } - {{/useVapor}} {{^useVapor}} diff --git a/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/AnotherFakeAPI.swift b/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/AnotherFakeAPI.swift index 78cd04bd6b1..85f7cf35117 100644 --- a/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/AnotherFakeAPI.swift +++ b/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/AnotherFakeAPI.swift @@ -60,5 +60,4 @@ open class AnotherFakeAPI { } } } - } diff --git a/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/FakeAPI.swift b/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/FakeAPI.swift index 144a6d4e68a..014da837833 100644 --- a/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/FakeAPI.swift +++ b/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/FakeAPI.swift @@ -61,7 +61,6 @@ open class FakeAPI { } } - /** POST /fake/outer/boolean Test serialization of outer boolean types @@ -110,7 +109,6 @@ open class FakeAPI { } } - /** POST /fake/outer/composite Test serialization of object with outer number type @@ -159,7 +157,6 @@ open class FakeAPI { } } - /** POST /fake/outer/number Test serialization of outer number types @@ -208,7 +205,6 @@ open class FakeAPI { } } - /** POST /fake/outer/string Test serialization of outer string types @@ -257,7 +253,6 @@ open class FakeAPI { } } - /** PUT /fake/body-with-file-schema For this test, the body for this request much reference a schema named `File`. @@ -304,7 +299,6 @@ open class FakeAPI { } } - /** PUT /fake/body-with-query-params - parameter query: (query) @@ -358,7 +352,6 @@ open class FakeAPI { } } - /** To test \"client\" model PATCH /fake @@ -407,7 +400,6 @@ open class FakeAPI { } } - /** Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 POST /fake @@ -507,7 +499,6 @@ open class FakeAPI { } } - /** * enum for parameter enumHeaderStringArray */ @@ -661,7 +652,6 @@ open class FakeAPI { } } - /** Fake endpoint to test group parameters (optional) DELETE /fake @@ -736,7 +726,6 @@ open class FakeAPI { } } - /** test inline additionalProperties POST /fake/inline-additionalProperties @@ -783,7 +772,6 @@ open class FakeAPI { } } - /** test json serialization of form data GET /fake/jsonFormData @@ -836,7 +824,6 @@ open class FakeAPI { } } - /** PUT /fake/test-query-parameters To test the collection format in query parameters @@ -904,5 +891,4 @@ open class FakeAPI { } } } - } diff --git a/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/FakeClassnameTags123API.swift b/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/FakeClassnameTags123API.swift index 0a104952526..e8ad26cffed 100644 --- a/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/FakeClassnameTags123API.swift +++ b/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/FakeClassnameTags123API.swift @@ -66,5 +66,4 @@ open class FakeClassnameTags123API { } } } - } diff --git a/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/PetAPI.swift b/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/PetAPI.swift index e07bf6753d1..5e801521501 100644 --- a/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/PetAPI.swift +++ b/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/PetAPI.swift @@ -68,7 +68,6 @@ open class PetAPI { } } - /** Deletes a pet DELETE /pet/{petId} @@ -130,7 +129,6 @@ open class PetAPI { } } - /** * enum for parameter status */ @@ -203,7 +201,6 @@ open class PetAPI { } } - /** Finds Pets by tags GET /pet/findByTags @@ -269,7 +266,6 @@ open class PetAPI { } } - /** Find pet by ID GET /pet/{petId} @@ -332,7 +328,6 @@ open class PetAPI { } } - /** Update an existing pet PUT /pet @@ -394,7 +389,6 @@ open class PetAPI { } } - /** Updates a pet in the store with form data POST /pet/{petId} @@ -458,7 +452,6 @@ open class PetAPI { } } - /** uploads an image POST /pet/{petId}/uploadImage @@ -522,7 +515,6 @@ open class PetAPI { } } - /** uploads an image (required) POST /fake/{petId}/uploadImageWithRequiredFile @@ -585,5 +577,4 @@ open class PetAPI { } } } - } diff --git a/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/StoreAPI.swift b/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/StoreAPI.swift index 6c3358a6163..d802c4c765e 100644 --- a/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/StoreAPI.swift +++ b/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/StoreAPI.swift @@ -66,7 +66,6 @@ open class StoreAPI { } } - /** Returns pet inventories by status GET /store/inventory @@ -118,7 +117,6 @@ open class StoreAPI { } } - /** Find purchase order by ID GET /store/order/{order_id} @@ -175,7 +173,6 @@ open class StoreAPI { } } - /** Place an order for a pet POST /store/order @@ -224,5 +221,4 @@ open class StoreAPI { } } } - } diff --git a/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/UserAPI.swift b/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/UserAPI.swift index e71a3ee7bf3..18320590769 100644 --- a/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/UserAPI.swift +++ b/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/APIs/UserAPI.swift @@ -58,7 +58,6 @@ open class UserAPI { } } - /** Creates list of users with given input array POST /user/createWithArray @@ -102,7 +101,6 @@ open class UserAPI { } } - /** Creates list of users with given input array POST /user/createWithList @@ -146,7 +144,6 @@ open class UserAPI { } } - /** Delete user DELETE /user/{username} @@ -200,7 +197,6 @@ open class UserAPI { } } - /** Get user by user name GET /user/{username} @@ -255,7 +251,6 @@ open class UserAPI { } } - /** Logs user into the system GET /user/login @@ -317,7 +312,6 @@ open class UserAPI { } } - /** Logs out current logged in user session GET /user/logout @@ -358,7 +352,6 @@ open class UserAPI { } } - /** Updated user PUT /user/{username} @@ -414,5 +407,4 @@ open class UserAPI { } } } - } diff --git a/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/ApiResponse.kt b/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/ApiResponse.kt deleted file mode 100644 index 223e80919ac..00000000000 --- a/samples/server/petstore/kotlin/vertx/src/main/kotlin/org/openapitools/server/api/model/ApiResponse.kt +++ /dev/null @@ -1,34 +0,0 @@ -/** -* OpenAPI Petstore -* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -* -* The version of the OpenAPI document: 1.0.0 -* -* -* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -* https://openapi-generator.tech -* Do not edit the class manually. -*/ -package org.openapitools.server.api.model - - - -import com.google.gson.annotations.SerializedName -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonInclude -/** - * Describes the result of uploading an image resource - * @param code - * @param type - * @param message - */ -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -data class ApiResponse ( - var code: kotlin.Int? = null, - var type: kotlin.String? = null, - var message: kotlin.String? = null -) { - -} -