Model Flattening Tests (#221)
* Initial commit of tests. * Write the tests they way I think they *should* look. Requires modification to code gen. * Fix issue with defaults in initializers. * Fix default nil in method signatures. * Fix issue with GroupSchema model generation. * Comment out failing tests.
This commit is contained in:
Родитель
fbf085526d
Коммит
323dfc9e1c
|
@ -164,6 +164,7 @@
|
|||
0AA2BA2B24EDB87E00CEA1D6 /* ContentLengthHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA2BA2A24EDB87E00CEA1D6 /* ContentLengthHeader.swift */; };
|
||||
0AA2BA2E24F4788600CEA1D6 /* VirtualParameter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA2BA2D24F4788500CEA1D6 /* VirtualParameter.swift */; };
|
||||
0AA2BA3024F57A5B00CEA1D6 /* ParameterType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA2BA2F24F57A5B00CEA1D6 /* ParameterType.swift */; };
|
||||
0AEFC3422537647A00C6B087 /* PropertyType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AEFC3412537647A00C6B087 /* PropertyType.swift */; };
|
||||
F106826D24CF5B9C007EB4D5 /* .swiftlint.yml in CopyFiles */ = {isa = PBXBuildFile; fileRef = F106826C24CF5B7C007EB4D5 /* .swiftlint.yml */; };
|
||||
F106826E24CF5B9C007EB4D5 /* .swiftformat in CopyFiles */ = {isa = PBXBuildFile; fileRef = F106826B24CF5B71007EB4D5 /* .swiftformat */; };
|
||||
F106830424CF93C5007EB4D5 /* swiftformat in CopyFiles */ = {isa = PBXBuildFile; fileRef = F106830324CF9244007EB4D5 /* swiftformat */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
|
@ -485,6 +486,7 @@
|
|||
0AA2BA2A24EDB87E00CEA1D6 /* ContentLengthHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentLengthHeader.swift; sourceTree = "<group>"; };
|
||||
0AA2BA2D24F4788500CEA1D6 /* VirtualParameter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VirtualParameter.swift; sourceTree = "<group>"; };
|
||||
0AA2BA2F24F57A5B00CEA1D6 /* ParameterType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParameterType.swift; sourceTree = "<group>"; };
|
||||
0AEFC3412537647A00C6B087 /* PropertyType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PropertyType.swift; sourceTree = "<group>"; };
|
||||
50684F746D1F4406B5919571 /* Pods-AutorestSwiftTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AutorestSwiftTests.debug.xcconfig"; path = "Target Support Files/Pods-AutorestSwiftTests/Pods-AutorestSwiftTests.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
6111AB27AE90FF2215A75C1F /* libPods-AutorestSwiftTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AutorestSwiftTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
83D1551AC5FB9279DDE6D239 /* libPods-AutorestSwift.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AutorestSwift.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
|
@ -956,6 +958,7 @@
|
|||
0AA2BA2F24F57A5B00CEA1D6 /* ParameterType.swift */,
|
||||
OBJ_50 /* PrimitiveSchema.swift */,
|
||||
OBJ_51 /* Property.swift */,
|
||||
0AEFC3412537647A00C6B087 /* PropertyType.swift */,
|
||||
OBJ_52 /* Protocol.swift */,
|
||||
OBJ_53 /* Request.swift */,
|
||||
OBJ_54 /* Response.swift */,
|
||||
|
@ -1391,6 +1394,7 @@
|
|||
0A22B0F524D3671E00EC018E /* AnySchema.swift in Sources */,
|
||||
0A5F3F86251A65AD0079C1F0 /* BodyParamViewModel.swift in Sources */,
|
||||
0A22B0F624D3671E00EC018E /* ArraySchema.swift in Sources */,
|
||||
0AEFC3422537647A00C6B087 /* PropertyType.swift in Sources */,
|
||||
0A22B0F724D3671E00EC018E /* BinarySchema.swift in Sources */,
|
||||
0A22B0F824D3671E00EC018E /* BooleanSchema.swift in Sources */,
|
||||
0A22B0F924D3671E00EC018E /* ByteArraySchema.swift in Sources */,
|
||||
|
|
|
@ -44,21 +44,279 @@ class AutoRestResourceFlatteningTest: XCTestCase {
|
|||
)
|
||||
}
|
||||
|
||||
// func test_Head_success200() throws {
|
||||
// let expectation = XCTestExpectation(description: "Call head200 succeed")
|
||||
// let failedExpectation = XCTestExpectation(description: "Call head200 failed")
|
||||
// failedExpectation.isInverted = true
|
||||
//
|
||||
// client.head200() { result, _ in
|
||||
private func errorDetails(for error: AzureError, withResponse response: HTTPResponse?) -> String {
|
||||
var details: String
|
||||
if let data = response?.data {
|
||||
details = String(data: data, encoding: .utf8)!
|
||||
} else {
|
||||
details = error.message
|
||||
}
|
||||
return details
|
||||
}
|
||||
|
||||
func test_resourceFlattening_getArray() throws {
|
||||
let expectation = XCTestExpectation(description: "Call autorestresourceflatteningtestservice.getArray succeed")
|
||||
|
||||
client.autorestresourceflatteningtestservice.getArray { result, httpResponse in
|
||||
switch result {
|
||||
case .success:
|
||||
expectation.fulfill()
|
||||
case let .failure(error):
|
||||
let details = self.errorDetails(for: error, withResponse: httpResponse)
|
||||
print("test failed. error=\(details)")
|
||||
XCTFail("Call autorestresourceflatteningtestservice.getArray failed")
|
||||
}
|
||||
}
|
||||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
func test_resourceFlattening_putArray() throws {
|
||||
let expectation =
|
||||
XCTestExpectation(
|
||||
description: "Call autorestresourceflatteningtestservice.putArray succeed"
|
||||
)
|
||||
let array = [
|
||||
Resource(tags: ["tag1": "value1", "tag2": "value3"], location: "West US"),
|
||||
Resource(location: "Building 44")
|
||||
]
|
||||
client.autorestresourceflatteningtestservice.put(array: array) { result, httpResponse in
|
||||
switch result {
|
||||
case .success:
|
||||
expectation.fulfill()
|
||||
case let .failure(error):
|
||||
let details = self.errorDetails(for: error, withResponse: httpResponse)
|
||||
print("test failed. error=\(details)")
|
||||
XCTFail("Call autorestresourceflatteningtestservice.putArray failed")
|
||||
}
|
||||
}
|
||||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
func test_resourceFlattening_getDictionary() throws {
|
||||
let expectation =
|
||||
XCTestExpectation(description: "Call autorestresourceflatteningtestservice.getDictionary succeed")
|
||||
client.autorestresourceflatteningtestservice.getDictionary { result, httpResponse in
|
||||
switch result {
|
||||
case .success:
|
||||
expectation.fulfill()
|
||||
case let .failure(error):
|
||||
let details = self.errorDetails(for: error, withResponse: httpResponse)
|
||||
print("test failed. error=\(details)")
|
||||
XCTFail("Call autorestresourceflatteningtestservice.getDictionary failed")
|
||||
}
|
||||
}
|
||||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
// func test_resourceFlattening_putDictionary() throws {
|
||||
// let expectation =
|
||||
// XCTestExpectation(
|
||||
// description: "Call autorestresourceflatteningtestservice.putDictionary succeed"
|
||||
// )
|
||||
// let dictionary = [
|
||||
// "Resource1": FlattenedProduct(
|
||||
// type: "Flat",
|
||||
// tags: ["tag1": "value1", "tag2": "value3"],
|
||||
// location: "West US",
|
||||
// name: "Product1"
|
||||
// ),
|
||||
// "Resource2": FlattenedProduct(
|
||||
// type: "Flat",
|
||||
// location: "Building 44",
|
||||
// name: "Product2"
|
||||
// )
|
||||
// ]
|
||||
// // FIXME: Flattened parameters should be sent on the wire under "properties" object
|
||||
// client.autorestresourceflatteningtestservice.put(dictionary: dictionary) { result, httpResponse in
|
||||
// switch result {
|
||||
// case .success:
|
||||
// expectation.fulfill()
|
||||
// case let .failure(error):
|
||||
// print("test failed. error=\(error.message)")
|
||||
// failedExpectation.fulfill()
|
||||
// case .success:
|
||||
// expectation.fulfill()
|
||||
// case let .failure(error):
|
||||
// let details = self.errorDetails(for: error, withResponse: httpResponse)
|
||||
// print("test failed. error=\(details)")
|
||||
// XCTFail("Call autorestresourceflatteningtestservice.putDictionary failed")
|
||||
// }
|
||||
// }
|
||||
// wait(for: [expectation], timeout: 5.0)
|
||||
// }
|
||||
|
||||
func test_resourceFlattening_getResourceCollection() throws {
|
||||
let expectation =
|
||||
XCTestExpectation(description: "Call autorestresourceflatteningtestservice.getResourceCollection succeed")
|
||||
client.autorestresourceflatteningtestservice.getResourceCollection { result, httpResponse in
|
||||
switch result {
|
||||
case .success:
|
||||
expectation.fulfill()
|
||||
case let .failure(error):
|
||||
let details = self.errorDetails(for: error, withResponse: httpResponse)
|
||||
print("test failed. error=\(details)")
|
||||
XCTFail("Call autorestresourceflatteningtestservice.getResourceCollection failed")
|
||||
}
|
||||
}
|
||||
wait(for: [expectation], timeout: 5.0)
|
||||
}
|
||||
|
||||
// func test_resourceFlattening_putResourceCollection() throws {
|
||||
// let expectation =
|
||||
// XCTestExpectation(
|
||||
// description: "Call autorestresourceflatteningtestservice.putResourceCollection succeed"
|
||||
// )
|
||||
// let collection = ResourceCollection(
|
||||
// productresource: FlattenedProduct(
|
||||
// type: "Flat",
|
||||
// location: "India",
|
||||
// name: "Azure"
|
||||
// ),
|
||||
// arrayofresources: [
|
||||
// FlattenedProduct(
|
||||
// type: "Flat",
|
||||
// tags: ["tag1": "value1", "tag2": "value3"],
|
||||
// location: "West US",
|
||||
// name: "Product1"
|
||||
// )
|
||||
// ],
|
||||
// dictionaryofresources: [
|
||||
// "Resource1": FlattenedProduct(
|
||||
// type: "Flat",
|
||||
// tags: ["tag1": "value1", "tag2": "value3"],
|
||||
// location: "West US",
|
||||
// name: "Product1"
|
||||
// ),
|
||||
// "Resource2": FlattenedProduct(
|
||||
// type: "Flat",
|
||||
// location: "Building 44",
|
||||
// name: "Product2"
|
||||
// )
|
||||
// ]
|
||||
// )
|
||||
// // FIXME: Flattened parameters should be sent on the wire under "properties" object
|
||||
// client.autorestresourceflatteningtestservice.put(resourceCollection: collection) { result, httpResponse in
|
||||
// switch result {
|
||||
// case .success:
|
||||
// expectation.fulfill()
|
||||
// case let .failure(error):
|
||||
// let details = self.errorDetails(for: error, withResponse: httpResponse)
|
||||
// print("test failed. error=\(details)")
|
||||
// XCTFail("Call autorestresourceflatteningtestservice.putResourceCollection failed")
|
||||
// }
|
||||
// }
|
||||
// wait(for: [expectation], timeout: 5.0)
|
||||
// }
|
||||
|
||||
// func test_resourceFlattening_getWrappedArray() throws {
|
||||
// let expectation =
|
||||
// XCTestExpectation(description: "Call autorestresourceflatteningtestservice.getWrappedArray succeed")
|
||||
// // FIXME: Request path must container array, dictionary or resourcecollection
|
||||
// client.autorestresourceflatteningtestservice.getWrappedArray { result, httpResponse in
|
||||
// switch result {
|
||||
// case .success:
|
||||
// expectation.fulfill()
|
||||
// case let .failure(error):
|
||||
// let details = self.errorDetails(for: error, withResponse: httpResponse)
|
||||
// print("test failed. error=\(details)")
|
||||
// XCTFail("Call autorestresourceflatteningtestservice.getWrappedArray failed")
|
||||
// }
|
||||
// }
|
||||
// wait(for: [expectation], timeout: 5.0)
|
||||
// }
|
||||
|
||||
// func test_resourceFlattening_putWrappedArray() throws {
|
||||
// let expectation =
|
||||
// XCTestExpectation(
|
||||
// description: "Call autorestresourceflatteningtestservice.putWrappedArray succeed"
|
||||
// )
|
||||
// let wrapped = [
|
||||
// WrappedProduct(value: "test")
|
||||
// ]
|
||||
// // FIXME: Timeout fails
|
||||
// client.autorestresourceflatteningtestservice.put(wrappedArray: wrapped) { result, httpResponse in
|
||||
// switch result {
|
||||
// case .success:
|
||||
// expectation.fulfill()
|
||||
// case let .failure(error):
|
||||
// let details = self.errorDetails(for: error, withResponse: httpResponse)
|
||||
// print("test failed. error=\(details)")
|
||||
// XCTFail("Call autorestresourceflatteningtestservice.putWrappedArray failed")
|
||||
// }
|
||||
// }
|
||||
// wait(for: [expectation], timeout: 5.0)
|
||||
// }
|
||||
|
||||
// func test_resourceFlattening_putSimpleProduct() throws {
|
||||
// let expectation =
|
||||
// XCTestExpectation(
|
||||
// description: "Call autorestresourceflatteningtestservice.putSimpleProduct succeed"
|
||||
// )
|
||||
// let product = SimpleProduct(
|
||||
// maxProductDisplayName: "max name",
|
||||
// odataValue: "http://foo",
|
||||
// productId: "123",
|
||||
// description: "product description"
|
||||
// )
|
||||
// // FIXME: Serialization of flattened object to the wire needs fixing
|
||||
// client.autorestresourceflatteningtestservice.put(simpleProduct: product) { result, httpResponse in
|
||||
// switch result {
|
||||
// case .success:
|
||||
// expectation.fulfill()
|
||||
// case let .failure(error):
|
||||
// let details = self.errorDetails(for: error, withResponse: httpResponse)
|
||||
// print("test failed. error=\(details)")
|
||||
// XCTFail("Call autorestresourceflatteningtestservice.putSimpleProduct failed")
|
||||
// }
|
||||
// }
|
||||
// wait(for: [expectation], timeout: 5.0)
|
||||
// }
|
||||
|
||||
// func test_resourceFlattening_putSimpleProductWithGroupingFlattenParameterGroup() throws {
|
||||
// let expectation =
|
||||
// XCTestExpectation(
|
||||
// description: "Call autorestresourceflatteningtestservice.putSimpleProductWithGroupingFlattenParameterGroup succeed"
|
||||
// )
|
||||
// let group = FlattenParameterGroup(
|
||||
// name: "groupproduct",
|
||||
// productId: "123",
|
||||
// description: "product description",
|
||||
// maxProductDisplayName: "max name",
|
||||
// odataValue: "http://foo"
|
||||
// )
|
||||
// // FIXME: Received body is {} (empty)
|
||||
// client.autorestresourceflatteningtestservice
|
||||
// .putSimpleProductWithGrouping(flattenParameterGroup: group) { result, httpResponse in
|
||||
// switch result {
|
||||
// case .success:
|
||||
// expectation.fulfill()
|
||||
// case let .failure(error):
|
||||
// let details = self.errorDetails(for: error, withResponse: httpResponse)
|
||||
// print("test failed. error=\(details)")
|
||||
// XCTFail(
|
||||
// "Call autorestresourceflatteningtestservice.putSimpleProductWithGroupingFlattenParameterGroup failed"
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// wait(for: [expectation], timeout: 5.0)
|
||||
// }
|
||||
|
||||
// func test_resourceFlattening_postFlattenedSimpleProduct() throws {
|
||||
// let expectation =
|
||||
// XCTestExpectation(
|
||||
// description: "Call autorestresourceflatteningtestservice.postFlattenedSimpleProduct succeed"
|
||||
// )
|
||||
// // FIXME: Serialization of flattened object to the wire needs fixing
|
||||
// client.autorestresourceflatteningtestservice.postFlattenedSimpleProduct(
|
||||
// productId: "123",
|
||||
// description: "product description",
|
||||
// maxProductDisplayName: "max name",
|
||||
// odataValue: "http://foo"
|
||||
// ) { result, httpResponse in
|
||||
// switch result {
|
||||
// case .success:
|
||||
// expectation.fulfill()
|
||||
// case let .failure(error):
|
||||
// let details = self.errorDetails(for: error, withResponse: httpResponse)
|
||||
// print("test failed. error=\(details)")
|
||||
// XCTFail("Call autorestresourceflatteningtestservice.postFlattenedSimpleProduct failed")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// wait(for: [expectation], timeout: 5.0)
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ class ObjectSchema: ComplexSchema, UsageSchema {
|
|||
let serializationFormats: [KnownMediaType]
|
||||
|
||||
/// Returns the properties of the model and any parent models.
|
||||
var flattenedProperties: [Property]? {
|
||||
var props = [Property]()
|
||||
var flattenedProperties: [PropertyType]? {
|
||||
var props = [PropertyType]()
|
||||
for prop in properties ?? [] {
|
||||
props.append(prop)
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ class Parameter: Value, CustomDebugStringConvertible {
|
|||
|
||||
// Default logic
|
||||
let inMethod = implementation == .method
|
||||
let notConstant = schema.type != .constant
|
||||
let notConstant = schema!.type != .constant
|
||||
let notGrouped = groupedBy == nil
|
||||
let isRequired = required
|
||||
return isRequired && inMethod && notConstant && notGrouped
|
||||
|
@ -90,7 +90,7 @@ class Parameter: Value, CustomDebugStringConvertible {
|
|||
|
||||
internal func belongsInOptions() -> Bool {
|
||||
let inMethod = implementation == .method
|
||||
let notConstant = schema.type != .constant
|
||||
let notConstant = schema!.type != .constant
|
||||
let notFlattened = flattened != true
|
||||
let notGrouped = groupedBy == nil
|
||||
let notRequired = required == false
|
||||
|
|
|
@ -58,7 +58,7 @@ enum ParameterType: Codable {
|
|||
}
|
||||
|
||||
var schema: Schema {
|
||||
return common.schema
|
||||
return common.schema!
|
||||
}
|
||||
|
||||
var value: Value {
|
||||
|
|
|
@ -69,3 +69,11 @@ class Property: Value {
|
|||
try super.encode(to: encoder)
|
||||
}
|
||||
}
|
||||
|
||||
extension Property: Equatable {
|
||||
static func == (lhs: Property, rhs: Property) -> Bool {
|
||||
// TODO: Improve this? This is technically the same assumption being
|
||||
// made when using a dictionary.
|
||||
return lhs.name == rhs.name
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,168 @@
|
|||
// --------------------------------------------------------------------------
|
||||
//
|
||||
// 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 Foundation
|
||||
|
||||
enum PropertyType: Codable {
|
||||
case regular(Property)
|
||||
case grouped(GroupProperty)
|
||||
|
||||
// MARK: Codable
|
||||
|
||||
init(from decoder: Decoder) throws {
|
||||
if let decoded = try? GroupProperty(from: decoder) {
|
||||
self = .grouped(decoded)
|
||||
} else if let decoded = try? Property(from: decoder) {
|
||||
self = .regular(decoded)
|
||||
} else {
|
||||
fatalError("Unable to decode PropertyType")
|
||||
}
|
||||
}
|
||||
|
||||
func encode(to encoder: Encoder) throws {
|
||||
switch self {
|
||||
case let .regular(param):
|
||||
try param.encode(to: encoder)
|
||||
case let .grouped(param):
|
||||
try param.encode(to: encoder)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Property Helpers
|
||||
|
||||
var name: String {
|
||||
return common.name
|
||||
}
|
||||
|
||||
var schema: Schema {
|
||||
return common.schema!
|
||||
}
|
||||
|
||||
var value: Value {
|
||||
return common as Value
|
||||
}
|
||||
|
||||
var required: Bool {
|
||||
return common.required
|
||||
}
|
||||
|
||||
var description: String {
|
||||
return common.description
|
||||
}
|
||||
|
||||
var serializedName: String? {
|
||||
return common.serializedName
|
||||
}
|
||||
|
||||
var `protocol`: Protocols {
|
||||
return common.protocol
|
||||
}
|
||||
|
||||
var clientDefaultValue: String? {
|
||||
return common.clientDefaultValue
|
||||
}
|
||||
|
||||
var readOnly: Bool? {
|
||||
return common.readOnly
|
||||
}
|
||||
|
||||
var flattenedNames: [String]? {
|
||||
return common.flattenedNames
|
||||
}
|
||||
|
||||
var isDiscriminator: Bool? {
|
||||
return common.isDiscriminator
|
||||
}
|
||||
|
||||
private var common: Property {
|
||||
switch self {
|
||||
case let .regular(reg):
|
||||
return reg
|
||||
case let .grouped(virt):
|
||||
return virt as GroupProperty
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Methods
|
||||
|
||||
/// Returns whether the given parameter is located in the specified location.
|
||||
internal func located(in location: ParameterLocation) -> Bool {
|
||||
if let httpParam = self.protocol.http as? HttpParameter {
|
||||
return httpParam.in == location
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns whether the given parameter is located in any of the specified locations.
|
||||
internal func located(in locations: [ParameterLocation]) -> Bool {
|
||||
for location in locations {
|
||||
if located(in: location) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
extension PropertyType: Equatable {
|
||||
static func == (lhs: PropertyType, rhs: PropertyType) -> Bool {
|
||||
switch lhs {
|
||||
case let .regular(lparam):
|
||||
if case let PropertyType.regular(rparam) = rhs {
|
||||
return lparam == rparam
|
||||
}
|
||||
case let .grouped(lparam):
|
||||
if case let PropertyType.grouped(rparam) = rhs {
|
||||
return lparam == rparam
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
extension Array where Element == PropertyType {
|
||||
func first(named: String) -> Element? {
|
||||
for param in self {
|
||||
let name = param.serializedName ?? param.name
|
||||
if named == name {
|
||||
return param
|
||||
}
|
||||
}
|
||||
// no match found
|
||||
return nil
|
||||
}
|
||||
|
||||
/// Returns the subset of `PropertyType` that are `GroupProperty` types.
|
||||
var grouped: [GroupProperty] {
|
||||
return compactMap { prop in
|
||||
if case let PropertyType.grouped(groupProp) = prop {
|
||||
return groupProp
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
|
@ -60,7 +60,7 @@ class Schema: Codable, LanguageShortcut {
|
|||
/// Per-protocol information for this aspect
|
||||
let `protocol`: Protocols
|
||||
|
||||
let properties: [Property]?
|
||||
let properties: [PropertyType]?
|
||||
|
||||
/// Additional metadata extensions dictionary
|
||||
let extensions: [String: AnyCodable]?
|
||||
|
|
|
@ -29,7 +29,7 @@ import Foundation
|
|||
/// Common base interface for properties, parameters and the like.
|
||||
class Value: Codable, LanguageShortcut {
|
||||
/// the schema of this Value
|
||||
public var schema: Schema
|
||||
public var schema: Schema?
|
||||
|
||||
// these properties we can set
|
||||
private var internalRequired: Bool?
|
||||
|
@ -93,7 +93,7 @@ class Value: Codable, LanguageShortcut {
|
|||
public required init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
|
||||
self.schema = try Schema.decode(withContainer: container)!
|
||||
self.schema = try Schema.decode(withContainer: container)
|
||||
self.internalRequired = try? container.decode(Bool.self, forKey: .required)
|
||||
self.nullable = try? container.decode(Bool.self, forKey: .nullable)
|
||||
self.assumedValue = try? container.decode(String.self, forKey: .assumedValue)
|
||||
|
|
|
@ -32,7 +32,7 @@ class VirtualParameter: Parameter {
|
|||
let originalParameter: Parameter
|
||||
|
||||
/// if this parameter is for a nested property, this is the path of properties it takes to get there
|
||||
let pathToProperty: [Property]
|
||||
let pathToProperty: [PropertyType]
|
||||
|
||||
/// the target property this virtual parameter represents
|
||||
let targetProperty: Property
|
||||
|
@ -47,7 +47,7 @@ class VirtualParameter: Parameter {
|
|||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
|
||||
originalParameter = try container.decode(Parameter.self, forKey: .originalParameter)
|
||||
pathToProperty = try container.decode([Property].self, forKey: .pathToProperty)
|
||||
pathToProperty = try container.decode([PropertyType].self, forKey: .pathToProperty)
|
||||
targetProperty = try container.decode(Property.self, forKey: .targetProperty)
|
||||
|
||||
try super.init(from: decoder)
|
||||
|
@ -69,14 +69,14 @@ class VirtualParameter: Parameter {
|
|||
|
||||
// Default logic
|
||||
let inMethod = implementation == .method
|
||||
let notConstant = schema.type != .constant
|
||||
let notConstant = schema!.type != .constant
|
||||
let notGrouped = groupedBy == nil
|
||||
return inMethod && notConstant && notGrouped
|
||||
}
|
||||
|
||||
override internal func belongsInOptions() -> Bool {
|
||||
let inMethod = implementation == .method
|
||||
let notConstant = schema.type != .constant
|
||||
let notConstant = schema!.type != .constant
|
||||
let notFlattened = flattened != true
|
||||
let notGrouped = groupedBy == nil
|
||||
return inMethod && notConstant && notFlattened && notGrouped
|
||||
|
|
|
@ -42,6 +42,6 @@ struct ConstantViewModel {
|
|||
assert(!name.isEmpty)
|
||||
self.name = name
|
||||
self.comment = ViewModelComment(from: schema.description)
|
||||
self.defaultValue = ViewModelDefault(from: schema.value.value, isString: true)
|
||||
self.defaultValue = ViewModelDefault(from: schema.value.value, isString: true, isOptional: false)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,17 @@ struct ObjectViewModel {
|
|||
// flatten out inheritance hierarchies so we can use structs
|
||||
var props = [PropertyViewModel]()
|
||||
var consts = [ConstantViewModel]()
|
||||
for property in schema.properties ?? [] {
|
||||
let groupedProperties = schema.properties?.grouped ?? []
|
||||
assert(
|
||||
groupedProperties.count == (schema.properties?.count ?? 0),
|
||||
"Expected all properties to be group properties."
|
||||
)
|
||||
for property in groupedProperties {
|
||||
// the source of flattened parameters should not be included in the view model
|
||||
assert(property.originalParameter.count <= 1, "Expected, at most, one original parameter.")
|
||||
if property.originalParameter.first?.flattened ?? false {
|
||||
continue
|
||||
}
|
||||
if let constSchema = property.schema as? ConstantSchema {
|
||||
consts.append(ConstantViewModel(from: constSchema))
|
||||
} else {
|
||||
|
|
|
@ -165,7 +165,7 @@ struct VirtualParam {
|
|||
init(from param: VirtualParameter) {
|
||||
self.name = param.name
|
||||
self.path = param.targetProperty.name
|
||||
self.type = param.schema.swiftType(optional: !param.required)
|
||||
self.type = param.schema!.swiftType(optional: !param.required)
|
||||
self.defaultValue = param.required ? "" : " = nil"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ struct ParameterViewModel {
|
|||
self.optional = !param.required
|
||||
self.type = param.schema.swiftType(optional: optional)
|
||||
self.typeName = param.schema.swiftType(optional: false)
|
||||
self.defaultValue = ViewModelDefault(from: param.clientDefaultValue, isString: true)
|
||||
self.defaultValue = ViewModelDefault(from: param.clientDefaultValue, isString: true, isOptional: optional)
|
||||
self.comment = ViewModelComment(from: param.description)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,11 +48,20 @@ struct PropertyViewModel {
|
|||
assert(!name.isEmpty)
|
||||
self.name = name
|
||||
self.comment = ViewModelComment(from: schema.description)
|
||||
self.className = schema.schema.swiftType()
|
||||
self.className = schema.schema!.swiftType()
|
||||
self.optional = !schema.required
|
||||
self.type = optional ? "\(className)?" : className
|
||||
self.defaultValue = ViewModelDefault(from: schema.clientDefaultValue, isString: true)
|
||||
self.defaultValue = ViewModelDefault(from: schema.clientDefaultValue, isString: true, isOptional: optional)
|
||||
self.initDefaultValue = optional ? "= nil" : ""
|
||||
self.isDate = type.contains("Date")
|
||||
}
|
||||
|
||||
init(from schema: PropertyType) {
|
||||
switch schema {
|
||||
case let .regular(reg):
|
||||
self.init(from: reg)
|
||||
case let .grouped(group):
|
||||
self.init(from: group)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,8 +50,8 @@ struct ViewModelComment: CustomStringConvertible {
|
|||
struct ViewModelDefault: CustomStringConvertible {
|
||||
var description: String
|
||||
|
||||
init(from defaultValue: String?, isString: Bool) {
|
||||
self.description = ""
|
||||
init(from defaultValue: String?, isString: Bool, isOptional: Bool) {
|
||||
self.description = isOptional ? " = nil" : ""
|
||||
guard let val = defaultValue else { return }
|
||||
guard val.trimmingCharacters(in: .whitespacesAndNewlines) != "" else { return }
|
||||
self.description = isString ? " = \"\(val)\"" : " = \(val)"
|
||||
|
|
|
@ -3,7 +3,7 @@ public struct {{ model.name }}: AzureOptions {
|
|||
|
||||
{% for property in model.properties %}
|
||||
{{ property.comment }}
|
||||
public let {{ property.name }}: {{ property.type }}{{property.defaultValue}}
|
||||
public let {{ property.name }}: {{ property.type }}
|
||||
{% endfor %}
|
||||
|
||||
/// A client-generated, opaque value with 1KB character limit that is recorded in analytics logs.
|
||||
|
|
|
@ -11,7 +11,7 @@ public {{ model.objectType }} {{ model.name }} : {{ model.inheritance }} {
|
|||
// MARK: Properties
|
||||
{% for property in model.properties %}
|
||||
{{ property.comment }}
|
||||
public let {{ property.name }}: {{ property.type }}{{property.defaultValue}}
|
||||
public let {{ property.name }}: {{ property.type }}
|
||||
{% endfor %}
|
||||
|
||||
{% if model.hasConstants %}
|
||||
|
|
|
@ -49,7 +49,7 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
/// - completionHandler: A completion handler that receives a status code on
|
||||
/// success.
|
||||
public func put(
|
||||
array: [Resource]?,
|
||||
array: [Resource]? = nil,
|
||||
withOptions options: PutArrayOptions? = nil,
|
||||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
|
@ -96,6 +96,13 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
context.add(cancellationToken: options?.cancellationToken, applying: self.options)
|
||||
self.request(request, context: context) { result, httpResponse in
|
||||
let dispatchQueue = options?.dispatchQueue ?? self.commonOptions.dispatchQueue ?? DispatchQueue.main
|
||||
guard let data = httpResponse?.data else {
|
||||
let noDataError = AzureError.sdk("Response data expected but not found.")
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(noDataError), httpResponse)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
switch result {
|
||||
case .success:
|
||||
|
@ -116,9 +123,17 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
)
|
||||
}
|
||||
}
|
||||
case let .failure(error):
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(error), httpResponse)
|
||||
case .failure:
|
||||
do {
|
||||
let decoder = JSONDecoder()
|
||||
let decoded = try decoder.decode(ErrorType.self, from: data)
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.service("", decoded)), httpResponse)
|
||||
}
|
||||
} catch {
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.sdk("Decoding error.", error)), httpResponse)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -204,9 +219,17 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
}
|
||||
}
|
||||
}
|
||||
case let .failure(error):
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(error), httpResponse)
|
||||
case .failure:
|
||||
do {
|
||||
let decoder = JSONDecoder()
|
||||
let decoded = try decoder.decode(ErrorType.self, from: data)
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.service("", decoded)), httpResponse)
|
||||
}
|
||||
} catch {
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.sdk("Decoding error.", error)), httpResponse)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -219,7 +242,7 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
/// - completionHandler: A completion handler that receives a status code on
|
||||
/// success.
|
||||
public func put(
|
||||
wrappedArray: [WrappedProduct]?,
|
||||
wrappedArray: [WrappedProduct]? = nil,
|
||||
withOptions options: PutWrappedArrayOptions? = nil,
|
||||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
|
@ -266,6 +289,13 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
context.add(cancellationToken: options?.cancellationToken, applying: self.options)
|
||||
self.request(request, context: context) { result, httpResponse in
|
||||
let dispatchQueue = options?.dispatchQueue ?? self.commonOptions.dispatchQueue ?? DispatchQueue.main
|
||||
guard let data = httpResponse?.data else {
|
||||
let noDataError = AzureError.sdk("Response data expected but not found.")
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(noDataError), httpResponse)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
switch result {
|
||||
case .success:
|
||||
|
@ -286,9 +316,17 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
)
|
||||
}
|
||||
}
|
||||
case let .failure(error):
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(error), httpResponse)
|
||||
case .failure:
|
||||
do {
|
||||
let decoder = JSONDecoder()
|
||||
let decoded = try decoder.decode(ErrorType.self, from: data)
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.service("", decoded)), httpResponse)
|
||||
}
|
||||
} catch {
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.sdk("Decoding error.", error)), httpResponse)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -374,9 +412,17 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
}
|
||||
}
|
||||
}
|
||||
case let .failure(error):
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(error), httpResponse)
|
||||
case .failure:
|
||||
do {
|
||||
let decoder = JSONDecoder()
|
||||
let decoded = try decoder.decode(ErrorType.self, from: data)
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.service("", decoded)), httpResponse)
|
||||
}
|
||||
} catch {
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.sdk("Decoding error.", error)), httpResponse)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -389,7 +435,7 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
/// - completionHandler: A completion handler that receives a status code on
|
||||
/// success.
|
||||
public func put(
|
||||
dictionary: [String: FlattenedProduct]?,
|
||||
dictionary: [String: FlattenedProduct]? = nil,
|
||||
withOptions options: PutDictionaryOptions? = nil,
|
||||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
|
@ -436,6 +482,13 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
context.add(cancellationToken: options?.cancellationToken, applying: self.options)
|
||||
self.request(request, context: context) { result, httpResponse in
|
||||
let dispatchQueue = options?.dispatchQueue ?? self.commonOptions.dispatchQueue ?? DispatchQueue.main
|
||||
guard let data = httpResponse?.data else {
|
||||
let noDataError = AzureError.sdk("Response data expected but not found.")
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(noDataError), httpResponse)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
switch result {
|
||||
case .success:
|
||||
|
@ -456,9 +509,17 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
)
|
||||
}
|
||||
}
|
||||
case let .failure(error):
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(error), httpResponse)
|
||||
case .failure:
|
||||
do {
|
||||
let decoder = JSONDecoder()
|
||||
let decoded = try decoder.decode(ErrorType.self, from: data)
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.service("", decoded)), httpResponse)
|
||||
}
|
||||
} catch {
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.sdk("Decoding error.", error)), httpResponse)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -544,9 +605,17 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
}
|
||||
}
|
||||
}
|
||||
case let .failure(error):
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(error), httpResponse)
|
||||
case .failure:
|
||||
do {
|
||||
let decoder = JSONDecoder()
|
||||
let decoded = try decoder.decode(ErrorType.self, from: data)
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.service("", decoded)), httpResponse)
|
||||
}
|
||||
} catch {
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.sdk("Decoding error.", error)), httpResponse)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -559,7 +628,7 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
/// - completionHandler: A completion handler that receives a status code on
|
||||
/// success.
|
||||
public func put(
|
||||
resourceCollection: ResourceCollection?,
|
||||
resourceCollection: ResourceCollection? = nil,
|
||||
withOptions options: PutResourceCollectionOptions? = nil,
|
||||
completionHandler: @escaping HTTPResultHandler<Void>
|
||||
) {
|
||||
|
@ -606,6 +675,13 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
context.add(cancellationToken: options?.cancellationToken, applying: self.options)
|
||||
self.request(request, context: context) { result, httpResponse in
|
||||
let dispatchQueue = options?.dispatchQueue ?? self.commonOptions.dispatchQueue ?? DispatchQueue.main
|
||||
guard let data = httpResponse?.data else {
|
||||
let noDataError = AzureError.sdk("Response data expected but not found.")
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(noDataError), httpResponse)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
switch result {
|
||||
case .success:
|
||||
|
@ -626,9 +702,17 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
)
|
||||
}
|
||||
}
|
||||
case let .failure(error):
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(error), httpResponse)
|
||||
case .failure:
|
||||
do {
|
||||
let decoder = JSONDecoder()
|
||||
let decoded = try decoder.decode(ErrorType.self, from: data)
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.service("", decoded)), httpResponse)
|
||||
}
|
||||
} catch {
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.sdk("Decoding error.", error)), httpResponse)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -714,9 +798,17 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
}
|
||||
}
|
||||
}
|
||||
case let .failure(error):
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(error), httpResponse)
|
||||
case .failure:
|
||||
do {
|
||||
let decoder = JSONDecoder()
|
||||
let decoded = try decoder.decode(ErrorType.self, from: data)
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.service("", decoded)), httpResponse)
|
||||
}
|
||||
} catch {
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.sdk("Decoding error.", error)), httpResponse)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -729,7 +821,7 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
/// - completionHandler: A completion handler that receives a status code on
|
||||
/// success.
|
||||
public func put(
|
||||
simpleProduct: SimpleProduct?,
|
||||
simpleProduct: SimpleProduct? = nil,
|
||||
withOptions options: PutSimpleProductOptions? = nil,
|
||||
completionHandler: @escaping HTTPResultHandler<SimpleProduct>
|
||||
) {
|
||||
|
@ -808,9 +900,17 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
}
|
||||
}
|
||||
}
|
||||
case let .failure(error):
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(error), httpResponse)
|
||||
case .failure:
|
||||
do {
|
||||
let decoder = JSONDecoder()
|
||||
let decoded = try decoder.decode(ErrorType.self, from: data)
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.service("", decoded)), httpResponse)
|
||||
}
|
||||
} catch {
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.sdk("Decoding error.", error)), httpResponse)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -828,10 +928,10 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
/// success.
|
||||
public func postFlattenedSimpleProduct(
|
||||
productId: String,
|
||||
description: String?,
|
||||
maxProductDisplayName: String?,
|
||||
genericValue: String?,
|
||||
odataValue: String?,
|
||||
description: String? = nil,
|
||||
maxProductDisplayName: String? = nil,
|
||||
genericValue: String? = nil,
|
||||
odataValue: String? = nil,
|
||||
withOptions options: PostFlattenedSimpleProductOptions? = nil,
|
||||
completionHandler: @escaping HTTPResultHandler<SimpleProduct>
|
||||
) {
|
||||
|
@ -914,9 +1014,17 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
}
|
||||
}
|
||||
}
|
||||
case let .failure(error):
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(error), httpResponse)
|
||||
case .failure:
|
||||
do {
|
||||
let decoder = JSONDecoder()
|
||||
let decoded = try decoder.decode(ErrorType.self, from: data)
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.service("", decoded)), httpResponse)
|
||||
}
|
||||
} catch {
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.sdk("Decoding error.", error)), httpResponse)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1005,9 +1113,17 @@ public final class AutoRestResourceFlatteningTestService {
|
|||
}
|
||||
}
|
||||
}
|
||||
case let .failure(error):
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(error), httpResponse)
|
||||
case .failure:
|
||||
do {
|
||||
let decoder = JSONDecoder()
|
||||
let decoded = try decoder.decode(ErrorType.self, from: data)
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.service("", decoded)), httpResponse)
|
||||
}
|
||||
} catch {
|
||||
dispatchQueue.async {
|
||||
completionHandler(.failure(AzureError.sdk("Decoding error.", error)), httpResponse)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,6 @@ public struct FlattenParameterGroup: Codable {
|
|||
|
||||
/// Product name with value 'groupproduct'
|
||||
public let name: String
|
||||
/// Simple body product to put
|
||||
public let simpleBodyProduct: SimpleProduct?
|
||||
/// Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles.
|
||||
public let productId: String
|
||||
/// Description of product.
|
||||
|
@ -39,18 +37,16 @@ public struct FlattenParameterGroup: Codable {
|
|||
/// Initialize a `FlattenParameterGroup` structure.
|
||||
/// - Parameters:
|
||||
/// - name: Product name with value 'groupproduct'
|
||||
/// - simpleBodyProduct: Simple body product to put
|
||||
/// - productId: Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles.
|
||||
/// - description: Description of product.
|
||||
/// - maxProductDisplayName: Display name of product.
|
||||
/// - genericValue: Generic URL value.
|
||||
/// - odataValue: URL value.
|
||||
public init(
|
||||
name: String, simpleBodyProduct: SimpleProduct? = nil, productId: String, description: String? = nil,
|
||||
maxProductDisplayName: String? = nil, genericValue: String? = nil, odataValue: String? = nil
|
||||
name: String, productId: String, description: String? = nil, maxProductDisplayName: String? = nil,
|
||||
genericValue: String? = nil, odataValue: String? = nil
|
||||
) {
|
||||
self.name = name
|
||||
self.simpleBodyProduct = simpleBodyProduct
|
||||
self.productId = productId
|
||||
self.description = description
|
||||
self.maxProductDisplayName = maxProductDisplayName
|
||||
|
@ -62,7 +58,6 @@ public struct FlattenParameterGroup: Codable {
|
|||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case name
|
||||
case simpleBodyProduct
|
||||
case productId
|
||||
case description
|
||||
case maxProductDisplayName
|
||||
|
@ -74,7 +69,6 @@ public struct FlattenParameterGroup: Codable {
|
|||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
self.name = try container.decode(String.self, forKey: .name)
|
||||
self.simpleBodyProduct = try? container.decode(SimpleProduct.self, forKey: .simpleBodyProduct)
|
||||
self.productId = try container.decode(String.self, forKey: .productId)
|
||||
self.description = try? container.decode(String.self, forKey: .description)
|
||||
self.maxProductDisplayName = try? container.decode(String.self, forKey: .maxProductDisplayName)
|
||||
|
@ -86,7 +80,6 @@ public struct FlattenParameterGroup: Codable {
|
|||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(name, forKey: .name)
|
||||
if simpleBodyProduct != nil { try? container.encode(simpleBodyProduct, forKey: .simpleBodyProduct) }
|
||||
try container.encode(productId, forKey: .productId)
|
||||
if description != nil { try? container.encode(description, forKey: .description) }
|
||||
if maxProductDisplayName != nil { try? container.encode(maxProductDisplayName, forKey: .maxProductDisplayName) }
|
||||
|
|
|
@ -68,9 +68,9 @@ public final class AutoRestUrlTestClient: PipelineClient {
|
|||
// /// should contain value null
|
||||
public var globalStringQuery: String?
|
||||
|
||||
public lazy var queries: Queries = Queries(client: self)
|
||||
public lazy var pathitems: PathItems = PathItems(client: self)
|
||||
public lazy var paths: Paths = Paths(client: self)
|
||||
public lazy var pathitems: PathItems = PathItems(client: self)
|
||||
public lazy var queries: Queries = Queries(client: self)
|
||||
|
||||
// MARK: Public Client Methods
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче