swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

Fetch error: Failed to fetch file I can run on the swagger website, but cannot run locally with a copy of this repo

Open dinoDayo opened this issue 3 years ago • 2 comments

Q&A:

  • OS: macOS
  • Browser: chrome
  • Version: Version 109.0.5414.119 (Official Build)
  • Method of installation: git clone
  • Swagger-UI version: 4.15.5
  • Swagger/OpenAPI version: OpenAPI 3.0.1

Content & configuration

  1. copy working openapi.json from the swagger editor into a file with the same name in my local copy of the swagger-ui/dist/ repo; swagger-ui/dist/openapi.json
  2. edit swagger-initiailizer.js to point to local file instead of the petstore URL example; file:///absolute/path/to/local/file
  3. open index.html from swagger-ui/dist/ folder
  4. errors abound. I've tried running with http-server --cors as well but get the same results. I've also tried changing from absolute to relative but that doesn't seem to work either. (ie. Failed to fetch file:///...etc.)

How can we help?

How can I serve my openapi.json file locally?

dinoDayo avatar Feb 10 '23 20:02 dinoDayo

@dinoDayo have you found any solution?

Ghayour-vialogic avatar Mar 10 '23 10:03 Ghayour-vialogic

@Ghayour-vialogic I was able to test & tune my openapi.json configuration directly in the swagger editor, which got me to where I needed to be in terms of documentation.

My use-case was statically hosting some API documentation in an s3 bucket via a serverless application. I think the bugs I was seeing were associated with something in that implementation and not with this specific repo. Closing this issue with this comment, lmk if you think I can be helpful.

dinoDayo avatar Apr 23 '23 21:04 dinoDayo