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

Use struct define in vendor #242

Closed
Nexucis opened this issue Nov 6, 2018 · 5 comments
Closed

Use struct define in vendor #242

Nexucis opened this issue Nov 6, 2018 · 5 comments

Comments

@Nexucis
Copy link

Nexucis commented Nov 6, 2018

Describe the bug
Hello,
I have the following folder hierarchy :

.
| -- endpoints
|     `-- user.go
| -- model
|     `-- error.go
| -- vendor
      `-- my.repository
           `-- common-lib
                `-- model
                     `--user.go

I would like to reference the struct contains in vendor/my.repository/.../user.go for the response of my endpoint user for example.

And I have no clue about how I can do it. I have tried several different possible configuration but nothing good so far.

Here is my go client of the endpoint :

import (
	"io"
	"net/http"

	"github.com/labstack/echo"
	commonModel "my.repository/common-lib/model"
	"my.repository/model"
)

// @Tags users
// @Router /users [post]
// @Accept  json
// @Produce  json
// @Success 200  {object} commonModel.UserEntity
// @Failure   400  {object} model.ErrorEntity
// @Failure   500  {object} model.ErrorEntity
func (e *UserEndpoint) CreateUser(ctx echo.Context) error {
	// code
}

This code produce the following error :

2018/11/06 19:33:28 ParseComment panic:can not parse response comment "200 {object} commonModel.UserEntity "
panic: ParseComment panic:can not parse response comment "200 {object} commonModel.UserEntity "

I also try to put the complete package name instead of the alias :

// @Success 200  {object} my.repository/common-lib/model.UserEntity

which is generate the swagger without the definition of the struct UserEntity

Expected behavior
The goal is at the end to generate the definition for all struct (in the swagger.json), event if the struct are in the vendor of the application

Your swag version
v1.4.0
I also tried with the last commit on master 6993bc5667b70aa...

Desktop (please complete the following information):

  • OS: windows 10

Additional context
I suppose this is related to the issue #188. But I don't get it how to reference the types that come from the vendor folder

@8tomat8
Copy link

8tomat8 commented Jan 21, 2019

Have the same problem on
v1.4.0
OS: Linux

Tried

{object} model.ErrorEntity

which throws a panic on swag init
and both

{object} my.repository/common-lib/model.ErrorEntity
{object} vendor/my.repository/common-lib/model.ErrorEntity

which builds docs, but swagger-ui shows an error Could not resolve reference because of: Could not resolve pointer: /definitions/vendor/my.repository/common-lib/model.ErrorEntity does not exist in document

@mthhk
Copy link

mthhk commented Mar 11, 2019

@easonlin404 @pei0804 could you please take a look at this issue ? thank you !

@icobani
Copy link

icobani commented Mar 20, 2019

I have same issue.

@pei0804
Copy link
Member

pei0804 commented Mar 21, 2019

OK.
I understand this issue.

@pei0804
Copy link
Member

pei0804 commented Mar 21, 2019

@a180285 fixed it Thx!
#331

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

No branches or pull requests

5 participants