protected static List<RequestResponsePair> parseRequestResponseTemplateOutput(Service service, Operation operation,
         String content) throws Exception {
      List<RequestResponsePair> results = new ArrayList<>();

      JsonNode root = YAML_MAPPER.readTree(sanitizeYamlContent(content));
      if (root.getNodeType() == JsonNodeType.ARRAY) {
         Iterator<JsonNode> examples = root.elements();
         while (examples.hasNext()) {
            JsonNode example = examples.next();

            // Deal with parsing request.
            JsonNode requestNode = example.path("request");
            Request request = new Request();
            JsonNode requestHeadersNode = requestNode.path(HEADERS_NODE);
            request.setHeaders(buildHeaders(requestHeadersNode));
            request.setContent(getRequestContent(requestHeadersNode, requestNode.path("body")));

            String url = requestNode.path("url").asText();
            if (url.contains("?")) {
               String[] kvPairs = url.substring(url.indexOf("?") + 1).split("&");
               for (String kvPair : kvPairs) {
                  String[] kv = kvPair.split("=");
                  Parameter param = new Parameter();
                  param.setName(kv[0]);
                  param.setValue(kv[1]);
                  request.addQueryParameter(param);
               }
            }

            // Deal with parsing response.
            JsonNode responseNode = example.path("response");
            Response response = new Response();
            JsonNode responseHeadersNode = responseNode.path(HEADERS_NODE);
            response.setHeaders(buildHeaders(responseHeadersNode));
            response.setContent(getResponseContent(responseHeadersNode, responseNode.path("body")));
            response.setMediaType(responseHeadersNode.path("content-type").asText(null));
            response.setStatus(responseNode.path("code").asText("200"));
            response.setFault(response.getStatus().startsWith("4") || response.getStatus().startsWith("5"));

            //
            String dispatchCriteria = null;

            if (DispatchStyles.URI_PARTS.equals(operation.getDispatcher())) {
               String resourcePathPattern = operation.getName().split(" ")[1];
               dispatchCriteria = DispatchCriteriaHelper.extractFromURIPattern(operation.getDispatcherRules(),
                     resourcePathPattern, url);
            } else if (DispatchStyles.URI_PARAMS.equals(operation.getDispatcher())) {
               dispatchCriteria = DispatchCriteriaHelper.extractFromURIParams(operation.getDispatcherRules(), url);
            } else if (DispatchStyles.URI_ELEMENTS.equals(operation.getDispatcher())) {
               String resourcePathPattern = operation.getName().split(" ")[1];
               dispatchCriteria = DispatchCriteriaHelper.extractFromURIPattern(operation.getDispatcherRules(),
                     resourcePathPattern, url);
               dispatchCriteria += DispatchCriteriaHelper.extractFromURIParams(operation.getDispatcherRules(), url);
            } else if (DispatchStyles.QUERY_ARGS.equals(operation.getDispatcher())) {
               // This dispatcher is used for GraphQL or gRPC
               if (ServiceType.GRAPHQL.equals(service.getType())) {
                  Map<String, String> variables = getGraphQLVariables(request.getContent());
                  dispatchCriteria = DispatchCriteriaHelper.extractFromParamMap(operation.getDispatcherRules(),
                        variables);
               } else if (ServiceType.GRPC.equals(service.getType())) {
                  Map<String, String> parameters = JSON_MAPPER.readValue(request.getContent(),
                        TypeFactory.defaultInstance().constructMapType(TreeMap.class, String.class, String.class));
                  dispatchCriteria = DispatchCriteriaHelper.extractFromParamMap(operation.getDispatcherRules(),
                        parameters);
               }
            }
            response.setDispatchCriteria(dispatchCriteria);

            if (service.getType() == ServiceType.GRAPHQL) {
               adaptGraphQLRequestContent(request);
            }

            results.add(new RequestResponsePair(request, response));
         }
      }
      return results;
   }
@Test
   void testParseRequestResponseOutputYamlWithMD2() {
      String aiResponse = """
            ### Example 1

            ```yaml
            - example: 1
              request:
                url: /pastry/ChocolateCroissant
                headers:
                  accept: application/json
                body:\s
              response:
                code: 200
                headers:
                  content-type: application/json
                body:
                  name: "ChocolateCroissant"
                  description: "A croissant filled with chocolate"
                  size: "M"
                  price: 2.5
                  status: "available"
            ```

            ### Example 2

            ```yaml
            - example: 2
              request:
                url: /pastry/BlueberryMuffin
                headers:
                  accept: application/json
                body:
              response:
                code: 200
                headers:
                  content-type: application/json
                body:
                  name: "BlueberryMuffin"
                  description: "A muffin filled with fresh blueberries"
                  size: "S"
                  price: 1.5
                  status: "available"
            ```
            """;

      Service service = new Service();
      service.setType(ServiceType.REST);
      Operation operation = new Operation();
      operation.setName("GET /pastry/{name}");
      operation.setDispatcher(DispatchStyles.URI_PARTS);
      operation.setDispatcherRules("name");

      List<RequestResponsePair> results = null;
      try {
         results = AICopilotHelper.parseRequestResponseTemplateOutput(service, operation, aiResponse);
      } catch (Exception e) {
         fail("Exception should not be thrown here");
      }

      assertNotNull(results);
      assertEquals(2, results.size());

   }