From c1c3e30a392b740397d5bd1456a552e8bd9a5128 Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Sat, 3 Dec 2022 15:03:32 -0900 Subject: [PATCH] code generation --- backend/app/api/static/docs/docs.go | 119 +++++++++++++++-------- backend/app/api/static/docs/swagger.json | 119 +++++++++++++++-------- backend/app/api/static/docs/swagger.yaml | 76 ++++++++++----- frontend/lib/api/types/data-contracts.ts | 15 +++ 4 files changed, 226 insertions(+), 103 deletions(-) diff --git a/backend/app/api/static/docs/docs.go b/backend/app/api/static/docs/docs.go index 6e8cebd..d3a89a1 100644 --- a/backend/app/api/static/docs/docs.go +++ b/backend/app/api/static/docs/docs.go @@ -148,9 +148,9 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Group" + "Statistics" ], - "summary": "Get the current user's group", + "summary": "Get the current user's group statistics", "responses": { "200": { "description": "OK", @@ -161,6 +161,44 @@ const docTemplate = `{ } } }, + "/v1/groups/statistics/purchase-price": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Statistics" + ], + "summary": "Queries the changes overtime of the purchase price over time", + "parameters": [ + { + "type": "string", + "description": "start date", + "name": "start", + "in": "query" + }, + { + "type": "string", + "description": "end date", + "name": "end", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ValueOverTime" + } + } + } + } + }, "/v1/items": { "get": { "security": [ @@ -449,43 +487,6 @@ const docTemplate = `{ } } }, - "/v1/items/{id}/attachments/download": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "produces": [ - "application/octet-stream" - ], - "tags": [ - "Items Attachments" - ], - "summary": "retrieves an attachment for an item", - "parameters": [ - { - "type": "string", - "description": "Item ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Attachment token", - "name": "token", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - } - } - } - }, "/v1/items/{id}/attachments/{attachment_id}": { "get": { "security": [ @@ -1237,6 +1238,9 @@ const docTemplate = `{ "repo.GroupStatistics": { "type": "object", "properties": { + "totalItemPrice": { + "type": "number" + }, "totalItems": { "type": "integer" }, @@ -1248,6 +1252,9 @@ const docTemplate = `{ }, "totalUsers": { "type": "integer" + }, + "totalWithWarranty": { + "type": "integer" } } }, @@ -1821,6 +1828,40 @@ const docTemplate = `{ } } }, + "repo.ValueOverTime": { + "type": "object", + "properties": { + "end": { + "type": "string" + }, + "entries": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ValueOverTimeEntry" + } + }, + "start": { + "type": "string" + }, + "valueAtEnd": { + "type": "number" + }, + "valueAtStart": { + "type": "number" + } + } + }, + "repo.ValueOverTimeEntry": { + "type": "object", + "properties": { + "date": { + "type": "string" + }, + "value": { + "type": "number" + } + } + }, "server.ErrorResponse": { "type": "object", "properties": { diff --git a/backend/app/api/static/docs/swagger.json b/backend/app/api/static/docs/swagger.json index f09cffa..5148bed 100644 --- a/backend/app/api/static/docs/swagger.json +++ b/backend/app/api/static/docs/swagger.json @@ -140,9 +140,9 @@ "application/json" ], "tags": [ - "Group" + "Statistics" ], - "summary": "Get the current user's group", + "summary": "Get the current user's group statistics", "responses": { "200": { "description": "OK", @@ -153,6 +153,44 @@ } } }, + "/v1/groups/statistics/purchase-price": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "Statistics" + ], + "summary": "Queries the changes overtime of the purchase price over time", + "parameters": [ + { + "type": "string", + "description": "start date", + "name": "start", + "in": "query" + }, + { + "type": "string", + "description": "end date", + "name": "end", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/repo.ValueOverTime" + } + } + } + } + }, "/v1/items": { "get": { "security": [ @@ -441,43 +479,6 @@ } } }, - "/v1/items/{id}/attachments/download": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "produces": [ - "application/octet-stream" - ], - "tags": [ - "Items Attachments" - ], - "summary": "retrieves an attachment for an item", - "parameters": [ - { - "type": "string", - "description": "Item ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Attachment token", - "name": "token", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK" - } - } - } - }, "/v1/items/{id}/attachments/{attachment_id}": { "get": { "security": [ @@ -1229,6 +1230,9 @@ "repo.GroupStatistics": { "type": "object", "properties": { + "totalItemPrice": { + "type": "number" + }, "totalItems": { "type": "integer" }, @@ -1240,6 +1244,9 @@ }, "totalUsers": { "type": "integer" + }, + "totalWithWarranty": { + "type": "integer" } } }, @@ -1813,6 +1820,40 @@ } } }, + "repo.ValueOverTime": { + "type": "object", + "properties": { + "end": { + "type": "string" + }, + "entries": { + "type": "array", + "items": { + "$ref": "#/definitions/repo.ValueOverTimeEntry" + } + }, + "start": { + "type": "string" + }, + "valueAtEnd": { + "type": "number" + }, + "valueAtStart": { + "type": "number" + } + } + }, + "repo.ValueOverTimeEntry": { + "type": "object", + "properties": { + "date": { + "type": "string" + }, + "value": { + "type": "number" + } + } + }, "server.ErrorResponse": { "type": "object", "properties": { diff --git a/backend/app/api/static/docs/swagger.yaml b/backend/app/api/static/docs/swagger.yaml index 1e3b528..f953715 100644 --- a/backend/app/api/static/docs/swagger.yaml +++ b/backend/app/api/static/docs/swagger.yaml @@ -24,6 +24,8 @@ definitions: type: object repo.GroupStatistics: properties: + totalItemPrice: + type: number totalItems: type: integer totalLabels: @@ -32,6 +34,8 @@ definitions: type: integer totalUsers: type: integer + totalWithWarranty: + type: integer type: object repo.GroupUpdate: properties: @@ -416,6 +420,28 @@ definitions: name: type: string type: object + repo.ValueOverTime: + properties: + end: + type: string + entries: + items: + $ref: '#/definitions/repo.ValueOverTimeEntry' + type: array + start: + type: string + valueAtEnd: + type: number + valueAtStart: + type: number + type: object + repo.ValueOverTimeEntry: + properties: + date: + type: string + value: + type: number + type: object server.ErrorResponse: properties: error: @@ -608,9 +634,32 @@ paths: $ref: '#/definitions/repo.GroupStatistics' security: - Bearer: [] - summary: Get the current user's group + summary: Get the current user's group statistics tags: - - Group + - Statistics + /v1/groups/statistics/purchase-price: + get: + parameters: + - description: start date + in: query + name: start + type: string + - description: end date + in: query + name: end + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/repo.ValueOverTime' + security: + - Bearer: [] + summary: Queries the changes overtime of the purchase price over time + tags: + - Statistics /v1/items: get: parameters: @@ -846,29 +895,6 @@ paths: summary: retrieves an attachment for an item tags: - Items Attachments - /v1/items/{id}/attachments/download: - get: - parameters: - - description: Item ID - in: path - name: id - required: true - type: string - - description: Attachment token - in: query - name: token - required: true - type: string - produces: - - application/octet-stream - responses: - "200": - description: OK - security: - - Bearer: [] - summary: retrieves an attachment for an item - tags: - - Items Attachments /v1/items/import: post: parameters: diff --git a/frontend/lib/api/types/data-contracts.ts b/frontend/lib/api/types/data-contracts.ts index 464b8e7..f93f6c2 100644 --- a/frontend/lib/api/types/data-contracts.ts +++ b/frontend/lib/api/types/data-contracts.ts @@ -25,10 +25,12 @@ export interface Group { } export interface GroupStatistics { + totalItemPrice: number; totalItems: number; totalLabels: number; totalLocations: number; totalUsers: number; + totalWithWarranty: number; } export interface GroupUpdate { @@ -261,6 +263,19 @@ export interface UserUpdate { name: string; } +export interface ValueOverTime { + end: string; + entries: ValueOverTimeEntry[]; + start: string; + valueAtEnd: number; + valueAtStart: number; +} + +export interface ValueOverTimeEntry { + date: string; + value: number; +} + export interface ServerErrorResponse { error: string; fields: Record;