File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 3333
3434import Foundation
3535
36+ @available ( * , deprecated, message: " Use JSONBodyPattern " )
3637public struct JSONPredicatePattern : HTTPBodyPattern {
3738
3839 #if compiler(>=6)
@@ -55,8 +56,10 @@ public struct JSONPredicatePattern: HTTPBodyPattern {
5556 }
5657}
5758
59+ @available ( * , deprecated, message: " Use JSONBodyPattern " )
5860public extension HTTPBodyPattern where Self == JSONPredicatePattern {
5961
62+ @available ( * , deprecated, message: " Use JSONBodyPattern " )
6063 static func json( where condition: String ) -> JSONPredicatePattern {
6164 JSONPredicatePattern ( NSPredicate ( format: condition) )
6265 }
Original file line number Diff line number Diff line change @@ -302,10 +302,13 @@ public protocol HTTPBodyPattern: Sendable {
302302}
303303```
304304
305- Darwin platforms can pattern match a JSON body with an [ ` NSPredicate ` ] ( https://developer.apple.com/documentation/foundation/nspredicate ) :
305+ JSON request bodies can be matched using a [ JSONPath ] ( https://en.wikipedia.org/wiki/JSONPath ) expression :
306306
307307``` swift
308- let route = HTTPRoute (" POST *" , body : .json (where : " food == 'fish'" ))
308+ let route = HTTPRoute (
309+ " POST *" ,
310+ jsonBody : { $0 [" $.food" ] == " chips" }
311+ )
309312```
310313``` json
311314{"side" : " chips" , "food" : " fish" }
You can’t perform that action at this time.
0 commit comments