Last active
March 21, 2021 21:21
-
-
Save mattpolzin/b8cf851cb2d61321909ce7d54d3f0a1e to your computer and use it in GitHub Desktop.
web hooks encode test tweaks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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