bmdavis419 / the-better-backend Goto Github PK
View Code? Open in Web Editor NEWA template for a GoLang backend using Fiber, MongoDB, a Makefile, and more
License: MIT License
A template for a GoLang backend using Fiber, MongoDB, a Makefile, and more
License: MIT License
when i build the swagger i get the following error
docs/docs.go:336:2: unknown field RightDelim in struct literal of type "github.com/swaggo/swag".Spec```
seems swag is adding LeftDelim and RightDelim which is no longer valid
When using gorm as The ORM to use Postgresql the generation of the swagger documentation fail.
here is my todo model:
package models
import "gorm.io/gorm"
type Todo struct {
gorm.Model
Title string `json:"title" gorm:"text;not null;default:null"`
Completed bool `json:"completed" gorm:"not null;default:false"`
}
and here the error of the swag command (swag init --dir ./,./handlers
) (Running on a docker but thje same append if running locally)
> [7/7] RUN swag init --dir ./,./handlers:
#0 0.545 2023/06/30 17:11:43 Generate swagger docs....
#0 0.545 2023/06/30 17:11:43 Generate general API Info, search dir:./
#0 1.030 2023/06/30 17:11:43 Generate general API Info, search dir:./handlers
#0 1.118 2023/06/30 17:11:43 Generating models.Todo
#0 1.118 2023/06/30 17:11:43 Error parsing type definition 'models.Todo': cannot find type definition: gorm.Model
#0 1.118 2023/06/30 17:11:43 ParseComment error in file /usr/src/app/handlers/todos.go :cannot find type definition: gorm.Model
For info here is my dockerfile:
FROM golang:1.20.2
WORKDIR /usr/src/app
RUN go install github.com/cosmtrek/air@latest
RUN go install github.com/swaggo/swag/cmd/swag@latest
COPY . .
RUN go mod tidy
RUN swag init --dir ./,./handlers
And my go.mod file:
module github.com/ZiplEix/API_template
go 1.20
require github.com/gofiber/swagger v0.1.12
require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/PuerkitoBio/purell v1.2.0 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/spec v0.20.4 // indirect
github.com/go-openapi/swag v0.19.15 // indirect
github.com/gofiber/fiber/v2 v2.47.0 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgx/v5 v5.3.1 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.16.3 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/philhofer/fwd v1.1.2 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94 // indirect
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee // indirect
github.com/swaggo/files/v2 v2.0.0 // indirect
github.com/swaggo/swag v1.16.1 // indirect
github.com/tinylib/msgp v1.1.8 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.47.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
golang.org/x/crypto v0.10.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/text v0.10.0 // indirect
golang.org/x/tools v0.7.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gorm.io/driver/postgres v1.5.2 // indirect
gorm.io/gorm v1.25.2 // indirect
)
Does anyone have a solution ?
Swagger doc package needs to be imported in the swagger.go file to work correctly.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.