Updated Request Matching (markdown)

Stef Heyenrath
2023-08-03 15:52:21 +02:00
parent f907d915f2
commit d5f36df5e6

@@ -93,7 +93,7 @@ At this moment these matchers are supported:
* [ExactMatcher](https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching#exact-matcher-exactmatcher)
* [LinqMatcher](https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching#dynamic-linq-linqmatcher)
* [CSharpCodeMatcher](https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching#csharp-code-csharpcodematcher)
* [GraphQLMatcher](https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching#graphql-schema-GraphQLMatcher)
* [GraphQLMatcher](https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching-GraphQLMatcher)
* [JsonMatcher](https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching-JsonMatcher)
* [JsonPartialMatcher](https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching-JsonPartialMatcher)
* [JsonPartialWildcardMatcher](https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching-JsonPartialWildcardMatcher)
@@ -250,81 +250,6 @@ server
}
```
## GraphQL Schema (GraphQLMatcher)
Can be used to match a GraphQL Query or Mutation using GraphQAL Schema.
#### C# option
```csharp
var TestSchema = @"
input MessageInput {
content: String
author: String
}
type Message {
id: ID!
content: String
author: String
}
type Mutation {
createMessage(input: MessageInput): Message
updateMessage(id: ID!, input: MessageInput): Message
}
type Query {
greeting:String
students:[Student]
studentById(id:ID!):Student
}
type Student {
id:ID!
firstName:String
lastName:String
fullName:String
}";
var server = WireMockServer.Start();
server
.Given(Request.Create()
.WithPath("/graphql")
.UsingPost()
.WithGraphQLSchema(TestSchema)
)
.RespondWith(Response.Create()
.WithBody("GraphQL is ok")
);
```
#### JSON Mapping option
``` json
{
"Guid": "5a36d1c1-11df-4976-90f9-22cae5dadb38",
"UpdatedAt": "2023-07-08T17:02:06.1072879Z",
"Request": {
"Path": {
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "/graphql",
"IgnoreCase": false
}
]
},
"Methods": [
"POST"
],
"Body": {
"Matcher": {
"Name": "GraphQLMatcher",
"Pattern": "\r\n input MessageInput {\r\n content: String\r\n author: String\r\n }\r\n\r\n type Message {\r\n id: ID!\r\n content: String\r\n author: String\r\n }\r\n\r\n type Mutation {\r\n createMessage(input: MessageInput): Message\r\n updateMessage(id: ID!, input: MessageInput): Message\r\n }\r\n\r\n type Query {\r\n greeting:String\r\n students:[Student]\r\n studentById(id:ID!):Student\r\n }\r\n\r\n type Student {\r\n id:ID!\r\n firstName:String\r\n lastName:String\r\n fullName:String \r\n }"
}
}
}
}
```
## CSharp Code (CSharpCodeMatcher)
*Advanced!* With this matcher you can use complex C# code to match an JObject or string value.
* You need to include the NuGet package [WireMock.Net.Matchers.CSharpCode](https://www.nuget.org/packages/WireMock.Net.Matchers.CSharpCode/)