DEV: Update email responses in api docs (#15178)

Documenting the `/u/:username:/emails.json` endpoint.

Also removing some email fields from user api responses because they
aren't actually included in the response unless you are querying
yourself.
This commit is contained in:
Blake Erickson 2021-12-03 08:03:58 -07:00 committed by GitHub
parent 75dbc488d9
commit 643f82d8d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 20 deletions

View File

@ -13,13 +13,6 @@
"avatar_template": {
"type": "string"
},
"email": {
"type": "string"
},
"secondary_emails": {
"type": "array",
"items": []
},
"active": {
"type": "boolean"
},

View File

@ -0,0 +1,26 @@
{
"additionalProperties": false,
"properties": {
"email": {
"type": "string"
},
"secondary_emails": {
"type": "array",
"items": []
},
"unconfirmed_emails": {
"type": "array",
"items": []
},
"associated_accounts": {
"type": "array",
"items": []
}
},
"required": [
"email",
"secondary_emails",
"unconfirmed_emails",
"associated_accounts"
]
}

View File

@ -74,18 +74,6 @@
"badge_count": {
"type": "integer"
},
"email": {
"type": "string"
},
"secondary_emails": {
"type": "array"
},
"unconfirmed_emails": {
"type": "array"
},
"associated_accounts": {
"type": "array"
},
"second_factor_backup_enabled": {
"type": "boolean"
},

View File

@ -63,7 +63,8 @@ describe 'users' do
expected_response_schema = load_spec_schema('user_get_response')
schema expected_response_schema
let(:username) { 'system' }
let(:username) { Fabricate(:user).username }
it_behaves_like "a JSON endpoint", 200 do
let(:expected_response_schema) { expected_response_schema }
let(:expected_request_schema) { expected_request_schema }
@ -583,4 +584,27 @@ describe 'users' do
end
end
path '/u/{username}/emails.json' do
get 'Get email addresses belonging to a user' do
tags 'Users'
operationId 'getUserEmails'
consumes 'application/json'
expected_request_schema = nil
parameter name: :username, in: :path, type: :string, required: true
produces 'application/json'
response '200', 'success response' do
expected_response_schema = load_spec_schema('user_emails_response')
schema expected_response_schema
let(:username) { Fabricate(:user).username }
it_behaves_like "a JSON endpoint", 200 do
let(:expected_response_schema) { expected_response_schema }
let(:expected_request_schema) { expected_request_schema }
end
end
end
end
end