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 frontend && pnpm install --shamefully-hoist
generate:
desc: |
Generates collateral files from the backend project
including swagger docs and typescripts type for the frontend
deps:
- db:generate
swag:
desc: Generate swagger docs
dir: backend/app/api/static/
vars:
API: "../"
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:
- cd backend/app/api/static && swag fmt --dir=../
- cd backend/app/api/static && swag init --dir=../,../../../internal,../../../pkgs
- |
npx swagger-typescript-api \
--no-client \
@ -28,12 +38,17 @@ tasks:
--path ./backend/app/api/static/docs/swagger.json \
--output ./frontend/lib/api/types
- 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:
- "./backend/app/api/**/*"
- "./backend/internal/data/**"
- "./backend/internal/core/services/**/*"
- "./backend/app/tools/typegen/main.go"
- ./backend/app/tools/typegen/main.go
- ./backend/app/api/static/docs/swagger.json
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:
desc: Starts the backend api server (depends on generate task)

View file

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

View file

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

View file

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

View file

@ -55,6 +55,7 @@ require (
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // 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/yeqown/reedsolomon v1.0.0 // 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": {
"description": "Edges",
"allOf": [
{
"$ref": "#/definitions/repo.LocationSummary"
}
],
"x-nullable": true,
"x-omitempty": true,
"$ref": "#/definitions/repo.LocationSummary"
"x-omitempty": true
},
"manufacturer": {
"type": "string"
@ -2048,9 +2052,13 @@
"type": "string"
},
"parent": {
"allOf": [
{
"$ref": "#/definitions/repo.ItemSummary"
}
],
"x-nullable": true,
"x-omitempty": true,
"$ref": "#/definitions/repo.ItemSummary"
"x-omitempty": true
},
"purchaseFrom": {
"type": "string"
@ -2136,9 +2144,13 @@
},
"location": {
"description": "Edges",
"allOf": [
{
"$ref": "#/definitions/repo.LocationSummary"
}
],
"x-nullable": true,
"x-omitempty": true,
"$ref": "#/definitions/repo.LocationSummary"
"x-omitempty": true
},
"name": {
"type": "string"
@ -2162,7 +2174,7 @@
"type": "boolean"
},
"assetId": {
"type": "string"
"type": "integer"
},
"description": {
"type": "string"
@ -2247,7 +2259,6 @@
"type": "string"
},
"warrantyExpires": {
"description": "Sold",
"type": "string"
}
}
@ -2421,7 +2432,6 @@
"type": "object",
"properties": {
"completedDate": {
"description": "Sold",
"type": "string"
},
"cost": {
@ -2438,7 +2448,6 @@
"type": "string"
},
"scheduledDate": {
"description": "Sold",
"type": "string"
}
}
@ -2450,7 +2459,6 @@
],
"properties": {
"completedDate": {
"description": "Sold",
"type": "string"
},
"cost": {
@ -2464,7 +2472,6 @@
"type": "string"
},
"scheduledDate": {
"description": "Sold",
"type": "string"
}
}
@ -2473,7 +2480,6 @@
"type": "object",
"properties": {
"completedDate": {
"description": "Sold",
"type": "string"
},
"cost": {
@ -2487,7 +2493,6 @@
"type": "string"
},
"scheduledDate": {
"description": "Sold",
"type": "string"
}
}

View file

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