fix: refactoring errors (#359)

* #352 - require one date to be set to save

* fix many type regressions
This commit is contained in:
Hayden 2023-03-20 21:48:22 -08:00 committed by GitHub
parent 4a8ba6231d
commit 97fb94d231
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 164 additions and 289 deletions

View file

@ -9,6 +9,14 @@ import (
"github.com/hay-kot/safeserve/server"
)
type Results[T any] struct {
Items []T `json:"items"`
}
func WrapResults[T any](items []T) Results[T] {
return Results[T]{Items: items}
}
type Wrapped struct {
Item interface{} `json:"item"`
}

View file

@ -15,7 +15,7 @@ import (
// @Summary Get All Labels
// @Tags Labels
// @Produce json
// @Success 200 {object} Wrapped{items=[]repo.LabelOut}
// @Success 200 {object} []repo.LabelOut
// @Router /v1/labels [GET]
// @Security Bearer
func (ctrl *V1Controller) HandleLabelsGetAll() errchain.HandlerFunc {

View file

@ -16,7 +16,7 @@ import (
// @Tags Locations
// @Produce json
// @Param withItems query bool false "include items in response tree"
// @Success 200 {object} Wrapped{items=[]repo.TreeItem}
// @Success 200 {object} []repo.TreeItem
// @Router /v1/locations/tree [GET]
// @Security Bearer
func (ctrl *V1Controller) HandleLocationTreeQuery() errchain.HandlerFunc {
@ -34,7 +34,7 @@ func (ctrl *V1Controller) HandleLocationTreeQuery() errchain.HandlerFunc {
// @Tags Locations
// @Produce json
// @Param filterChildren query bool false "Filter locations with parents"
// @Success 200 {object} Wrapped{items=[]repo.LocationOutCount}
// @Success 200 {object} []repo.LocationOutCount
// @Router /v1/locations [GET]
// @Security Bearer
func (ctrl *V1Controller) HandleLocationGetAll() errchain.HandlerFunc {

View file

@ -16,7 +16,7 @@ import (
// @Summary Get Notifiers
// @Tags Notifiers
// @Produce json
// @Success 200 {object} Wrapped{items=[]repo.NotifierOut}
// @Success 200 {object} []repo.NotifierOut
// @Router /v1/notifiers [GET]
// @Security Bearer
func (ctrl *V1Controller) HandleGetUserNotifiers() errchain.HandlerFunc {

View file

@ -945,22 +945,10 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/v1.Wrapped"
},
{
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/repo.LabelOut"
}
}
}
}
]
"type": "array",
"items": {
"$ref": "#/definitions/repo.LabelOut"
}
}
}
}
@ -1117,22 +1105,10 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/v1.Wrapped"
},
{
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/repo.LocationOutCount"
}
}
}
}
]
"type": "array",
"items": {
"$ref": "#/definitions/repo.LocationOutCount"
}
}
}
}
@ -1197,22 +1173,10 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/v1.Wrapped"
},
{
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/repo.TreeItem"
}
}
}
}
]
"type": "array",
"items": {
"$ref": "#/definitions/repo.TreeItem"
}
}
}
}
@ -1337,22 +1301,10 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/v1.Wrapped"
},
{
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/repo.NotifierOut"
}
}
}
}
]
"type": "array",
"items": {
"$ref": "#/definitions/repo.NotifierOut"
}
}
}
}
@ -1917,14 +1869,12 @@ const docTemplate = `{
"repo.ItemCreate": {
"type": "object",
"required": [
"description",
"name"
],
"properties": {
"description": {
"type": "string",
"maxLength": 1000,
"minLength": 1
"maxLength": 1000
},
"labelIds": {
"type": "array",
@ -2433,6 +2383,9 @@ const docTemplate = `{
},
"repo.MaintenanceEntryCreate": {
"type": "object",
"required": [
"name"
],
"properties": {
"completedDate": {
"description": "Sold",

View file

@ -937,22 +937,10 @@
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/v1.Wrapped"
},
{
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/repo.LabelOut"
}
}
}
}
]
"type": "array",
"items": {
"$ref": "#/definitions/repo.LabelOut"
}
}
}
}
@ -1109,22 +1097,10 @@
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/v1.Wrapped"
},
{
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/repo.LocationOutCount"
}
}
}
}
]
"type": "array",
"items": {
"$ref": "#/definitions/repo.LocationOutCount"
}
}
}
}
@ -1189,22 +1165,10 @@
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/v1.Wrapped"
},
{
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/repo.TreeItem"
}
}
}
}
]
"type": "array",
"items": {
"$ref": "#/definitions/repo.TreeItem"
}
}
}
}
@ -1329,22 +1293,10 @@
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/v1.Wrapped"
},
{
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/repo.NotifierOut"
}
}
}
}
]
"type": "array",
"items": {
"$ref": "#/definitions/repo.NotifierOut"
}
}
}
}
@ -1909,14 +1861,12 @@
"repo.ItemCreate": {
"type": "object",
"required": [
"description",
"name"
],
"properties": {
"description": {
"type": "string",
"maxLength": 1000,
"minLength": 1
"maxLength": 1000
},
"labelIds": {
"type": "array",
@ -2425,6 +2375,9 @@
},
"repo.MaintenanceEntryCreate": {
"type": "object",
"required": [
"name"
],
"properties": {
"completedDate": {
"description": "Sold",

View file

@ -77,7 +77,6 @@ definitions:
properties:
description:
maxLength: 1000
minLength: 1
type: string
labelIds:
items:
@ -94,7 +93,6 @@ definitions:
type: string
x-nullable: true
required:
- description
- name
type: object
repo.ItemField:
@ -442,6 +440,8 @@ definitions:
scheduledDate:
description: Sold
type: string
required:
- name
type: object
repo.MaintenanceEntryUpdate:
properties:
@ -1258,14 +1258,9 @@ paths:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/v1.Wrapped'
- properties:
items:
items:
$ref: '#/definitions/repo.LabelOut'
type: array
type: object
items:
$ref: '#/definitions/repo.LabelOut'
type: array
security:
- Bearer: []
summary: Get All Labels
@ -1360,14 +1355,9 @@ paths:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/v1.Wrapped'
- properties:
items:
items:
$ref: '#/definitions/repo.LocationOutCount'
type: array
type: object
items:
$ref: '#/definitions/repo.LocationOutCount'
type: array
security:
- Bearer: []
summary: Get All Locations
@ -1468,14 +1458,9 @@ paths:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/v1.Wrapped'
- properties:
items:
items:
$ref: '#/definitions/repo.TreeItem'
type: array
type: object
items:
$ref: '#/definitions/repo.TreeItem'
type: array
security:
- Bearer: []
summary: Get Locations Tree
@ -1489,14 +1474,9 @@ paths:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/v1.Wrapped'
- properties:
items:
items:
$ref: '#/definitions/repo.NotifierOut'
type: array
type: object
items:
$ref: '#/definitions/repo.NotifierOut'
type: array
security:
- Bearer: []
summary: Get Notifiers