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

Invalid paths in go generate directive #1789

Closed
blez opened this issue Nov 9, 2018 · 1 comment · Fixed by #1810
Closed

Invalid paths in go generate directive #1789

blez opened this issue Nov 9, 2018 · 1 comment · Fixed by #1810

Comments

@blez
Copy link

blez commented Nov 9, 2018

Problem statement

Invalid path in go generate directive in generated/restapi/configure*.go file

Steps to reproduce

  1. Run swagger generate
    swagger generate server -f ./swagger.yaml -t ./generated --exclude-main
  2. Go to generated/restapi/configure*.go
    There I have comment
//go:generate swagger generate server --target ../generated --name ExampleSwaggerServer --spec ../swagger.yaml --exclude-main

Which is not right, because swagger.yaml and generated directory are 2 levels up, but not one.
If you try to run go generate you will get an error couldn't find a swagger spec
So comment should be

//go:generate swagger generate server --target ../../generated --name ExampleSwaggerServer --spec ../../swagger.yaml --exclude-main

Environment

swagger version: v0.17.2
commit: 800a305
go version: 1.10.3
OS: Ubuntu

@fredbi
Copy link
Contributor

fredbi commented Nov 18, 2018

That's right.
This statement is defined here in templates:

//go:generate swagger generate server --target {{ .TargetPath }} --name {{ .Name }} --spec {{ .SpecPath }}

The generate_xxx.go is actually put in {{ ServerPackage }} relative to {{ Target }}.

So the issue is the incorrect relative path computed by this function:

func (g *GenOpts) TargetPath() string {

@fredbi fredbi self-assigned this Nov 20, 2018
fredbi added a commit to fredbi/go-swagger that referenced this issue Nov 21, 2018
* fixes go-swagger#1789

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
fredbi added a commit to fredbi/go-swagger that referenced this issue Nov 21, 2018
* fixes go-swagger#1789

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
fredbi added a commit to fredbi/go-swagger that referenced this issue Nov 21, 2018
* fixes go-swagger#1789

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants