From cc60c2d6a86e62c83165ef718fcbcb6e49329a3e Mon Sep 17 00:00:00 2001 From: Yang Yang Date: Tue, 7 Jan 2025 15:38:51 +0800 Subject: [PATCH] chore: add POST payload validation --- api/openapispec/docs.go | 28 ++++++++++++---------------- api/openapispec/swagger.json | 28 ++++++++++++---------------- api/openapispec/swagger.yaml | 16 ++++++---------- package.json | 2 +- src/client/schemas.gen.ts | 20 ++++++++++---------- src/client/types.gen.ts | 32 ++++++++++++++++---------------- 6 files changed, 57 insertions(+), 69 deletions(-) diff --git a/api/openapispec/docs.go b/api/openapispec/docs.go index 7619f99..6bfa927 100644 --- a/api/openapispec/docs.go +++ b/api/openapispec/docs.go @@ -3753,18 +3753,18 @@ const docTemplate = `{ "constant.SourceProviderType": { "type": "string", "enum": [ + "git", "git", "github", "oci", - "local", - "git" + "local" ], "x-enum-varnames": [ + "DefaultSourceType", "SourceProviderTypeGit", "SourceProviderTypeGithub", "SourceProviderTypeOCI", - "SourceProviderTypeLocal", - "DefaultSourceType" + "SourceProviderTypeLocal" ] }, "constant.StackState": { @@ -4919,6 +4919,7 @@ const docTemplate = `{ "request.CreateBackendRequest": { "type": "object", "required": [ + "backendConfig", "name" ], "properties": { @@ -4975,6 +4976,7 @@ const docTemplate = `{ "request.CreateOrganizationRequest": { "type": "object", "required": [ + "name", "owners" ], "properties": { @@ -5005,7 +5007,8 @@ const docTemplate = `{ "request.CreateProjectRequest": { "type": "object", "required": [ - "domain" + "name", + "path" ], "properties": { "description": { @@ -5188,8 +5191,7 @@ const docTemplate = `{ "request.UpdateBackendRequest": { "type": "object", "required": [ - "id", - "name" + "id" ], "properties": { "backendConfig": { @@ -5248,8 +5250,7 @@ const docTemplate = `{ "request.UpdateOrganizationRequest": { "type": "object", "required": [ - "id", - "owners" + "id" ], "properties": { "description": { @@ -5283,7 +5284,6 @@ const docTemplate = `{ "request.UpdateProjectRequest": { "type": "object", "required": [ - "domain", "id" ], "properties": { @@ -5334,10 +5334,7 @@ const docTemplate = `{ "request.UpdateSourceRequest": { "type": "object", "required": [ - "id", - "name", - "remote", - "sourceProvider" + "id" ], "properties": { "description": { @@ -5379,8 +5376,7 @@ const docTemplate = `{ "request.UpdateStackRequest": { "type": "object", "required": [ - "id", - "name" + "id" ], "properties": { "description": { diff --git a/api/openapispec/swagger.json b/api/openapispec/swagger.json index bf39c69..72b6e73 100644 --- a/api/openapispec/swagger.json +++ b/api/openapispec/swagger.json @@ -3742,18 +3742,18 @@ "constant.SourceProviderType": { "type": "string", "enum": [ + "git", "git", "github", "oci", - "local", - "git" + "local" ], "x-enum-varnames": [ + "DefaultSourceType", "SourceProviderTypeGit", "SourceProviderTypeGithub", "SourceProviderTypeOCI", - "SourceProviderTypeLocal", - "DefaultSourceType" + "SourceProviderTypeLocal" ] }, "constant.StackState": { @@ -4908,6 +4908,7 @@ "request.CreateBackendRequest": { "type": "object", "required": [ + "backendConfig", "name" ], "properties": { @@ -4964,6 +4965,7 @@ "request.CreateOrganizationRequest": { "type": "object", "required": [ + "name", "owners" ], "properties": { @@ -4994,7 +4996,8 @@ "request.CreateProjectRequest": { "type": "object", "required": [ - "domain" + "name", + "path" ], "properties": { "description": { @@ -5177,8 +5180,7 @@ "request.UpdateBackendRequest": { "type": "object", "required": [ - "id", - "name" + "id" ], "properties": { "backendConfig": { @@ -5237,8 +5239,7 @@ "request.UpdateOrganizationRequest": { "type": "object", "required": [ - "id", - "owners" + "id" ], "properties": { "description": { @@ -5272,7 +5273,6 @@ "request.UpdateProjectRequest": { "type": "object", "required": [ - "domain", "id" ], "properties": { @@ -5323,10 +5323,7 @@ "request.UpdateSourceRequest": { "type": "object", "required": [ - "id", - "name", - "remote", - "sourceProvider" + "id" ], "properties": { "description": { @@ -5368,8 +5365,7 @@ "request.UpdateStackRequest": { "type": "object", "required": [ - "id", - "name" + "id" ], "properties": { "description": { diff --git a/api/openapispec/swagger.yaml b/api/openapispec/swagger.yaml index b4ccc00..ad73e28 100644 --- a/api/openapispec/swagger.yaml +++ b/api/openapispec/swagger.yaml @@ -30,17 +30,17 @@ definitions: constant.SourceProviderType: enum: - git + - git - github - oci - local - - git type: string x-enum-varnames: + - DefaultSourceType - SourceProviderTypeGit - SourceProviderTypeGithub - SourceProviderTypeOCI - SourceProviderTypeLocal - - DefaultSourceType constant.StackState: enum: - UnSynced @@ -864,6 +864,7 @@ definitions: description: Name is the name of the backend. type: string required: + - backendConfig - name type: object request.CreateModuleRequest: @@ -908,6 +909,7 @@ definitions: type: string type: array required: + - name - owners type: object request.CreateProjectRequest: @@ -942,7 +944,8 @@ definitions: description: SourceID is the configuration source id associated with the project. type: integer required: - - domain + - name + - path type: object request.CreateSourceRequest: properties: @@ -1060,7 +1063,6 @@ definitions: type: string required: - id - - name type: object request.UpdateModuleRequest: properties: @@ -1107,7 +1109,6 @@ definitions: type: array required: - id - - owners type: object request.UpdateProjectRequest: properties: @@ -1144,7 +1145,6 @@ definitions: description: SourceID is the configuration source id associated with the project. type: integer required: - - domain - id type: object request.UpdateSourceRequest: @@ -1176,9 +1176,6 @@ definitions: type: string required: - id - - name - - remote - - sourceProvider type: object request.UpdateStackRequest: properties: @@ -1218,7 +1215,6 @@ definitions: type: string required: - id - - name type: object request.UpdateWorkspaceRequest: properties: diff --git a/package.json b/package.json index 69cf1e1..62c81e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kusionstack/kusion-api-client-sdk", - "version": "1.1.0", + "version": "1.1.1", "description": "Kusion API Client SDK", "main": "dist/src/client/index.js", "types": "dist/src/client/index.d.ts", diff --git a/src/client/schemas.gen.ts b/src/client/schemas.gen.ts index 8e70b4c..dfa46de 100644 --- a/src/client/schemas.gen.ts +++ b/src/client/schemas.gen.ts @@ -13,9 +13,9 @@ export const constant_RunTypeSchema = { } as const; export const constant_SourceProviderTypeSchema = { - enum: ['git', 'github', 'oci', 'local', 'git'], + enum: ['git', 'git', 'github', 'oci', 'local'], type: 'string', - 'x-enum-varnames': ['SourceProviderTypeGit', 'SourceProviderTypeGithub', 'SourceProviderTypeOCI', 'SourceProviderTypeLocal', 'DefaultSourceType'] + 'x-enum-varnames': ['DefaultSourceType', 'SourceProviderTypeGit', 'SourceProviderTypeGithub', 'SourceProviderTypeOCI', 'SourceProviderTypeLocal'] } as const; export const constant_StackStateSchema = { @@ -1152,7 +1152,7 @@ export const request_CreateBackendRequestSchema = { type: 'string' } }, - required: ['name'], + required: ['backendConfig', 'name'], type: 'object' } as const; @@ -1211,7 +1211,7 @@ export const request_CreateOrganizationRequestSchema = { type: 'array' } }, - required: ['owners'], + required: ['name', 'owners'], type: 'object' } as const; @@ -1256,7 +1256,7 @@ export const request_CreateProjectRequestSchema = { type: 'integer' } }, - required: ['domain'], + required: ['name', 'path'], type: 'object' } as const; @@ -1414,7 +1414,7 @@ export const request_UpdateBackendRequestSchema = { type: 'string' } }, - required: ['id', 'name'], + required: ['id'], type: 'object' } as const; @@ -1477,7 +1477,7 @@ export const request_UpdateOrganizationRequestSchema = { type: 'array' } }, - required: ['id', 'owners'], + required: ['id'], type: 'object' } as const; @@ -1526,7 +1526,7 @@ export const request_UpdateProjectRequestSchema = { type: 'integer' } }, - required: ['domain', 'id'], + required: ['id'], type: 'object' } as const; @@ -1567,7 +1567,7 @@ export const request_UpdateSourceRequestSchema = { type: 'string' } }, - required: ['id', 'name', 'remote', 'sourceProvider'], + required: ['id'], type: 'object' } as const; @@ -1620,7 +1620,7 @@ export const request_UpdateStackRequestSchema = { type: 'string' } }, - required: ['id', 'name'], + required: ['id'], type: 'object' } as const; diff --git a/src/client/types.gen.ts b/src/client/types.gen.ts index 9323ff0..1697e0f 100644 --- a/src/client/types.gen.ts +++ b/src/client/types.gen.ts @@ -17,10 +17,10 @@ export enum constant_RunType { } export enum constant_SourceProviderType { - SourceProviderTypeGit = 'git', - SourceProviderTypeGithub = 'github', - SourceProviderTypeOCI = 'oci', - SourceProviderTypeLocal = 'local' + DefaultSourceType = 'git', + SourceProviderTypeGit = 'github', + SourceProviderTypeGithub = 'oci', + SourceProviderTypeOCI = 'local' } export enum constant_StackState { @@ -833,7 +833,7 @@ export type request_CreateBackendRequest = { /** * BackendConfig is the configuration of the backend. */ - backendConfig?: (kusionstack_io_kusion_pkg_apis_api_kusion_io_v1_BackendConfig); + backendConfig: (kusionstack_io_kusion_pkg_apis_api_kusion_io_v1_BackendConfig); /** * Description is a human-readable description of the backend. */ @@ -879,7 +879,7 @@ export type request_CreateOrganizationRequest = { /** * Name is the name of the organization. */ - name?: string; + name: string; /** * Owners is a list of owners for the organization. */ @@ -894,7 +894,7 @@ export type request_CreateProjectRequest = { /** * Domain is the domain of the project, typically serving as the parent folder name for the project. */ - domain: string; + domain?: string; /** * Labels are custom labels associated with the project. */ @@ -902,7 +902,7 @@ export type request_CreateProjectRequest = { /** * Name is the name of the project. */ - name?: string; + name: string; /** * OrganizationID is the organization id associated with the project. */ @@ -914,7 +914,7 @@ export type request_CreateProjectRequest = { /** * Path is the relative path of the project within the sources. */ - path?: string; + path: string; /** * SourceID is the configuration source id associated with the project. */ @@ -1032,7 +1032,7 @@ export type request_UpdateBackendRequest = { /** * Name is the name of the backend. */ - name: string; + name?: string; }; export type request_UpdateModuleRequest = { @@ -1078,7 +1078,7 @@ export type request_UpdateOrganizationRequest = { /** * Owners is a list of owners for the organization. */ - owners: Array<(string)>; + owners?: Array<(string)>; }; export type request_UpdateProjectRequest = { @@ -1089,7 +1089,7 @@ export type request_UpdateProjectRequest = { /** * Domain is the domain of the project, typically serving as the parent folder name for the project. */ - domain: string; + domain?: string; /** * ID is the id of the project. */ @@ -1136,7 +1136,7 @@ export type request_UpdateSourceRequest = { /** * Name is the name of the source. */ - name: string; + name?: string; /** * Owners is a list of owners for the source. */ @@ -1144,11 +1144,11 @@ export type request_UpdateSourceRequest = { /** * Remote is the source URL, including scheme. */ - remote: string; + remote?: string; /** * SourceProvider is the type of the source provider. */ - sourceProvider: string; + sourceProvider?: string; }; export type request_UpdateStackRequest = { @@ -1171,7 +1171,7 @@ export type request_UpdateStackRequest = { /** * Name is the name of the stack. */ - name: string; + name?: string; /** * Owners is a list of owners for the stack. */