-
Notifications
You must be signed in to change notification settings - Fork 0
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
6434438023/oph24 8 documentation swagger #11
Conversation
do a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please rebase on origin/beta. I can't read what you've written because code pr is mixed with other.
cmd/main.go
Outdated
r.GET("/live", container.FeatureflagHandler.GetLivestreamInfo) | ||
r.GET("/events", container.EventHandler.GetAllEvents) | ||
r.GET("/events/:eventId", container.EventHandler.GetEventById) | ||
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check for env it is deployed in
if container.Config.AppConfig.Env != "development" {
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
}
cmd/main.go
Outdated
// @title OPH-66 Backend API | ||
// @version 1.0 | ||
// @description This is a sample server celler server. | ||
// @securityDefinitions.basic BasicAuth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use BearerAuth
not BasicAuth
cmd/main.go
Outdated
) | ||
|
||
// @title OPH-66 Backend API | ||
// @version 1.0 | ||
// @description This is a sample server celler server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it little more meaningful.
cmd/main.go
Outdated
|
||
fmt.Println(container.Config.AppConfig.Port) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this debug
package response | ||
|
||
type featureFlagResponse struct { | ||
Key string `json:"key" example:"livestream"` | ||
Enabled bool `json:"enabled" example:"true"` | ||
ExtraInfo string `json:"extra_info" example:"https://www.youtube.com/watch?v=6n3pFFPSlW4"` | ||
} | ||
|
||
type featureFlagErrorResponse struct { | ||
Instance string `json:"instance" example:"/featureflag/live"` | ||
Title string `json:"title" example:"internal-server-error"` | ||
} | ||
|
||
type featureFlagInvalidResponse struct { | ||
Instance string `json:"instance" example:"/featureflag/live"` | ||
Title string `json:"title" example:"invalid-feature-flag-key"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be more appropiate to put this in each /internal/X
. For example,
// internal/feature_flag/feature_flag.dto.go
type featureFlagResponse struct {
Key string `json:"key" example:"livestream"`
Enabled bool `json:"enabled" example:"true"`
ExtraInfo string `json:"extra_info" example:"https://www.youtube.com/watch?v=6n3pFFPSlW4"`
}
type featureFlagErrorResponse struct {
Instance string `json:"instance" example:"/featureflag/live"`
Title string `json:"title" example:"internal-server-error"`
}
type featureFlagInvalidResponse struct {
Instance string `json:"instance" example:"/featureflag/live"`
Title string `json:"title" example:"invalid-feature-flag-key"`
}
This is roughly your git branch situation gitGraph
commit
commit
branch develop
checkout main
commit id: "feat: event"
checkout develop
merge main
commit
checkout main
commit id: "fix: featureflag"
checkout develop
merge main
commit
commit
commit
checkout main
merge develop
You can see that from you branch perspective, you have commit other code as well. To fix this (not easy tho), you need to rebase your code on origin beta git rebase -i origin beta then resolve every conflict after that your git history should look like this gitGraph
commit
commit
checkout main
commit id: "feat: event"
commit id: "fix: featureflag"
branch develop
commit
commit
commit
commit
checkout main
merge develop
To prevent this from happening again you can do git config --global pull.rebase true |
76070b0
to
05651f0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please rebase on origin/beta. I can't read what you've written because code pr is mixed with other.
cfgldr/cfgldr.go
Outdated
@@ -26,6 +26,7 @@ type RedisConfig struct { | |||
} | |||
|
|||
func LoadConfig() (*Config, error) { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.env.example
Outdated
DB_URL=postgres://postgres:[email protected]:5432/postgres | ||
|
||
REDIS_ADDR=127.0.0.1 | ||
REDIS_PORT=6379 | ||
REDIS_PASSWORD=123456 | ||
|
||
APP_PORT=3000 | ||
APP_ENV=development |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bring back .env.example
internal/event/event.dto.go
Outdated
type eventInvalidResponse struct { | ||
Instance string `json:"instance" example:"/events/:eventId"` | ||
Title string `json:"title" example:"invalid-event-id"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type eventInvalidResponse struct { | |
Instance string `json:"instance" example:"/events/:eventId"` | |
Title string `json:"title" example:"invalid-event-id"` | |
} | |
//nolint:all | |
type EventInvalidResponse struct { | |
Instance string `json:"instance" example:"/events/:eventId"` | |
Title string `json:"title" example:"invalid-event-id"` | |
} |
internal/event/event.dto.go
Outdated
type eventErrorResponse struct { | ||
Instance string `json:"instance" example:"/events/:eventId"` | ||
Title string `json:"title" example:"internal-server-error"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type eventErrorResponse struct { | |
Instance string `json:"instance" example:"/events/:eventId"` | |
Title string `json:"title" example:"internal-server-error"` | |
} | |
//nolint:all | |
type EventErrorResponse struct { | |
Instance string `json:"instance" example:"/events/:eventId"` | |
Title string `json:"title" example:"internal-server-error"` | |
} |
internal/event/event.dto.go
Outdated
type EventDTO struct { | ||
Id string `json:"id" example:"first-event"` | ||
Name NameEventBilingual `json:"name" ` | ||
FacultyCode int `json:"-" ` | ||
Faculty Faculty `json:"faculty"` | ||
Department DepartmentBilingual `json:"department" ` | ||
RequireRegistration bool `json:"require_registration" example:"true"` | ||
MaxCapacity int `json:"max_capacity" example:"100"` | ||
Schedules []Schedule `json:"schedules" ` | ||
Location LocationBilingual `json:"location"` | ||
Description DescriptionBilingual `json:"description,omitempty"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type EventDTO struct { | |
Id string `json:"id" example:"first-event"` | |
Name NameEventBilingual `json:"name" ` | |
FacultyCode int `json:"-" ` | |
Faculty Faculty `json:"faculty"` | |
Department DepartmentBilingual `json:"department" ` | |
RequireRegistration bool `json:"require_registration" example:"true"` | |
MaxCapacity int `json:"max_capacity" example:"100"` | |
Schedules []Schedule `json:"schedules" ` | |
Location LocationBilingual `json:"location"` | |
Description DescriptionBilingual `json:"description,omitempty"` | |
} | |
type EventDTO struct { | |
Id string `json:"id" example:"first-event"` | |
Name NameEventBilingual `json:"name"` | |
FacultyCode int `json:"-"` | |
Faculty Faculty `json:"faculty"` | |
Department DepartmentBilingual `json:"department"` | |
RequireRegistration bool `json:"require_registration" example:"true"` | |
MaxCapacity int `json:"max_capacity" example:"100"` | |
Schedules []Schedule `json:"schedules"` | |
Location LocationBilingual `json:"location"` | |
Description DescriptionBilingual `json:"description,omitempty"` | |
} |
internal/event/event.handler.go
Outdated
// GetAllEvents godoc | ||
// @summary Get all events | ||
// @description Get all events as array of events | ||
// @id GetAllEvents | ||
// @produce json | ||
// @tags event | ||
// @Security Bearer | ||
// @router /events [get] | ||
// @success 200 {object} event.EventAll | ||
// @Failure 500 {object} event.eventAllErrorResponse | ||
// @Failure 404 {object} event.eventInvalidResponse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// GetAllEvents godoc | |
// @summary Get all events | |
// @description Get all events as array of events | |
// @id GetAllEvents | |
// @produce json | |
// @tags event | |
// @Security Bearer | |
// @router /events [get] | |
// @success 200 {object} event.EventAll | |
// @Failure 500 {object} event.eventAllErrorResponse | |
// @Failure 404 {object} event.eventInvalidResponse | |
// GetAllEvents godoc | |
// @summary Get all events | |
// @description Get all events as array of events | |
// @id GetAllEvents | |
// @produce json | |
// @tags event | |
// @Security Bearer | |
// @router /events [get] | |
// @success 200 {object} event.EventAll | |
// @Failure 500 {object} event.eventAllErrorResponse | |
// @Failure 404 {object} event.eventInvalidResponse |
internal/event/event.handler.go
Outdated
// GetEvent godoc | ||
// @summary get event by id | ||
// @description Get event by id | ||
// @id GetEventById | ||
// @produce json | ||
// @tags event | ||
// @Security Bearer | ||
// @param eventId path string true "event id" | ||
// @router /events/{eventId} [get] | ||
// @success 200 {object} event.EventDTO | ||
// @Failure 500 {object} event.eventErrorResponse | ||
// @Failure 404 {object} event.eventInvalidResponse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// GetEvent godoc | |
// @summary get event by id | |
// @description Get event by id | |
// @id GetEventById | |
// @produce json | |
// @tags event | |
// @Security Bearer | |
// @param eventId path string true "event id" | |
// @router /events/{eventId} [get] | |
// @success 200 {object} event.EventDTO | |
// @Failure 500 {object} event.eventErrorResponse | |
// @Failure 404 {object} event.eventInvalidResponse | |
// GetEvent godoc | |
// @summary get event by id | |
// @description Get event by id | |
// @id GetEventById | |
// @produce json | |
// @tags event | |
// @Security Bearer | |
// @param eventId path string true "event id" | |
// @router /events/{eventId} [get] | |
// @success 200 {object} event.EventDTO | |
// @Failure 500 {object} event.eventErrorResponse | |
// @Failure 404 {object} event.eventInvalidResponse |
// GetLivestreamInfo godoc | ||
// @summary Get livestream flag | ||
// @description Get livestream flag | ||
// @id GetLivestreamInfo | ||
// @produce json | ||
// @tags LiveStream | ||
// @Security Bearer | ||
// @router /live [get] | ||
// @success 200 {object} featureflag.response | ||
// @Failure 500 {object} featureflag.errorResponse | ||
// @Failure 404 {object} featureflag.invalidResponse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// GetLivestreamInfo godoc | |
// @summary Get livestream flag | |
// @description Get livestream flag | |
// @id GetLivestreamInfo | |
// @produce json | |
// @tags LiveStream | |
// @Security Bearer | |
// @router /live [get] | |
// @success 200 {object} featureflag.response | |
// @Failure 500 {object} featureflag.errorResponse | |
// @Failure 404 {object} featureflag.invalidResponse | |
// GetLivestreamInfo godoc | |
// @summary Get livestream flag | |
// @description Get livestream flag | |
// @id GetLivestreamInfo | |
// @produce json | |
// @tags FeatureFlag | |
// @Security Bearer | |
// @router /live [get] | |
// @success 200 {object} featureflag.response | |
// @Failure 500 {object} featureflag.errorResponse | |
// @Failure 404 {object} featureflag.invalidResponse |
type response struct { | ||
Key string `json:"key" example:"livestream"` | ||
Enabled bool `json:"enabled" example:"true"` | ||
ExtraInfo string `json:"extra_info" example:"https://www.youtube.com/watch?v=6n3pFFPSlW4"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type response struct { | |
Key string `json:"key" example:"livestream"` | |
Enabled bool `json:"enabled" example:"true"` | |
ExtraInfo string `json:"extra_info" example:"https://www.youtube.com/watch?v=6n3pFFPSlW4"` | |
} | |
type response struct { | |
Key string `json:"key" example:"livestream"` | |
Enabled bool `json:"enabled" example:"true"` | |
ExtraInfo string `json:"extra_info" example:"https://www.youtube.com/watch?v=6n3pFFPSlW4"` | |
} |
// HealthCheck godoc | ||
// @summary Health Check | ||
// @description Health Check for the service | ||
// @id HealthCheck | ||
// @produce plain | ||
// @tags healthcheck | ||
// @Security Bearer | ||
// @router /_hc [get] | ||
// @Success 200 {string} string "OK" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// HealthCheck godoc | |
// @summary Health Check | |
// @description Health Check for the service | |
// @id HealthCheck | |
// @produce plain | |
// @tags healthcheck | |
// @Security Bearer | |
// @router /_hc [get] | |
// @Success 200 {string} string "OK" | |
// HealthCheck godoc | |
// @summary Health Check | |
// @description Health Check for the service | |
// @id HealthCheck | |
// @produce plain | |
// @tags healthcheck | |
// @Security Bearer | |
// @router /_hc [get] | |
// @Success 200 {string} string "OK" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add more doc on new route
05651f0
to
5a8bd3e
Compare
parent 3afc3f0 author Wer1d <[email protected]> 1703441246 +0700 committer Wer1d <[email protected]> 1703441246 +0700 refactor: delete godotenv feat : add swagger fix: change BasicAuth to Bearer fix: delete import godotenv docs: auth docs docs: add user-not-found feat: config cors (#15) feat: Register + Login OIDC (#4) * feat: Register + Login OIDC * fix: fix user model * fix: combine login ®ister, add apperror, normalize database, getUser by header * fix: add atlas migrate, move logic from handler to service, use dto, add logic update * fix: repository, typo, ip/op type * fix: update init sql * refactor: remove migrate.md * fix:typo, config linters * refactor: run lint-fix * fix: normalize round, department, section * fix: model dep and section * refactor:linter-fix * refactor: lint-fix * fix: add fk in init sql, remove update in register, move convert to util file * fix: init sql , remove endpoint, change id to composit key * refactor: auth handler feat: document swagger fix: change BasicAuth to Bearer docs: auth docs docs: all refactor: go mod tidy
ef848ec
to
40a35d9
Compare
เขียน swagger ของ event , healthcheck and livestreamFlag