From 014bc650899d321509ad0380bfaa085443ea2c38 Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Wed, 8 Mar 2023 10:08:36 -0900 Subject: [PATCH] code gen --- backend/app/api/static/docs/docs.go | 37 ++++++++++++++++++------ backend/app/api/static/docs/swagger.json | 37 ++++++++++++++++++------ backend/app/api/static/docs/swagger.yaml | 24 ++++++++++++--- docs/docs/api/openapi-2.0.json | 37 ++++++++++++++++++------ frontend/lib/api/types/data-contracts.ts | 17 +++++++++++ 5 files changed, 121 insertions(+), 31 deletions(-) diff --git a/backend/app/api/static/docs/docs.go b/backend/app/api/static/docs/docs.go index c68703b..d660f08 100644 --- a/backend/app/api/static/docs/docs.go +++ b/backend/app/api/static/docs/docs.go @@ -425,8 +425,8 @@ const docTemplate = `{ } ], "responses": { - "200": { - "description": "OK", + "201": { + "description": "Created", "schema": { "$ref": "#/definitions/repo.ItemSummary" } @@ -864,8 +864,8 @@ const docTemplate = `{ } ], "responses": { - "200": { - "description": "OK", + "201": { + "description": "Created", "schema": { "$ref": "#/definitions/repo.MaintenanceEntry" } @@ -1902,9 +1902,15 @@ const docTemplate = `{ }, "repo.ItemCreate": { "type": "object", + "required": [ + "description", + "name" + ], "properties": { "description": { - "type": "string" + "type": "string", + "maxLength": 1000, + "minLength": 1 }, "labelIds": { "type": "array", @@ -1917,7 +1923,9 @@ const docTemplate = `{ "type": "string" }, "name": { - "type": "string" + "type": "string", + "maxLength": 255, + "minLength": 1 }, "parentId": { "type": "string", @@ -2208,15 +2216,21 @@ const docTemplate = `{ }, "repo.LabelCreate": { "type": "object", + "required": [ + "name" + ], "properties": { "color": { "type": "string" }, "description": { - "type": "string" + "type": "string", + "maxLength": 255 }, "name": { - "type": "string" + "type": "string", + "maxLength": 255, + "minLength": 1 } } }, @@ -2791,12 +2805,17 @@ const docTemplate = `{ }, "v1.GroupInvitationCreate": { "type": "object", + "required": [ + "uses" + ], "properties": { "expiresAt": { "type": "string" }, "uses": { - "type": "integer" + "type": "integer", + "maximum": 100, + "minimum": 1 } } }, diff --git a/backend/app/api/static/docs/swagger.json b/backend/app/api/static/docs/swagger.json index c46f5a5..4fa3dba 100644 --- a/backend/app/api/static/docs/swagger.json +++ b/backend/app/api/static/docs/swagger.json @@ -417,8 +417,8 @@ } ], "responses": { - "200": { - "description": "OK", + "201": { + "description": "Created", "schema": { "$ref": "#/definitions/repo.ItemSummary" } @@ -856,8 +856,8 @@ } ], "responses": { - "200": { - "description": "OK", + "201": { + "description": "Created", "schema": { "$ref": "#/definitions/repo.MaintenanceEntry" } @@ -1894,9 +1894,15 @@ }, "repo.ItemCreate": { "type": "object", + "required": [ + "description", + "name" + ], "properties": { "description": { - "type": "string" + "type": "string", + "maxLength": 1000, + "minLength": 1 }, "labelIds": { "type": "array", @@ -1909,7 +1915,9 @@ "type": "string" }, "name": { - "type": "string" + "type": "string", + "maxLength": 255, + "minLength": 1 }, "parentId": { "type": "string", @@ -2200,15 +2208,21 @@ }, "repo.LabelCreate": { "type": "object", + "required": [ + "name" + ], "properties": { "color": { "type": "string" }, "description": { - "type": "string" + "type": "string", + "maxLength": 255 }, "name": { - "type": "string" + "type": "string", + "maxLength": 255, + "minLength": 1 } } }, @@ -2783,12 +2797,17 @@ }, "v1.GroupInvitationCreate": { "type": "object", + "required": [ + "uses" + ], "properties": { "expiresAt": { "type": "string" }, "uses": { - "type": "integer" + "type": "integer", + "maximum": 100, + "minimum": 1 } } }, diff --git a/backend/app/api/static/docs/swagger.yaml b/backend/app/api/static/docs/swagger.yaml index 658d4b0..83cdadd 100644 --- a/backend/app/api/static/docs/swagger.yaml +++ b/backend/app/api/static/docs/swagger.yaml @@ -67,6 +67,8 @@ definitions: repo.ItemCreate: properties: description: + maxLength: 1000 + minLength: 1 type: string labelIds: items: @@ -76,10 +78,15 @@ definitions: description: Edges type: string name: + maxLength: 255 + minLength: 1 type: string parentId: type: string x-nullable: true + required: + - description + - name type: object repo.ItemField: properties: @@ -281,9 +288,14 @@ definitions: color: type: string description: + maxLength: 255 type: string name: + maxLength: 255 + minLength: 1 type: string + required: + - name type: object repo.LabelOut: properties: @@ -666,7 +678,11 @@ definitions: expiresAt: type: string uses: + maximum: 100 + minimum: 1 type: integer + required: + - uses type: object v1.ItemAttachmentToken: properties: @@ -932,8 +948,8 @@ paths: produces: - application/json responses: - "200": - description: OK + "201": + description: Created schema: $ref: '#/definitions/repo.ItemSummary' security: @@ -1140,8 +1156,8 @@ paths: produces: - application/json responses: - "200": - description: OK + "201": + description: Created schema: $ref: '#/definitions/repo.MaintenanceEntry' security: diff --git a/docs/docs/api/openapi-2.0.json b/docs/docs/api/openapi-2.0.json index c46f5a5..4fa3dba 100644 --- a/docs/docs/api/openapi-2.0.json +++ b/docs/docs/api/openapi-2.0.json @@ -417,8 +417,8 @@ } ], "responses": { - "200": { - "description": "OK", + "201": { + "description": "Created", "schema": { "$ref": "#/definitions/repo.ItemSummary" } @@ -856,8 +856,8 @@ } ], "responses": { - "200": { - "description": "OK", + "201": { + "description": "Created", "schema": { "$ref": "#/definitions/repo.MaintenanceEntry" } @@ -1894,9 +1894,15 @@ }, "repo.ItemCreate": { "type": "object", + "required": [ + "description", + "name" + ], "properties": { "description": { - "type": "string" + "type": "string", + "maxLength": 1000, + "minLength": 1 }, "labelIds": { "type": "array", @@ -1909,7 +1915,9 @@ "type": "string" }, "name": { - "type": "string" + "type": "string", + "maxLength": 255, + "minLength": 1 }, "parentId": { "type": "string", @@ -2200,15 +2208,21 @@ }, "repo.LabelCreate": { "type": "object", + "required": [ + "name" + ], "properties": { "color": { "type": "string" }, "description": { - "type": "string" + "type": "string", + "maxLength": 255 }, "name": { - "type": "string" + "type": "string", + "maxLength": 255, + "minLength": 1 } } }, @@ -2783,12 +2797,17 @@ }, "v1.GroupInvitationCreate": { "type": "object", + "required": [ + "uses" + ], "properties": { "expiresAt": { "type": "string" }, "uses": { - "type": "integer" + "type": "integer", + "maximum": 100, + "minimum": 1 } } }, diff --git a/frontend/lib/api/types/data-contracts.ts b/frontend/lib/api/types/data-contracts.ts index adee10d..bd3e89c 100644 --- a/frontend/lib/api/types/data-contracts.ts +++ b/frontend/lib/api/types/data-contracts.ts @@ -52,10 +52,18 @@ export interface ItemAttachmentUpdate { } export interface ItemCreate { + /** + * @minLength 1 + * @maxLength 1000 + */ description: string; labelIds: string[]; /** Edges */ locationId: string; + /** + * @minLength 1 + * @maxLength 255 + */ name: string; parentId: string | null; } @@ -164,7 +172,12 @@ export interface ItemUpdate { export interface LabelCreate { color: string; + /** @maxLength 255 */ description: string; + /** + * @minLength 1 + * @maxLength 255 + */ name: string; } @@ -402,6 +415,10 @@ export interface GroupInvitation { export interface GroupInvitationCreate { expiresAt: Date | string; + /** + * @min 1 + * @max 100 + */ uses: number; }