Add 14 test cases from Url.json (#229)
* Fix URL path , query parameters encoding * All 77 test cases passed * Add test case for Path.stringUrlEncoded * Revert set of allowable characters in query parameter * Fix test case Queries.stringUrlEncoded * Add queries.unicode test case * Add queries array test cases * Add Path.base64 url test * Add .paths.stringUrlNonEncoded test case * Add new test case for arrayStringNoCollectionFormatEmpty * Add test case test_Queries_arrayStringCsvEmpty200 * Cleanup * Update testserver_codegen.sh * Update testserver_codegen.sh * Address PR Feedback * Remove scripts/testserver_codegen.sh * Update per PR feedkbac * Address PR feedback * Add support for custom baseURl test cases (#230) * Add test generated custom-baseUrl * Add XC project * WIP * Add custombaseurl support * Refactor * Regenerate code after merge * Address PR feedback * Address PR feedback * Address PR feedback * Address PR feedback * Remove scripts/testserver_codegen.sh * Fix stencil file * Code gen updates for AzureCore (#234) * Updates for AzureCore changes in PR 510. * Regenerate test code. * Address PR feedback * Address PR feedback * Regenerated code * Rename url parameters * Rename parameters in url * Address PR feedback Co-authored-by: Travis Prescott <tjprescott@users.noreply.github.com> * Regenerate code after rebase Co-authored-by: Travis Prescott <tjprescott@users.noreply.github.com>
This commit is contained in:
Родитель
955a866fc2
Коммит
fe054250f8
|
@ -184,6 +184,7 @@
|
|||
F151510B25128E2D00DF0B9F /* OperationExceptionSnippet.stencil in CopyFiles */ = {isa = PBXBuildFile; fileRef = F151510725128E0B00DF0B9F /* OperationExceptionSnippet.stencil */; };
|
||||
F151510C25128E2D00DF0B9F /* OperationExceptionStringBodySnippet.stencil in CopyFiles */ = {isa = PBXBuildFile; fileRef = F151510425128E0B00DF0B9F /* OperationExceptionStringBodySnippet.stencil */; };
|
||||
F15151272512AA5B00DF0B9F /* OperationResponseExceptionSnippet.stencil in CopyFiles */ = {isa = PBXBuildFile; fileRef = F15151262512AA2D00DF0B9F /* OperationResponseExceptionSnippet.stencil */; };
|
||||
F15D2C5C2547536400265366 /* AutoRestParameterizedHostTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = F15D2C5B2547536400265366 /* AutoRestParameterizedHostTest.swift */; };
|
||||
F170D322253F786800A569A0 /* Util.swift in Sources */ = {isa = PBXBuildFile; fileRef = F170D321253F786800A569A0 /* Util.swift */; };
|
||||
F1731F322522E531006CDED8 /* MethodOptionsSnippet.stencil in CopyFiles */ = {isa = PBXBuildFile; fileRef = F1731F2E2522E4D8006CDED8 /* MethodOptionsSnippet.stencil */; };
|
||||
F1731F332522E531006CDED8 /* NamedMethodOptionsFile.stencil in CopyFiles */ = {isa = PBXBuildFile; fileRef = F1731F2F2522E4F0006CDED8 /* NamedMethodOptionsFile.stencil */; };
|
||||
|
@ -259,6 +260,20 @@
|
|||
remoteGlobalIDString = "AutoRestSwaggerBatFile::AutoRestSwaggerBatFile";
|
||||
remoteInfo = AutoRestSwaggerBatFile;
|
||||
};
|
||||
F15D2C4F2547523B00265366 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F15D2C472547523B00265366 /* AutoRestParameterizedHostTest.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = "AutoRestParameterizedHostTest::AutoRestParameterizedHostTest::Product";
|
||||
remoteInfo = AutoRestParameterizedHostTest;
|
||||
};
|
||||
F15D2C5F254753BE00265366 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F15D2C472547523B00265366 /* AutoRestParameterizedHostTest.xcodeproj */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = "AutoRestParameterizedHostTest::AutoRestParameterizedHostTest";
|
||||
remoteInfo = AutoRestParameterizedHostTest;
|
||||
};
|
||||
F186E8E8250FE46100723FA3 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F18718E0250C58B900318867 /* AutoRestReport.xcodeproj */;
|
||||
|
@ -518,6 +533,8 @@
|
|||
F151510725128E0B00DF0B9F /* OperationExceptionSnippet.stencil */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = OperationExceptionSnippet.stencil; sourceTree = "<group>"; };
|
||||
F15151262512AA2D00DF0B9F /* OperationResponseExceptionSnippet.stencil */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = OperationResponseExceptionSnippet.stencil; sourceTree = "<group>"; };
|
||||
F1587DA8251A965900A89B98 /* NamedOperationGroupFile.stencil */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NamedOperationGroupFile.stencil; sourceTree = "<group>"; };
|
||||
F15D2C472547523B00265366 /* AutoRestParameterizedHostTest.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = AutoRestParameterizedHostTest.xcodeproj; path = "test/integration/generated/custom-baseUrl/AutoRestParameterizedHostTest.xcodeproj"; sourceTree = SOURCE_ROOT; };
|
||||
F15D2C5B2547536400265366 /* AutoRestParameterizedHostTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AutoRestParameterizedHostTest.swift; sourceTree = "<group>"; };
|
||||
F170D321253F786800A569A0 /* Util.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Util.swift; sourceTree = "<group>"; };
|
||||
F1731F2E2522E4D8006CDED8 /* MethodOptionsSnippet.stencil */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MethodOptionsSnippet.stencil; sourceTree = "<group>"; };
|
||||
F1731F2F2522E4F0006CDED8 /* NamedMethodOptionsFile.stencil */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NamedMethodOptionsFile.stencil; sourceTree = "<group>"; };
|
||||
|
@ -850,6 +867,14 @@
|
|||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F15D2C482547523B00265366 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F15D2C502547523B00265366 /* AutoRestParameterizedHostTest.framework */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F186E8FD250FEAEC00723FA3 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
@ -883,12 +908,14 @@
|
|||
F113049624F8BA0C007FF3A3 /* AutoRestSwaggerBatFile.xcodeproj */,
|
||||
F18718E0250C58B900318867 /* AutoRestReport.xcodeproj */,
|
||||
0A7476E82527CDAC00819FC9 /* AutoRestResourceFlatteningTest.xcodeproj */,
|
||||
F15D2C472547523B00265366 /* AutoRestParameterizedHostTest.xcodeproj */,
|
||||
F186E8F2250FE9A100723FA3 /* XmsErrorResponseExtensions.xcodeproj */,
|
||||
0A747B22252E897200819FC9 /* AutoRestUrlTest.swift */,
|
||||
F113047424F78283007FF3A3 /* AutoRestHeadTest.swift */,
|
||||
F186EB1425116AC500723FA3 /* AutoRestBodyIntegerTest.swift */,
|
||||
F11304A624F8BA85007FF3A3 /* AutoRestSwaggerBatFileTest.swift */,
|
||||
0A7477002527CE4500819FC9 /* AutoRestResourceFlatteningTest.swift */,
|
||||
F15D2C5B2547536400265366 /* AutoRestParameterizedHostTest.swift */,
|
||||
F10B1F6125414556007DA581 /* Dictionary+Extension.swift */,
|
||||
F186E914250FF08D00723FA3 /* XmsErrorResponseExtensionsTest.swift */,
|
||||
F18718F0250C592300318867 /* ZZZAutoRestReportTest.swift */,
|
||||
|
@ -1134,6 +1161,7 @@
|
|||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
F15D2C60254753BE00265366 /* PBXTargetDependency */,
|
||||
0A7477382527D17800819FC9 /* PBXTargetDependency */,
|
||||
0A7476FF2527CE2100819FC9 /* PBXTargetDependency */,
|
||||
F186EB2E25116BE200723FA3 /* PBXTargetDependency */,
|
||||
|
@ -1184,6 +1212,10 @@
|
|||
ProductGroup = F186EB2325116ADF00723FA3 /* Products */;
|
||||
ProjectRef = F186EB2225116ADF00723FA3 /* AutoRestIntegerTest.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = F15D2C482547523B00265366 /* Products */;
|
||||
ProjectRef = F15D2C472547523B00265366 /* AutoRestParameterizedHostTest.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = F18718E1250C58B900318867 /* Products */;
|
||||
ProjectRef = F18718E0250C58B900318867 /* AutoRestReport.xcodeproj */;
|
||||
|
@ -1196,14 +1228,14 @@
|
|||
ProductGroup = F113049724F8BA0C007FF3A3 /* Products */;
|
||||
ProjectRef = F113049624F8BA0C007FF3A3 /* AutoRestSwaggerBatFile.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = 0A74777D252CD3D500819FC9 /* Products */;
|
||||
ProjectRef = F13C48092527EB86004E7CCF /* AutoRestUrlTest.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = 0A7477232527D15F00819FC9 /* Products */;
|
||||
ProjectRef = 0A7477222527D15F00819FC9 /* AutoRestUrlTest.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = 0A74777D252CD3D500819FC9 /* Products */;
|
||||
ProjectRef = F13C48092527EB86004E7CCF /* AutoRestUrlTest.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = F186E8FD250FEAEC00723FA3 /* Products */;
|
||||
ProjectRef = F186E8F2250FE9A100723FA3 /* XmsErrorResponseExtensions.xcodeproj */;
|
||||
|
@ -1246,6 +1278,13 @@
|
|||
remoteRef = F11304A024F8BA0C007FF3A3 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
F15D2C502547523B00265366 /* AutoRestParameterizedHostTest.framework */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.framework;
|
||||
path = AutoRestParameterizedHostTest.framework;
|
||||
remoteRef = F15D2C4F2547523B00265366 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
F186E906250FEAEC00723FA3 /* XmsErrorResponseExtensions.framework */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.framework;
|
||||
|
@ -1357,13 +1396,14 @@
|
|||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F15D2C5C2547536400265366 /* AutoRestParameterizedHostTest.swift in Sources */,
|
||||
F186E916250FF08D00723FA3 /* XmsErrorResponseExtensionsTest.swift in Sources */,
|
||||
F11304A724F8BA85007FF3A3 /* AutoRestSwaggerBatFileTest.swift in Sources */,
|
||||
F186EB1525116AC500723FA3 /* AutoRestBodyIntegerTest.swift in Sources */,
|
||||
F10B1F6325414556007DA581 /* Dictionary+Extension.swift in Sources */,
|
||||
F113047524F78283007FF3A3 /* AutoRestHeadTest.swift in Sources */,
|
||||
F170D322253F786800A569A0 /* Util.swift in Sources */,
|
||||
F113047524F78283007FF3A3 /* AutorestHeadTest.swift in Sources */,
|
||||
F113047524F78283007FF3A3 /* AutoRestHeadTest.swift in Sources */,
|
||||
0A7477012527CE4500819FC9 /* AutoRestResourceFlatteningTest.swift in Sources */,
|
||||
F18718F1250C592300318867 /* ZZZAutoRestReportTest.swift in Sources */,
|
||||
0A747B24252E897300819FC9 /* AutoRestUrlTest.swift in Sources */,
|
||||
|
@ -1528,6 +1568,11 @@
|
|||
name = AutoRestSwaggerBatFile;
|
||||
targetProxy = F11304A424F8BA30007FF3A3 /* PBXContainerItemProxy */;
|
||||
};
|
||||
F15D2C60254753BE00265366 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
name = AutoRestParameterizedHostTest;
|
||||
targetProxy = F15D2C5F254753BE00265366 /* PBXContainerItemProxy */;
|
||||
};
|
||||
F186E8E9250FE46100723FA3 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
name = AutoRestReport;
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
// --------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the ""Software""), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
import AutoRestParameterizedHostTest
|
||||
import AzureCore
|
||||
import XCTest
|
||||
|
||||
class AutoRestParameterizedHostTest: XCTestCase {
|
||||
var client: AutoRestParameterizedHostTestClient!
|
||||
|
||||
override func setUpWithError() throws {
|
||||
guard let baseUrl = URL(string: "http://wronghost") else {
|
||||
fatalError("Can't creat a base URL")
|
||||
}
|
||||
client = try AutoRestParameterizedHostTestClient(
|
||||
host: "host:3000",
|
||||
baseUrl: baseUrl,
|
||||
authPolicy: AnonymousAccessPolicy(),
|
||||
withOptions: AutoRestParameterizedHostTestClientOptions()
|
||||
)
|
||||
}
|
||||
|
||||
func test_get_empty200() throws {
|
||||
let expectation = XCTestExpectation(description: "Call paths.getEmpty succeed")
|
||||
|
||||
client.paths.getEmpty(accountName: "local") { result, _ in
|
||||
switch result {
|
||||
case .success:
|
||||
expectation.fulfill()
|
||||
case let .failure(error):
|
||||
print("test failed. error=\(error.message)")
|
||||
XCTFail("Call paths.getEmpty failed")
|
||||
}
|
||||
}
|
||||
|
||||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
func test_get_emptyFailed() throws {
|
||||
let expectation = XCTestExpectation(description: "Call paths.getEmpty failed")
|
||||
|
||||
client.paths.getEmpty(accountName: "bad") { result, _ in
|
||||
switch result {
|
||||
case .success:
|
||||
XCTFail("Call paths.getEmptyFailed should failed")
|
||||
case let .failure:
|
||||
expectation.fulfill()
|
||||
}
|
||||
}
|
||||
|
||||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
}
|
|
@ -31,6 +31,7 @@ import XCTest
|
|||
// swiftlint:disable function_body_length
|
||||
// swiftlint:disable type_body_length
|
||||
// swiftlint:disable file_length
|
||||
|
||||
class AutoRestUrlTest: XCTestCase {
|
||||
var client: AutoRestUrlTestClient!
|
||||
|
||||
|
@ -282,6 +283,74 @@ class AutoRestUrlTest: XCTestCase {
|
|||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
func test_Paths_stringUrlEncoded200() throws {
|
||||
let expectation = XCTestExpectation(description: "Call paths.stringUrlEncoded succeed")
|
||||
|
||||
client.paths.stringUrlEncoded { result, httpResponse in
|
||||
switch result {
|
||||
case .success:
|
||||
expectation.fulfill()
|
||||
case let .failure(error):
|
||||
let details = errorDetails(for: error, withResponse: httpResponse)
|
||||
print("test failed. error=\(details)")
|
||||
XCTFail("Call paths.stringUrlEncoded failed")
|
||||
}
|
||||
}
|
||||
|
||||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
func test_Paths_arrayStringCsvValid200() throws {
|
||||
let expectation = XCTestExpectation(description: "Call paths.arrayStringCsvValid succeed")
|
||||
|
||||
client.paths
|
||||
.arrayCsvInPath(arrayPath: ["ArrayPath1", "begin!*'();:@ &=+$,/?#[]end", "", ""]) { result, httpResponse in
|
||||
switch result {
|
||||
case .success:
|
||||
expectation.fulfill()
|
||||
case let .failure(error):
|
||||
let details = errorDetails(for: error, withResponse: httpResponse)
|
||||
print("test failed. error=\(details)")
|
||||
XCTFail("Call paths.arrayStringCsvValid failed")
|
||||
}
|
||||
}
|
||||
|
||||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
func test_Paths_base64Url200() throws {
|
||||
let expectation = XCTestExpectation(description: "Call paths.base64Url succeed")
|
||||
|
||||
client.paths.base64Url(base64UrlPath: Data("lorem".utf8)) { result, httpResponse in
|
||||
switch result {
|
||||
case .success:
|
||||
expectation.fulfill()
|
||||
case let .failure(error):
|
||||
let details = errorDetails(for: error, withResponse: httpResponse)
|
||||
print("test failed. error=\(details)")
|
||||
XCTFail("Call paths.base64Url failed")
|
||||
}
|
||||
}
|
||||
|
||||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
func test_Paths_stringUrlNonEncoded200() throws {
|
||||
let expectation = XCTestExpectation(description: "Call paths.stringUrlNonEncoded succeed")
|
||||
|
||||
client.paths.stringUrlNonEncoded { result, _ in
|
||||
switch result {
|
||||
case .success:
|
||||
expectation.fulfill()
|
||||
case let .failure(error):
|
||||
print("test failed. error=\(error.message)")
|
||||
XCTFail("Call paths.stringUrlNonEncoded failed")
|
||||
}
|
||||
}
|
||||
|
||||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
func test_Queries_byteNull200() throws {
|
||||
let expectation = XCTestExpectation(description: "Call queries.byteNull succeed")
|
||||
|
||||
|
@ -605,6 +674,203 @@ class AutoRestUrlTest: XCTestCase {
|
|||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
func test_Queries_arrayStringCsvValid200() throws {
|
||||
let expectation = XCTestExpectation(description: "Call queries.arrayStringCsvValid succeed")
|
||||
|
||||
let options = Queries.ArrayStringCsvValidOptions(
|
||||
arrayQuery: ["ArrayQuery1", "begin!*'();:@ &=+$,/?#[]end", "", ""]
|
||||
)
|
||||
|
||||
client.queries.arrayStringCsvValid(withOptions: options) { result, httpResponse in
|
||||
switch result {
|
||||
case .success:
|
||||
expectation.fulfill()
|
||||
case let .failure(error):
|
||||
let details = errorDetails(for: error, withResponse: httpResponse)
|
||||
print("test failed. error=\(details)")
|
||||
XCTFail("Call queries.arrayStringCsvValid failed")
|
||||
}
|
||||
}
|
||||
|
||||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
func test_Queries_arrayStringPipesValid200() throws {
|
||||
let expectation = XCTestExpectation(description: "Call queries.arrayStringPipesValid succeed")
|
||||
|
||||
let options = Queries.ArrayStringPipesValidOptions(
|
||||
arrayQuery: ["ArrayQuery1", "begin!*'();:@ &=+$,/?#[]end", "", ""]
|
||||
)
|
||||
|
||||
client.queries.arrayStringPipesValid(withOptions: options) { result, httpResponse in
|
||||
switch result {
|
||||
case .success:
|
||||
expectation.fulfill()
|
||||
case let .failure(error):
|
||||
let details = errorDetails(for: error, withResponse: httpResponse)
|
||||
print("test failed. error=\(details)")
|
||||
XCTFail("Call queries.arrayStringPipesValid failed")
|
||||
}
|
||||
}
|
||||
|
||||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
func test_Queries_arrayStringSsvValid200() throws {
|
||||
let expectation = XCTestExpectation(description: "Call queries.arrayStringSsvValid succeed")
|
||||
|
||||
let options = Queries.ArrayStringSsvValidOptions(
|
||||
arrayQuery: ["ArrayQuery1", "begin!*'();:@ &=+$,/?#[]end", "", ""]
|
||||
)
|
||||
|
||||
client.queries.arrayStringSsvValid(withOptions: options) { result, httpResponse in
|
||||
switch result {
|
||||
case .success:
|
||||
expectation.fulfill()
|
||||
case let .failure(error):
|
||||
let details = errorDetails(for: error, withResponse: httpResponse)
|
||||
print("test failed. error=\(details)")
|
||||
XCTFail("Call queries.arrayStringSsvValid failed")
|
||||
}
|
||||
}
|
||||
|
||||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
func test_Queries_arrayStringTsvValid200() throws {
|
||||
let expectation = XCTestExpectation(description: "Call queries.arrayStringTsvValid succeed")
|
||||
|
||||
let options = Queries.ArrayStringTsvValidOptions(
|
||||
arrayQuery: ["ArrayQuery1", "begin!*'();:@ &=+$,/?#[]end", "", ""]
|
||||
)
|
||||
|
||||
client.queries.arrayStringTsvValid(withOptions: options) { result, httpResponse in
|
||||
switch result {
|
||||
case .success:
|
||||
expectation.fulfill()
|
||||
case let .failure(error):
|
||||
let details = errorDetails(for: error, withResponse: httpResponse)
|
||||
print("test failed. error=\(details)")
|
||||
XCTFail("Call queries.arrayStringTsvValid failed")
|
||||
}
|
||||
}
|
||||
|
||||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
func test_Queries_arrayStringNoCollectionFormatEmpty200() throws {
|
||||
let expectation = XCTestExpectation(description: "Call queries.arrayStringNoCollectionFormatEmpty succeed")
|
||||
|
||||
let options = Queries.ArrayStringNoCollectionFormatEmptyOptions(
|
||||
arrayQuery: ["hello", "nihao", "bonjour"]
|
||||
)
|
||||
|
||||
client.queries.arrayStringNoCollectionFormatEmpty(withOptions: options) { result, httpResponse in
|
||||
switch result {
|
||||
case .success:
|
||||
expectation.fulfill()
|
||||
case let .failure(error):
|
||||
let details = errorDetails(for: error, withResponse: httpResponse)
|
||||
print("test failed. error=\(details)")
|
||||
XCTFail("Call queries.arrayStringNoCollectionFormatEmpty failed")
|
||||
}
|
||||
}
|
||||
|
||||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
func test_Queries_arrayStringCsvEmpty200() throws {
|
||||
let expectation = XCTestExpectation(description: "Call queries.arrayStringCsvEmpty succeed")
|
||||
|
||||
let options = Queries.ArrayStringCsvEmptyOptions(
|
||||
arrayQuery: []
|
||||
)
|
||||
|
||||
client.queries.arrayStringCsvEmpty(withOptions: options) { result, httpResponse in
|
||||
switch result {
|
||||
case .success:
|
||||
expectation.fulfill()
|
||||
case let .failure(error):
|
||||
let details = errorDetails(for: error, withResponse: httpResponse)
|
||||
print("test failed. error=\(details)")
|
||||
XCTFail("Call queries.arrayStringCsvEmpty failed")
|
||||
}
|
||||
}
|
||||
|
||||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
func test_Queries_arrayStringCsvNull200() throws {
|
||||
let expectation = XCTestExpectation(description: "Call queries.arrayStringCsvNull succeed")
|
||||
|
||||
let options = Queries.ArrayStringCsvNullOptions(
|
||||
arrayQuery: nil
|
||||
)
|
||||
|
||||
client.queries.arrayStringCsvNull(withOptions: options) { result, httpResponse in
|
||||
switch result {
|
||||
case .success:
|
||||
expectation.fulfill()
|
||||
case let .failure(error):
|
||||
let details = errorDetails(for: error, withResponse: httpResponse)
|
||||
print("test failed. error=\(details)")
|
||||
XCTFail("Call queries.arrayStringCsvNull failed")
|
||||
}
|
||||
}
|
||||
|
||||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
func test_Queries_stringUrlEncoded200() throws {
|
||||
let expectation = XCTestExpectation(description: "Call queries.stringUrlEncoded succeed")
|
||||
|
||||
client.queries.stringUrlEncoded { result, httpResponse in
|
||||
switch result {
|
||||
case .success:
|
||||
expectation.fulfill()
|
||||
case let .failure(error):
|
||||
let details = errorDetails(for: error, withResponse: httpResponse)
|
||||
print("test failed. error=\(details)")
|
||||
XCTFail("Call queries.stringUrlEncoded failed")
|
||||
}
|
||||
}
|
||||
|
||||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
func test_Queries_stringUnicoded200() throws {
|
||||
let expectation = XCTestExpectation(description: "Call queries.stringUnicode succeed")
|
||||
|
||||
client.queries.stringUnicode { result, httpResponse in
|
||||
switch result {
|
||||
case .success:
|
||||
expectation.fulfill()
|
||||
case let .failure(error):
|
||||
let details = errorDetails(for: error, withResponse: httpResponse)
|
||||
print("test failed. error=\(details)")
|
||||
XCTFail("Call queries.stringUnicode failed")
|
||||
}
|
||||
}
|
||||
|
||||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
func test_Queries_floatScientificPositive200() throws {
|
||||
let expectation = XCTestExpectation(description: "Call queries.floatScientificPositive succeed")
|
||||
|
||||
client.queries.floatScientificPositive { result, _ in
|
||||
switch result {
|
||||
case .success:
|
||||
expectation.fulfill()
|
||||
case let .failure(error):
|
||||
print("test failed. error=\(error.message)")
|
||||
XCTFail("Call queries.floatScientificPositive failed")
|
||||
}
|
||||
}
|
||||
|
||||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
func test_Pathitems_getGlobalQueryNull200() throws {
|
||||
let expectation = XCTestExpectation(description: "Call pathitems_getGlobalQueryNull succeed")
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ let package = Package(
|
|||
.package(name: "AutoRestIntegerTest", path: "./test/integration/generated/body-integer/"),
|
||||
.package(name: "AutoRestUrlTest", path: "./test/integration/generated/url/"),
|
||||
.package(name: "AutoRestResourceFlatteningTest", path: "./test/integration/generated/model-flattening/"),
|
||||
.package(name: "AutoRestParameterizedHostTest", path: "./test/integration/generated/custom-baseUrl/"),
|
||||
],
|
||||
targets: [
|
||||
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||
|
@ -45,7 +46,8 @@ let package = Package(
|
|||
"AutoRestReport",
|
||||
"AutoRestIntegerTest",
|
||||
"AutoRestUrlTest",
|
||||
"AutoRestResourceFlatteningTest"],
|
||||
"AutoRestResourceFlatteningTest",
|
||||
"AutoRestParameterizedHostTest"],
|
||||
path: "AutorestSwiftTest"
|
||||
)
|
||||
],
|
||||
|
|
|
@ -45,6 +45,31 @@ class Parameter: Value, CustomDebugStringConvertible {
|
|||
return nil
|
||||
}
|
||||
|
||||
var style: SerializationStyle? {
|
||||
if let httpParam = self.protocol.http as? HttpParameter {
|
||||
return httpParam.style
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var delimiter: String {
|
||||
guard let delimiterStyle = style else {
|
||||
return ","
|
||||
}
|
||||
switch delimiterStyle {
|
||||
case .pipeDelimited:
|
||||
return "|"
|
||||
case .spaceDelimited:
|
||||
return " "
|
||||
case .tabDelimited:
|
||||
return "\\t"
|
||||
case .form:
|
||||
return ","
|
||||
default:
|
||||
return ","
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Codable
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
|
|
|
@ -89,6 +89,14 @@ enum ParameterType: Codable {
|
|||
return common.paramLocation
|
||||
}
|
||||
|
||||
var style: SerializationStyle? {
|
||||
return common.style
|
||||
}
|
||||
|
||||
var delimiter: String {
|
||||
return common.delimiter
|
||||
}
|
||||
|
||||
var clientDefaultValue: String? {
|
||||
return common.clientDefaultValue
|
||||
}
|
||||
|
|
|
@ -31,4 +31,5 @@ enum QueryEncodingStyle: String, Codable {
|
|||
case form
|
||||
case pipeDelimited
|
||||
case spaceDelimited
|
||||
case tabDelimited
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import Foundation
|
|||
|
||||
enum KeyValueDecodeStrategy: String {
|
||||
case byteArray
|
||||
case base64ByteArray
|
||||
case date
|
||||
case dateTime
|
||||
case `default`
|
||||
|
@ -71,7 +72,8 @@ struct KeyValueViewModel: Comparable {
|
|||
} else if param.implementation == .client {
|
||||
self.init(
|
||||
key: name,
|
||||
value: name,
|
||||
// if the parameter is $host, retrieve the value from client's 'baseUrl' property
|
||||
value: (name == "$host") ? "baseUrl.absoluteString" : name,
|
||||
optional: !param.required,
|
||||
path: "client."
|
||||
)
|
||||
|
@ -117,7 +119,7 @@ struct KeyValueViewModel: Comparable {
|
|||
let type = signatureParameter.schema.type
|
||||
|
||||
// value is referring a signature parameter, no need to wrap as String
|
||||
self.value = KeyValueViewModel.formatValueForType(type: type, value: name)
|
||||
self.value = KeyValueViewModel.formatValue(forSignatureParameter: signatureParameter, value: name)
|
||||
|
||||
// if parameter is from method signature (not from option) and type is date or byteArray,
|
||||
// add decoding logic to string in the method and specify the right decoding strategy
|
||||
|
@ -128,7 +130,12 @@ struct KeyValueViewModel: Comparable {
|
|||
case .dateTime:
|
||||
keyValueType = .dateTime
|
||||
case .byteArray:
|
||||
keyValueType = .byteArray
|
||||
if let byteArraySchema = signatureParameter.schema as? ByteArraySchema,
|
||||
byteArraySchema.format == .base64url {
|
||||
keyValueType = .base64ByteArray
|
||||
} else {
|
||||
keyValueType = .byteArray
|
||||
}
|
||||
default:
|
||||
keyValueType = .default
|
||||
}
|
||||
|
@ -154,10 +161,9 @@ struct KeyValueViewModel: Comparable {
|
|||
/**
|
||||
Convert the type into String format in Swift
|
||||
*/
|
||||
private static func formatValueForType(type: AllSchemaTypes, value: String) -> String {
|
||||
private static func formatValue(forSignatureParameter signatureParameter: ParameterType, value: String) -> String {
|
||||
let type = signatureParameter.schema.type
|
||||
switch type {
|
||||
case .string:
|
||||
return "\(value)"
|
||||
case .integer,
|
||||
.number,
|
||||
.boolean:
|
||||
|
@ -172,7 +178,7 @@ struct KeyValueViewModel: Comparable {
|
|||
.sealedChoice:
|
||||
return "\(value).rawValue"
|
||||
case .array:
|
||||
return "\(value).map { String($0) }.joined(separator: \",\") "
|
||||
return "\(value).map { String($0) }.joined(separator: \"\(signatureParameter.delimiter)\") "
|
||||
default:
|
||||
return "\(value)"
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@ struct OperationParameters {
|
|||
.append(viewModel)
|
||||
case .path:
|
||||
path.append(viewModel)
|
||||
case .uri:
|
||||
path.append(viewModel)
|
||||
default:
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ enum RequestBodyType: String {
|
|||
|
||||
/// View Model for the method request creation.
|
||||
struct RequestViewModel {
|
||||
let uri: String?
|
||||
let path: String
|
||||
let method: String
|
||||
let bodyParam: BodyParamViewModel?
|
||||
|
@ -46,6 +47,7 @@ struct RequestViewModel {
|
|||
init(from request: Request, with operation: Operation) {
|
||||
// load HttpRequest properties
|
||||
let httpRequest = request.protocol.http as? HttpRequest
|
||||
self.uri = httpRequest?.uri
|
||||
self.path = httpRequest?.path ?? ""
|
||||
self.method = httpRequest?.method.rawValue ?? ""
|
||||
|
||||
|
|
|
@ -23,12 +23,16 @@ public final class {{ group.name }} {
|
|||
self.commonOptions = client.commonOptions
|
||||
}
|
||||
|
||||
public func url(forTemplate templateIn: String, withKwargs kwargs: [String: String]? = nil) -> URL? {
|
||||
return client.url(forTemplate: templateIn, withKwargs: kwargs)
|
||||
public func url(
|
||||
host hostIn: String? = nil,
|
||||
template templateIn: String,
|
||||
pathParams pathParamsIn: [String: String]? = nil,
|
||||
queryParams queryParamsIn: [QueryParameter]? = nil
|
||||
) -> URL? {
|
||||
return client.url(host: hostIn, template: templateIn, pathParams: pathParamsIn, queryParams: queryParamsIn)
|
||||
}
|
||||
|
||||
public func request(_ request: HTTPRequest, context: PipelineContext?, completionHandler: @escaping HTTPResultHandler<Data?>
|
||||
) {
|
||||
public func request(_ request: HTTPRequest, context: PipelineContext?, completionHandler: @escaping HTTPResultHandler<Data?>) {
|
||||
return client.request(request, context: context, completionHandler: completionHandler)
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
self.options.logger.error("Failed to construct String for {{ method.key }}")
|
||||
return
|
||||
}
|
||||
{% elif method.strategy == "base64ByteArray" %}
|
||||
let {{ method.key }}String = {{ method.key }}.base64URLEncodedString()
|
||||
{% else %}
|
||||
{# Do nothing #}
|
||||
{% endif %}
|
||||
|
|
|
@ -4,6 +4,8 @@ let {{ param.key }}String = DateFormatter().string(from: {{ param.key }})
|
|||
let {{ param.key }}String = Date.Format.iso8601.formatter.string(from: {{ param.key }})
|
||||
{% elif param.strategy == "byteArray" %}
|
||||
let {{ param.key }}String = String(bytes: {{ param.key }}, encoding: .utf8)
|
||||
{% elif param.strategy == "base64ByteArray" %}
|
||||
let {{ param.key }}String = {{ param.key }}.base64URLEncodedString()
|
||||
{% else %}
|
||||
{# No need to decode the parameter to String. Leave this blank #}
|
||||
{% endif %}
|
||||
|
|
|
@ -22,8 +22,8 @@ guard let requestBody = try? JSONEncoder().encode(body) else {
|
|||
return
|
||||
}
|
||||
{% endif %}
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to URL")
|
||||
guard let requestUrl = self.url(host: "{{ op.request.uri }}", template: urlTemplate, pathParams: pathParams, queryParams: queryParams) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ guard let patchBody = try? JSONEncoder().encode(patch) else {
|
|||
return
|
||||
}
|
||||
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to URL")
|
||||
guard let requestUrl = self.url(host: "{{ op.request.uri }}", template: urlTemplate, pathParams: pathParams, queryParams: queryParams) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = self.url(host: "{{ op.request.uri }}", template: urlTemplate, pathParams: pathParams, queryParams: queryParams) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,7 @@
|
|||
// Construct URL
|
||||
guard let urlTemplate = "{{ op.request.path }}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "{{ op.request.path }}"
|
||||
let pathParams = [
|
||||
{% for param in op.params.path %}
|
||||
"{{ param.key }}" : {{ param.path}}{{ param.value }},
|
||||
{% endfor %}
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
|
|
|
@ -16,3 +16,12 @@ extension Int64: LocalizedError {
|
|||
public var errorDescription: String? { return String(self) }
|
||||
}
|
||||
|
||||
extension Data {
|
||||
func base64URLEncodedString() -> String {
|
||||
let base64String = self.base64EncodedString()
|
||||
let base64UrlString = base64String.replacingOccurrences(of: "/", with: "_")
|
||||
.replacingOccurrences(of: "+", with: "-")
|
||||
.replacingOccurrences(of: "=", with: "")
|
||||
return base64UrlString
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,11 @@
|
|||
// swiftlint:disable function_body_length
|
||||
// swiftlint:disable type_body_length
|
||||
|
||||
extension CharacterSet {
|
||||
static let azureUrlQueryAllowed = urlQueryAllowed.subtracting(.init(charactersIn: "!*'();:@&=+$,/?"))
|
||||
static let azureUrlPathAllowed = urlPathAllowed.subtracting(.init(charactersIn: "!*'()@&=+$,/:"))
|
||||
}
|
||||
|
||||
{{ model.comment }}
|
||||
public final class {{ model.name }}: {{ model.protocols }} {
|
||||
|
||||
|
@ -79,6 +84,45 @@ public final class {{ model.name }}: {{ model.protocols }} {
|
|||
)
|
||||
}
|
||||
|
||||
public func url(host hostIn: String? = nil, template templateIn: String, pathParams pathParamsIn: [String: String]? = nil, queryParams queryParamsIn: [QueryParameter]? = nil) -> URL? {
|
||||
var template = templateIn
|
||||
var hostString = hostIn
|
||||
if template.hasPrefix("/") { template = String(template.dropFirst()) }
|
||||
|
||||
if let pathParams = pathParamsIn {
|
||||
for (key, value) in pathParams {
|
||||
if let encodedPathValue = value.addingPercentEncoding(withAllowedCharacters: .azureUrlPathAllowed) {
|
||||
template = template.replacingOccurrences(of: "{\(key)}", with: encodedPathValue)
|
||||
}
|
||||
if let host = hostString {
|
||||
hostString = host.replacingOccurrences(of: "{\(key)}", with: value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let hostUnwrapped = hostString,
|
||||
!hostUnwrapped.hasSuffix("/") {
|
||||
hostString = hostUnwrapped + "/"
|
||||
}
|
||||
let urlString = (hostString ?? self.baseUrl.absoluteString) + template
|
||||
guard let url = URL(string: urlString) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
guard !(queryParamsIn?.isEmpty ?? false) else { return url }
|
||||
|
||||
return appendingQueryParameters(url: url, queryParamsIn ?? [])
|
||||
}
|
||||
|
||||
private func appendingQueryParameters(url: URL, _ queryParams: [QueryParameter]) -> URL? {
|
||||
guard !queryParams.isEmpty else { return url }
|
||||
guard var urlComps = URLComponents(url: url, resolvingAgainstBaseURL: true) else { return nil }
|
||||
|
||||
let queryItems = queryParams.map { name, value in URLQueryItem(name: name, value: value?.addingPercentEncoding(withAllowedCharacters: .azureUrlQueryAllowed)) }
|
||||
urlComps.percentEncodedQueryItems = queryItems
|
||||
return urlComps.url
|
||||
}
|
||||
|
||||
{% for param in model.globalParameters %}
|
||||
// {{ param.comment }}
|
||||
public var {{ param.name }}: {{ param.type }}{{ param.defaultValue }}
|
||||
|
|
|
@ -16,6 +16,11 @@ import Foundation
|
|||
// swiftlint:disable function_body_length
|
||||
// swiftlint:disable type_body_length
|
||||
|
||||
extension CharacterSet {
|
||||
static let azureUrlQueryAllowed = urlQueryAllowed.subtracting(.init(charactersIn: "!*'();:@&=+$,/?"))
|
||||
static let azureUrlPathAllowed = urlPathAllowed.subtracting(.init(charactersIn: "!*'()@&=+$,/:"))
|
||||
}
|
||||
|
||||
public final class AutoRestSwaggerBatFileClient: PipelineClient {
|
||||
/// API version of the to invoke. Defaults to the latest.
|
||||
public enum ApiVersion: String {
|
||||
|
@ -65,6 +70,53 @@ public final class AutoRestSwaggerBatFileClient: PipelineClient {
|
|||
)
|
||||
}
|
||||
|
||||
public func url(
|
||||
host hostIn: String? = nil,
|
||||
template templateIn: String,
|
||||
pathParams pathParamsIn: [String: String]? = nil,
|
||||
queryParams queryParamsIn: [QueryParameter]? = nil
|
||||
) -> URL? {
|
||||
var template = templateIn
|
||||
var hostString = hostIn
|
||||
if template.hasPrefix("/") { template = String(template.dropFirst()) }
|
||||
|
||||
if let pathParams = pathParamsIn {
|
||||
for (key, value) in pathParams {
|
||||
if let encodedPathValue = value.addingPercentEncoding(withAllowedCharacters: .azureUrlPathAllowed) {
|
||||
template = template.replacingOccurrences(of: "{\(key)}", with: encodedPathValue)
|
||||
}
|
||||
if let host = hostString {
|
||||
hostString = host.replacingOccurrences(of: "{\(key)}", with: value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let hostUnwrapped = hostString,
|
||||
!hostUnwrapped.hasSuffix("/") {
|
||||
hostString = hostUnwrapped + "/"
|
||||
}
|
||||
let urlString = (hostString ?? baseUrl.absoluteString) + template
|
||||
guard let url = URL(string: urlString) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
guard !(queryParamsIn?.isEmpty ?? false) else { return url }
|
||||
|
||||
return appendingQueryParameters(url: url, queryParamsIn ?? [])
|
||||
}
|
||||
|
||||
private func appendingQueryParameters(url: URL, _ queryParams: [QueryParameter]) -> URL? {
|
||||
guard !queryParams.isEmpty else { return url }
|
||||
guard var urlComps = URLComponents(url: url, resolvingAgainstBaseURL: true) else { return nil }
|
||||
|
||||
let queryItems = queryParams.map { name, value in URLQueryItem(
|
||||
name: name,
|
||||
value: value?.addingPercentEncoding(withAllowedCharacters: .azureUrlQueryAllowed)
|
||||
) }
|
||||
urlComps.percentEncodedQueryItems = queryItems
|
||||
return urlComps.url
|
||||
}
|
||||
|
||||
public lazy var files: Files = Files(client: self)
|
||||
|
||||
// MARK: Public Client Methods
|
||||
|
|
|
@ -30,8 +30,13 @@ public final class Files {
|
|||
self.commonOptions = client.commonOptions
|
||||
}
|
||||
|
||||
public func url(forTemplate templateIn: String, withKwargs kwargs: [String: String]? = nil) -> URL? {
|
||||
return client.url(forTemplate: templateIn, withKwargs: kwargs)
|
||||
public func url(
|
||||
host hostIn: String? = nil,
|
||||
template templateIn: String,
|
||||
pathParams pathParamsIn: [String: String]? = nil,
|
||||
queryParams queryParamsIn: [QueryParameter]? = nil
|
||||
) -> URL? {
|
||||
return client.url(host: hostIn, template: templateIn, pathParams: pathParamsIn, queryParams: queryParamsIn)
|
||||
}
|
||||
|
||||
public func request(
|
||||
|
@ -53,17 +58,10 @@ public final class Files {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/files/stream/nonempty".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/files/stream/nonempty"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -72,8 +70,13 @@ public final class Files {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "image/png, application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -143,17 +146,10 @@ public final class Files {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/files/stream/verylarge".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/files/stream/verylarge"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -162,8 +158,13 @@ public final class Files {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "image/png, application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -233,17 +234,10 @@ public final class Files {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/files/stream/empty".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/files/stream/empty"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -252,8 +246,13 @@ public final class Files {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "image/png, application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -15,3 +15,13 @@ extension Int32: LocalizedError {
|
|||
extension Int64: LocalizedError {
|
||||
public var errorDescription: String? { return String(self) }
|
||||
}
|
||||
|
||||
extension Data {
|
||||
func base64URLEncodedString() -> String {
|
||||
let base64String = base64EncodedString()
|
||||
let base64UrlString = base64String.replacingOccurrences(of: "/", with: "_")
|
||||
.replacingOccurrences(of: "+", with: "-")
|
||||
.replacingOccurrences(of: "=", with: "")
|
||||
return base64UrlString
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,11 @@ import Foundation
|
|||
// swiftlint:disable function_body_length
|
||||
// swiftlint:disable type_body_length
|
||||
|
||||
extension CharacterSet {
|
||||
static let azureUrlQueryAllowed = urlQueryAllowed.subtracting(.init(charactersIn: "!*'();:@&=+$,/?"))
|
||||
static let azureUrlPathAllowed = urlPathAllowed.subtracting(.init(charactersIn: "!*'()@&=+$,/:"))
|
||||
}
|
||||
|
||||
public final class AutoRestIntegerTestClient: PipelineClient {
|
||||
/// API version of the to invoke. Defaults to the latest.
|
||||
public enum ApiVersion: String {
|
||||
|
@ -65,6 +70,53 @@ public final class AutoRestIntegerTestClient: PipelineClient {
|
|||
)
|
||||
}
|
||||
|
||||
public func url(
|
||||
host hostIn: String? = nil,
|
||||
template templateIn: String,
|
||||
pathParams pathParamsIn: [String: String]? = nil,
|
||||
queryParams queryParamsIn: [QueryParameter]? = nil
|
||||
) -> URL? {
|
||||
var template = templateIn
|
||||
var hostString = hostIn
|
||||
if template.hasPrefix("/") { template = String(template.dropFirst()) }
|
||||
|
||||
if let pathParams = pathParamsIn {
|
||||
for (key, value) in pathParams {
|
||||
if let encodedPathValue = value.addingPercentEncoding(withAllowedCharacters: .azureUrlPathAllowed) {
|
||||
template = template.replacingOccurrences(of: "{\(key)}", with: encodedPathValue)
|
||||
}
|
||||
if let host = hostString {
|
||||
hostString = host.replacingOccurrences(of: "{\(key)}", with: value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let hostUnwrapped = hostString,
|
||||
!hostUnwrapped.hasSuffix("/") {
|
||||
hostString = hostUnwrapped + "/"
|
||||
}
|
||||
let urlString = (hostString ?? baseUrl.absoluteString) + template
|
||||
guard let url = URL(string: urlString) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
guard !(queryParamsIn?.isEmpty ?? false) else { return url }
|
||||
|
||||
return appendingQueryParameters(url: url, queryParamsIn ?? [])
|
||||
}
|
||||
|
||||
private func appendingQueryParameters(url: URL, _ queryParams: [QueryParameter]) -> URL? {
|
||||
guard !queryParams.isEmpty else { return url }
|
||||
guard var urlComps = URLComponents(url: url, resolvingAgainstBaseURL: true) else { return nil }
|
||||
|
||||
let queryItems = queryParams.map { name, value in URLQueryItem(
|
||||
name: name,
|
||||
value: value?.addingPercentEncoding(withAllowedCharacters: .azureUrlQueryAllowed)
|
||||
) }
|
||||
urlComps.percentEncodedQueryItems = queryItems
|
||||
return urlComps.url
|
||||
}
|
||||
|
||||
public lazy var inttype: IntType = IntType(client: self)
|
||||
|
||||
// MARK: Public Client Methods
|
||||
|
|
|
@ -30,8 +30,13 @@ public final class IntType {
|
|||
self.commonOptions = client.commonOptions
|
||||
}
|
||||
|
||||
public func url(forTemplate templateIn: String, withKwargs kwargs: [String: String]? = nil) -> URL? {
|
||||
return client.url(forTemplate: templateIn, withKwargs: kwargs)
|
||||
public func url(
|
||||
host hostIn: String? = nil,
|
||||
template templateIn: String,
|
||||
pathParams pathParamsIn: [String: String]? = nil,
|
||||
queryParams queryParamsIn: [QueryParameter]? = nil
|
||||
) -> URL? {
|
||||
return client.url(host: hostIn, template: templateIn, pathParams: pathParamsIn, queryParams: queryParamsIn)
|
||||
}
|
||||
|
||||
public func request(
|
||||
|
@ -53,17 +58,10 @@ public final class IntType {
|
|||
completionHandler: @escaping HTTPResultHandler<Int32?>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/int/null".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/int/null"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -72,8 +70,13 @@ public final class IntType {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -154,17 +157,10 @@ public final class IntType {
|
|||
completionHandler: @escaping HTTPResultHandler<Int32>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/int/invalid".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/int/invalid"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -173,8 +169,13 @@ public final class IntType {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -248,17 +249,10 @@ public final class IntType {
|
|||
completionHandler: @escaping HTTPResultHandler<Int32>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/int/overflowint32".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/int/overflowint32"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -267,8 +261,13 @@ public final class IntType {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -342,17 +341,10 @@ public final class IntType {
|
|||
completionHandler: @escaping HTTPResultHandler<Int32>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/int/underflowint32".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/int/underflowint32"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -361,8 +353,13 @@ public final class IntType {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -436,17 +433,10 @@ public final class IntType {
|
|||
completionHandler: @escaping HTTPResultHandler<Int64>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/int/overflowint64".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/int/overflowint64"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -455,8 +445,13 @@ public final class IntType {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -530,17 +525,10 @@ public final class IntType {
|
|||
completionHandler: @escaping HTTPResultHandler<Int64>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/int/underflowint64".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/int/underflowint64"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -549,8 +537,13 @@ public final class IntType {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -625,17 +618,10 @@ public final class IntType {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/int/max/32".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/int/max/32"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -649,8 +635,13 @@ public final class IntType {
|
|||
self.options.logger.error("Failed to encode request body as json.")
|
||||
return
|
||||
}
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to URL")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -721,17 +712,10 @@ public final class IntType {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/int/max/64".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/int/max/64"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -745,8 +729,13 @@ public final class IntType {
|
|||
self.options.logger.error("Failed to encode request body as json.")
|
||||
return
|
||||
}
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to URL")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -817,17 +806,10 @@ public final class IntType {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/int/min/32".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/int/min/32"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -841,8 +823,13 @@ public final class IntType {
|
|||
self.options.logger.error("Failed to encode request body as json.")
|
||||
return
|
||||
}
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to URL")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -913,17 +900,10 @@ public final class IntType {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/int/min/64".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/int/min/64"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -937,8 +917,13 @@ public final class IntType {
|
|||
self.options.logger.error("Failed to encode request body as json.")
|
||||
return
|
||||
}
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to URL")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1008,17 +993,10 @@ public final class IntType {
|
|||
completionHandler: @escaping HTTPResultHandler<Date>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/int/unixtime".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/int/unixtime"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -1027,8 +1005,13 @@ public final class IntType {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1104,17 +1087,10 @@ public final class IntType {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/int/unixtime".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/int/unixtime"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -1130,8 +1106,13 @@ public final class IntType {
|
|||
self.options.logger.error("Failed to encode request body in unixTime.")
|
||||
return
|
||||
}
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to URL")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1201,17 +1182,10 @@ public final class IntType {
|
|||
completionHandler: @escaping HTTPResultHandler<Date>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/int/invalidunixtime".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/int/invalidunixtime"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -1220,8 +1194,13 @@ public final class IntType {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1296,17 +1275,10 @@ public final class IntType {
|
|||
completionHandler: @escaping HTTPResultHandler<Date?>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/int/nullunixtime".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/int/nullunixtime"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -1315,8 +1287,13 @@ public final class IntType {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -15,3 +15,13 @@ extension Int32: LocalizedError {
|
|||
extension Int64: LocalizedError {
|
||||
public var errorDescription: String? { return String(self) }
|
||||
}
|
||||
|
||||
extension Data {
|
||||
func base64URLEncodedString() -> String {
|
||||
let base64String = base64EncodedString()
|
||||
let base64UrlString = base64String.replacingOccurrences(of: "/", with: "_")
|
||||
.replacingOccurrences(of: "+", with: "-")
|
||||
.replacingOccurrences(of: "=", with: "")
|
||||
return base64UrlString
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,502 @@
|
|||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
OBJ_90 /* AutoRestParameterizedHostTestClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_8 /* AutoRestParameterizedHostTestClient.swift */; };
|
||||
OBJ_91 /* ErrorType.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_10 /* ErrorType.swift */; };
|
||||
OBJ_92 /* AutoRestParameterizedHostTestClientOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_12 /* AutoRestParameterizedHostTestClientOptions.swift */; };
|
||||
OBJ_93 /* Paths+GetEmptyOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_13 /* Paths+GetEmptyOptions.swift */; };
|
||||
OBJ_94 /* Paths.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_14 /* Paths.swift */; };
|
||||
OBJ_95 /* PatchUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_16 /* PatchUtil.swift */; };
|
||||
OBJ_96 /* Primitives+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_17 /* Primitives+Extension.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
"AutoRestParameterizedHostTest::AutoRestParameterizedHostTest::Product" /* AutoRestParameterizedHostTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = AutoRestParameterizedHostTest.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
OBJ_10 /* ErrorType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorType.swift; sourceTree = "<group>"; };
|
||||
OBJ_12 /* AutoRestParameterizedHostTestClientOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoRestParameterizedHostTestClientOptions.swift; sourceTree = "<group>"; };
|
||||
OBJ_13 /* Paths+GetEmptyOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Paths+GetEmptyOptions.swift"; sourceTree = "<group>"; };
|
||||
OBJ_14 /* Paths.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Paths.swift; sourceTree = "<group>"; };
|
||||
OBJ_16 /* PatchUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PatchUtil.swift; sourceTree = "<group>"; };
|
||||
OBJ_17 /* Primitives+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Primitives+Extension.swift"; sourceTree = "<group>"; };
|
||||
OBJ_25 /* AzureTask.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AzureTask.swift; sourceTree = "<group>"; };
|
||||
OBJ_26 /* ClientLogger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientLogger.swift; sourceTree = "<group>"; };
|
||||
OBJ_28 /* CancellationToken.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CancellationToken.swift; sourceTree = "<group>"; };
|
||||
OBJ_29 /* Collections.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Collections.swift; sourceTree = "<group>"; };
|
||||
OBJ_30 /* MatchCondition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatchCondition.swift; sourceTree = "<group>"; };
|
||||
OBJ_31 /* XMLMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XMLMap.swift; sourceTree = "<group>"; };
|
||||
OBJ_32 /* XMLModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XMLModel.swift; sourceTree = "<group>"; };
|
||||
OBJ_33 /* XMLTree.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XMLTree.swift; sourceTree = "<group>"; };
|
||||
OBJ_34 /* Errors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Errors.swift; sourceTree = "<group>"; };
|
||||
OBJ_36 /* Pipeline.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Pipeline.swift; sourceTree = "<group>"; };
|
||||
OBJ_37 /* PipelineClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PipelineClient.swift; sourceTree = "<group>"; };
|
||||
OBJ_38 /* PipelineContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PipelineContext.swift; sourceTree = "<group>"; };
|
||||
OBJ_39 /* PipelineRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PipelineRequest.swift; sourceTree = "<group>"; };
|
||||
OBJ_40 /* PipelineResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PipelineResponse.swift; sourceTree = "<group>"; };
|
||||
OBJ_41 /* PipelineStage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PipelineStage.swift; sourceTree = "<group>"; };
|
||||
OBJ_43 /* AddDatePolicy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddDatePolicy.swift; sourceTree = "<group>"; };
|
||||
OBJ_44 /* AuthenticationPolicy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationPolicy.swift; sourceTree = "<group>"; };
|
||||
OBJ_45 /* ContentDecodePolicy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentDecodePolicy.swift; sourceTree = "<group>"; };
|
||||
OBJ_46 /* HeadersPolicy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersPolicy.swift; sourceTree = "<group>"; };
|
||||
OBJ_47 /* HeadersValidationPolicy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersValidationPolicy.swift; sourceTree = "<group>"; };
|
||||
OBJ_48 /* LoggingPolicy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggingPolicy.swift; sourceTree = "<group>"; };
|
||||
OBJ_49 /* NormalizeETagPolicy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NormalizeETagPolicy.swift; sourceTree = "<group>"; };
|
||||
OBJ_50 /* RequestIdPolicy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestIdPolicy.swift; sourceTree = "<group>"; };
|
||||
OBJ_51 /* UserAgentPolicy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserAgentPolicy.swift; sourceTree = "<group>"; };
|
||||
OBJ_53 /* DataStringConvertible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataStringConvertible.swift; sourceTree = "<group>"; };
|
||||
OBJ_54 /* HTTPHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HTTPHeader.swift; sourceTree = "<group>"; };
|
||||
OBJ_55 /* HTTPMethod.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HTTPMethod.swift; sourceTree = "<group>"; };
|
||||
OBJ_56 /* HTTPRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HTTPRequest.swift; sourceTree = "<group>"; };
|
||||
OBJ_57 /* HTTPResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HTTPResponse.swift; sourceTree = "<group>"; };
|
||||
OBJ_58 /* HTTPTransportStage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HTTPTransportStage.swift; sourceTree = "<group>"; };
|
||||
OBJ_59 /* TelemetryOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TelemetryOptions.swift; sourceTree = "<group>"; };
|
||||
OBJ_6 /* Package.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; path = Package.swift; sourceTree = "<group>"; };
|
||||
OBJ_60 /* TransportOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransportOptions.swift; sourceTree = "<group>"; };
|
||||
OBJ_61 /* URLHTTPResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLHTTPResponse.swift; sourceTree = "<group>"; };
|
||||
OBJ_62 /* URLSessionTransport.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLSessionTransport.swift; sourceTree = "<group>"; };
|
||||
OBJ_64 /* BundleInfoProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BundleInfoProvider.swift; sourceTree = "<group>"; };
|
||||
OBJ_65 /* DeviceProviders.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceProviders.swift; sourceTree = "<group>"; };
|
||||
OBJ_66 /* LocaleInfoProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocaleInfoProvider.swift; sourceTree = "<group>"; };
|
||||
OBJ_67 /* PlatformInfoProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlatformInfoProvider.swift; sourceTree = "<group>"; };
|
||||
OBJ_69 /* ApplicationUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationUtil.swift; sourceTree = "<group>"; };
|
||||
OBJ_70 /* AzureCodable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AzureCodable.swift; sourceTree = "<group>"; };
|
||||
OBJ_71 /* ConvertingInitializers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConvertingInitializers.swift; sourceTree = "<group>"; };
|
||||
OBJ_72 /* Copyable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Copyable.swift; sourceTree = "<group>"; };
|
||||
OBJ_73 /* CryptoUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptoUtil.swift; sourceTree = "<group>"; };
|
||||
OBJ_74 /* KeychainUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainUtil.swift; sourceTree = "<group>"; };
|
||||
OBJ_75 /* ReachabilityManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReachabilityManager.swift; sourceTree = "<group>"; };
|
||||
OBJ_76 /* ReachabilityManagerType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReachabilityManagerType.swift; sourceTree = "<group>"; };
|
||||
OBJ_77 /* RegexUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegexUtil.swift; sourceTree = "<group>"; };
|
||||
OBJ_78 /* StringUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringUtil.swift; sourceTree = "<group>"; };
|
||||
OBJ_79 /* URLUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLUtil.swift; sourceTree = "<group>"; };
|
||||
OBJ_8 /* AutoRestParameterizedHostTestClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoRestParameterizedHostTestClient.swift; sourceTree = "<group>"; };
|
||||
OBJ_80 /* Package.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; name = Package.swift; path = "/Users/sacheu/Documents/GitHub/autorest.swift/test/integration/generated/custom-baseUrl/.build/checkouts/azure-sdk-for-ios/Package.swift"; sourceTree = "<group>"; };
|
||||
OBJ_84 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
OBJ_97 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 0;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
OBJ_11 /* Options */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
OBJ_12 /* AutoRestParameterizedHostTestClientOptions.swift */,
|
||||
OBJ_13 /* Paths+GetEmptyOptions.swift */,
|
||||
);
|
||||
path = Options;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
OBJ_15 /* Util */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
OBJ_16 /* PatchUtil.swift */,
|
||||
OBJ_17 /* Primitives+Extension.swift */,
|
||||
);
|
||||
path = Util;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
OBJ_18 /* Tests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
);
|
||||
name = Tests;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
OBJ_19 /* Dependencies */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
OBJ_20 /* AzureSDK */,
|
||||
);
|
||||
name = Dependencies;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
OBJ_20 /* AzureSDK */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
OBJ_21 /* AzureCommunication */,
|
||||
OBJ_22 /* AzureCommunicationChat */,
|
||||
OBJ_23 /* AzureCore */,
|
||||
OBJ_80 /* Package.swift */,
|
||||
);
|
||||
name = AzureSDK;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
OBJ_21 /* AzureCommunication */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
);
|
||||
name = AzureCommunication;
|
||||
path = ".build/checkouts/azure-sdk-for-ios/sdk/communication/AzureCommunication";
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
OBJ_22 /* AzureCommunicationChat */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
);
|
||||
name = AzureCommunicationChat;
|
||||
path = ".build/checkouts/azure-sdk-for-ios/sdk/communication/AzureCommunicationChat";
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
OBJ_23 /* AzureCore */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
OBJ_24 /* Source */,
|
||||
);
|
||||
name = AzureCore;
|
||||
path = ".build/checkouts/azure-sdk-for-ios/sdk/core/AzureCore";
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
OBJ_24 /* Source */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
OBJ_25 /* AzureTask.swift */,
|
||||
OBJ_26 /* ClientLogger.swift */,
|
||||
OBJ_27 /* DataStructures */,
|
||||
OBJ_34 /* Errors.swift */,
|
||||
OBJ_35 /* Pipeline */,
|
||||
OBJ_63 /* Providers */,
|
||||
OBJ_68 /* Util */,
|
||||
);
|
||||
path = Source;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
OBJ_27 /* DataStructures */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
OBJ_28 /* CancellationToken.swift */,
|
||||
OBJ_29 /* Collections.swift */,
|
||||
OBJ_30 /* MatchCondition.swift */,
|
||||
OBJ_31 /* XMLMap.swift */,
|
||||
OBJ_32 /* XMLModel.swift */,
|
||||
OBJ_33 /* XMLTree.swift */,
|
||||
);
|
||||
path = DataStructures;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
OBJ_35 /* Pipeline */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
OBJ_36 /* Pipeline.swift */,
|
||||
OBJ_37 /* PipelineClient.swift */,
|
||||
OBJ_38 /* PipelineContext.swift */,
|
||||
OBJ_39 /* PipelineRequest.swift */,
|
||||
OBJ_40 /* PipelineResponse.swift */,
|
||||
OBJ_41 /* PipelineStage.swift */,
|
||||
OBJ_42 /* Policies */,
|
||||
OBJ_52 /* Transport */,
|
||||
);
|
||||
path = Pipeline;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
OBJ_42 /* Policies */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
OBJ_43 /* AddDatePolicy.swift */,
|
||||
OBJ_44 /* AuthenticationPolicy.swift */,
|
||||
OBJ_45 /* ContentDecodePolicy.swift */,
|
||||
OBJ_46 /* HeadersPolicy.swift */,
|
||||
OBJ_47 /* HeadersValidationPolicy.swift */,
|
||||
OBJ_48 /* LoggingPolicy.swift */,
|
||||
OBJ_49 /* NormalizeETagPolicy.swift */,
|
||||
OBJ_50 /* RequestIdPolicy.swift */,
|
||||
OBJ_51 /* UserAgentPolicy.swift */,
|
||||
);
|
||||
path = Policies;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
OBJ_5 /* */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
OBJ_6 /* Package.swift */,
|
||||
OBJ_7 /* Sources */,
|
||||
OBJ_18 /* Tests */,
|
||||
OBJ_19 /* Dependencies */,
|
||||
OBJ_81 /* Products */,
|
||||
OBJ_84 /* README.md */,
|
||||
);
|
||||
name = "";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
OBJ_52 /* Transport */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
OBJ_53 /* DataStringConvertible.swift */,
|
||||
OBJ_54 /* HTTPHeader.swift */,
|
||||
OBJ_55 /* HTTPMethod.swift */,
|
||||
OBJ_56 /* HTTPRequest.swift */,
|
||||
OBJ_57 /* HTTPResponse.swift */,
|
||||
OBJ_58 /* HTTPTransportStage.swift */,
|
||||
OBJ_59 /* TelemetryOptions.swift */,
|
||||
OBJ_60 /* TransportOptions.swift */,
|
||||
OBJ_61 /* URLHTTPResponse.swift */,
|
||||
OBJ_62 /* URLSessionTransport.swift */,
|
||||
);
|
||||
path = Transport;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
OBJ_63 /* Providers */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
OBJ_64 /* BundleInfoProvider.swift */,
|
||||
OBJ_65 /* DeviceProviders.swift */,
|
||||
OBJ_66 /* LocaleInfoProvider.swift */,
|
||||
OBJ_67 /* PlatformInfoProvider.swift */,
|
||||
);
|
||||
path = Providers;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
OBJ_68 /* Util */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
OBJ_69 /* ApplicationUtil.swift */,
|
||||
OBJ_70 /* AzureCodable.swift */,
|
||||
OBJ_71 /* ConvertingInitializers.swift */,
|
||||
OBJ_72 /* Copyable.swift */,
|
||||
OBJ_73 /* CryptoUtil.swift */,
|
||||
OBJ_74 /* KeychainUtil.swift */,
|
||||
OBJ_75 /* ReachabilityManager.swift */,
|
||||
OBJ_76 /* ReachabilityManagerType.swift */,
|
||||
OBJ_77 /* RegexUtil.swift */,
|
||||
OBJ_78 /* StringUtil.swift */,
|
||||
OBJ_79 /* URLUtil.swift */,
|
||||
);
|
||||
path = Util;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
OBJ_7 /* Sources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
OBJ_8 /* AutoRestParameterizedHostTestClient.swift */,
|
||||
OBJ_9 /* Models */,
|
||||
OBJ_11 /* Options */,
|
||||
OBJ_14 /* Paths.swift */,
|
||||
OBJ_15 /* Util */,
|
||||
);
|
||||
name = Sources;
|
||||
path = Source;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
OBJ_81 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
"AutoRestParameterizedHostTest::AutoRestParameterizedHostTest::Product" /* AutoRestParameterizedHostTest.framework */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
OBJ_9 /* Models */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
OBJ_10 /* ErrorType.swift */,
|
||||
);
|
||||
path = Models;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
"AutoRestParameterizedHostTest::AutoRestParameterizedHostTest" /* AutoRestParameterizedHostTest */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = OBJ_86 /* Build configuration list for PBXNativeTarget "AutoRestParameterizedHostTest" */;
|
||||
buildPhases = (
|
||||
OBJ_89 /* Sources */,
|
||||
OBJ_97 /* Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = AutoRestParameterizedHostTest;
|
||||
productName = AutoRestParameterizedHostTest;
|
||||
productReference = "AutoRestParameterizedHostTest::AutoRestParameterizedHostTest::Product" /* AutoRestParameterizedHostTest.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
OBJ_1 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftMigration = 9999;
|
||||
LastUpgradeCheck = 9999;
|
||||
};
|
||||
buildConfigurationList = OBJ_2 /* Build configuration list for PBXProject "AutoRestParameterizedHostTest" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = OBJ_5 /* */;
|
||||
productRefGroup = OBJ_81 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
"AutoRestParameterizedHostTest::AutoRestParameterizedHostTest" /* AutoRestParameterizedHostTest */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
OBJ_89 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 0;
|
||||
files = (
|
||||
OBJ_90 /* AutoRestParameterizedHostTestClient.swift in Sources */,
|
||||
OBJ_91 /* ErrorType.swift in Sources */,
|
||||
OBJ_92 /* AutoRestParameterizedHostTestClientOptions.swift in Sources */,
|
||||
OBJ_93 /* Paths+GetEmptyOptions.swift in Sources */,
|
||||
OBJ_94 /* Paths.swift in Sources */,
|
||||
OBJ_95 /* PatchUtil.swift in Sources */,
|
||||
OBJ_96 /* Primitives+Extension.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
OBJ_3 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_NS_ASSERTIONS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
"SWIFT_PACKAGE=1",
|
||||
"DEBUG=1",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) -DXcode";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator";
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) SWIFT_PACKAGE DEBUG";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
USE_HEADERMAP = NO;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
OBJ_4 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
GCC_OPTIMIZATION_LEVEL = s;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
"SWIFT_PACKAGE=1",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) -DXcode";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator";
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) SWIFT_PACKAGE";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
USE_HEADERMAP = NO;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
OBJ_87 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ENABLE_TESTABILITY = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PLATFORM_DIR)/Developer/Library/Frameworks",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = "$(inherited)";
|
||||
INFOPLIST_FILE = AutoRestParameterizedHostTest.xcodeproj/AutoRestParameterizedHostTest_Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) $(TOOLCHAIN_DIR)/usr/lib/swift/macosx";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.15;
|
||||
OTHER_CFLAGS = "$(inherited)";
|
||||
OTHER_LDFLAGS = "$(inherited)";
|
||||
OTHER_SWIFT_FLAGS = "$(inherited)";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = AutoRestParameterizedHostTest;
|
||||
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGET_NAME = AutoRestParameterizedHostTest;
|
||||
TVOS_DEPLOYMENT_TARGET = 12.0;
|
||||
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
OBJ_88 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ENABLE_TESTABILITY = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PLATFORM_DIR)/Developer/Library/Frameworks",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = "$(inherited)";
|
||||
INFOPLIST_FILE = AutoRestParameterizedHostTest.xcodeproj/AutoRestParameterizedHostTest_Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) $(TOOLCHAIN_DIR)/usr/lib/swift/macosx";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.15;
|
||||
OTHER_CFLAGS = "$(inherited)";
|
||||
OTHER_LDFLAGS = "$(inherited)";
|
||||
OTHER_SWIFT_FLAGS = "$(inherited)";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = AutoRestParameterizedHostTest;
|
||||
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGET_NAME = AutoRestParameterizedHostTest;
|
||||
TVOS_DEPLOYMENT_TARGET = 12.0;
|
||||
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
OBJ_2 /* Build configuration list for PBXProject "AutoRestParameterizedHostTest" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
OBJ_3 /* Debug */,
|
||||
OBJ_4 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
OBJ_86 /* Build configuration list for PBXNativeTarget "AutoRestParameterizedHostTest" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
OBJ_87 /* Debug */,
|
||||
OBJ_88 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = OBJ_1 /* Project object */;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,58 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "9999"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "AutoRestParameterizedHostTest::AutoRestParameterizedHostTest"
|
||||
BuildableName = "AutoRestParameterizedHostTest.framework"
|
||||
BlueprintName = "AutoRestParameterizedHostTest"
|
||||
ReferencedContainer = "container:AutoRestParameterizedHostTest.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
|
@ -16,6 +16,11 @@ import Foundation
|
|||
// swiftlint:disable function_body_length
|
||||
// swiftlint:disable type_body_length
|
||||
|
||||
extension CharacterSet {
|
||||
static let azureUrlQueryAllowed = urlQueryAllowed.subtracting(.init(charactersIn: "!*'();:@&=+$,/?"))
|
||||
static let azureUrlPathAllowed = urlPathAllowed.subtracting(.init(charactersIn: "!*'()@&=+$,/:"))
|
||||
}
|
||||
|
||||
public final class AutoRestParameterizedHostTestClient: PipelineClient {
|
||||
/// API version of the to invoke. Defaults to the latest.
|
||||
public enum ApiVersion: String {
|
||||
|
@ -66,6 +71,53 @@ public final class AutoRestParameterizedHostTestClient: PipelineClient {
|
|||
)
|
||||
}
|
||||
|
||||
public func url(
|
||||
host hostIn: String? = nil,
|
||||
template templateIn: String,
|
||||
pathParams pathParamsIn: [String: String]? = nil,
|
||||
queryParams queryParamsIn: [QueryParameter]? = nil
|
||||
) -> URL? {
|
||||
var template = templateIn
|
||||
var hostString = hostIn
|
||||
if template.hasPrefix("/") { template = String(template.dropFirst()) }
|
||||
|
||||
if let pathParams = pathParamsIn {
|
||||
for (key, value) in pathParams {
|
||||
if let encodedPathValue = value.addingPercentEncoding(withAllowedCharacters: .azureUrlPathAllowed) {
|
||||
template = template.replacingOccurrences(of: "{\(key)}", with: encodedPathValue)
|
||||
}
|
||||
if let host = hostString {
|
||||
hostString = host.replacingOccurrences(of: "{\(key)}", with: value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let hostUnwrapped = hostString,
|
||||
!hostUnwrapped.hasSuffix("/") {
|
||||
hostString = hostUnwrapped + "/"
|
||||
}
|
||||
let urlString = (hostString ?? baseUrl.absoluteString) + template
|
||||
guard let url = URL(string: urlString) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
guard !(queryParamsIn?.isEmpty ?? false) else { return url }
|
||||
|
||||
return appendingQueryParameters(url: url, queryParamsIn ?? [])
|
||||
}
|
||||
|
||||
private func appendingQueryParameters(url: URL, _ queryParams: [QueryParameter]) -> URL? {
|
||||
guard !queryParams.isEmpty else { return url }
|
||||
guard var urlComps = URLComponents(url: url, resolvingAgainstBaseURL: true) else { return nil }
|
||||
|
||||
let queryItems = queryParams.map { name, value in URLQueryItem(
|
||||
name: name,
|
||||
value: value?.addingPercentEncoding(withAllowedCharacters: .azureUrlQueryAllowed)
|
||||
) }
|
||||
urlComps.percentEncodedQueryItems = queryItems
|
||||
return urlComps.url
|
||||
}
|
||||
|
||||
// /// A string value that is used as a global part of the parameterized host
|
||||
public var host: String = "host"
|
||||
|
||||
|
|
|
@ -30,8 +30,13 @@ public final class Paths {
|
|||
self.commonOptions = client.commonOptions
|
||||
}
|
||||
|
||||
public func url(forTemplate templateIn: String, withKwargs kwargs: [String: String]? = nil) -> URL? {
|
||||
return client.url(forTemplate: templateIn, withKwargs: kwargs)
|
||||
public func url(
|
||||
host hostIn: String? = nil,
|
||||
template templateIn: String,
|
||||
pathParams pathParamsIn: [String: String]? = nil,
|
||||
queryParams queryParamsIn: [QueryParameter]? = nil
|
||||
) -> URL? {
|
||||
return client.url(host: hostIn, template: templateIn, pathParams: pathParamsIn, queryParams: queryParamsIn)
|
||||
}
|
||||
|
||||
public func request(
|
||||
|
@ -49,22 +54,16 @@ public final class Paths {
|
|||
/// - completionHandler: A completion handler that receives a status code on
|
||||
/// success.
|
||||
public func getEmpty(
|
||||
accountName _: String,
|
||||
accountName: String,
|
||||
withOptions options: GetEmptyOptions? = nil,
|
||||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/customuri".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/customuri"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"accountName": accountName,
|
||||
"host": client.host
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -73,8 +72,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "http://{accountName}{host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -15,3 +15,13 @@ extension Int32: LocalizedError {
|
|||
extension Int64: LocalizedError {
|
||||
public var errorDescription: String? { return String(self) }
|
||||
}
|
||||
|
||||
extension Data {
|
||||
func base64URLEncodedString() -> String {
|
||||
let base64String = base64EncodedString()
|
||||
let base64UrlString = base64String.replacingOccurrences(of: "/", with: "_")
|
||||
.replacingOccurrences(of: "+", with: "-")
|
||||
.replacingOccurrences(of: "=", with: "")
|
||||
return base64UrlString
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,11 @@ import Foundation
|
|||
// swiftlint:disable function_body_length
|
||||
// swiftlint:disable type_body_length
|
||||
|
||||
extension CharacterSet {
|
||||
static let azureUrlQueryAllowed = urlQueryAllowed.subtracting(.init(charactersIn: "!*'();:@&=+$,/?"))
|
||||
static let azureUrlPathAllowed = urlPathAllowed.subtracting(.init(charactersIn: "!*'()@&=+$,/:"))
|
||||
}
|
||||
|
||||
public final class AutoRestHeadTestClient: PipelineClient {
|
||||
/// API version of the to invoke. Defaults to the latest.
|
||||
public enum ApiVersion: String {
|
||||
|
@ -65,6 +70,53 @@ public final class AutoRestHeadTestClient: PipelineClient {
|
|||
)
|
||||
}
|
||||
|
||||
public func url(
|
||||
host hostIn: String? = nil,
|
||||
template templateIn: String,
|
||||
pathParams pathParamsIn: [String: String]? = nil,
|
||||
queryParams queryParamsIn: [QueryParameter]? = nil
|
||||
) -> URL? {
|
||||
var template = templateIn
|
||||
var hostString = hostIn
|
||||
if template.hasPrefix("/") { template = String(template.dropFirst()) }
|
||||
|
||||
if let pathParams = pathParamsIn {
|
||||
for (key, value) in pathParams {
|
||||
if let encodedPathValue = value.addingPercentEncoding(withAllowedCharacters: .azureUrlPathAllowed) {
|
||||
template = template.replacingOccurrences(of: "{\(key)}", with: encodedPathValue)
|
||||
}
|
||||
if let host = hostString {
|
||||
hostString = host.replacingOccurrences(of: "{\(key)}", with: value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let hostUnwrapped = hostString,
|
||||
!hostUnwrapped.hasSuffix("/") {
|
||||
hostString = hostUnwrapped + "/"
|
||||
}
|
||||
let urlString = (hostString ?? baseUrl.absoluteString) + template
|
||||
guard let url = URL(string: urlString) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
guard !(queryParamsIn?.isEmpty ?? false) else { return url }
|
||||
|
||||
return appendingQueryParameters(url: url, queryParamsIn ?? [])
|
||||
}
|
||||
|
||||
private func appendingQueryParameters(url: URL, _ queryParams: [QueryParameter]) -> URL? {
|
||||
guard !queryParams.isEmpty else { return url }
|
||||
guard var urlComps = URLComponents(url: url, resolvingAgainstBaseURL: true) else { return nil }
|
||||
|
||||
let queryItems = queryParams.map { name, value in URLQueryItem(
|
||||
name: name,
|
||||
value: value?.addingPercentEncoding(withAllowedCharacters: .azureUrlQueryAllowed)
|
||||
) }
|
||||
urlComps.percentEncodedQueryItems = queryItems
|
||||
return urlComps.url
|
||||
}
|
||||
|
||||
public lazy var httpsuccess: HttpSuccess = HttpSuccess(client: self)
|
||||
|
||||
// MARK: Public Client Methods
|
||||
|
|
|
@ -30,8 +30,13 @@ public final class HttpSuccess {
|
|||
self.commonOptions = client.commonOptions
|
||||
}
|
||||
|
||||
public func url(forTemplate templateIn: String, withKwargs kwargs: [String: String]? = nil) -> URL? {
|
||||
return client.url(forTemplate: templateIn, withKwargs: kwargs)
|
||||
public func url(
|
||||
host hostIn: String? = nil,
|
||||
template templateIn: String,
|
||||
pathParams pathParamsIn: [String: String]? = nil,
|
||||
queryParams queryParamsIn: [QueryParameter]? = nil
|
||||
) -> URL? {
|
||||
return client.url(host: hostIn, template: templateIn, pathParams: pathParamsIn, queryParams: queryParamsIn)
|
||||
}
|
||||
|
||||
public func request(
|
||||
|
@ -53,17 +58,10 @@ public final class HttpSuccess {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/http/success/200".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/http/success/200"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -71,8 +69,13 @@ public final class HttpSuccess {
|
|||
// Construct headers
|
||||
let headers = HTTPHeaders()
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -137,17 +140,10 @@ public final class HttpSuccess {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/http/success/204".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/http/success/204"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -155,8 +151,13 @@ public final class HttpSuccess {
|
|||
// Construct headers
|
||||
let headers = HTTPHeaders()
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -221,17 +222,10 @@ public final class HttpSuccess {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/http/success/404".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/http/success/404"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -239,8 +233,13 @@ public final class HttpSuccess {
|
|||
// Construct headers
|
||||
let headers = HTTPHeaders()
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -15,3 +15,13 @@ extension Int32: LocalizedError {
|
|||
extension Int64: LocalizedError {
|
||||
public var errorDescription: String? { return String(self) }
|
||||
}
|
||||
|
||||
extension Data {
|
||||
func base64URLEncodedString() -> String {
|
||||
let base64String = base64EncodedString()
|
||||
let base64UrlString = base64String.replacingOccurrences(of: "/", with: "_")
|
||||
.replacingOccurrences(of: "+", with: "-")
|
||||
.replacingOccurrences(of: "=", with: "")
|
||||
return base64UrlString
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,11 @@ import Foundation
|
|||
// swiftlint:disable function_body_length
|
||||
// swiftlint:disable type_body_length
|
||||
|
||||
extension CharacterSet {
|
||||
static let azureUrlQueryAllowed = urlQueryAllowed.subtracting(.init(charactersIn: "!*'();:@&=+$,/?"))
|
||||
static let azureUrlPathAllowed = urlPathAllowed.subtracting(.init(charactersIn: "!*'()@&=+$,/:"))
|
||||
}
|
||||
|
||||
public final class AutoRestResourceFlatteningTestClient: PipelineClient {
|
||||
/// API version of the to invoke. Defaults to the latest.
|
||||
public enum ApiVersion: String {
|
||||
|
@ -68,6 +73,53 @@ public final class AutoRestResourceFlatteningTestClient: PipelineClient {
|
|||
)
|
||||
}
|
||||
|
||||
public func url(
|
||||
host hostIn: String? = nil,
|
||||
template templateIn: String,
|
||||
pathParams pathParamsIn: [String: String]? = nil,
|
||||
queryParams queryParamsIn: [QueryParameter]? = nil
|
||||
) -> URL? {
|
||||
var template = templateIn
|
||||
var hostString = hostIn
|
||||
if template.hasPrefix("/") { template = String(template.dropFirst()) }
|
||||
|
||||
if let pathParams = pathParamsIn {
|
||||
for (key, value) in pathParams {
|
||||
if let encodedPathValue = value.addingPercentEncoding(withAllowedCharacters: .azureUrlPathAllowed) {
|
||||
template = template.replacingOccurrences(of: "{\(key)}", with: encodedPathValue)
|
||||
}
|
||||
if let host = hostString {
|
||||
hostString = host.replacingOccurrences(of: "{\(key)}", with: value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let hostUnwrapped = hostString,
|
||||
!hostUnwrapped.hasSuffix("/") {
|
||||
hostString = hostUnwrapped + "/"
|
||||
}
|
||||
let urlString = (hostString ?? baseUrl.absoluteString) + template
|
||||
guard let url = URL(string: urlString) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
guard !(queryParamsIn?.isEmpty ?? false) else { return url }
|
||||
|
||||
return appendingQueryParameters(url: url, queryParamsIn ?? [])
|
||||
}
|
||||
|
||||
private func appendingQueryParameters(url: URL, _ queryParams: [QueryParameter]) -> URL? {
|
||||
guard !queryParams.isEmpty else { return url }
|
||||
guard var urlComps = URLComponents(url: url, resolvingAgainstBaseURL: true) else { return nil }
|
||||
|
||||
let queryItems = queryParams.map { name, value in URLQueryItem(
|
||||
name: name,
|
||||
value: value?.addingPercentEncoding(withAllowedCharacters: .azureUrlQueryAllowed)
|
||||
) }
|
||||
urlComps.percentEncodedQueryItems = queryItems
|
||||
return urlComps.url
|
||||
}
|
||||
|
||||
public lazy var autorestresourceflatteningtestservice: AutoRestResourceFlatteningTestService =
|
||||
AutoRestResourceFlatteningTestService(client: self)
|
||||
|
||||
|
|
|
@ -30,8 +30,13 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
self.commonOptions = client.commonOptions
|
||||
}
|
||||
|
||||
public func url(forTemplate templateIn: String, withKwargs kwargs: [String: String]? = nil) -> URL? {
|
||||
return client.url(forTemplate: templateIn, withKwargs: kwargs)
|
||||
public func url(
|
||||
host hostIn: String? = nil,
|
||||
template templateIn: String,
|
||||
pathParams pathParamsIn: [String: String]? = nil,
|
||||
queryParams queryParamsIn: [QueryParameter]? = nil
|
||||
) -> URL? {
|
||||
return client.url(host: hostIn, template: templateIn, pathParams: pathParamsIn, queryParams: queryParamsIn)
|
||||
}
|
||||
|
||||
public func request(
|
||||
|
@ -54,17 +59,10 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/model-flatten/array".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/model-flatten/array"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -78,8 +76,13 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
self.options.logger.error("Failed to encode request body as json.")
|
||||
return
|
||||
}
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to URL")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -149,17 +152,10 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
completionHandler: @escaping HTTPResultHandler<[FlattenedProduct]>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/model-flatten/array".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/model-flatten/array"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -168,8 +164,13 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -245,17 +246,10 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/model-flatten/wrappedarray".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/model-flatten/wrappedarray"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -269,8 +263,13 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
self.options.logger.error("Failed to encode request body as json.")
|
||||
return
|
||||
}
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to URL")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -340,17 +339,10 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
completionHandler: @escaping HTTPResultHandler<[ProductWrapper]>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/model-flatten/wrappedarray".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/model-flatten/wrappedarray"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -359,8 +351,13 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -436,17 +433,10 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/model-flatten/dictionary".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/model-flatten/dictionary"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -460,8 +450,13 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
self.options.logger.error("Failed to encode request body as json.")
|
||||
return
|
||||
}
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to URL")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -531,17 +526,10 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
completionHandler: @escaping HTTPResultHandler<[String: FlattenedProduct]>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/model-flatten/dictionary".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/model-flatten/dictionary"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -550,8 +538,13 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -627,17 +620,10 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/model-flatten/resourcecollection".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/model-flatten/resourcecollection"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -651,8 +637,13 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
self.options.logger.error("Failed to encode request body as json.")
|
||||
return
|
||||
}
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to URL")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -722,17 +713,10 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
completionHandler: @escaping HTTPResultHandler<ResourceCollection>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/model-flatten/resourcecollection".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/model-flatten/resourcecollection"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -741,8 +725,13 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -818,17 +807,10 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
completionHandler: @escaping HTTPResultHandler<SimpleProduct>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/model-flatten/customFlattening".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/model-flatten/customFlattening"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -842,8 +824,13 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
self.options.logger.error("Failed to encode request body as json.")
|
||||
return
|
||||
}
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to URL")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -927,17 +914,10 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
completionHandler: @escaping HTTPResultHandler<SimpleProduct>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/model-flatten/customFlattening".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/model-flatten/customFlattening"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -955,8 +935,13 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
self.options.logger.error("Failed to encode request body as json.")
|
||||
return
|
||||
}
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to URL")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1032,18 +1017,11 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
completionHandler: @escaping HTTPResultHandler<SimpleProduct>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/model-flatten/customFlattening/parametergrouping/{name}/".removingPercentEncoding
|
||||
else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/model-flatten/customFlattening/parametergrouping/{name}/"
|
||||
let pathParams = [
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"name": flattenParameterGroup.name
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -1053,8 +1031,13 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
headers["Content-Type"] = "application/json"
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -15,3 +15,13 @@ extension Int32: LocalizedError {
|
|||
extension Int64: LocalizedError {
|
||||
public var errorDescription: String? { return String(self) }
|
||||
}
|
||||
|
||||
extension Data {
|
||||
func base64URLEncodedString() -> String {
|
||||
let base64String = base64EncodedString()
|
||||
let base64UrlString = base64String.replacingOccurrences(of: "/", with: "_")
|
||||
.replacingOccurrences(of: "+", with: "-")
|
||||
.replacingOccurrences(of: "=", with: "")
|
||||
return base64UrlString
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,11 @@ import Foundation
|
|||
// swiftlint:disable function_body_length
|
||||
// swiftlint:disable type_body_length
|
||||
|
||||
extension CharacterSet {
|
||||
static let azureUrlQueryAllowed = urlQueryAllowed.subtracting(.init(charactersIn: "!*'();:@&=+$,/?"))
|
||||
static let azureUrlPathAllowed = urlPathAllowed.subtracting(.init(charactersIn: "!*'()@&=+$,/:"))
|
||||
}
|
||||
|
||||
public final class AutoRestReportClient: PipelineClient {
|
||||
/// API version of the to invoke. Defaults to the latest.
|
||||
public enum ApiVersion: String {
|
||||
|
@ -65,6 +70,53 @@ public final class AutoRestReportClient: PipelineClient {
|
|||
)
|
||||
}
|
||||
|
||||
public func url(
|
||||
host hostIn: String? = nil,
|
||||
template templateIn: String,
|
||||
pathParams pathParamsIn: [String: String]? = nil,
|
||||
queryParams queryParamsIn: [QueryParameter]? = nil
|
||||
) -> URL? {
|
||||
var template = templateIn
|
||||
var hostString = hostIn
|
||||
if template.hasPrefix("/") { template = String(template.dropFirst()) }
|
||||
|
||||
if let pathParams = pathParamsIn {
|
||||
for (key, value) in pathParams {
|
||||
if let encodedPathValue = value.addingPercentEncoding(withAllowedCharacters: .azureUrlPathAllowed) {
|
||||
template = template.replacingOccurrences(of: "{\(key)}", with: encodedPathValue)
|
||||
}
|
||||
if let host = hostString {
|
||||
hostString = host.replacingOccurrences(of: "{\(key)}", with: value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let hostUnwrapped = hostString,
|
||||
!hostUnwrapped.hasSuffix("/") {
|
||||
hostString = hostUnwrapped + "/"
|
||||
}
|
||||
let urlString = (hostString ?? baseUrl.absoluteString) + template
|
||||
guard let url = URL(string: urlString) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
guard !(queryParamsIn?.isEmpty ?? false) else { return url }
|
||||
|
||||
return appendingQueryParameters(url: url, queryParamsIn ?? [])
|
||||
}
|
||||
|
||||
private func appendingQueryParameters(url: URL, _ queryParams: [QueryParameter]) -> URL? {
|
||||
guard !queryParams.isEmpty else { return url }
|
||||
guard var urlComps = URLComponents(url: url, resolvingAgainstBaseURL: true) else { return nil }
|
||||
|
||||
let queryItems = queryParams.map { name, value in URLQueryItem(
|
||||
name: name,
|
||||
value: value?.addingPercentEncoding(withAllowedCharacters: .azureUrlQueryAllowed)
|
||||
) }
|
||||
urlComps.percentEncodedQueryItems = queryItems
|
||||
return urlComps.url
|
||||
}
|
||||
|
||||
public lazy var autorestreportservice: AutoRestReportService = AutoRestReportService(client: self)
|
||||
|
||||
// MARK: Public Client Methods
|
||||
|
|
|
@ -30,8 +30,13 @@ public final class AutoRestReportService {
|
|||
self.commonOptions = client.commonOptions
|
||||
}
|
||||
|
||||
public func url(forTemplate templateIn: String, withKwargs kwargs: [String: String]? = nil) -> URL? {
|
||||
return client.url(forTemplate: templateIn, withKwargs: kwargs)
|
||||
public func url(
|
||||
host hostIn: String? = nil,
|
||||
template templateIn: String,
|
||||
pathParams pathParamsIn: [String: String]? = nil,
|
||||
queryParams queryParamsIn: [QueryParameter]? = nil
|
||||
) -> URL? {
|
||||
return client.url(host: hostIn, template: templateIn, pathParams: pathParamsIn, queryParams: queryParamsIn)
|
||||
}
|
||||
|
||||
public func request(
|
||||
|
@ -53,17 +58,10 @@ public final class AutoRestReportService {
|
|||
completionHandler: @escaping HTTPResultHandler<[String: Int32]>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/report".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/report"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
var queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -78,8 +76,13 @@ public final class AutoRestReportService {
|
|||
}
|
||||
// Header options
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -154,17 +157,10 @@ public final class AutoRestReportService {
|
|||
completionHandler: @escaping HTTPResultHandler<[String: Int32]>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/report/optional".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/report/optional"
|
||||
let pathParams = [
|
||||
"": ""
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
var queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -179,8 +175,13 @@ public final class AutoRestReportService {
|
|||
}
|
||||
// Header options
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -15,3 +15,13 @@ extension Int32: LocalizedError {
|
|||
extension Int64: LocalizedError {
|
||||
public var errorDescription: String? { return String(self) }
|
||||
}
|
||||
|
||||
extension Data {
|
||||
func base64URLEncodedString() -> String {
|
||||
let base64String = base64EncodedString()
|
||||
let base64UrlString = base64String.replacingOccurrences(of: "/", with: "_")
|
||||
.replacingOccurrences(of: "+", with: "-")
|
||||
.replacingOccurrences(of: "=", with: "")
|
||||
return base64UrlString
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,11 @@ import Foundation
|
|||
// swiftlint:disable function_body_length
|
||||
// swiftlint:disable type_body_length
|
||||
|
||||
extension CharacterSet {
|
||||
static let azureUrlQueryAllowed = urlQueryAllowed.subtracting(.init(charactersIn: "!*'();:@&=+$,/?"))
|
||||
static let azureUrlPathAllowed = urlPathAllowed.subtracting(.init(charactersIn: "!*'()@&=+$,/:"))
|
||||
}
|
||||
|
||||
public final class AutoRestUrlTestClient: PipelineClient {
|
||||
/// API version of the to invoke. Defaults to the latest.
|
||||
public enum ApiVersion: String {
|
||||
|
@ -67,6 +72,53 @@ public final class AutoRestUrlTestClient: PipelineClient {
|
|||
)
|
||||
}
|
||||
|
||||
public func url(
|
||||
host hostIn: String? = nil,
|
||||
template templateIn: String,
|
||||
pathParams pathParamsIn: [String: String]? = nil,
|
||||
queryParams queryParamsIn: [QueryParameter]? = nil
|
||||
) -> URL? {
|
||||
var template = templateIn
|
||||
var hostString = hostIn
|
||||
if template.hasPrefix("/") { template = String(template.dropFirst()) }
|
||||
|
||||
if let pathParams = pathParamsIn {
|
||||
for (key, value) in pathParams {
|
||||
if let encodedPathValue = value.addingPercentEncoding(withAllowedCharacters: .azureUrlPathAllowed) {
|
||||
template = template.replacingOccurrences(of: "{\(key)}", with: encodedPathValue)
|
||||
}
|
||||
if let host = hostString {
|
||||
hostString = host.replacingOccurrences(of: "{\(key)}", with: value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let hostUnwrapped = hostString,
|
||||
!hostUnwrapped.hasSuffix("/") {
|
||||
hostString = hostUnwrapped + "/"
|
||||
}
|
||||
let urlString = (hostString ?? baseUrl.absoluteString) + template
|
||||
guard let url = URL(string: urlString) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
guard !(queryParamsIn?.isEmpty ?? false) else { return url }
|
||||
|
||||
return appendingQueryParameters(url: url, queryParamsIn ?? [])
|
||||
}
|
||||
|
||||
private func appendingQueryParameters(url: URL, _ queryParams: [QueryParameter]) -> URL? {
|
||||
guard !queryParams.isEmpty else { return url }
|
||||
guard var urlComps = URLComponents(url: url, resolvingAgainstBaseURL: true) else { return nil }
|
||||
|
||||
let queryItems = queryParams.map { name, value in URLQueryItem(
|
||||
name: name,
|
||||
value: value?.addingPercentEncoding(withAllowedCharacters: .azureUrlQueryAllowed)
|
||||
) }
|
||||
urlComps.percentEncodedQueryItems = queryItems
|
||||
return urlComps.url
|
||||
}
|
||||
|
||||
// /// A string value 'globalItemStringPath' that appears in the path
|
||||
public var globalStringPath: String
|
||||
// /// should contain value null
|
||||
|
|
|
@ -30,8 +30,13 @@ public final class PathItems {
|
|||
self.commonOptions = client.commonOptions
|
||||
}
|
||||
|
||||
public func url(forTemplate templateIn: String, withKwargs kwargs: [String: String]? = nil) -> URL? {
|
||||
return client.url(forTemplate: templateIn, withKwargs: kwargs)
|
||||
public func url(
|
||||
host hostIn: String? = nil,
|
||||
template templateIn: String,
|
||||
pathParams pathParamsIn: [String: String]? = nil,
|
||||
queryParams queryParamsIn: [QueryParameter]? = nil
|
||||
) -> URL? {
|
||||
return client.url(host: hostIn, template: templateIn, pathParams: pathParamsIn, queryParams: queryParamsIn)
|
||||
}
|
||||
|
||||
public func request(
|
||||
|
@ -56,21 +61,14 @@ public final class PathItems {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate =
|
||||
let urlTemplate =
|
||||
"/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/pathItemStringQuery/localStringQuery"
|
||||
.removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let pathParams = [
|
||||
"pathItemStringPath": pathItemStringPath,
|
||||
"localStringPath": localStringPath,
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"globalStringPath": client.globalStringPath
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
var queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -91,8 +89,13 @@ public final class PathItems {
|
|||
}
|
||||
// Header options
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -165,21 +168,14 @@ public final class PathItems {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate =
|
||||
let urlTemplate =
|
||||
"/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/localStringQuery"
|
||||
.removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let pathParams = [
|
||||
"pathItemStringPath": pathItemStringPath,
|
||||
"localStringPath": localStringPath,
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"globalStringPath": client.globalStringPath
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
var queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -200,8 +196,13 @@ public final class PathItems {
|
|||
}
|
||||
// Header options
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -274,21 +275,14 @@ public final class PathItems {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate =
|
||||
let urlTemplate =
|
||||
"/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/null"
|
||||
.removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let pathParams = [
|
||||
"pathItemStringPath": pathItemStringPath,
|
||||
"localStringPath": localStringPath,
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"globalStringPath": client.globalStringPath
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
var queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -309,8 +303,13 @@ public final class PathItems {
|
|||
}
|
||||
// Header options
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -383,21 +382,14 @@ public final class PathItems {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate =
|
||||
let urlTemplate =
|
||||
"/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/null/null"
|
||||
.removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let pathParams = [
|
||||
"pathItemStringPath": pathItemStringPath,
|
||||
"localStringPath": localStringPath,
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"globalStringPath": client.globalStringPath
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
var queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -418,8 +410,13 @@ public final class PathItems {
|
|||
}
|
||||
// Header options
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,13 @@ public final class Paths {
|
|||
self.commonOptions = client.commonOptions
|
||||
}
|
||||
|
||||
public func url(forTemplate templateIn: String, withKwargs kwargs: [String: String]? = nil) -> URL? {
|
||||
return client.url(forTemplate: templateIn, withKwargs: kwargs)
|
||||
public func url(
|
||||
host hostIn: String? = nil,
|
||||
template templateIn: String,
|
||||
pathParams pathParamsIn: [String: String]? = nil,
|
||||
queryParams queryParamsIn: [QueryParameter]? = nil
|
||||
) -> URL? {
|
||||
return client.url(host: hostIn, template: templateIn, pathParams: pathParamsIn, queryParams: queryParamsIn)
|
||||
}
|
||||
|
||||
public func request(
|
||||
|
@ -53,17 +58,11 @@ public final class Paths {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/bool/true/{boolPath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/bool/true/{boolPath}"
|
||||
let pathParams = [
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"boolPath": String(true)
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -72,8 +71,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -143,17 +147,11 @@ public final class Paths {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/bool/false/{boolPath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/bool/false/{boolPath}"
|
||||
let pathParams = [
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"boolPath": String(false)
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -162,8 +160,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -233,17 +236,11 @@ public final class Paths {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/int/1000000/{intPath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/int/1000000/{intPath}"
|
||||
let pathParams = [
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"intPath": String(1_000_000)
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -252,8 +249,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -323,17 +325,11 @@ public final class Paths {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/int/-1000000/{intPath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/int/-1000000/{intPath}"
|
||||
let pathParams = [
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"intPath": String(-1_000_000)
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -342,8 +338,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -413,17 +414,11 @@ public final class Paths {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/long/10000000000/{longPath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/long/10000000000/{longPath}"
|
||||
let pathParams = [
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"longPath": String(10_000_000_000)
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -432,8 +427,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -503,17 +503,11 @@ public final class Paths {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/long/-10000000000/{longPath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/long/-10000000000/{longPath}"
|
||||
let pathParams = [
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"longPath": String(-10_000_000_000)
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -522,8 +516,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -593,17 +592,11 @@ public final class Paths {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/float/1.034E+20/{floatPath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/float/1.034E+20/{floatPath}"
|
||||
let pathParams = [
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"floatPath": String(Double(103_400_000_000_000_000_000))
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -612,8 +605,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -683,17 +681,11 @@ public final class Paths {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/float/-1.034E-20/{floatPath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/float/-1.034E-20/{floatPath}"
|
||||
let pathParams = [
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"floatPath": String(Double(-1.034e-20))
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -702,8 +694,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -773,17 +770,11 @@ public final class Paths {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/double/9999999.999/{doublePath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/double/9999999.999/{doublePath}"
|
||||
let pathParams = [
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"doublePath": String(Double(9_999_999.999))
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -792,8 +783,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -863,17 +859,11 @@ public final class Paths {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/double/-9999999.999/{doublePath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/double/-9999999.999/{doublePath}"
|
||||
let pathParams = [
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"doublePath": String(Double(-9_999_999.999))
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -882,8 +872,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -953,17 +948,11 @@ public final class Paths {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/string/unicode/{stringPath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/string/unicode/{stringPath}"
|
||||
let pathParams = [
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"stringPath": "啊齄丂狛狜隣郎隣兀﨩"
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -972,8 +961,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1043,19 +1037,11 @@ public final class Paths {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate =
|
||||
"/paths/string/begin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend/{stringPath}"
|
||||
.removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/string/begin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend/{stringPath}"
|
||||
let pathParams = [
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"stringPath": "begin!*'();:@ &=+$,/?#[]end"
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -1064,8 +1050,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1135,17 +1126,11 @@ public final class Paths {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/string/begin!*'();:@&=+$,end/{stringPath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/string/begin!*'();:@&=+$,end/{stringPath}"
|
||||
let pathParams = [
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"stringPath": "begin!*'();:@&=+$,end".removingPercentEncoding ?? ""
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -1154,8 +1139,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1225,17 +1215,11 @@ public final class Paths {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/string/empty/{stringPath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/string/empty/{stringPath}"
|
||||
let pathParams = [
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"stringPath": ""
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -1244,8 +1228,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1316,17 +1305,11 @@ public final class Paths {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/string/null/{stringPath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/string/null/{stringPath}"
|
||||
let pathParams = [
|
||||
"stringPath": stringPath
|
||||
"stringPath": stringPath,
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -1335,8 +1318,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1407,17 +1395,11 @@ public final class Paths {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/enum/green%20color/{enumPath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/enum/green%20color/{enumPath}"
|
||||
let pathParams = [
|
||||
"enumPath": enumPath.rawValue
|
||||
"enumPath": enumPath.rawValue,
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -1426,8 +1408,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1498,17 +1485,11 @@ public final class Paths {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/string/null/{enumPath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/string/null/{enumPath}"
|
||||
let pathParams = [
|
||||
"enumPath": enumPath.rawValue
|
||||
"enumPath": enumPath.rawValue,
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -1517,8 +1498,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1594,17 +1580,11 @@ public final class Paths {
|
|||
}
|
||||
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/byte/multibyte/{bytePath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/byte/multibyte/{bytePath}"
|
||||
let pathParams = [
|
||||
"bytePath": bytePathString
|
||||
"bytePath": bytePathString,
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -1613,8 +1593,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1684,17 +1669,11 @@ public final class Paths {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/byte/empty/{bytePath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/byte/empty/{bytePath}"
|
||||
let pathParams = [
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"bytePath": ""
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -1703,8 +1682,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1780,17 +1764,11 @@ public final class Paths {
|
|||
}
|
||||
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/byte/null/{bytePath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/byte/null/{bytePath}"
|
||||
let pathParams = [
|
||||
"bytePath": bytePathString
|
||||
"bytePath": bytePathString,
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -1799,8 +1777,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1870,17 +1853,11 @@ public final class Paths {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/date/2012-01-01/{datePath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/date/2012-01-01/{datePath}"
|
||||
let pathParams = [
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"datePath": "2012-01-01"
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -1889,8 +1866,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1965,17 +1947,11 @@ public final class Paths {
|
|||
let datePathString = dateFormatter.string(from: datePath)
|
||||
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/date/null/{datePath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/date/null/{datePath}"
|
||||
let pathParams = [
|
||||
"datePath": datePathString
|
||||
"datePath": datePathString,
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -1984,8 +1960,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -2055,17 +2036,11 @@ public final class Paths {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/datetime/2012-01-01T01%3A01%3A01Z/{dateTimePath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/datetime/2012-01-01T01%3A01%3A01Z/{dateTimePath}"
|
||||
let pathParams = [
|
||||
"$host": client.baseUrl.absoluteString,
|
||||
"dateTimePath": "2012-01-01T01:01:01Z"
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -2074,8 +2049,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -2148,17 +2128,11 @@ public final class Paths {
|
|||
let dateTimePathString = Date.Format.iso8601.formatter.string(from: dateTimePath)
|
||||
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/datetime/null/{dateTimePath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/datetime/null/{dateTimePath}"
|
||||
let pathParams = [
|
||||
"dateTimePath": dateTimePathString
|
||||
"dateTimePath": dateTimePathString,
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -2167,8 +2141,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -2238,23 +2217,14 @@ public final class Paths {
|
|||
withOptions options: Base64UrlOptions? = nil,
|
||||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
guard let base64UrlPathString = String(bytes: base64UrlPath, encoding: .utf8) else {
|
||||
self.options.logger.error("Failed to construct String for base64UrlPath")
|
||||
return
|
||||
}
|
||||
let base64UrlPathString = base64UrlPath.base64URLEncodedString()
|
||||
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/string/bG9yZW0/{base64UrlPath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/string/bG9yZW0/{base64UrlPath}"
|
||||
let pathParams = [
|
||||
"base64UrlPath": base64UrlPathString
|
||||
"base64UrlPath": base64UrlPathString,
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -2263,8 +2233,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -2335,19 +2310,12 @@ public final class Paths {
|
|||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate =
|
||||
let urlTemplate =
|
||||
"/paths/array/ArrayPath1%2cbegin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend%2c%2c/{arrayPath}"
|
||||
.removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let pathParams = [
|
||||
"arrayPath": arrayPath.map { String($0) }.joined(separator: ",")
|
||||
"arrayPath": arrayPath.map { String($0) }.joined(separator: ","),
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -2356,8 +2324,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -2432,17 +2405,11 @@ public final class Paths {
|
|||
let unixTimeUrlPathString = dateFormatter.string(from: unixTimeUrlPath)
|
||||
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/paths/int/1460505600/{unixTimeUrlPath}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/paths/int/1460505600/{unixTimeUrlPath}"
|
||||
let pathParams = [
|
||||
"unixTimeUrlPath": unixTimeUrlPathString
|
||||
"unixTimeUrlPath": unixTimeUrlPathString,
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -2451,8 +2418,13 @@ public final class Paths {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -15,3 +15,13 @@ extension Int32: LocalizedError {
|
|||
extension Int64: LocalizedError {
|
||||
public var errorDescription: String? { return String(self) }
|
||||
}
|
||||
|
||||
extension Data {
|
||||
func base64URLEncodedString() -> String {
|
||||
let base64String = base64EncodedString()
|
||||
let base64UrlString = base64String.replacingOccurrences(of: "/", with: "_")
|
||||
.replacingOccurrences(of: "+", with: "-")
|
||||
.replacingOccurrences(of: "=", with: "")
|
||||
return base64UrlString
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,8 +30,13 @@ public final class PetOperation {
|
|||
self.commonOptions = client.commonOptions
|
||||
}
|
||||
|
||||
public func url(forTemplate templateIn: String, withKwargs kwargs: [String: String]? = nil) -> URL? {
|
||||
return client.url(forTemplate: templateIn, withKwargs: kwargs)
|
||||
public func url(
|
||||
host hostIn: String? = nil,
|
||||
template templateIn: String,
|
||||
pathParams pathParamsIn: [String: String]? = nil,
|
||||
queryParams queryParamsIn: [QueryParameter]? = nil
|
||||
) -> URL? {
|
||||
return client.url(host: hostIn, template: templateIn, pathParams: pathParamsIn, queryParams: queryParamsIn)
|
||||
}
|
||||
|
||||
public func request(
|
||||
|
@ -54,17 +59,11 @@ public final class PetOperation {
|
|||
completionHandler: @escaping HTTPResultHandler<Pet?>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/errorStatusCodes/Pets/{petId}/GetPet".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/errorStatusCodes/Pets/{petId}/GetPet"
|
||||
let pathParams = [
|
||||
"petId": petId
|
||||
"petId": petId,
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -73,8 +72,13 @@ public final class PetOperation {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -189,17 +193,11 @@ public final class PetOperation {
|
|||
completionHandler: @escaping HTTPResultHandler<PetAction>
|
||||
) {
|
||||
// Construct URL
|
||||
guard let urlTemplate = "/errorStatusCodes/Pets/doSomething/{whatAction}".removingPercentEncoding else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
let urlTemplate = "/errorStatusCodes/Pets/doSomething/{whatAction}"
|
||||
let pathParams = [
|
||||
"whatAction": whatAction
|
||||
"whatAction": whatAction,
|
||||
"$host": client.baseUrl.absoluteString
|
||||
]
|
||||
guard let url = self.url(forTemplate: urlTemplate, withKwargs: pathParams) else {
|
||||
self.options.logger.error("Failed to construct url")
|
||||
return
|
||||
}
|
||||
// Construct query
|
||||
let queryParams: [QueryParameter] = [
|
||||
]
|
||||
|
@ -208,8 +206,13 @@ public final class PetOperation {
|
|||
var headers = HTTPHeaders()
|
||||
headers["Accept"] = "application/json"
|
||||
// Construct request
|
||||
guard let requestUrl = url.appendingQueryParameters(queryParams) else {
|
||||
self.options.logger.error("Failed to append query parameters to url")
|
||||
guard let requestUrl = url(
|
||||
host: "{$host}",
|
||||
template: urlTemplate,
|
||||
pathParams: pathParams,
|
||||
queryParams: queryParams
|
||||
) else {
|
||||
self.options.logger.error("Failed to construct request url")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -15,3 +15,13 @@ extension Int32: LocalizedError {
|
|||
extension Int64: LocalizedError {
|
||||
public var errorDescription: String? { return String(self) }
|
||||
}
|
||||
|
||||
extension Data {
|
||||
func base64URLEncodedString() -> String {
|
||||
let base64String = base64EncodedString()
|
||||
let base64UrlString = base64String.replacingOccurrences(of: "/", with: "_")
|
||||
.replacingOccurrences(of: "+", with: "-")
|
||||
.replacingOccurrences(of: "=", with: "")
|
||||
return base64UrlString
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,11 @@ import Foundation
|
|||
// swiftlint:disable function_body_length
|
||||
// swiftlint:disable type_body_length
|
||||
|
||||
extension CharacterSet {
|
||||
static let azureUrlQueryAllowed = urlQueryAllowed.subtracting(.init(charactersIn: "!*'();:@&=+$,/?"))
|
||||
static let azureUrlPathAllowed = urlPathAllowed.subtracting(.init(charactersIn: "!*'()@&=+$,/:"))
|
||||
}
|
||||
|
||||
public final class XmsErrorResponseExtensionsClient: PipelineClient {
|
||||
/// API version of the to invoke. Defaults to the latest.
|
||||
public enum ApiVersion: String {
|
||||
|
@ -65,6 +70,53 @@ public final class XmsErrorResponseExtensionsClient: PipelineClient {
|
|||
)
|
||||
}
|
||||
|
||||
public func url(
|
||||
host hostIn: String? = nil,
|
||||
template templateIn: String,
|
||||
pathParams pathParamsIn: [String: String]? = nil,
|
||||
queryParams queryParamsIn: [QueryParameter]? = nil
|
||||
) -> URL? {
|
||||
var template = templateIn
|
||||
var hostString = hostIn
|
||||
if template.hasPrefix("/") { template = String(template.dropFirst()) }
|
||||
|
||||
if let pathParams = pathParamsIn {
|
||||
for (key, value) in pathParams {
|
||||
if let encodedPathValue = value.addingPercentEncoding(withAllowedCharacters: .azureUrlPathAllowed) {
|
||||
template = template.replacingOccurrences(of: "{\(key)}", with: encodedPathValue)
|
||||
}
|
||||
if let host = hostString {
|
||||
hostString = host.replacingOccurrences(of: "{\(key)}", with: value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let hostUnwrapped = hostString,
|
||||
!hostUnwrapped.hasSuffix("/") {
|
||||
hostString = hostUnwrapped + "/"
|
||||
}
|
||||
let urlString = (hostString ?? baseUrl.absoluteString) + template
|
||||
guard let url = URL(string: urlString) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
guard !(queryParamsIn?.isEmpty ?? false) else { return url }
|
||||
|
||||
return appendingQueryParameters(url: url, queryParamsIn ?? [])
|
||||
}
|
||||
|
||||
private func appendingQueryParameters(url: URL, _ queryParams: [QueryParameter]) -> URL? {
|
||||
guard !queryParams.isEmpty else { return url }
|
||||
guard var urlComps = URLComponents(url: url, resolvingAgainstBaseURL: true) else { return nil }
|
||||
|
||||
let queryItems = queryParams.map { name, value in URLQueryItem(
|
||||
name: name,
|
||||
value: value?.addingPercentEncoding(withAllowedCharacters: .azureUrlQueryAllowed)
|
||||
) }
|
||||
urlComps.percentEncodedQueryItems = queryItems
|
||||
return urlComps.url
|
||||
}
|
||||
|
||||
public lazy var petoperation: PetOperation = PetOperation(client: self)
|
||||
|
||||
// MARK: Public Client Methods
|
||||
|
|
Загрузка…
Ссылка в новой задаче