How do I do this better
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const openApiList = [ | |
{ | |
swagger: "2.0", | |
info: { | |
description: "Test API", | |
version: "1.0.0", | |
title: "Request Catcher Testing API", | |
}, | |
host: "kyung.requestcatcher.com", | |
basePath: "/root", | |
schemes: ["https"], | |
paths: { | |
"/test/{id}": { | |
post: { | |
summary: "Post Body Test", | |
description: "", | |
operationId: "testPost", | |
consumes: ["application/json"], | |
produces: ["application/json"], | |
parameters: [ | |
{ | |
name: "id", | |
in: "path", | |
required: true, | |
}, | |
{ | |
name: "body", | |
in: "body", | |
required: false, | |
type: "object", | |
}, | |
], | |
}, | |
get: { | |
operationId: "testGet", | |
produces: ["application/json"], | |
parameters: [ | |
{ | |
name: "id", | |
in: "path", | |
required: true, | |
}, | |
], | |
}, | |
}, | |
}, | |
}, | |
] | |
// const foo = openApiList[0] | |
// const pathOptions = [] | |
const pathOptStrings = Object.keys(openApiList[0].paths) | |
.map((pathKey) => { | |
return Object.keys((openApiList[0].paths as any)[pathKey]).map((methodKey) => { | |
return (openApiList[0].paths as any)[pathKey][methodKey].operationId | |
}) | |
}) | |
.flat() | |
console.log(pathOptStrings) | |
const pathOpts = pathOptStrings.map((s) => { | |
key: s, | |
value: s, | |
children: s | |
}) |
airkitjeremy
commented
Nov 19, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment