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

cannot find type definition: sql.NullTime #1739

Open
EAS-Rhys opened this issue Jan 14, 2024 · 4 comments
Open

cannot find type definition: sql.NullTime #1739

EAS-Rhys opened this issue Jan 14, 2024 · 4 comments

Comments

@EAS-Rhys
Copy link

Describe the bug
When executing:
swag init --md ./docs --parseInternal --parseDependency --parseDepth 2
Receiving error:
ParseComment error in file /Users/morgan/leadgen/data-ms/routes/content.go :cannot find type definition: sql.NullTime

To Reproduce
Steps to reproduce the behavior:
Execute swag init --md ./docs --parseInternal --parseDependency --parseDepth 2 with a gorm model in your swagger comment spec.

Example:

Gorm Model:

import (
    "gorm.io/gorm"
    "time"
)
type Content struct {
    gorm.Model
    OrganisationId  int        `json:"organisation_id"`
    ContentTypeId   int        `json:"content_type_id"`
    AvailableDatetime *time.Time `json:"available_datetime"`
    ExpiryDatetime  *time.Time `json:"expiry_datetime"`
    Pinned          bool       `json:"pinned"`
    MediaId         int        `json:"media_id"`
}

Swagger Comment:

// @Summary      List Content in Organisation
// @Description  Get a list of content in the organisation.
// @Tags         content
// @Produce      json
// @Param        orgId path int true "Organization ID" minimum(1)
// @Success      200  {array}  models.Content
// @Router       /organizations/{orgId}/content [get]

Expected behavior
Swagger docs to be generated successfully

Your swag version

github.com/swaggo/files v1.0.1
github.com/swaggo/gin-swagger v1.6.0
github.com/swaggo/swag v1.16.2

Your go version
e.g. 1.21.5

Additional info:
I have tried the solution specified in #1228 with .swaggo file in the root of the project but am still getting this issue.

Gorm version: gorm.io/gorm v1.25.5

@sdghchj
Copy link
Member

sdghchj commented Jan 16, 2024

debug it.

@EAS-Rhys
Copy link
Author

debug it.

I've tried, or i wouldn't have raised it as a bug. If there is something you think i'm missing can you at least give me a pointer?

@sdghchj
Copy link
Member

sdghchj commented Jan 17, 2024

You have to check your swag version by cmd swag --version.
The swag version means the version of the swag tool you are using, other than the dependent package version you have imported.

@sdghchj
Copy link
Member

sdghchj commented Jan 17, 2024

I have also tried model you gave above with the newest swag tool. It work well.

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

2 participants