{"id":2624,"date":"2025-11-25T14:27:04","date_gmt":"2025-11-25T14:27:04","guid":{"rendered":"https:\/\/fintx.dev\/?p=2624"},"modified":"2025-11-25T14:28:20","modified_gmt":"2025-11-25T14:28:20","slug":"customizing-grpc-mock-responses","status":"publish","type":"post","link":"https:\/\/fintx.dev\/?p=2624","title":{"rendered":"Customizing gRPC mock responses"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"2624\" class=\"elementor elementor-2624\">\n\t\t\t\t<div class=\"elementor-element elementor-element-5110a109 e-flex e-con-boxed e-con e-parent\" data-id=\"5110a109\" data-element_type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-2c68d66b elementor-widget elementor-widget-text-editor\" data-id=\"2c68d66b\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<!-- wp:paragraph -->\n<p>Before you can customize the mock response, you will first of course need to <a href=\"https:\/\/fintx.dev\/?p=2602\" data-type=\"post\" data-id=\"2602\">mock a gRPC service<\/a><\/p>\n<!-- \/wp:paragraph --><!-- wp:heading -->\n<h2 class=\"wp-block-heading\">Steps to customize the response<\/h2>\n<!-- \/wp:heading --><!-- wp:list {\"ordered\":true} -->\n<ol class=\"wp-block-list\"><!-- wp:list-item -->\n<li>Create a mock gRPC service<\/li>\n<!-- \/wp:list-item --><!-- wp:list-item -->\n<li>Double click on a method to open it in a tab<br \/><a href=\"https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/mockGrpcExplorer.png\"><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-2609 size-large\" style=\"width: 1024px;\" src=\"https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/mockGrpcExplorer-1024x523.png\" alt=\"\" width=\"1024\" height=\"523\" srcset=\"https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/mockGrpcExplorer-1024x523.png 1024w, https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/mockGrpcExplorer-300x153.png 300w, https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/mockGrpcExplorer-768x392.png 768w, https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/mockGrpcExplorer-1536x784.png 1536w, https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/mockGrpcExplorer.png 1911w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/li>\n<!-- \/wp:list-item --><!-- wp:list-item -->\n<li>Note the commented out parts of the script. It shows examples on how to customize the response by using C# snippets<br \/><a href=\"https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/CsharpSnippetSample.png\"><img decoding=\"async\" class=\"alignnone wp-image-2627 size-full\" style=\"width: 800px;\" src=\"https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/CsharpSnippetSample.png\" alt=\"\" width=\"688\" height=\"219\" srcset=\"https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/CsharpSnippetSample.png 688w, https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/CsharpSnippetSample-300x95.png 300w\" sizes=\"(max-width: 688px) 100vw, 688px\" \/><\/a><br \/><br \/>Note : anything in between <code><strong>$&lt;&lt;<\/strong> <\/code>and <strong><code>&gt;&gt;<\/code><\/strong> should be valid C# code<\/li>\n<!-- \/wp:list-item --><!-- wp:list-item -->\n<li>Copy the sample snippets to the json (as below)<br \/><a href=\"https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/EditedJsonResponse.png\"><img decoding=\"async\" class=\"alignleft wp-image-2628 size-full\" style=\"width: 800px;\" src=\"https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/EditedJsonResponse.png\" alt=\"\" width=\"639\" height=\"598\" srcset=\"https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/EditedJsonResponse.png 639w, https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/EditedJsonResponse-300x281.png 300w\" sizes=\"(max-width: 639px) 100vw, 639px\" \/><\/a><\/li>\n<!-- \/wp:list-item --><!-- wp:list-item -->\n<li>If the mock server is not yet started, click on the Play button<\/li>\n<!-- \/wp:list-item --><\/ol>\n<!-- \/wp:list --><!-- wp:heading -->\n<h2 class=\"wp-block-heading\">Testing the mocked method<\/h2>\n<!-- \/wp:heading --><!-- wp:list {\"ordered\":true} -->\n<ol class=\"wp-block-list\"><!-- wp:list-item -->\n<li>Open FintX (or your own gRPC client application) and c<a href=\"https:\/\/fintx.dev\/?p=345\" data-type=\"post\" data-id=\"345\">reate a gRPC client<\/a>. Configure the client to point to the port used by the above mock service<\/li>\n<!-- \/wp:list-item --><!-- wp:list-item -->\n<li>Invoke the mocked method. The code snippets will be executed and the response will contain the output of the code snippets <br \/><br \/>You should get the response something like below<br \/><br \/><a href=\"https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/ResponseFromMock2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-large wp-image-2629\" src=\"https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/ResponseFromMock2-1024x525.png\" alt=\"\" width=\"1024\" height=\"525\" srcset=\"https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/ResponseFromMock2-1024x525.png 1024w, https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/ResponseFromMock2-300x154.png 300w, https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/ResponseFromMock2-768x393.png 768w, https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/ResponseFromMock2-1536x787.png 1536w, https:\/\/fintx.dev\/wp-content\/uploads\/2025\/11\/ResponseFromMock2.png 1913w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/li>\n<!-- \/wp:list-item --><\/ol>\n<!-- \/wp:list -->\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Before you can customize the mock response, you will first of course need to mock a gRPC service Steps to customize the response Testing the mocked method<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[46],"tags":[],"class_list":["post-2624","post","type-post","status-publish","format-standard","hentry","category-grpc-mocks"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/fintx.dev\/index.php?rest_route=\/wp\/v2\/posts\/2624","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fintx.dev\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fintx.dev\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fintx.dev\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fintx.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2624"}],"version-history":[{"count":6,"href":"https:\/\/fintx.dev\/index.php?rest_route=\/wp\/v2\/posts\/2624\/revisions"}],"predecessor-version":[{"id":2633,"href":"https:\/\/fintx.dev\/index.php?rest_route=\/wp\/v2\/posts\/2624\/revisions\/2633"}],"wp:attachment":[{"href":"https:\/\/fintx.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2624"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fintx.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2624"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fintx.dev\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2624"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}