             Kitura.start()
         }
 
-        sectionsAssertions(json: router.swaggerJSON)
-        appleDefinitionsAssertions(json: router.swaggerJSON)
-        pearDefinitionsAssertions(json: router.swaggerJSON)
-        uglifruitDefinitionsAssertions(json: router.swaggerJSON)
-        pathAssertions(json: router.swaggerJSON)
-        pathContentAssertions1(json: router.swaggerJSON)
-        pathContentAssertions2(json: router.swaggerJSON)
-        pathContentAssertions3(json: router.swaggerJSON)
-        pathContentAssertions4(json: router.swaggerJSON)
+        if let jsonString = router.swaggerJSON {
+            guard let data = jsonString.data(using: String.Encoding.utf8, allowLossyConversion: false) else {
+                XCTFail("got unexpected nil from router.swaggerJSON")
+                return
+            }
+            guard let json = try? JSONSerialization.jsonObject(with: data, options: []) else {
+                XCTFail("got unexpected nil from router.swaggerJSON")
+                return
+            }
+            guard let dict = json as? [String: Any] else {
+                XCTFail("got unexpected nil from router.swaggerJSON")
+                return
+            }
+
+            // test for document sections
+            sectionsAssertions(dict: dict)
+        } else {
+            XCTFail("got unexpected nil from router.swaggerJSON")
+        }
 
         requestQueue.async() {
             Kitura.stop()


        router.put("/me/puts", handler: putSingleAppleHandlerStringId)
        router.put("/me/puti", handler: putSingleAppleHandlerIntId)

        setupServerAndExpectations(router: router, expectStart: true, expectStop: true, expectFail: false)

        let requestQueue = DispatchQueue(label: "Request queue")

    }
}

// handler to use in the tests
func deleteHandler(completion: (RequestError?) -> Void ) -> Void {
    completion(nil)
}

func getPearHandler(completion: (Pear?, RequestError?) -> Void ) -> Void {
    completion(nil, nil)
}

func getAppleHandler(completion: (Apple?, RequestError?) -> Void ) -> Void {
    completion(nil, nil)
}

func getArrayAppleHandler(completion: ([Apple]?, RequestError?) -> Void ) -> Void {
    completion(nil, nil)
}

func getSingleAppleHandler(id: Int, completion: (Apple?, RequestError?) -> Void) -> Void {
    completion(nil, nil)
}

func getSingleArrayAppleHandler(completion: ([(Int, Apple)]?, RequestError?) -> Void) -> Void {
    completion(nil, nil)
}

func postAppleHandler(posted: Apple, completion: (Apple?, RequestError?) -> Void ) -> Void {
    completion(nil, nil)
}

func postSingleAppleHandler(posted: Apple, completion: (Int?, Apple?, RequestError?) -> Void ) -> Void {
    completion(nil, nil, nil)
}

func putSingleAppleHandlerStringId(id: String, posted: Apple, completion: (Apple?, RequestError?) -> Void ) -> Void {
    completion(nil, nil)
}

func putSingleAppleHandlerIntId(id: Int, posted: Apple, completion: (Apple?, RequestError?) -> Void ) -> Void {
    completion(nil, nil)
}

func patchSingleAppleHandler(id: Int, posted: Apple, completion: (Apple?, RequestError?) -> Void ) -> Void {
    completion(nil, nil)
}

class TestSwaggerGeneration: KituraTest {

    static var allTests: [(String, (TestSwaggerGeneration) -> () throws -> Void)] {
        return [
            ("testSwaggerDefinitions", testSwaggerDefinitions),
            ("testSwaggerSections", testSwaggerSections),
            ("testSwaggerContent", testSwaggerContent),
        ]
    }

    let httpPort = 8080
    let router = Router()

    override func setUp() {
        super.setUp()
        stopServer() // stop common server so we can run these tests
        router.delete("/me/pear", handler: deleteHandler)
        router.get("/me/pear", handler: getPearHandler)
        router.get("/me/apple", handler: getAppleHandler)
