Skip to content

Commit

Permalink
Add yaml support (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
bourdakos1 authored Dec 4, 2021
1 parent 03716d4 commit 8e4e941
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/docusaurus-plugin-openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@docusaurus/module-type-aliases": "2.0.0-beta.9",
"@types/concurrently": "^6.3.0",
"@types/fs-extra": "^9.0.13",
"@types/js-yaml": "^4.0.5",
"@types/lodash": "^4.14.176",
"@types/postman-collection": "^3.5.3",
"concurrently": "^5.2.0",
Expand All @@ -32,6 +33,7 @@
"@docusaurus/utils-validation": "^2.0.0-beta.9",
"chalk": "^4.1.2",
"fs-extra": "^9.0.1",
"js-yaml": "^4.1.0",
"json-refs": "^3.0.15",
"lodash": "^4.17.20",
"openapi-to-postmanv2": "^1.2.1",
Expand Down
3 changes: 2 additions & 1 deletion packages/docusaurus-plugin-openapi/src/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import { normalizeUrl } from "@docusaurus/utils";
import fs from "fs-extra";
import yaml from "js-yaml";
import JsonRefs from "json-refs";
import { kebabCase } from "lodash";
import Converter from "openapi-to-postmanv2";
Expand Down Expand Up @@ -176,7 +177,7 @@ export async function loadOpenapi(
routeBasePath: string
) {
const openapiString = await fs.readFile(openapiPath, "utf-8");
const openapiData = JSON.parse(openapiString) as OpenApiObject;
const openapiData = yaml.load(openapiString) as OpenApiObject;

// Attach a postman request object to the openapi spec.
const postmanCollection = await convertToPostman(openapiData);
Expand Down
7 changes: 6 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3142,6 +3142,11 @@
jest-diff "^27.0.0"
pretty-format "^27.0.0"

"@types/js-yaml@^4.0.5":
version "4.0.5"
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-4.0.5.tgz#738dd390a6ecc5442f35e7f03fa1431353f7e138"
integrity sha512-FhpRzf927MNQdRZP0J5DLIdTXhjLYzeUTmLAu69mnVksLH9CJY3IuSeEgbKUki7GQZm0WqDkGzyxju2EZGD2wA==

"@types/json-schema@*", "@types/json-schema@^7.0.4", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.7", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9":
version "7.0.9"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d"
Expand Down Expand Up @@ -9158,7 +9163,7 @@ js-yaml@^3.13.1:
argparse "^1.0.7"
esprima "^4.0.0"

js-yaml@^4.0.0:
js-yaml@^4.0.0, js-yaml@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602"
integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==
Expand Down

0 comments on commit 8e4e941

Please sign in to comment.