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

Generate spec: Unable to find responses defined in other package using swagger:operation #2233

Open
aasikraja opened this issue Feb 18, 2020 · 0 comments
Labels
generate spec Related to spec generation from code scanner

Comments

@aasikraja
Copy link

aasikraja commented Feb 18, 2020

Swagger operation is unable to find definitions for models defined in another package when generating spec. I am getting "$refs must reference a valid location in the document " error when opening the generated yaml using swagger editor.

How to annotate and generate spec in this case?

File model/user.go:
package model

type User struct {
        ID        string   `json:"id"`
}
// User response payload
// swagger:response User
type swaggUserInfo struct {
        // in:body
        Body model.User
}

File docs/docs.go:
package docs
import "xxx/model"

// swagger:operation GET /user queryUser
// ---
// responses:
//   '200':
//     schema:
//       "$ref": "#/definitions/User"

Environment

swagger version: v0.21.0
go version: go1.12.12
OS: RHEL

@fredbi fredbi added the generate spec Related to spec generation from code label Mar 11, 2020
@fredbi fredbi added the scanner label Dec 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
generate spec Related to spec generation from code scanner
Projects
None yet
Development

No branches or pull requests

2 participants