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

Unable to reference models in referenced module #2963

Open
tommed opened this issue Aug 17, 2023 · 0 comments
Open

Unable to reference models in referenced module #2963

tommed opened this issue Aug 17, 2023 · 0 comments
Labels
generate spec Related to spec generation from code scanner

Comments

@tommed
Copy link

tommed commented Aug 17, 2023

Problem statement

Forgive me if I've missed the docs or ticket that explains this (as it seems fairly fundamental), but I have a base class library which contains common models across several packages, and the models aren't found when generating swagger generate spec. The example says null and none of the fields are detected.

I am within the GOPATH, although the base class module is a relative import like so:

replace github.com/VigilantApps/core-services/bcl => ../bcl

Is there any workaround to allow me to avoid duplicating code (model definitions) whilst keeping my swagger docs functioning? Thanks for your time.

Swagger specification

// route defined like so:

// Get
//
// swagger:route GET /instances/{id} Instance readInstance
//
// # Read
//
// Retrieve an instance by its ID.
//
//	Produces:
//	- application/json
//
//	Security:
//		instance:read: read
//
//	Parameters:
//	+ name: id
//	  in: path
//	  required: true
//	  type: string
//
//	Responses:
//		200: instance
//		400: problem bad input from user
//		401: problem unauthorised user
//		500: problem server issue
func (r controller) Get(c *gin.Context) {

And when instance is defined in the same module, it works fine. But as soon as I move the definition to my bcl module, it stops working:

// An Instance of an authority tenant.
//
// swagger:model instance
type Instance struct {

Environment

swagger version:

version: v0.30.5
commit: ab6a7885723430004f1d7db6395369b6e7f3370b

go version: 1.21
OS: macOS 13.5

@fredbi fredbi added the generate spec Related to spec generation from code label Dec 10, 2023
@fredbi fredbi added the scanner label Dec 20, 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