-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add user registration schemas and update tests
- Loading branch information
1 parent
febb9e5
commit da7311a
Showing
4 changed files
with
98 additions
and
21 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ defmodule BuildelWeb.Schemas.Users do | |
title: "User", | ||
type: :object, | ||
properties: %{ | ||
id: %Schema{type: :integer, description: "User ID"}, | ||
id: %Schema{type: :integer, description: "User ID"} | ||
}, | ||
required: [:id] | ||
}) | ||
|
@@ -36,7 +36,11 @@ defmodule BuildelWeb.Schemas.Users do | |
properties: %{ | ||
current_password: %Schema{type: :string, description: "Current password", minLength: 12}, | ||
password: %Schema{type: :string, description: "New password", minLength: 12}, | ||
password_confirmation: %Schema{type: :string, description: "New password confirmation", minLength: 12} | ||
password_confirmation: %Schema{ | ||
type: :string, | ||
description: "New password confirmation", | ||
minLength: 12 | ||
} | ||
}, | ||
required: [:current_password, :password, :password_confirmation] | ||
}) | ||
|
@@ -49,7 +53,12 @@ defmodule BuildelWeb.Schemas.Users do | |
title: "UserCreateForgotPasswordRequest", | ||
type: :object, | ||
properties: %{ | ||
email: %Schema{type: :string, description: "User email", pattern: ~r/@/}, | ||
email: %Schema{ | ||
type: :string, | ||
description: "User email", | ||
pattern: ~r/^[^\s]+@[^\s]+$/, | ||
example: "[email protected]" | ||
} | ||
}, | ||
required: [:email] | ||
}) | ||
|
@@ -64,9 +73,38 @@ defmodule BuildelWeb.Schemas.Users do | |
properties: %{ | ||
token: %Schema{type: :string, description: "Token"}, | ||
password: %Schema{type: :string, description: "New password", minLength: 12}, | ||
password_confirmation: %Schema{type: :string, description: "New password confirmation", minLength: 12}, | ||
password_confirmation: %Schema{ | ||
type: :string, | ||
description: "New password confirmation", | ||
minLength: 12 | ||
} | ||
}, | ||
required: [:token, :password, :password_confirmation] | ||
}) | ||
end | ||
|
||
defmodule CreateRegistrationRequest do | ||
require OpenApiSpex | ||
|
||
OpenApiSpex.schema(%{ | ||
title: "UserCreateRegistrationRequest", | ||
type: :object, | ||
properties: %{ | ||
user: %Schema{ | ||
type: :object, | ||
properties: %{ | ||
email: %Schema{ | ||
type: :string, | ||
description: "Email", | ||
pattern: ~r/^[^\s]+@[^\s]+$/, | ||
example: "[email protected]" | ||
}, | ||
password: %Schema{type: :string, description: "Password", minLength: 12} | ||
}, | ||
required: [:email, :password] | ||
} | ||
}, | ||
required: [:user] | ||
}) | ||
end | ||
end |
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