feat: import collections from URL (#2262)

Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
This commit is contained in:
Akash K
2022-05-03 17:54:47 +05:30
committed by GitHub
parent c20339d222
commit 4ef2844a22
13 changed files with 239 additions and 59 deletions

View File

@@ -27,7 +27,7 @@ import * as RA from "fp-ts/ReadonlyArray"
import { step } from "../steps"
import { defineImporter, IMPORTER_INVALID_FILE_FORMAT } from "."
const OPENAPI_DEREF_ERROR = "openapi/deref_error" as const
export const OPENAPI_DEREF_ERROR = "openapi/deref_error" as const
// TODO: URL Import Support
@@ -586,7 +586,9 @@ const parseOpenAPIDocContent = (str: string) =>
)
export default defineImporter({
id: "openapi",
name: "import.from_openapi",
applicableTo: ["my-collections", "team-collections", "url-import"],
icon: "file",
steps: [
step({
@@ -603,7 +605,6 @@ export default defineImporter({
fileContent,
parseOpenAPIDocContent,
TE.fromOption(() => IMPORTER_INVALID_FILE_FORMAT),
// Try validating, else the importer is invalid file format
TE.chainW((obj) =>
pipe(
@@ -613,7 +614,6 @@ export default defineImporter({
)
)
),
// Deference the references
TE.chainW((obj) =>
pipe(
@@ -623,7 +623,6 @@ export default defineImporter({
)
)
),
TE.chainW(convertOpenApiDocToHopp)
),
})