feat: fully implement profile controller;
feat: implement file upload handling in controller with size and type validation; feat: add custom validation rules for bio and color hex fields; refactor: enhance request handling with dedicated client info extraction; chore: update profile DTOs with validation tags; docs: profile controller swagger
This commit is contained in:
@@ -269,6 +269,210 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/profile": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"JWT": []
|
||||
}
|
||||
],
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Profile"
|
||||
],
|
||||
"summary": "Get your profile",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": " ",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.ProfileDto"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"patch": {
|
||||
"security": [
|
||||
{
|
||||
"JWT": []
|
||||
}
|
||||
],
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Profile"
|
||||
],
|
||||
"summary": "Update your profile",
|
||||
"parameters": [
|
||||
{
|
||||
"description": " ",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.ProfileDto"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": " ",
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/profile/avatar": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"JWT": []
|
||||
}
|
||||
],
|
||||
"consumes": [
|
||||
"multipart/form-data"
|
||||
],
|
||||
"produces": [
|
||||
"text/plain"
|
||||
],
|
||||
"tags": [
|
||||
"Profile"
|
||||
],
|
||||
"summary": "Upload an avatar",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "file",
|
||||
"description": "Avatar image file",
|
||||
"name": "file",
|
||||
"in": "formData",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Uploaded image url",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/profile/settings": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"JWT": []
|
||||
}
|
||||
],
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Profile"
|
||||
],
|
||||
"summary": "Get your profile settings",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": " ",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.ProfileSettingsDto"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"patch": {
|
||||
"security": [
|
||||
{
|
||||
"JWT": []
|
||||
}
|
||||
],
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Profile"
|
||||
],
|
||||
"summary": "Update your profile's settings",
|
||||
"parameters": [
|
||||
{
|
||||
"description": " ",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.ProfileSettingsDto"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": " ",
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/profile/{username}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"JWT": []
|
||||
}
|
||||
],
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Profile"
|
||||
],
|
||||
"summary": "Get profile by username",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": " ",
|
||||
"name": "username",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": " ",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.ProfileDto"
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Restricted profile"
|
||||
},
|
||||
"404": {
|
||||
"description": "Profile not found"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/service/health": {
|
||||
"get": {
|
||||
"description": "Used internally for checking service health",
|
||||
@@ -294,6 +498,58 @@ const docTemplate = `{
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"dto.ProfileDto": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"avatar_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"bio": {
|
||||
"type": "string"
|
||||
},
|
||||
"birthday": {
|
||||
"type": "integer"
|
||||
},
|
||||
"color": {
|
||||
"type": "string"
|
||||
},
|
||||
"color_grad": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.ProfileSettingsDto": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"captcha": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"followers_only_interaction": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hide_birthday": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hide_dates": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hide_for_unauthenticated": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hide_fulfilled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hide_profile_details": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.ChangePasswordRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
||||
@@ -265,6 +265,210 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/profile": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"JWT": []
|
||||
}
|
||||
],
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Profile"
|
||||
],
|
||||
"summary": "Get your profile",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": " ",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.ProfileDto"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"patch": {
|
||||
"security": [
|
||||
{
|
||||
"JWT": []
|
||||
}
|
||||
],
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Profile"
|
||||
],
|
||||
"summary": "Update your profile",
|
||||
"parameters": [
|
||||
{
|
||||
"description": " ",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.ProfileDto"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": " ",
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/profile/avatar": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"JWT": []
|
||||
}
|
||||
],
|
||||
"consumes": [
|
||||
"multipart/form-data"
|
||||
],
|
||||
"produces": [
|
||||
"text/plain"
|
||||
],
|
||||
"tags": [
|
||||
"Profile"
|
||||
],
|
||||
"summary": "Upload an avatar",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "file",
|
||||
"description": "Avatar image file",
|
||||
"name": "file",
|
||||
"in": "formData",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Uploaded image url",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/profile/settings": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"JWT": []
|
||||
}
|
||||
],
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Profile"
|
||||
],
|
||||
"summary": "Get your profile settings",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": " ",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.ProfileSettingsDto"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"patch": {
|
||||
"security": [
|
||||
{
|
||||
"JWT": []
|
||||
}
|
||||
],
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Profile"
|
||||
],
|
||||
"summary": "Update your profile's settings",
|
||||
"parameters": [
|
||||
{
|
||||
"description": " ",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.ProfileSettingsDto"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": " ",
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/profile/{username}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"JWT": []
|
||||
}
|
||||
],
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Profile"
|
||||
],
|
||||
"summary": "Get profile by username",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": " ",
|
||||
"name": "username",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": " ",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.ProfileDto"
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Restricted profile"
|
||||
},
|
||||
"404": {
|
||||
"description": "Profile not found"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/service/health": {
|
||||
"get": {
|
||||
"description": "Used internally for checking service health",
|
||||
@@ -290,6 +494,58 @@
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"dto.ProfileDto": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"avatar_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"bio": {
|
||||
"type": "string"
|
||||
},
|
||||
"birthday": {
|
||||
"type": "integer"
|
||||
},
|
||||
"color": {
|
||||
"type": "string"
|
||||
},
|
||||
"color_grad": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.ProfileSettingsDto": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"captcha": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"followers_only_interaction": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hide_birthday": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hide_dates": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hide_for_unauthenticated": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hide_fulfilled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"hide_profile_details": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.ChangePasswordRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
||||
@@ -1,5 +1,39 @@
|
||||
basePath: /api/
|
||||
definitions:
|
||||
dto.ProfileDto:
|
||||
properties:
|
||||
avatar_url:
|
||||
type: string
|
||||
bio:
|
||||
type: string
|
||||
birthday:
|
||||
type: integer
|
||||
color:
|
||||
type: string
|
||||
color_grad:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
required:
|
||||
- name
|
||||
type: object
|
||||
dto.ProfileSettingsDto:
|
||||
properties:
|
||||
captcha:
|
||||
type: boolean
|
||||
followers_only_interaction:
|
||||
type: boolean
|
||||
hide_birthday:
|
||||
type: boolean
|
||||
hide_dates:
|
||||
type: boolean
|
||||
hide_for_unauthenticated:
|
||||
type: boolean
|
||||
hide_fulfilled:
|
||||
type: boolean
|
||||
hide_profile_details:
|
||||
type: boolean
|
||||
type: object
|
||||
models.ChangePasswordRequest:
|
||||
properties:
|
||||
old_password:
|
||||
@@ -285,6 +319,130 @@ paths:
|
||||
summary: Confirm with code, finish creating the account
|
||||
tags:
|
||||
- Auth
|
||||
/profile:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: ' '
|
||||
schema:
|
||||
$ref: '#/definitions/dto.ProfileDto'
|
||||
security:
|
||||
- JWT: []
|
||||
summary: Get your profile
|
||||
tags:
|
||||
- Profile
|
||||
patch:
|
||||
consumes:
|
||||
- application/json
|
||||
parameters:
|
||||
- description: ' '
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/dto.ProfileDto'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: ' '
|
||||
schema:
|
||||
type: boolean
|
||||
security:
|
||||
- JWT: []
|
||||
summary: Update your profile
|
||||
tags:
|
||||
- Profile
|
||||
/profile/{username}:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
parameters:
|
||||
- description: ' '
|
||||
in: path
|
||||
name: username
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: ' '
|
||||
schema:
|
||||
$ref: '#/definitions/dto.ProfileDto'
|
||||
"403":
|
||||
description: Restricted profile
|
||||
"404":
|
||||
description: Profile not found
|
||||
security:
|
||||
- JWT: []
|
||||
summary: Get profile by username
|
||||
tags:
|
||||
- Profile
|
||||
/profile/avatar:
|
||||
post:
|
||||
consumes:
|
||||
- multipart/form-data
|
||||
parameters:
|
||||
- description: Avatar image file
|
||||
in: formData
|
||||
name: file
|
||||
required: true
|
||||
type: file
|
||||
produces:
|
||||
- text/plain
|
||||
responses:
|
||||
"200":
|
||||
description: Uploaded image url
|
||||
schema:
|
||||
type: string
|
||||
security:
|
||||
- JWT: []
|
||||
summary: Upload an avatar
|
||||
tags:
|
||||
- Profile
|
||||
/profile/settings:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: ' '
|
||||
schema:
|
||||
$ref: '#/definitions/dto.ProfileSettingsDto'
|
||||
security:
|
||||
- JWT: []
|
||||
summary: Get your profile settings
|
||||
tags:
|
||||
- Profile
|
||||
patch:
|
||||
consumes:
|
||||
- application/json
|
||||
parameters:
|
||||
- description: ' '
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/dto.ProfileSettingsDto'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: ' '
|
||||
schema:
|
||||
type: boolean
|
||||
security:
|
||||
- JWT: []
|
||||
summary: Update your profile's settings
|
||||
tags:
|
||||
- Profile
|
||||
/service/health:
|
||||
get:
|
||||
consumes:
|
||||
|
||||
Reference in New Issue
Block a user