Created
May 2, 2020 13:21
-
-
Save RubaXa/d1e442083211ba3bd13ce55910effd73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// InitEndpointScheme - инициализация описания «конца» | |
func (a *AuthLogin) InitEndpointScheme(s *draft.Scheme) { | |
// Проект, которому принадлежит «конец» | |
s.Project("auth") | |
// Метод доступен всем | |
s.Access(draft.Access.All) | |
// Базовый метод для всех кейсов | |
s.Method(draft.Method.POST) | |
// Название метода | |
s.Name("«Вход»") | |
// URL по которому будет доступен метод | |
s.URL("/api/v1/auth/login") | |
// Базовые параметры запроса для всех кейсов | |
s.Params(AuthLoginParams{ | |
Login: types.GenLogin(), | |
Password: types.GenPassword(), | |
}) | |
// 200 OK | |
s.Case(draft.Status.OK, "Успешная авторизация", func() { | |
s.Body(AuthLoginResponse{ | |
UserID: types.GenUserID(), | |
}) | |
}) | |
// 403 OK | |
s.Case(draft.Status.Denied, "Неправильный Логин или Пароль", func() { | |
// Переопределяем базовые параметры запроса | |
s.Params(AuthLoginParams{ | |
Login: "not-exists-login", | |
Password: types.GenPassword(), | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment