From 1271885124fd884aeb1a73decf9cf7e7379a54a4 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sat, 14 Sep 2024 10:22:51 +0200 Subject: [PATCH] [FIX] correct the API generation --- front2/src/back-api/model/index.ts | 2 +- front2/src/back-api/model/int.ts | 36 ---------------- front2/src/back-api/model/integer.ts | 30 +------------- .../src/back-api/model/rest-error-response.ts | 4 +- front2/src/back-api/model/user-out.ts | 41 ------------------- 5 files changed, 4 insertions(+), 109 deletions(-) delete mode 100644 front2/src/back-api/model/int.ts delete mode 100644 front2/src/back-api/model/user-out.ts diff --git a/front2/src/back-api/model/index.ts b/front2/src/back-api/model/index.ts index 9070c63..fef4de1 100644 --- a/front2/src/back-api/model/index.ts +++ b/front2/src/back-api/model/index.ts @@ -8,7 +8,7 @@ export * from "./generic-data" export * from "./generic-data-soft-delete" export * from "./generic-timing" export * from "./health-result" -export * from "./int" +export * from "./integer" export * from "./iso-date" export * from "./local-date" export * from "./long" diff --git a/front2/src/back-api/model/int.ts b/front2/src/back-api/model/int.ts deleted file mode 100644 index 7147943..0000000 --- a/front2/src/back-api/model/int.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Interface of the server (auto-generated code) - */ -import { z as zod } from "zod"; - - -export const Zodint = zod.object({ - -}); - -export type int = zod.infer; - -export function isint(data: any): data is int { - try { - Zodint.parse(data); - return true; - } catch (e: any) { - console.log(`Fail to parse data type='Zodint' error=${e}`); - return false; - } -} -export const ZodintWrite = zod.object({ - -}); - -export type intWrite = zod.infer; - -export function isintWrite(data: any): data is intWrite { - try { - ZodintWrite.parse(data); - return true; - } catch (e: any) { - console.log(`Fail to parse data type='ZodintWrite' error=${e}`); - return false; - } -} diff --git a/front2/src/back-api/model/integer.ts b/front2/src/back-api/model/integer.ts index b95c26b..03fd143 100644 --- a/front2/src/back-api/model/integer.ts +++ b/front2/src/back-api/model/integer.ts @@ -4,33 +4,5 @@ import { z as zod } from "zod"; -export const ZodInteger = zod.object({ - -}); - +export const ZodInteger = zod.number().safe(); export type Integer = zod.infer; - -export function isInteger(data: any): data is Integer { - try { - ZodInteger.parse(data); - return true; - } catch (e: any) { - console.log(`Fail to parse data type='ZodInteger' error=${e}`); - return false; - } -} -export const ZodIntegerWrite = zod.object({ - -}); - -export type IntegerWrite = zod.infer; - -export function isIntegerWrite(data: any): data is IntegerWrite { - try { - ZodIntegerWrite.parse(data); - return true; - } catch (e: any) { - console.log(`Fail to parse data type='ZodIntegerWrite' error=${e}`); - return false; - } -} diff --git a/front2/src/back-api/model/rest-error-response.ts b/front2/src/back-api/model/rest-error-response.ts index 3dca846..74b1f74 100644 --- a/front2/src/back-api/model/rest-error-response.ts +++ b/front2/src/back-api/model/rest-error-response.ts @@ -4,14 +4,14 @@ import { z as zod } from "zod"; import {ZodUUID} from "./uuid"; -import {Zodint, ZodintWrite } from "./int"; +import {ZodInteger} from "./integer"; export const ZodRestErrorResponse = zod.object({ uuid: ZodUUID.optional(), name: zod.string(), message: zod.string(), time: zod.string(), - status: Zodint, + status: ZodInteger, statusMessage: zod.string(), }); diff --git a/front2/src/back-api/model/user-out.ts b/front2/src/back-api/model/user-out.ts deleted file mode 100644 index 345750c..0000000 --- a/front2/src/back-api/model/user-out.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Interface of the server (auto-generated code) - */ -import { z as zod } from "zod"; - -import {ZodLong} from "./long"; - -export const ZodUserOut = zod.object({ - id: ZodLong, - login: zod.string().max(255).optional(), - -}); - -export type UserOut = zod.infer; - -export function isUserOut(data: any): data is UserOut { - try { - ZodUserOut.parse(data); - return true; - } catch (e: any) { - console.log(`Fail to parse data type='ZodUserOut' error=${e}`); - return false; - } -} -export const ZodUserOutWrite = zod.object({ - id: ZodLong, - login: zod.string().max(255).nullable().optional(), - -}); - -export type UserOutWrite = zod.infer; - -export function isUserOutWrite(data: any): data is UserOutWrite { - try { - ZodUserOutWrite.parse(data); - return true; - } catch (e: any) { - console.log(`Fail to parse data type='ZodUserOutWrite' error=${e}`); - return false; - } -}