Merge new changes from sacheu/pathitems to master (#228)
* Remvoe UserInterfaceState.xcuserstate from version control * Support PathItems test cases * Remove default empty string in query param * Address PR feedback * Address PR feedback * Support encode unixTime in request body (#225) * Add support to encode UnixTime * Address PR Feedback * Address PR feedback * Address PR feedback * Address PR feedback * Address PR feedback * Address PR feedback * Address PR feedback * Remove constantValue in KeyValueModel * Simpify format value for type * Simpify format value for type * Remove source in KeyValueModel * Address PR feedback * Add generated code per new change * Remove unnecessary stencil file * Refactor KeyValueViewModel.swift * Remove unused condition in OperationMethodDecodingSnippet.stencil * Simplify KeyValueDecodeStrategy * Support $host in generated code (#226) * current progress * Support Host in generated code * Support Host in generated code * Address PR feedback * Address PR feedback * Address PR feedback * Fix xc projec file
This commit is contained in:
Родитель
5bdacda557
Коммит
e4a0f59797
|
@ -348,6 +348,7 @@
|
|||
dstPath = "";
|
||||
dstSubfolderSpec = 7;
|
||||
files = (
|
||||
F170D49A253F8DEC00A569A0 /* OperationOptionalQueryParamSnippet.stencil in CopyFiles */,
|
||||
F1731F322522E531006CDED8 /* MethodOptionsSnippet.stencil in CopyFiles */,
|
||||
F1731F332522E531006CDED8 /* NamedMethodOptionsFile.stencil in CopyFiles */,
|
||||
F1731F342522E531006CDED8 /* OperationMethodDecodingSnippet.stencil in CopyFiles */,
|
||||
|
|
|
@ -32,12 +32,7 @@ class AutoRestIntegerTest: XCTestCase {
|
|||
var client: AutoRestIntegerTestClient!
|
||||
|
||||
override func setUpWithError() throws {
|
||||
guard let baseUrl = URL(string: "http://localhost:3000") else {
|
||||
fatalError("Unable to form base URL")
|
||||
}
|
||||
|
||||
client = try AutoRestIntegerTestClient(
|
||||
baseUrl: baseUrl,
|
||||
authPolicy: AnonymousAccessPolicy(),
|
||||
withOptions: AutoRestIntegerTestClientOptions()
|
||||
)
|
||||
|
|
|
@ -32,12 +32,7 @@ class AutoRestHeadTest: XCTestCase {
|
|||
var client: AutoRestHeadTestClient!
|
||||
|
||||
override func setUpWithError() throws {
|
||||
guard let baseUrl = URL(string: "http://localhost:3000") else {
|
||||
fatalError("Unable to form base URL")
|
||||
}
|
||||
|
||||
client = try AutoRestHeadTestClient(
|
||||
baseUrl: baseUrl,
|
||||
authPolicy: AnonymousAccessPolicy(),
|
||||
withOptions: AutoRestHeadTestClientOptions()
|
||||
)
|
||||
|
|
|
@ -33,12 +33,7 @@ class AutoRestReportTest: XCTestCase {
|
|||
var client: AutoRestReportClient!
|
||||
|
||||
override func setUpWithError() throws {
|
||||
guard let baseUrl = URL(string: "http://localhost:3000") else {
|
||||
fatalError("Unable to form base URL")
|
||||
}
|
||||
|
||||
client = try AutoRestReportClient(
|
||||
baseUrl: baseUrl,
|
||||
authPolicy: AnonymousAccessPolicy(),
|
||||
withOptions: AutoRestReportClientOptions()
|
||||
)
|
||||
|
|
|
@ -33,12 +33,7 @@ class AutoRestResourceFlatteningTest: XCTestCase {
|
|||
var client: AutoRestResourceFlatteningTestClient!
|
||||
|
||||
override func setUpWithError() throws {
|
||||
guard let baseUrl = URL(string: "http://localhost:3000") else {
|
||||
fatalError("Unable to form base URL")
|
||||
}
|
||||
|
||||
client = try AutoRestResourceFlatteningTestClient(
|
||||
baseUrl: baseUrl,
|
||||
authPolicy: AnonymousAccessPolicy(),
|
||||
withOptions: AutoRestResourceFlatteningTestClientOptions()
|
||||
)
|
||||
|
|
|
@ -33,12 +33,7 @@ class AutoRestSwaggerBatFileTest: XCTestCase {
|
|||
var client: AutoRestSwaggerBatFileClient!
|
||||
|
||||
override func setUpWithError() throws {
|
||||
guard let baseUrl = URL(string: "http://localhost:3000") else {
|
||||
fatalError("Unable to form base URL")
|
||||
}
|
||||
|
||||
client = try AutoRestSwaggerBatFileClient(
|
||||
baseUrl: baseUrl,
|
||||
authPolicy: AnonymousAccessPolicy(),
|
||||
withOptions: AutoRestSwaggerBatFileClientOptions()
|
||||
)
|
||||
|
|
|
@ -35,13 +35,8 @@ class AutoRestUrlTest: XCTestCase {
|
|||
var client: AutoRestUrlTestClient!
|
||||
|
||||
override func setUpWithError() throws {
|
||||
guard let baseUrl = URL(string: "http://localhost:3000") else {
|
||||
fatalError("Unable to form base URL")
|
||||
}
|
||||
|
||||
client = try AutoRestUrlTestClient(
|
||||
globalStringPath: "globalStringPath",
|
||||
baseUrl: baseUrl,
|
||||
authPolicy: AnonymousAccessPolicy(),
|
||||
withOptions: AutoRestUrlTestClientOptions()
|
||||
)
|
||||
|
|
|
@ -37,7 +37,7 @@ class XmsErrorResponseExtensionsTest: XCTestCase {
|
|||
}
|
||||
|
||||
client = try XmsErrorResponseExtensionsClient(
|
||||
baseUrl: baseUrl,
|
||||
url: baseUrl,
|
||||
authPolicy: AnonymousAccessPolicy(),
|
||||
withOptions: XmsErrorResponseExtensionsClientOptions()
|
||||
)
|
||||
|
|
|
@ -40,6 +40,7 @@ struct ServiceClientFileViewModel {
|
|||
let namedOperationGroups: [String: OperationGroupViewModel]
|
||||
// A key,Value pairs of all the named operation group for stencil template engine
|
||||
let namedOperationGroupShortcuts: [KeyValueViewModel]
|
||||
let host: String
|
||||
|
||||
init(from model: CodeModel) {
|
||||
self.name = "\(model.packageName)Client"
|
||||
|
@ -61,14 +62,33 @@ struct ServiceClientFileViewModel {
|
|||
self.apiVersionName = "v\(apiVersion.replacingOccurrences(of: "-", with: ""))"
|
||||
self.paging = model.pagingNames
|
||||
self.protocols = paging != nil ? "PipelineClient, PageableClient" : "PipelineClient"
|
||||
var globalParameters = [ParameterViewModel]()
|
||||
for globalParameter in model.globalParameters ?? [] where !globalParameter.name.starts(with: "$") {
|
||||
globalParameters.append(ParameterViewModel(from: globalParameter))
|
||||
}
|
||||
self.globalParameters = globalParameters
|
||||
|
||||
(self.globalParameters, self.host) = resolveGlobalParameters(from: model)
|
||||
|
||||
for key in namedOperationGroups.keys {
|
||||
namedOperationGroupShortcuts.append(KeyValueViewModel(key: key, value: key.lowercased()))
|
||||
}
|
||||
self.namedOperationGroupShortcuts = namedOperationGroupShortcuts.sorted()
|
||||
}
|
||||
}
|
||||
|
||||
func resolveGlobalParameters(from model: CodeModel) -> ([ParameterViewModel], String) {
|
||||
var globalParameters = [ParameterViewModel]()
|
||||
var host: String?
|
||||
var hostString: String
|
||||
for globalParameter in model.globalParameters ?? [] {
|
||||
if globalParameter.name == "$host" {
|
||||
host = globalParameter.value.clientDefaultValue
|
||||
} else {
|
||||
globalParameters.append(ParameterViewModel(from: globalParameter))
|
||||
}
|
||||
}
|
||||
|
||||
if let hostValue = host {
|
||||
hostString = "\"\(hostValue)\""
|
||||
} else {
|
||||
hostString = ""
|
||||
}
|
||||
|
||||
return (globalParameters, hostString)
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ public final class {{ model.name }}: {{ model.protocols }} {
|
|||
public let options: {{ model.name }}Options
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
/// Create a {{ model.name }} client.
|
||||
/// - Parameters:
|
||||
/// - baseUrl: Base URL for the {{ model.name }}.
|
||||
|
@ -43,10 +42,20 @@ public final class {{ model.name }}: {{ model.protocols }} {
|
|||
{{ param.name }} : {{ param.type }},
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if model.host != "" %}
|
||||
url: URL? = nil,
|
||||
{% else %}
|
||||
baseUrl: URL,
|
||||
{% endif %}
|
||||
authPolicy: Authenticating,
|
||||
withOptions options: {{ model.name }}Options
|
||||
) throws {
|
||||
{% if model.host != "" %}
|
||||
let defaultHost = URL(string: {{ model.host }})
|
||||
guard let baseUrl = url ?? defaultHost else {
|
||||
fatalError("Unable to determine base URL. ")
|
||||
}
|
||||
{% endif %}
|
||||
{% for param in model.globalParameters %}
|
||||
{% if param.optional == false %}
|
||||
self.{{ param.name }} = {{ param.name }}
|
||||
|
|
|
@ -39,10 +39,14 @@ public final class AutoRestSwaggerBatFileClient: PipelineClient {
|
|||
/// - authPolicy: An `Authenticating` policy to use for authenticating client requests.
|
||||
/// - options: Options used to configure the client.
|
||||
public init(
|
||||
baseUrl: URL,
|
||||
url: URL? = nil,
|
||||
authPolicy: Authenticating,
|
||||
withOptions options: AutoRestSwaggerBatFileClientOptions
|
||||
) throws {
|
||||
let defaultHost = URL(string: "http://localhost:3000")
|
||||
guard let baseUrl = url ?? defaultHost else {
|
||||
fatalError("Unable to determine base URL. ")
|
||||
}
|
||||
self.options = options
|
||||
super.init(
|
||||
baseUrl: baseUrl,
|
||||
|
|
|
@ -39,10 +39,14 @@ public final class AutoRestIntegerTestClient: PipelineClient {
|
|||
/// - authPolicy: An `Authenticating` policy to use for authenticating client requests.
|
||||
/// - options: Options used to configure the client.
|
||||
public init(
|
||||
baseUrl: URL,
|
||||
url: URL? = nil,
|
||||
authPolicy: Authenticating,
|
||||
withOptions options: AutoRestIntegerTestClientOptions
|
||||
) throws {
|
||||
let defaultHost = URL(string: "http://localhost:3000")
|
||||
guard let baseUrl = url ?? defaultHost else {
|
||||
fatalError("Unable to determine base URL. ")
|
||||
}
|
||||
self.options = options
|
||||
super.init(
|
||||
baseUrl: baseUrl,
|
||||
|
|
|
@ -39,10 +39,14 @@ public final class AutoRestHeadTestClient: PipelineClient {
|
|||
/// - authPolicy: An `Authenticating` policy to use for authenticating client requests.
|
||||
/// - options: Options used to configure the client.
|
||||
public init(
|
||||
baseUrl: URL,
|
||||
url: URL? = nil,
|
||||
authPolicy: Authenticating,
|
||||
withOptions options: AutoRestHeadTestClientOptions
|
||||
) throws {
|
||||
let defaultHost = URL(string: "http://localhost:3000")
|
||||
guard let baseUrl = url ?? defaultHost else {
|
||||
fatalError("Unable to determine base URL. ")
|
||||
}
|
||||
self.options = options
|
||||
super.init(
|
||||
baseUrl: baseUrl,
|
||||
|
|
|
@ -39,10 +39,14 @@ public final class AutoRestResourceFlatteningTestClient: PipelineClient {
|
|||
/// - authPolicy: An `Authenticating` policy to use for authenticating client requests.
|
||||
/// - options: Options used to configure the client.
|
||||
public init(
|
||||
baseUrl: URL,
|
||||
url: URL? = nil,
|
||||
authPolicy: Authenticating,
|
||||
withOptions options: AutoRestResourceFlatteningTestClientOptions
|
||||
) throws {
|
||||
let defaultHost = URL(string: "http://localhost:3000")
|
||||
guard let baseUrl = url ?? defaultHost else {
|
||||
fatalError("Unable to determine base URL. ")
|
||||
}
|
||||
self.options = options
|
||||
super.init(
|
||||
baseUrl: baseUrl,
|
||||
|
|
|
@ -39,10 +39,14 @@ public final class AutoRestReportClient: PipelineClient {
|
|||
/// - authPolicy: An `Authenticating` policy to use for authenticating client requests.
|
||||
/// - options: Options used to configure the client.
|
||||
public init(
|
||||
baseUrl: URL,
|
||||
url: URL? = nil,
|
||||
authPolicy: Authenticating,
|
||||
withOptions options: AutoRestReportClientOptions
|
||||
) throws {
|
||||
let defaultHost = URL(string: "http://localhost:3000")
|
||||
guard let baseUrl = url ?? defaultHost else {
|
||||
fatalError("Unable to determine base URL. ")
|
||||
}
|
||||
self.options = options
|
||||
super.init(
|
||||
baseUrl: baseUrl,
|
||||
|
|
|
@ -40,10 +40,14 @@ public final class AutoRestUrlTestClient: PipelineClient {
|
|||
/// - options: Options used to configure the client.
|
||||
public init(
|
||||
globalStringPath: String,
|
||||
baseUrl: URL,
|
||||
url: URL? = nil,
|
||||
authPolicy: Authenticating,
|
||||
withOptions options: AutoRestUrlTestClientOptions
|
||||
) throws {
|
||||
let defaultHost = URL(string: "http://localhost:3000")
|
||||
guard let baseUrl = url ?? defaultHost else {
|
||||
fatalError("Unable to determine base URL. ")
|
||||
}
|
||||
self.globalStringPath = globalStringPath
|
||||
self.options = options
|
||||
super.init(
|
||||
|
|
|
@ -39,10 +39,14 @@ public final class XmsErrorResponseExtensionsClient: PipelineClient {
|
|||
/// - authPolicy: An `Authenticating` policy to use for authenticating client requests.
|
||||
/// - options: Options used to configure the client.
|
||||
public init(
|
||||
baseUrl: URL,
|
||||
url: URL? = nil,
|
||||
authPolicy: Authenticating,
|
||||
withOptions options: XmsErrorResponseExtensionsClientOptions
|
||||
) throws {
|
||||
let defaultHost = URL(string: "http://localhost")
|
||||
guard let baseUrl = url ?? defaultHost else {
|
||||
fatalError("Unable to determine base URL. ")
|
||||
}
|
||||
self.options = options
|
||||
super.init(
|
||||
baseUrl: baseUrl,
|
||||
|
|
Загрузка…
Ссылка в новой задаче