refactor: update openapi import
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
|||||||
makeRESTRequest,
|
makeRESTRequest,
|
||||||
HoppCollection,
|
HoppCollection,
|
||||||
makeCollection,
|
makeCollection,
|
||||||
|
HoppRESTRequestVariable,
|
||||||
} from "@hoppscotch/data"
|
} from "@hoppscotch/data"
|
||||||
import { pipe, flow } from "fp-ts/function"
|
import { pipe, flow } from "fp-ts/function"
|
||||||
import * as A from "fp-ts/Array"
|
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[] =>
|
const parseOpenAPIHeaders = (params: OpenAPIParamsType[]): HoppRESTHeader[] =>
|
||||||
pipe(
|
pipe(
|
||||||
params,
|
params,
|
||||||
@@ -577,6 +599,10 @@ const convertPathToHoppReqs = (
|
|||||||
|
|
||||||
preRequestScript: "",
|
preRequestScript: "",
|
||||||
testScript: "",
|
testScript: "",
|
||||||
|
|
||||||
|
requestVariables: parseOpenAPIVariables(
|
||||||
|
(info.parameters as OpenAPIParamsType[] | undefined) ?? []
|
||||||
|
),
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user