diff --git a/README.md b/README.md index bf1ad1d..fda404c 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ extension ApplicationError : WebSerializable{ ```Swift let basic = try? BasicStruct( - "http://localhost:8080/basic", + path: "http://localhost:8080/basic", body: RequestStruct(value: "hello") ) ``` @@ -70,7 +70,7 @@ let basic = try? BasicStruct( ```Swift do{ let _ = try ErrorStruct( - "http://localhost:8080/error", + path: "http://localhost:8080/error", body: RequestStruct(value: "hello") ) } diff --git a/Sources/WebStruct.swift b/Sources/WebStruct.swift index 183cba2..bc6b761 100644 --- a/Sources/WebStruct.swift +++ b/Sources/WebStruct.swift @@ -85,8 +85,8 @@ public protocol WebInitializable : WebSerializable { Default implement for WebInitializable */ extension WebInitializable{ - public init(_ path:String, body:Self.bodyType? = nil) throws { - self = try WebStruct().get( path, body: body) + public init(path:String, body:Self.bodyType? = nil) throws { + self = try WebStruct().get(path: path, body: body) } // default values @@ -98,7 +98,6 @@ extension WebInitializable{ public static var session:URLSession { return URLSession(configuration: URLSessionConfiguration.default, delegate: nil, delegateQueue: nil) } - } @@ -109,7 +108,7 @@ fileprivate struct WebStruct { fileprivate init(){} - fileprivate func get(_ path:String, body:BodyT?) throws -> GenT { + fileprivate func get(path:String, body:BodyT?) throws -> GenT { // setup for request var request = GenT.request diff --git a/Tests/WebStructTests/OpenWebAPITests.swift b/Tests/WebStructTests/OpenWebAPITests.swift index 13080b5..61bb02e 100644 --- a/Tests/WebStructTests/OpenWebAPITests.swift +++ b/Tests/WebStructTests/OpenWebAPITests.swift @@ -28,17 +28,15 @@ class OpenWebAPITests: XCTestCase { } func testItunesSearch() { - guard let search = try? iTunesSearch( - "https://itunes.apple.com/search?term=twitter&media=software&entity=software&limit=10" - ) else { fatalError() } + guard let search = try? iTunesSearch(path: "https://itunes.apple.com/search?term=twitter&media=software&entity=software&limit=10") else{ + fatalError() + } XCTAssertEqual( search.resultCount, 10 ) } func testItunesSearchTimeout() { do{ - let _ = try iTunesTimeoutSearch( - "https://itunes.apple.com/search?term=twitter&media=software&entity=software&limit=10" - ) + let _ = try iTunesTimeoutSearch(path: "https://itunes.apple.com/search?term=twitter&media=software&entity=software&limit=10") } catch let error as WebStruct.Error{ if case .network(let e) = error{ diff --git a/Tests/WebStructTests/StaticJsonFileTests.swift b/Tests/WebStructTests/StaticJsonFileTests.swift index e8cc934..733e3fb 100644 --- a/Tests/WebStructTests/StaticJsonFileTests.swift +++ b/Tests/WebStructTests/StaticJsonFileTests.swift @@ -29,7 +29,7 @@ class StaticJsonFileTests: XCTestCase { func testGetJSONFile() { let file:[Place] - do{ file = try [Place]("http://motorhomes.addli.jp/assets/json/places.json") }catch{ + do{ file = try [Place](path: "http://motorhomes.addli.jp/assets/json/places.json") }catch{ print(error) fatalError() } diff --git a/Tests/WebStructTests/WebStructTests.swift b/Tests/WebStructTests/WebStructTests.swift index d0d4a74..8742af9 100644 --- a/Tests/WebStructTests/WebStructTests.swift +++ b/Tests/WebStructTests/WebStructTests.swift @@ -31,7 +31,7 @@ class WebStructTests: XCTestCase { func testBasicInitalize() { let basic = try? BasicStruct( - "http://localhost:8080/basic", + path: "http://localhost:8080/basic", body: RequestStruct(value: "hello") ) XCTAssert(basic != nil,"test is nil.") @@ -40,7 +40,7 @@ class WebStructTests: XCTestCase { func testInitializationFailedServersideError(){ do{ let _ = try ErrorStruct( - "http://localhost:8080/error", + path: "http://localhost:8080/error", body: RequestStruct(value: "hello") ) } @@ -72,7 +72,7 @@ class WebStructTests: XCTestCase { func testInitializationFailedDueToTimeout(){ do{ let _ = try CustomRequestStruct( - "http://localhost:8080/timeout", + path: "http://localhost:8080/timeout", body: RequestStruct(value: "hello") ) } @@ -93,7 +93,7 @@ class WebStructTests: XCTestCase { let st:CustomHeadersStruct do{ st = try CustomHeadersStruct( - "http://localhost:8080/headers", + path: "http://localhost:8080/headers", body: RequestStruct(value: "hello") ) }