Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading failed for local openapi json file #190

Closed
yzhe819 opened this issue Jun 28, 2022 · 4 comments · Fixed by #197
Closed

Loading failed for local openapi json file #190

yzhe819 opened this issue Jun 28, 2022 · 4 comments · Fixed by #197

Comments

@yzhe819
Copy link
Contributor

yzhe819 commented Jun 28, 2022

When I update my project from the old version "0.4.0" to the latest version "0.6.0", I can't start the project.
Below is a screenshot of the error.

screenshot

图片

How to reproduce

I started from the template one

npx create-docusaurus-openapi docusaurus-openapi-example

Then update the package

yarn upgrade docusaurus-preset-openapi --latest

Also, add url for fixing url issue

yarn add url

Then, I start the project

cd docusaurus-openapi-example
yarn start

Check the above screenshot.

The following is my package.json

package.json
{
  "name": "docusaurus-openapi-example",
  "version": "0.0.0",
  "private": true,
  "dependencies": {
    "@docusaurus/core": "2.0.0-beta.21",
    "@mdx-js/react": "^1.6.21",
    "clsx": "^1.1.1",
    "docusaurus-preset-openapi": "0.6.0",
    "prism-react-renderer": "^1.2.1",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "url": "^0.11.0"
  },
  "scripts": {
    "docusaurus": "docusaurus",
    "start": "docusaurus start",
    "build": "docusaurus build",
    "swizzle": "docusaurus swizzle",
    "deploy": "docusaurus deploy",
    "clear": "docusaurus clear",
    "serve": "docusaurus serve",
    "write-translations": "docusaurus write-translations",
    "write-heading-ids": "docusaurus write-heading-ids"
  },
  "browserslist": {
    "production": [
      ">0.5%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Comment

Please let me know if I make any mistakes in the initialization of the project.

PS: Maybe the template example also needs a version update💖

@yzhe819
Copy link
Contributor Author

yzhe819 commented Jun 29, 2022

screenshot

图片

Here is the test run result which only happened on my windows env. Looks like reading the local file fails.
I am trying to figure out how to solve this problem? Any suggestions? @bourdakos1

@ianberryman
Copy link

ianberryman commented Jul 21, 2022

@yzhe819 I have the same issue on Windows. The absolute path of the api file is recognized as a valid URL (see nodejs/node#34765). utils.isUrl() needs to be changed to support absolute paths. Seems like you might need to fork this repo to get it working.

@yzhe819
Copy link
Contributor Author

yzhe819 commented Jul 22, 2022

@ianberryman Thanks for your advice. I use regular expressions instead of URL to avoid this platform issue. Just waiting for code review. Feel free to take a look.

@ianberryman
Copy link

@yzhe819 Nice, I'm going to pull your fork and use it until the PR is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants