rewrite generator to resolve strange name generation

This commit is contained in:
Hayden 2023-11-15 11:28:56 -06:00
parent b08e52104c
commit fb6dd3a008
No known key found for this signature in database
GPG key ID: 17CF79474E257545
8 changed files with 104 additions and 1165 deletions

View file

@ -12,15 +12,25 @@ tasks:
- cd backend && go mod tidy - cd backend && go mod tidy
- cd frontend && pnpm install --shamefully-hoist - cd frontend && pnpm install --shamefully-hoist
generate: swag:
desc: | desc: Generate swagger docs
Generates collateral files from the backend project dir: backend/app/api/static/
including swagger docs and typescripts type for the frontend vars:
deps: API: "../"
- db:generate INTERNAL: "../../../internal"
PKGS: "../../../pkgs"
cmds:
- swag fmt --dir={{ .API }}
- swag init --dir={{ .API }},{{ .INTERNAL }}/core/services,{{ .INTERNAL }}/data/repo --parseDependency
sources:
- "./backend/app/api/**/*"
- "./backend/internal/data/**"
- "./backend/internal/core/services/**/*"
- "./backend/app/tools/typegen/main.go"
typescript-types:
desc: Generates typescript types from swagger definition
cmds: cmds:
- cd backend/app/api/static && swag fmt --dir=../
- cd backend/app/api/static && swag init --dir=../,../../../internal,../../../pkgs
- | - |
npx swagger-typescript-api \ npx swagger-typescript-api \
--no-client \ --no-client \
@ -28,12 +38,17 @@ tasks:
--path ./backend/app/api/static/docs/swagger.json \ --path ./backend/app/api/static/docs/swagger.json \
--output ./frontend/lib/api/types --output ./frontend/lib/api/types
- go run ./backend/app/tools/typegen/main.go ./frontend/lib/api/types/data-contracts.ts - go run ./backend/app/tools/typegen/main.go ./frontend/lib/api/types/data-contracts.ts
- cp ./backend/app/api/static/docs/swagger.json docs/docs/api/openapi-2.0.json
sources: sources:
- "./backend/app/api/**/*" - ./backend/app/tools/typegen/main.go
- "./backend/internal/data/**" - ./backend/app/api/static/docs/swagger.json
- "./backend/internal/core/services/**/*"
- "./backend/app/tools/typegen/main.go" generate:
deps:
- db:generate
cmds:
- task: swag
- task: typescript-types
- cp ./backend/app/api/static/docs/swagger.json docs/docs/api/openapi-2.0.json
go:run: go:run:
desc: Starts the backend api server (depends on generate task) desc: Starts the backend api server (depends on generate task)

View file

@ -1,5 +1,4 @@
// Package docs GENERATED BY SWAG; DO NOT EDIT // Package docs Code generated by swaggo/swag. DO NOT EDIT
// This file was generated by swaggo/swag
package docs package docs
import "github.com/swaggo/swag" import "github.com/swaggo/swag"
@ -2038,9 +2037,13 @@ const docTemplate = `{
}, },
"location": { "location": {
"description": "Edges", "description": "Edges",
"allOf": [
{
"$ref": "#/definitions/repo.LocationSummary"
}
],
"x-nullable": true, "x-nullable": true,
"x-omitempty": true, "x-omitempty": true
"$ref": "#/definitions/repo.LocationSummary"
}, },
"manufacturer": { "manufacturer": {
"type": "string" "type": "string"
@ -2056,9 +2059,13 @@ const docTemplate = `{
"type": "string" "type": "string"
}, },
"parent": { "parent": {
"allOf": [
{
"$ref": "#/definitions/repo.ItemSummary"
}
],
"x-nullable": true, "x-nullable": true,
"x-omitempty": true, "x-omitempty": true
"$ref": "#/definitions/repo.ItemSummary"
}, },
"purchaseFrom": { "purchaseFrom": {
"type": "string" "type": "string"
@ -2144,9 +2151,13 @@ const docTemplate = `{
}, },
"location": { "location": {
"description": "Edges", "description": "Edges",
"allOf": [
{
"$ref": "#/definitions/repo.LocationSummary"
}
],
"x-nullable": true, "x-nullable": true,
"x-omitempty": true, "x-omitempty": true
"$ref": "#/definitions/repo.LocationSummary"
}, },
"name": { "name": {
"type": "string" "type": "string"
@ -2170,7 +2181,7 @@ const docTemplate = `{
"type": "boolean" "type": "boolean"
}, },
"assetId": { "assetId": {
"type": "string" "type": "integer"
}, },
"description": { "description": {
"type": "string" "type": "string"
@ -2255,7 +2266,6 @@ const docTemplate = `{
"type": "string" "type": "string"
}, },
"warrantyExpires": { "warrantyExpires": {
"description": "Sold",
"type": "string" "type": "string"
} }
} }
@ -2429,7 +2439,6 @@ const docTemplate = `{
"type": "object", "type": "object",
"properties": { "properties": {
"completedDate": { "completedDate": {
"description": "Sold",
"type": "string" "type": "string"
}, },
"cost": { "cost": {
@ -2446,7 +2455,6 @@ const docTemplate = `{
"type": "string" "type": "string"
}, },
"scheduledDate": { "scheduledDate": {
"description": "Sold",
"type": "string" "type": "string"
} }
} }
@ -2458,7 +2466,6 @@ const docTemplate = `{
], ],
"properties": { "properties": {
"completedDate": { "completedDate": {
"description": "Sold",
"type": "string" "type": "string"
}, },
"cost": { "cost": {
@ -2472,7 +2479,6 @@ const docTemplate = `{
"type": "string" "type": "string"
}, },
"scheduledDate": { "scheduledDate": {
"description": "Sold",
"type": "string" "type": "string"
} }
} }
@ -2481,7 +2487,6 @@ const docTemplate = `{
"type": "object", "type": "object",
"properties": { "properties": {
"completedDate": { "completedDate": {
"description": "Sold",
"type": "string" "type": "string"
}, },
"cost": { "cost": {
@ -2495,7 +2500,6 @@ const docTemplate = `{
"type": "string" "type": "string"
}, },
"scheduledDate": { "scheduledDate": {
"description": "Sold",
"type": "string" "type": "string"
} }
} }
@ -2897,6 +2901,8 @@ var SwaggerInfo = &swag.Spec{
Description: "Track, Manage, and Organize your Things.", Description: "Track, Manage, and Organize your Things.",
InfoInstanceName: "swagger", InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate, SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
} }
func init() { func init() {

View file

@ -2030,9 +2030,13 @@
}, },
"location": { "location": {
"description": "Edges", "description": "Edges",
"allOf": [
{
"$ref": "#/definitions/repo.LocationSummary"
}
],
"x-nullable": true, "x-nullable": true,
"x-omitempty": true, "x-omitempty": true
"$ref": "#/definitions/repo.LocationSummary"
}, },
"manufacturer": { "manufacturer": {
"type": "string" "type": "string"
@ -2048,9 +2052,13 @@
"type": "string" "type": "string"
}, },
"parent": { "parent": {
"allOf": [
{
"$ref": "#/definitions/repo.ItemSummary"
}
],
"x-nullable": true, "x-nullable": true,
"x-omitempty": true, "x-omitempty": true
"$ref": "#/definitions/repo.ItemSummary"
}, },
"purchaseFrom": { "purchaseFrom": {
"type": "string" "type": "string"
@ -2136,9 +2144,13 @@
}, },
"location": { "location": {
"description": "Edges", "description": "Edges",
"allOf": [
{
"$ref": "#/definitions/repo.LocationSummary"
}
],
"x-nullable": true, "x-nullable": true,
"x-omitempty": true, "x-omitempty": true
"$ref": "#/definitions/repo.LocationSummary"
}, },
"name": { "name": {
"type": "string" "type": "string"
@ -2162,7 +2174,7 @@
"type": "boolean" "type": "boolean"
}, },
"assetId": { "assetId": {
"type": "string" "type": "integer"
}, },
"description": { "description": {
"type": "string" "type": "string"
@ -2247,7 +2259,6 @@
"type": "string" "type": "string"
}, },
"warrantyExpires": { "warrantyExpires": {
"description": "Sold",
"type": "string" "type": "string"
} }
} }
@ -2421,7 +2432,6 @@
"type": "object", "type": "object",
"properties": { "properties": {
"completedDate": { "completedDate": {
"description": "Sold",
"type": "string" "type": "string"
}, },
"cost": { "cost": {
@ -2438,7 +2448,6 @@
"type": "string" "type": "string"
}, },
"scheduledDate": { "scheduledDate": {
"description": "Sold",
"type": "string" "type": "string"
} }
} }
@ -2450,7 +2459,6 @@
], ],
"properties": { "properties": {
"completedDate": { "completedDate": {
"description": "Sold",
"type": "string" "type": "string"
}, },
"cost": { "cost": {
@ -2464,7 +2472,6 @@
"type": "string" "type": "string"
}, },
"scheduledDate": { "scheduledDate": {
"description": "Sold",
"type": "string" "type": "string"
} }
} }
@ -2473,7 +2480,6 @@
"type": "object", "type": "object",
"properties": { "properties": {
"completedDate": { "completedDate": {
"description": "Sold",
"type": "string" "type": "string"
}, },
"cost": { "cost": {
@ -2487,7 +2493,6 @@
"type": "string" "type": "string"
}, },
"scheduledDate": { "scheduledDate": {
"description": "Sold",
"type": "string" "type": "string"
} }
} }

View file

@ -142,7 +142,8 @@ definitions:
description: Warranty description: Warranty
type: boolean type: boolean
location: location:
$ref: '#/definitions/repo.LocationSummary' allOf:
- $ref: '#/definitions/repo.LocationSummary'
description: Edges description: Edges
x-nullable: true x-nullable: true
x-omitempty: true x-omitempty: true
@ -156,7 +157,8 @@ definitions:
description: Extras description: Extras
type: string type: string
parent: parent:
$ref: '#/definitions/repo.ItemSummary' allOf:
- $ref: '#/definitions/repo.ItemSummary'
x-nullable: true x-nullable: true
x-omitempty: true x-omitempty: true
purchaseFrom: purchaseFrom:
@ -216,7 +218,8 @@ definitions:
$ref: '#/definitions/repo.LabelSummary' $ref: '#/definitions/repo.LabelSummary'
type: array type: array
location: location:
$ref: '#/definitions/repo.LocationSummary' allOf:
- $ref: '#/definitions/repo.LocationSummary'
description: Edges description: Edges
x-nullable: true x-nullable: true
x-omitempty: true x-omitempty: true
@ -235,7 +238,7 @@ definitions:
archived: archived:
type: boolean type: boolean
assetId: assetId:
type: string type: integer
description: description:
type: string type: string
fields: fields:
@ -295,7 +298,6 @@ definitions:
warrantyDetails: warrantyDetails:
type: string type: string
warrantyExpires: warrantyExpires:
description: Sold
type: string type: string
type: object type: object
repo.LabelCreate: repo.LabelCreate:
@ -410,7 +412,6 @@ definitions:
repo.MaintenanceEntry: repo.MaintenanceEntry:
properties: properties:
completedDate: completedDate:
description: Sold
type: string type: string
cost: cost:
example: "0" example: "0"
@ -422,13 +423,11 @@ definitions:
name: name:
type: string type: string
scheduledDate: scheduledDate:
description: Sold
type: string type: string
type: object type: object
repo.MaintenanceEntryCreate: repo.MaintenanceEntryCreate:
properties: properties:
completedDate: completedDate:
description: Sold
type: string type: string
cost: cost:
example: "0" example: "0"
@ -438,7 +437,6 @@ definitions:
name: name:
type: string type: string
scheduledDate: scheduledDate:
description: Sold
type: string type: string
required: required:
- name - name
@ -446,7 +444,6 @@ definitions:
repo.MaintenanceEntryUpdate: repo.MaintenanceEntryUpdate:
properties: properties:
completedDate: completedDate:
description: Sold
type: string type: string
cost: cost:
example: "0" example: "0"
@ -456,7 +453,6 @@ definitions:
name: name:
type: string type: string
scheduledDate: scheduledDate:
description: Sold
type: string type: string
type: object type: object
repo.MaintenanceLog: repo.MaintenanceLog:

View file

@ -55,6 +55,7 @@ require (
github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/swaggo/files v1.0.1 // indirect github.com/swaggo/files v1.0.1 // indirect
github.com/yeqown/reedsolomon v1.0.0 // indirect github.com/yeqown/reedsolomon v1.0.0 // indirect
github.com/zclconf/go-cty v1.13.2 // indirect github.com/zclconf/go-cty v1.13.2 // indirect

File diff suppressed because it is too large Load diff

View file

@ -2030,9 +2030,13 @@
}, },
"location": { "location": {
"description": "Edges", "description": "Edges",
"allOf": [
{
"$ref": "#/definitions/repo.LocationSummary"
}
],
"x-nullable": true, "x-nullable": true,
"x-omitempty": true, "x-omitempty": true
"$ref": "#/definitions/repo.LocationSummary"
}, },
"manufacturer": { "manufacturer": {
"type": "string" "type": "string"
@ -2048,9 +2052,13 @@
"type": "string" "type": "string"
}, },
"parent": { "parent": {
"allOf": [
{
"$ref": "#/definitions/repo.ItemSummary"
}
],
"x-nullable": true, "x-nullable": true,
"x-omitempty": true, "x-omitempty": true
"$ref": "#/definitions/repo.ItemSummary"
}, },
"purchaseFrom": { "purchaseFrom": {
"type": "string" "type": "string"
@ -2136,9 +2144,13 @@
}, },
"location": { "location": {
"description": "Edges", "description": "Edges",
"allOf": [
{
"$ref": "#/definitions/repo.LocationSummary"
}
],
"x-nullable": true, "x-nullable": true,
"x-omitempty": true, "x-omitempty": true
"$ref": "#/definitions/repo.LocationSummary"
}, },
"name": { "name": {
"type": "string" "type": "string"
@ -2162,7 +2174,7 @@
"type": "boolean" "type": "boolean"
}, },
"assetId": { "assetId": {
"type": "string" "type": "integer"
}, },
"description": { "description": {
"type": "string" "type": "string"
@ -2247,7 +2259,6 @@
"type": "string" "type": "string"
}, },
"warrantyExpires": { "warrantyExpires": {
"description": "Sold",
"type": "string" "type": "string"
} }
} }
@ -2421,7 +2432,6 @@
"type": "object", "type": "object",
"properties": { "properties": {
"completedDate": { "completedDate": {
"description": "Sold",
"type": "string" "type": "string"
}, },
"cost": { "cost": {
@ -2438,7 +2448,6 @@
"type": "string" "type": "string"
}, },
"scheduledDate": { "scheduledDate": {
"description": "Sold",
"type": "string" "type": "string"
} }
} }
@ -2450,7 +2459,6 @@
], ],
"properties": { "properties": {
"completedDate": { "completedDate": {
"description": "Sold",
"type": "string" "type": "string"
}, },
"cost": { "cost": {
@ -2464,7 +2472,6 @@
"type": "string" "type": "string"
}, },
"scheduledDate": { "scheduledDate": {
"description": "Sold",
"type": "string" "type": "string"
} }
} }
@ -2473,7 +2480,6 @@
"type": "object", "type": "object",
"properties": { "properties": {
"completedDate": { "completedDate": {
"description": "Sold",
"type": "string" "type": "string"
}, },
"cost": { "cost": {
@ -2487,7 +2493,6 @@
"type": "string" "type": "string"
}, },
"scheduledDate": { "scheduledDate": {
"description": "Sold",
"type": "string" "type": "string"
} }
} }

View file

@ -141,7 +141,7 @@ export interface ItemSummary {
export interface ItemUpdate { export interface ItemUpdate {
archived: boolean; archived: boolean;
assetId: string; assetId: number;
description: string; description: string;
fields: ItemField[]; fields: ItemField[];
id: string; id: string;
@ -172,7 +172,6 @@ export interface ItemUpdate {
soldTime: Date | string; soldTime: Date | string;
soldTo: string; soldTo: string;
warrantyDetails: string; warrantyDetails: string;
/** Sold */
warrantyExpires: Date | string; warrantyExpires: Date | string;
} }
@ -244,36 +243,30 @@ export interface LocationUpdate {
} }
export interface MaintenanceEntry { export interface MaintenanceEntry {
/** Sold */
completedDate: Date | string; completedDate: Date | string;
/** @example "0" */ /** @example "0" */
cost: string; cost: string;
description: string; description: string;
id: string; id: string;
name: string; name: string;
/** Sold */
scheduledDate: Date | string; scheduledDate: Date | string;
} }
export interface MaintenanceEntryCreate { export interface MaintenanceEntryCreate {
/** Sold */
completedDate: Date | string; completedDate: Date | string;
/** @example "0" */ /** @example "0" */
cost: string; cost: string;
description: string; description: string;
name: string; name: string;
/** Sold */
scheduledDate: Date | string; scheduledDate: Date | string;
} }
export interface MaintenanceEntryUpdate { export interface MaintenanceEntryUpdate {
/** Sold */
completedDate: Date | string; completedDate: Date | string;
/** @example "0" */ /** @example "0" */
cost: string; cost: string;
description: string; description: string;
name: string; name: string;
/** Sold */
scheduledDate: Date | string; scheduledDate: Date | string;
} }