diff --git a/_data/doc-categories.yml b/_data/doc-categories.yml index d3bc77e4..78468c4d 100644 --- a/_data/doc-categories.yml +++ b/_data/doc-categories.yml @@ -52,20 +52,21 @@ record-playback: pages: - record-playback +protocols: + title: Protocols + pages: + - webhooks-and-callbacks + - grpc + - solutions/graphql + - https + configuration: title: Advanced use-cases pages: - - https - multi-domain-mocking - advanced/deploy-to-servlet-container - advanced/java7 -protocols: - title: Protocols - pages: - - webhooks-and-callbacks - - grpc - extensibility: title: Extensibility link: /docs/extending-wiremock/ diff --git a/_docs/grpc.md b/_docs/grpc.md index 6dc515ce..7d264bc3 100644 --- a/_docs/grpc.md +++ b/_docs/grpc.md @@ -1,17 +1,26 @@ --- layout: docs -title: gRPC -meta_title: gRPC +title: Mocking gRPC services +meta_title: Mocking gRPC services description: Mocking gRPC services with WireMock +og_image: solutions/grpc/wiremock_grpc_opengraph.png +header: + image: solutions/grpc/header.png +redirect_from: +- "/grpc.html" +- "/grpc/" --- -WireMock 3.2.0+ supports mocking of gRPC services via an extension. +WireMock 3.2.0+ supports mocking of gRPC services via the +[WireMock extension for gRPC](https://github.com/wiremock/wiremock-grpc-extension). The extension scans for descriptor files (generated from the service's `.proto` files) in the `grpc` subdirectory of WireMock's root. Using these, it converts incoming messages to JSON before passing them to WireMock's core stubbing system which allows the existing JSON matchers to be used when matching requests. It also converts JSON responses back into proto messages so that all of WireMock's response definition features including templating can be used. + + The extension also adds a Java DSL that works with the Java classes generated by `protoc`, while also providing a more gRPC idiomatic way of defining stubs. ## Java usage @@ -163,4 +172,6 @@ gRPC stubs are defined using WireMock's standard JSON format. Requests should al } ``` +## More Demos + For more see the [standalone demo project](https://github.com/wiremock/wiremock-grpc-demos/tree/main/standalone). \ No newline at end of file diff --git a/_docs/index.html b/_docs/index.html index 9ace5128..01f3e013 100644 --- a/_docs/index.html +++ b/_docs/index.html @@ -107,6 +107,10 @@
+ WireMock can serve all HTTP-based protocols and REST API. + Through built-in features and extensions, + it provides additional capabilities for widely used protocols. +
+ + +diff --git a/_docs/solutions/graphql.md b/_docs/solutions/graphql.md new file mode 100644 index 00000000..24b0f91e --- /dev/null +++ b/_docs/solutions/graphql.md @@ -0,0 +1,45 @@ +--- +layout: solution +title: "WireMock and GraphQL" +meta_title: "GraphQL Solutions | WireMock" +description: "Additional solutions for WireMock when using Golang" +logo: /images/logos/technology/graphql.svg +og_image: solutions/graphql/wiremock_graphql_opengraph.png +redirect_from: +- "/graphql.html" +- "/graphql/" +hide-disclaimer: true +--- + +## WireMock Extension + +There is a [GraphQL extension for WireMock](https://github.com/wiremock/wiremock-graphql-extension) +that allows semantically matching GraphQL queries, +regardless of the order of the fields in the original request. +It brings powers of request matching and response templating to the +[GraphQL](https://graphql.org/) query language. + +Example: + +```kotlin +import com.github.tomakehurst.wiremock.client.WireMock +import com.github.tomakehurst.wiremock.client.WireMock.* +import io.github.nilwurtz.GraphqlBodyMatcher + +fun registerGraphQLWiremock(json: String) { + WireMock(8080).register( + post(urlPathEqualTo(endPoint)) + .andMatching(GraphqlBodyMatcher.extensionName, GraphqlBodyMatcher.withRequest(json)) + .willReturn( + aResponse() + .withStatus(200) + ) + ) +} +``` + +## Read More + +- [GraphQL API mocking with the new WireMock extension](https://www.wiremock.io/post/graphql-api-mocking-with-the-new-wiremock-extension?utm_medium=referral&utm_source=wiremock.org&utm_content=solution-page) + blogpost by Eiki Hayashi +- [GitHub repository with documentation](https://github.com/wiremock/wiremock-graphql-extension) diff --git a/images/logos/technology/graphql.svg b/images/logos/technology/graphql.svg new file mode 100644 index 00000000..779374f7 --- /dev/null +++ b/images/logos/technology/graphql.svg @@ -0,0 +1,8 @@ + + + \ No newline at end of file diff --git a/images/logos/technology/grpc.png b/images/logos/technology/grpc.png new file mode 100644 index 00000000..30061b6a Binary files /dev/null and b/images/logos/technology/grpc.png differ diff --git a/images/logos/technology/http.svg b/images/logos/technology/http.svg new file mode 100644 index 00000000..1a1658a0 --- /dev/null +++ b/images/logos/technology/http.svg @@ -0,0 +1,28 @@ + + + \ No newline at end of file diff --git a/images/logos/technology/https.svg b/images/logos/technology/https.svg new file mode 100644 index 00000000..14e8f802 --- /dev/null +++ b/images/logos/technology/https.svg @@ -0,0 +1,28 @@ + + + \ No newline at end of file diff --git a/images/logos/technology/webhooks.svg b/images/logos/technology/webhooks.svg new file mode 100644 index 00000000..cfd60f01 --- /dev/null +++ b/images/logos/technology/webhooks.svg @@ -0,0 +1,12 @@ + + + \ No newline at end of file diff --git a/images/solutions/graphql/wiremock_graphql_opengraph.png b/images/solutions/graphql/wiremock_graphql_opengraph.png new file mode 100644 index 00000000..3568348e Binary files /dev/null and b/images/solutions/graphql/wiremock_graphql_opengraph.png differ diff --git a/images/solutions/grpc/header.png b/images/solutions/grpc/header.png new file mode 100644 index 00000000..0cc25ebe Binary files /dev/null and b/images/solutions/grpc/header.png differ diff --git a/images/solutions/grpc/intro_schema.png b/images/solutions/grpc/intro_schema.png new file mode 100644 index 00000000..82115fa9 Binary files /dev/null and b/images/solutions/grpc/intro_schema.png differ diff --git a/images/solutions/grpc/wiremock-grpc-opengraph.png b/images/solutions/grpc/wiremock-grpc-opengraph.png new file mode 100644 index 00000000..59300a34 Binary files /dev/null and b/images/solutions/grpc/wiremock-grpc-opengraph.png differ diff --git a/images/wiremock-cloud/wiremock_cloud_favicon.svg b/images/wiremock-cloud/wiremock_cloud_favicon.svg new file mode 100644 index 00000000..051f2c18 --- /dev/null +++ b/images/wiremock-cloud/wiremock_cloud_favicon.svg @@ -0,0 +1,88 @@ + + diff --git a/images/wiremock-cloud/wiremock_cloud_logo.svg b/images/wiremock-cloud/wiremock_cloud_logo.svg new file mode 100644 index 00000000..4e20271e --- /dev/null +++ b/images/wiremock-cloud/wiremock_cloud_logo.svg @@ -0,0 +1,12 @@ +