forked from mirrors/homebox
chore: refactor api endpoints (#339)
* move typegen code * update taskfile to fix code-gen caches and use 'dir' attribute * enable dumping stack traces for errors * log request start and stop * set zerolog stack handler * fix routes function * refactor context adapters to use requests directly * change some method signatures to support GID * start requiring validation tags * first pass on updating handlers to use adapters * add errs package * code gen * tidy * rework API to use external server package
This commit is contained in:
parent
184b494fc3
commit
db80f8a159
56 changed files with 806 additions and 1947 deletions
|
@ -425,8 +425,8 @@ const docTemplate = `{
|
|||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"201": {
|
||||
"description": "Created",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/repo.ItemSummary"
|
||||
}
|
||||
|
@ -694,7 +694,7 @@ const docTemplate = `{
|
|||
"422": {
|
||||
"description": "Unprocessable Entity",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/server.ErrorResponse"
|
||||
"$ref": "#/definitions/mid.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -864,8 +864,8 @@ const docTemplate = `{
|
|||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"201": {
|
||||
"description": "Created",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/repo.MaintenanceEntry"
|
||||
}
|
||||
|
@ -947,7 +947,7 @@ const docTemplate = `{
|
|||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/server.Results"
|
||||
"$ref": "#/definitions/v1.Wrapped"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
|
@ -1119,7 +1119,7 @@ const docTemplate = `{
|
|||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/server.Results"
|
||||
"$ref": "#/definitions/v1.Wrapped"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
|
@ -1199,7 +1199,7 @@ const docTemplate = `{
|
|||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/server.Results"
|
||||
"$ref": "#/definitions/v1.Wrapped"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
|
@ -1339,7 +1339,7 @@ const docTemplate = `{
|
|||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/server.Results"
|
||||
"$ref": "#/definitions/v1.Wrapped"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
|
@ -1719,7 +1719,7 @@ const docTemplate = `{
|
|||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/server.Result"
|
||||
"$ref": "#/definitions/v1.Wrapped"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
|
@ -1764,7 +1764,7 @@ const docTemplate = `{
|
|||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/server.Result"
|
||||
"$ref": "#/definitions/v1.Wrapped"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
|
@ -1801,6 +1801,20 @@ const docTemplate = `{
|
|||
}
|
||||
},
|
||||
"definitions": {
|
||||
"mid.ErrorResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string"
|
||||
},
|
||||
"fields": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.DocumentOut": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -1902,9 +1916,15 @@ const docTemplate = `{
|
|||
},
|
||||
"repo.ItemCreate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"description",
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"maxLength": 1000,
|
||||
"minLength": 1
|
||||
},
|
||||
"labelIds": {
|
||||
"type": "array",
|
||||
|
@ -1917,7 +1937,9 @@ const docTemplate = `{
|
|||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"minLength": 1
|
||||
},
|
||||
"parentId": {
|
||||
"type": "string",
|
||||
|
@ -2208,15 +2230,21 @@ const docTemplate = `{
|
|||
},
|
||||
"repo.LabelCreate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"color": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"maxLength": 255
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"minLength": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -2663,39 +2691,6 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"server.ErrorResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string"
|
||||
},
|
||||
"fields": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"server.Result": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"details": {},
|
||||
"error": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"item": {},
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"server.Results": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"items": {}
|
||||
}
|
||||
},
|
||||
"services.UserRegistration": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -2791,12 +2786,17 @@ const docTemplate = `{
|
|||
},
|
||||
"v1.GroupInvitationCreate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"uses"
|
||||
],
|
||||
"properties": {
|
||||
"expiresAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"uses": {
|
||||
"type": "integer"
|
||||
"type": "integer",
|
||||
"maximum": 100,
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -2821,6 +2821,12 @@ const docTemplate = `{
|
|||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.Wrapped": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"item": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"securityDefinitions": {
|
||||
|
|
|
@ -417,8 +417,8 @@
|
|||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"201": {
|
||||
"description": "Created",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/repo.ItemSummary"
|
||||
}
|
||||
|
@ -686,7 +686,7 @@
|
|||
"422": {
|
||||
"description": "Unprocessable Entity",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/server.ErrorResponse"
|
||||
"$ref": "#/definitions/mid.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -856,8 +856,8 @@
|
|||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"201": {
|
||||
"description": "Created",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/repo.MaintenanceEntry"
|
||||
}
|
||||
|
@ -939,7 +939,7 @@
|
|||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/server.Results"
|
||||
"$ref": "#/definitions/v1.Wrapped"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
|
@ -1111,7 +1111,7 @@
|
|||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/server.Results"
|
||||
"$ref": "#/definitions/v1.Wrapped"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
|
@ -1191,7 +1191,7 @@
|
|||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/server.Results"
|
||||
"$ref": "#/definitions/v1.Wrapped"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
|
@ -1331,7 +1331,7 @@
|
|||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/server.Results"
|
||||
"$ref": "#/definitions/v1.Wrapped"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
|
@ -1711,7 +1711,7 @@
|
|||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/server.Result"
|
||||
"$ref": "#/definitions/v1.Wrapped"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
|
@ -1756,7 +1756,7 @@
|
|||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/server.Result"
|
||||
"$ref": "#/definitions/v1.Wrapped"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
|
@ -1793,6 +1793,20 @@
|
|||
}
|
||||
},
|
||||
"definitions": {
|
||||
"mid.ErrorResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string"
|
||||
},
|
||||
"fields": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.DocumentOut": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -1894,9 +1908,15 @@
|
|||
},
|
||||
"repo.ItemCreate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"description",
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"maxLength": 1000,
|
||||
"minLength": 1
|
||||
},
|
||||
"labelIds": {
|
||||
"type": "array",
|
||||
|
@ -1909,7 +1929,9 @@
|
|||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"minLength": 1
|
||||
},
|
||||
"parentId": {
|
||||
"type": "string",
|
||||
|
@ -2200,15 +2222,21 @@
|
|||
},
|
||||
"repo.LabelCreate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"color": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"maxLength": 255
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"minLength": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -2655,39 +2683,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"server.ErrorResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string"
|
||||
},
|
||||
"fields": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"server.Result": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"details": {},
|
||||
"error": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"item": {},
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"server.Results": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"items": {}
|
||||
}
|
||||
},
|
||||
"services.UserRegistration": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -2783,12 +2778,17 @@
|
|||
},
|
||||
"v1.GroupInvitationCreate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"uses"
|
||||
],
|
||||
"properties": {
|
||||
"expiresAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"uses": {
|
||||
"type": "integer"
|
||||
"type": "integer",
|
||||
"maximum": 100,
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -2813,6 +2813,12 @@
|
|||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.Wrapped": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"item": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"securityDefinitions": {
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
basePath: /api
|
||||
definitions:
|
||||
mid.ErrorResponse:
|
||||
properties:
|
||||
error:
|
||||
type: string
|
||||
fields:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
repo.DocumentOut:
|
||||
properties:
|
||||
id:
|
||||
|
@ -67,6 +76,8 @@ definitions:
|
|||
repo.ItemCreate:
|
||||
properties:
|
||||
description:
|
||||
maxLength: 1000
|
||||
minLength: 1
|
||||
type: string
|
||||
labelIds:
|
||||
items:
|
||||
|
@ -76,10 +87,15 @@ definitions:
|
|||
description: Edges
|
||||
type: string
|
||||
name:
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
type: string
|
||||
parentId:
|
||||
type: string
|
||||
x-nullable: true
|
||||
required:
|
||||
- description
|
||||
- name
|
||||
type: object
|
||||
repo.ItemField:
|
||||
properties:
|
||||
|
@ -281,9 +297,14 @@ definitions:
|
|||
color:
|
||||
type: string
|
||||
description:
|
||||
maxLength: 255
|
||||
type: string
|
||||
name:
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
type: string
|
||||
required:
|
||||
- name
|
||||
type: object
|
||||
repo.LabelOut:
|
||||
properties:
|
||||
|
@ -579,28 +600,6 @@ definitions:
|
|||
value:
|
||||
type: number
|
||||
type: object
|
||||
server.ErrorResponse:
|
||||
properties:
|
||||
error:
|
||||
type: string
|
||||
fields:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
server.Result:
|
||||
properties:
|
||||
details: {}
|
||||
error:
|
||||
type: boolean
|
||||
item: {}
|
||||
message:
|
||||
type: string
|
||||
type: object
|
||||
server.Results:
|
||||
properties:
|
||||
items: {}
|
||||
type: object
|
||||
services.UserRegistration:
|
||||
properties:
|
||||
email:
|
||||
|
@ -666,7 +665,11 @@ definitions:
|
|||
expiresAt:
|
||||
type: string
|
||||
uses:
|
||||
maximum: 100
|
||||
minimum: 1
|
||||
type: integer
|
||||
required:
|
||||
- uses
|
||||
type: object
|
||||
v1.ItemAttachmentToken:
|
||||
properties:
|
||||
|
@ -682,6 +685,10 @@ definitions:
|
|||
token:
|
||||
type: string
|
||||
type: object
|
||||
v1.Wrapped:
|
||||
properties:
|
||||
item: {}
|
||||
type: object
|
||||
info:
|
||||
contact:
|
||||
name: Don't
|
||||
|
@ -932,8 +939,8 @@ paths:
|
|||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
"201":
|
||||
description: Created
|
||||
schema:
|
||||
$ref: '#/definitions/repo.ItemSummary'
|
||||
security:
|
||||
|
@ -1036,7 +1043,7 @@ paths:
|
|||
"422":
|
||||
description: Unprocessable Entity
|
||||
schema:
|
||||
$ref: '#/definitions/server.ErrorResponse'
|
||||
$ref: '#/definitions/mid.ErrorResponse'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Create Item Attachment
|
||||
|
@ -1140,8 +1147,8 @@ paths:
|
|||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
"201":
|
||||
description: Created
|
||||
schema:
|
||||
$ref: '#/definitions/repo.MaintenanceEntry'
|
||||
security:
|
||||
|
@ -1252,7 +1259,7 @@ paths:
|
|||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/server.Results'
|
||||
- $ref: '#/definitions/v1.Wrapped'
|
||||
- properties:
|
||||
items:
|
||||
items:
|
||||
|
@ -1354,7 +1361,7 @@ paths:
|
|||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/server.Results'
|
||||
- $ref: '#/definitions/v1.Wrapped'
|
||||
- properties:
|
||||
items:
|
||||
items:
|
||||
|
@ -1462,7 +1469,7 @@ paths:
|
|||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/server.Results'
|
||||
- $ref: '#/definitions/v1.Wrapped'
|
||||
- properties:
|
||||
items:
|
||||
items:
|
||||
|
@ -1483,7 +1490,7 @@ paths:
|
|||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/server.Results'
|
||||
- $ref: '#/definitions/v1.Wrapped'
|
||||
- properties:
|
||||
items:
|
||||
items:
|
||||
|
@ -1725,7 +1732,7 @@ paths:
|
|||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/server.Result'
|
||||
- $ref: '#/definitions/v1.Wrapped'
|
||||
- properties:
|
||||
item:
|
||||
$ref: '#/definitions/repo.UserOut'
|
||||
|
@ -1750,7 +1757,7 @@ paths:
|
|||
description: OK
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/server.Result'
|
||||
- $ref: '#/definitions/v1.Wrapped'
|
||||
- properties:
|
||||
item:
|
||||
$ref: '#/definitions/repo.UserUpdate'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue