refactor: update openapi import
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
makeRESTRequest,
|
||||
HoppCollection,
|
||||
makeCollection,
|
||||
HoppRESTRequestVariable,
|
||||
} from "@hoppscotch/data"
|
||||
import { pipe, flow } from "fp-ts/function"
|
||||
import * as A from "fp-ts/Array"
|
||||
@@ -82,6 +83,27 @@ const parseOpenAPIParams = (params: OpenAPIParamsType[]): HoppRESTParam[] =>
|
||||
)
|
||||
)
|
||||
|
||||
const parseOpenAPIVariables = (
|
||||
variables: OpenAPIParamsType[]
|
||||
): HoppRESTRequestVariable[] =>
|
||||
pipe(
|
||||
variables,
|
||||
|
||||
A.filterMap(
|
||||
flow(
|
||||
O.fromPredicate((param) => param.in === "path"),
|
||||
O.map(
|
||||
(param) =>
|
||||
<HoppRESTRequestVariable>{
|
||||
key: param.name,
|
||||
value: "", // TODO: Can we do anything more ? (parse default values maybe)
|
||||
active: true,
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
const parseOpenAPIHeaders = (params: OpenAPIParamsType[]): HoppRESTHeader[] =>
|
||||
pipe(
|
||||
params,
|
||||
@@ -577,6 +599,10 @@ const convertPathToHoppReqs = (
|
||||
|
||||
preRequestScript: "",
|
||||
testScript: "",
|
||||
|
||||
requestVariables: parseOpenAPIVariables(
|
||||
(info.parameters as OpenAPIParamsType[] | undefined) ?? []
|
||||
),
|
||||
})
|
||||
}),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user