go-swagger: couldn't find a swagger spec

Problem statement

Getting couldn't find a swagger spec when doing swagger generate server -A todo-list -f ./swagger.yml. I am following https://goswagger.io/tutorial/todo-list.html.

Steps to reproduce

  1. Go to https://goswagger.io/tutorial/todo-list.html and copy the complete spec to a file called swagger.yml.
  2. Run swagger generate server -A todo-list -f ./swagger.yml from the directory of the file.

Environment

swagger version: version: v0.27.0 go version: go1.15.8 OS: Amazon Linux 2

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 20 (8 by maintainers)

Most upvoted comments

i think the init path is not right alias swagger=“docker run --rm -it --user $(id -u)😒(id -g) -e GOPATH=$HOME/go:/go -v $HOME:$HOME -w $(pwd) quay.io/goswagger/swagger” swagger version

swagger validate ./swagger/swagger.yml

open ./swagger/swagger.yml: no such file or directory

try with:

alias swagger="docker run --rm -it --user $(id -u):$(id -g) -e GOPATH=$HOME/go:/go -v $HOME:$HOME -v $PWD:$PWD -w $PWD quay.io/goswagger/swagger"

i think the init path is not right alias swagger=“docker run --rm -it --user $(id -u)😒(id -g) -e GOPATH=$HOME/go:/go -v $HOME:$HOME -w $(pwd) quay.io/goswagger/swagger” swagger version

swagger validate ./swagger/swagger.yml

open ./swagger/swagger.yml: no such file or directory

Hi @santosh,

I feel like this might have something to do with running swagger from the Docker container, as volumes need to be mounted for the files to be read in the container. Are you running swagger from Docker?

You could try using the static binary https://goswagger.io/install.html#static-binary and see if it resolves the issue.

Same problem