mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-22 16:45:43 +00:00
fix types
This commit is contained in:
parent
1143246816
commit
a67316a889
7 changed files with 42 additions and 37 deletions
|
@ -42,7 +42,7 @@ const docTemplate = `{
|
||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/v1.GroupTokenPayload"
|
"$ref": "#/definitions/v1.GroupInvitationCreate"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -50,7 +50,7 @@ const docTemplate = `{
|
||||||
"200": {
|
"200": {
|
||||||
"description": "OK",
|
"description": "OK",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/v1.GroupTokenResponse"
|
"$ref": "#/definitions/v1.GroupInvitation"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1582,26 +1582,26 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"v1.GroupTokenPayload": {
|
"v1.GroupInvitation": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"expiresAt": {
|
"expiresAt": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"token": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"uses": {
|
"uses": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"v1.GroupTokenResponse": {
|
"v1.GroupInvitationCreate": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"expiresAt": {
|
"expiresAt": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"token": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"uses": {
|
"uses": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/v1.GroupTokenPayload"
|
"$ref": "#/definitions/v1.GroupInvitationCreate"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
"200": {
|
"200": {
|
||||||
"description": "OK",
|
"description": "OK",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/v1.GroupTokenResponse"
|
"$ref": "#/definitions/v1.GroupInvitation"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1574,26 +1574,26 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"v1.GroupTokenPayload": {
|
"v1.GroupInvitation": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"expiresAt": {
|
"expiresAt": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"token": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"uses": {
|
"uses": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"v1.GroupTokenResponse": {
|
"v1.GroupInvitationCreate": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"expiresAt": {
|
"expiresAt": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"token": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"uses": {
|
"uses": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
}
|
}
|
||||||
|
|
|
@ -355,14 +355,7 @@ definitions:
|
||||||
version:
|
version:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
v1.GroupTokenPayload:
|
v1.GroupInvitation:
|
||||||
properties:
|
|
||||||
expiresAt:
|
|
||||||
type: string
|
|
||||||
uses:
|
|
||||||
type: integer
|
|
||||||
type: object
|
|
||||||
v1.GroupTokenResponse:
|
|
||||||
properties:
|
properties:
|
||||||
expiresAt:
|
expiresAt:
|
||||||
type: string
|
type: string
|
||||||
|
@ -371,6 +364,13 @@ definitions:
|
||||||
uses:
|
uses:
|
||||||
type: integer
|
type: integer
|
||||||
type: object
|
type: object
|
||||||
|
v1.GroupInvitationCreate:
|
||||||
|
properties:
|
||||||
|
expiresAt:
|
||||||
|
type: string
|
||||||
|
uses:
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
v1.ItemAttachmentToken:
|
v1.ItemAttachmentToken:
|
||||||
properties:
|
properties:
|
||||||
token:
|
token:
|
||||||
|
@ -402,14 +402,14 @@ paths:
|
||||||
name: payload
|
name: payload
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/v1.GroupTokenPayload'
|
$ref: '#/definitions/v1.GroupInvitationCreate'
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/v1.GroupTokenResponse'
|
$ref: '#/definitions/v1.GroupInvitation'
|
||||||
security:
|
security:
|
||||||
- Bearer: []
|
- Bearer: []
|
||||||
summary: Get the current user
|
summary: Get the current user
|
||||||
|
|
|
@ -10,12 +10,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
GroupTokenPayload struct {
|
GroupInvitationCreate struct {
|
||||||
Uses int `json:"uses"`
|
Uses int `json:"uses"`
|
||||||
ExpiresAt time.Time `json:"expiresAt"`
|
ExpiresAt time.Time `json:"expiresAt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupTokenResponse struct {
|
GroupInvitation struct {
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
ExpiresAt time.Time `json:"expiresAt"`
|
ExpiresAt time.Time `json:"expiresAt"`
|
||||||
Uses int `json:"uses"`
|
Uses int `json:"uses"`
|
||||||
|
@ -26,13 +26,13 @@ type (
|
||||||
// @Summary Get the current user
|
// @Summary Get the current user
|
||||||
// @Tags User
|
// @Tags User
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param payload body GroupTokenPayload true "User Data"
|
// @Param payload body GroupInvitationCreate true "User Data"
|
||||||
// @Success 200 {object} GroupTokenResponse
|
// @Success 200 {object} GroupInvitation
|
||||||
// @Router /v1/groups/invitations [Post]
|
// @Router /v1/groups/invitations [Post]
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
func (ctrl *V1Controller) HandleGroupInvitationsCreate() http.HandlerFunc {
|
func (ctrl *V1Controller) HandleGroupInvitationsCreate() http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
data := GroupTokenPayload{}
|
data := GroupInvitationCreate{}
|
||||||
|
|
||||||
if err := server.Decode(r, &data); err != nil {
|
if err := server.Decode(r, &data); err != nil {
|
||||||
log.Err(err).Msg("failed to decode user registration data")
|
log.Err(err).Msg("failed to decode user registration data")
|
||||||
|
@ -53,10 +53,10 @@ func (ctrl *V1Controller) HandleGroupInvitationsCreate() http.HandlerFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
server.Respond(w, http.StatusCreated, server.Wrap(GroupTokenResponse{
|
server.Respond(w, http.StatusCreated, GroupInvitation{
|
||||||
Token: token,
|
Token: token,
|
||||||
ExpiresAt: data.ExpiresAt,
|
ExpiresAt: data.ExpiresAt,
|
||||||
Uses: data.Uses,
|
Uses: data.Uses,
|
||||||
}))
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,14 +239,14 @@ export interface Build {
|
||||||
version: string;
|
version: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GroupTokenPayload {
|
export interface GroupInvitation {
|
||||||
expiresAt: string;
|
expiresAt: Date;
|
||||||
|
token: string;
|
||||||
uses: number;
|
uses: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GroupTokenResponse {
|
export interface GroupInvitationCreate {
|
||||||
expiresAt: string;
|
expiresAt: Date;
|
||||||
token: string;
|
|
||||||
uses: number;
|
uses: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,6 +255,6 @@ export interface ItemAttachmentToken {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TokenResponse {
|
export interface TokenResponse {
|
||||||
expiresAt: string;
|
expiresAt: Date;
|
||||||
token: string;
|
token: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,3 +4,7 @@ export enum AttachmentTypes {
|
||||||
Warranty = "warranty",
|
Warranty = "warranty",
|
||||||
Attachment = "attachment",
|
Attachment = "attachment",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type Result<T> = {
|
||||||
|
item: T;
|
||||||
|
};
|
||||||
|
|
|
@ -32,6 +32,7 @@ regex_replace: dict[re.Pattern, str] = {
|
||||||
"soldTime",
|
"soldTime",
|
||||||
"purchaseTime",
|
"purchaseTime",
|
||||||
"warrantyExpires",
|
"warrantyExpires",
|
||||||
|
"expiresAt",
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue