Skip to content

Instantly share code, notes, and snippets.

@mattpolzin
Last active March 21, 2021 21:21
Show Gist options
  • Save mattpolzin/b8cf851cb2d61321909ce7d54d3f0a1e to your computer and use it in GitHub Desktop.
Save mattpolzin/b8cf851cb2d61321909ce7d54d3f0a1e to your computer and use it in GitHub Desktop.
web hooks encode test tweaks
func test_webhooks_encode() throws {
let op = OpenAPI.Operation(responses: [:])
let document = OpenAPI.Document(
info: .init(title: "API", version: "1.0"),
servers: [],
paths: [:],
webhooks: [
"webhook-test": .init(get: op, put: op, post: op, delete: op, options: op, head: op, patch: op, trace: op)
],
components: .noComponents,
externalDocs: .init(url: URL(string: "http://google.com")!)
)
let encodedDocument = try orderUnstableTestStringFromEncoding(of: document)
let documentJSON: String? =
"""
{
"externalDocs" : {
"url" : "http:\\/\\/google.com"
},
"info" : {
"title" : "API",
"version" : "1.0"
},
"openapi" : "3.0.0",
"paths" : {
},
"webhooks" : {
"webhook-test" : {
"delete" : {
"responses" : {
}
},
"get" : {
"responses" : {
}
},
"head" : {
"responses" : {
}
},
"options" : {
"responses" : {
}
},
"patch" : {
"responses" : {
}
},
"post" : {
"responses" : {
}
},
"put" : {
"responses" : {
}
},
"trace" : {
"responses" : {
}
}
}
}
}
"""
assertJSONEquivalent(encodedDocument, documentJSON)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment