vim-swagger-preview icon indicating copy to clipboard operation
vim-swagger-preview copied to clipboard

Opens browser but can't connect

Open aka-mj opened this issue 4 years ago • 9 comments

With my openapi.yaml file open I press <leader>e and get the browser to launch but it is unable to connect to localhost:8017. Docker is installed, the zsh functions were copied.

zsh 5.8 nvim 0.5.0-dev+919-g08ec36efa docker 20.10.5, build 55c4c88

Any ideas to troubleshoot this issue?

aka-mj avatar Mar 10 '21 14:03 aka-mj

make sure port 8017 is availabe to listen on, of course you can change it here.

Could you check if

  • docker is running(docker ps)
  • is port 8017 available(blocked by firewall/proxy etc.)

xavierchow avatar Mar 11 '21 01:03 xavierchow

Docker is running and port 8017 is available

>> docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
>> lsof -i -P -n | grep LISTEN
reqrep  2630068 mj    3u  IPv4 8254863      0t0  TCP 127.0.0.1:40899 (LISTEN)

aka-mj avatar Mar 16 '21 18:03 aka-mj

hmm, there is a directory called vim-swagger-preview under the tmp you can check if there is any error in the validate.log. I also noticed the container swagger-ui-preview didn't seem to be running from your output of docker ps. @dangerousHobo

 /tmp/vim-swagger-preview  ls
README.md    openapi.json validate.log

 /tmp/vim-swagger-preview  cat validate.log

 /tmp/vim-swagger-preview  docker ps
CONTAINER ID   IMAGE                       COMMAND                  CREATED          STATUS                PORTS                                                                                                                                                                   NAMES
0cffe5ad6c85   swaggerapi/swagger-ui       "/docker-entrypoint.…"   37 seconds ago   Up 36 seconds         80/tcp, 0.0.0.0:8017->8080/tcp                                                                                                                                          swagger-ui-preview

if there is an openapi.json(generated by the vim plugin), or maybe you can check if you can set up the container separately from the command line? docker run --name swagger-ui-preview -d -p 8017:8080 -e SWAGGER_JSON=/docs/openapi.json -v /tmp:/docs swaggerapi/swagger-ui

xavierchow avatar Mar 21 '21 10:03 xavierchow

@xavierchow - Original issue with the docker image was not downloaded. I now have it downloaded and the browser connects to localhost:8017 and opens a webpage but gets an error "Failed to load API definition'. There is nothing under the /tmp/vim-swagger-preview directory.

image

aka-mj avatar Jul 13 '21 17:07 aka-mj

There is nothing under the /tmp/vim-swagger-preview directory.

There should be something wrong, did you start the docker via the command I list above? if so the swagger.json just didn't get transformed from the original yaml file.

Please try to run leader + e from your vim as described here.

xavierchow avatar Jul 14 '21 05:07 xavierchow

The docker container is running:

~> docker ps
CONTAINER ID   IMAGE                   COMMAND                  CREATED       STATUS       PORTS                                               NAMES
94a2075583fe   swaggerapi/swagger-ui   "/docker-entrypoint.…"   3 hours ago   Up 3 hours   80/tcp, 0.0.0.0:8017->8080/tcp, :::8017->8080/tcp   swagger-ui-preview

Running leader + e does open the browser page shown above. The zsh .zshenv is also installed as described.

aka-mj avatar Jul 14 '21 13:07 aka-mj

@dangerousHobo can you try to run the following command from your shell? I'd suspect something wrong with the docker download here.

swagger_yaml2json  your-swagger.yaml

please paste the outcome of above command and also check if there is any files created under the /tmp/vim-swagger-preview, thanks.

xavierchow avatar Jul 15 '21 02:07 xavierchow

Hi, I've the same issue reported, my log was:

Validating spec (/docs/my-openapi.yaml)
[main] INFO  o.o.codegen.utils.ModelUtils - [deprecated] inheritance without use of 'discriminator.propertyName' has been deprecated in the 5.x release. Composed schema name: null. Title: null
[main] INFO  o.o.codegen.utils.ModelUtils - [deprecated] inheritance without use of 'discriminator.propertyName' has been deprecated in the 5.x release. Composed schema name: null. Title: null
No validation issues detected.

After looking at this issue, I've changed all references from openapitools/openapi-generator-cli on my .zshenv to: openapitools/openapi-generator-cli:v4.1.3 and it's working!

WendelHime avatar Jul 22 '21 15:07 WendelHime

I have this same issue and I see WendelHime worked around it with a different version of openapitools/openapi-generator-cli but shouldn't this thing check the return code env variable $? instead of looking to see how many log lines are there and assuming that the validation failed? I might have to patch/change this shell script funciton because warnings shouldn't cause the validation to actually fail.

dbaber avatar Aug 27 '22 22:08 dbaber