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

v1.7.0 failed to parse response #853

Open
sdghchj opened this issue Dec 8, 2020 · 3 comments
Open

v1.7.0 failed to parse response #853

sdghchj opened this issue Dec 8, 2020 · 3 comments
Labels

Comments

@sdghchj
Copy link
Member

sdghchj commented Dec 8, 2020

With v1.6.9 we get a warning but the docs are still generated:

${HOME}/go/bin/swag init --generalInfo internal/http/client.go --propertyStrategy snakecase --parseVendor --output spec
2020/12/08 07:28:49 Generate swagger docs....
2020/12/08 07:28:49 Generate general API Info, search dir:./
2020/12/08 07:28:49 warning: failed to get package name in dir: ./, error: execute go list command, exit status 1, stdout:, stderr:no Go files in /Users/mi/projects/localcover/code/svc/product-svc
2020/12/08 07:28:50 create docs.go at spec/docs.go
2020/12/08 07:28:50 create swagger.json at spec/swagger.json
2020/12/08 07:28:50 create swagger.yaml at spec/swagger.yaml
[product-svc] ${HOME}/go/bin/swag --version
swag version v1.6.9

And after upgrading to v1.7.0 the doc generation fails:

${HOME}/go/bin/swag init --generalInfo internal/http/client.go --propertyStrategy snakecase --parseVendor --output spec
2020/12/08 08:02:56 Generate swagger docs....
2020/12/08 08:02:56 Generate general API Info, search dir:./
2020/12/08 08:02:56 warning: failed to get package name in dir: ./, error: execute go list command, exit status 1, stdout:, stderr:no Go files in /Users/mi/projects/localcover/code/svc/product-svc
2020/12/08 08:02:58 ParseComment error in file internal/http/routes/merchant_cancel_process.go :can not parse response comment "400 "Failed to pass json schema""
[product-svc] ${HOME}/go/bin/swag --version
swag version v1.7.0

--parseDepth 1 has no effect on the error:

${HOME}/go/bin/swag init --generalInfo internal/http/client.go --parseDepth 1  --propertyStrategy snakecase --parseVendor --output spec
2020/12/08 08:07:50 Generate swagger docs....
2020/12/08 08:07:50 Generate general API Info, search dir:./
2020/12/08 08:07:51 warning: failed to get package name in dir: ./, error: execute go list command, exit status 1, stdout:, stderr:no Go files in /Users/mi/projects/localcover/code/svc/product-svc
2020/12/08 08:07:52 ParseComment error in file internal/http/routes/merchant_return_period.go :can not parse response comment "400 "Failed to pass json schema""

Originally posted by @lc-chrisbarton in #852 (comment)

@drewsilcock
Copy link

I'm seeing the same error trying and failing to parse the following comment on an endpoint (works on v1.6.9, fails on v1.7.0):

// @Success 204 "Sucessfully deleted user."

Output:

> swag init --parseDependency
2020/12/08 09:40:24 Generate swagger docs....
2020/12/08 09:40:24 Generate general API Info, search dir:./
2020/12/08 09:40:57 Generating [redacted]
2020/12/08 09:40:57 Generating [redacted]
2020/12/08 09:40:57 Generating [redacted]
2020/12/08 09:40:57 Generating [redacted]
2020/12/08 09:40:57 Generating [redacted]
2020/12/08 09:40:57 Generating [redacted]
2020/12/08 09:40:57 Generating [redacted]
2020/12/08 09:40:57 Generating [redacted]
2020/12/08 09:40:57 Generating [redacted]
2020/12/08 09:40:57 Generating [redacted]
2020/12/08 09:40:57 Generating echo.HTTPError
2020/12/08 09:40:57 Type definition of type '*ast.InterfaceType' is not supported yet. Using 'object' instead.
2020/12/08 09:40:57 Generating [redacted]
2020/12/08 09:40:57 ParseComment error in file [redacted] :can not parse response comment "204 "Sucessfully deleted user.""

@odidev
Copy link
Contributor

odidev commented Dec 17, 2020

I am working on the package ‘cloudfoundry/stratos’, which is successfully using swaggo/swag version 1.6.7.
As we know, we need to upgrade the swag version to 1.7.0 for AArch64 support in stratos. However, after changing the version to 1.7.0 (go get github.com/swaggo/swag/cmd/swag@v1.7.0), and including checksum for swaggo/swag@1.7.0 in my go.sum file, as below:

github.com/swaggo/swag v1.7.0 h1:5bCA/MTLQoIqDXXyHfOpMeDvL9j68OY/udlK4pQoo4E=
github.com/swaggo/swag v1.7.0/go.mod h1:BdPIL73gvS9NBsdi7M1JOxLvlbfvNRaBP8m6WT6Aajo=

, I am getting the same error for the docs not getting generated, after executing (swag init) command.
Facing below error in stratos after updating swag version to 1.7.0:

build github.com/cloudfoundry-incubator/stratos/src/jetstream: cannot load github.com/cloudfoundry-incubator/stratos/src/jetstream/docs: module github.com/cloudfoundry-incubator/stratos@latest found (v2.0.0-beta-001+incompatible), but does not contain package github.com/cloudfoundry-incubator/stratos/src/jetstream/docs

This is my go.sum file placed at ‘stratos/src/jetstream’: https://github.com/cloudfoundry/stratos/blob/master/src/jetstream/go.sum
The same error has been seen with ‘swaggo/swag’ version 1.6.9.

I have also tried setting depth to 2 and 3, as suggested in the issue #852 (comment); but that has not helped.

swag init --parseDependency --parseInternal --depth 2

As this is a known issue after version 1.6.7, can you please check and resolve this issue, or else provide some pointers so that I can proceed to add arm64 support in stratos?

@isgj
Copy link

isgj commented Jun 1, 2021

@drewsilcock for the 204 error you can try

// @Success 204 {null} nil "Your message here"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants