liuxiran commented on a change in pull request #485:
URL: https://github.com/apache/apisix-dashboard/pull/485#discussion_r490778454



##########
File path: src/pages/Route/transform.ts
##########
@@ -252,3 +252,131 @@ export const transformRouteData = (data: 
RouteModule.Body) => {
     step3Data,
   };
 };
+
+export const transformRouteDebugData = (data: RouteModule.Body) => {
+  const {
+    name,
+    desc,
+    methods,
+    uris,
+    protocols,
+    // hosts,
+    vars,
+    // redirect,
+    url,
+  } = data;
+
+  const paths = {};
+  const tags: RouteModule.TagSchema[] = [
+    {
+      name: `Route-${name}`,
+      description: desc,
+    },
+  ];
+  const servers: RouteModule.Server[] = [];
+  const responses: RouteModule.ResponseSchema = {
+    // default response code
+    '200': {
+      description: 'successful operation',
+      content: {},
+    },
+    '400': {
+      description: 'Invalid parameter',
+      content: {},
+    },
+    '500': {
+      description: 'Internal Server Error',
+      content: {},
+    },
+  };
+  const params = transformVarsToRules(vars);
+  const formatParams = params.map((param) => {
+    const { position, operator } = param;
+    let paramPostion;
+
+    switch (position) {
+      case 'cookie':
+        paramPostion = 'cookie';
+        break;
+      case 'http':
+        paramPostion = 'header';
+        break;
+      case 'arg':
+        paramPostion = 'query';
+        break;
+      default:
+        break;
+    }
+    return {
+      name: param.name,
+      in: paramPostion,
+      description: `default value should ${operator} ${param.value}`,
+      required: true,
+      type: 'string',
+    };
+  });
+  const pathParams = {
+    name: 'pathParam',
+    in: 'path',
+    description: `enter your path param`,
+    required: true,
+    type: 'string',
+  };
+  const requestBodyMethod = ['POST', 'PUT', 'PATCH'];
+
+  protocols.forEach((protocol) => {
+    if (protocol !== 'websocket') {
+      servers.push({

Review comment:
       got it 👍,thank you, and both of concat and spread syntax  have the same 
effect here , I perfer the latter :) 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to