|
| 1 | +// Generated by ts-to-zod |
| 2 | +import { z } from "zod"; |
| 3 | + |
| 4 | +export const operationIdSchema = z.string(); |
| 5 | + |
| 6 | +export const testCaseIdSchema = z.string(); |
| 7 | + |
| 8 | +export const httpStatusSchema = z.number(); |
| 9 | + |
| 10 | +export const testFilePathSchema = z.string(); |
| 11 | + |
| 12 | +export const testCaseSchema = z.record(z.unknown()).and( |
| 13 | + z.object({ |
| 14 | + id: testCaseIdSchema.optional(), |
| 15 | + filePath: testFilePathSchema.optional(), |
| 16 | + name: z.string().optional(), |
| 17 | + startLine: z.number().optional(), |
| 18 | + endLine: z.number().optional(), |
| 19 | + }), |
| 20 | +); |
| 21 | + |
| 22 | +export const faultCategoryIdSchema = z.record(z.unknown()).and( |
| 23 | + z.object({ |
| 24 | + code: z.number(), |
| 25 | + context: z.string().optional(), |
| 26 | + }), |
| 27 | +); |
| 28 | + |
| 29 | +export const coveredEndpointSchema = z.record(z.unknown()).and( |
| 30 | + z.object({ |
| 31 | + endpointId: operationIdSchema, |
| 32 | + testCaseId: testCaseIdSchema, |
| 33 | + httpStatus: z.tuple([httpStatusSchema]).rest(httpStatusSchema), |
| 34 | + }), |
| 35 | +); |
| 36 | + |
| 37 | +export const coverageCriterionSchema = z.record(z.unknown()).and( |
| 38 | + z.object({ |
| 39 | + name: z.string(), |
| 40 | + covered: z.number(), |
| 41 | + total: z.number().optional(), |
| 42 | + }), |
| 43 | +); |
| 44 | + |
| 45 | +export const rESTReportSchema = z.record(z.unknown()).and( |
| 46 | + z.object({ |
| 47 | + totalHttpCalls: z.number(), |
| 48 | + endpointIds: z.array(operationIdSchema), |
| 49 | + coveredHttpStatus: z.array(coveredEndpointSchema), |
| 50 | + }), |
| 51 | +); |
| 52 | + |
| 53 | +export const coverageSchema = z.record(z.unknown()).and( |
| 54 | + z.object({ |
| 55 | + toolName: z.string(), |
| 56 | + criteria: z.array(coverageCriterionSchema), |
| 57 | + }), |
| 58 | +); |
| 59 | + |
| 60 | +export const foundFaultSchema = z.record(z.unknown()).and( |
| 61 | + z.object({ |
| 62 | + operationId: operationIdSchema.optional(), |
| 63 | + testCaseId: testCaseIdSchema, |
| 64 | + faultCategories: z |
| 65 | + .tuple([faultCategoryIdSchema]) |
| 66 | + .rest(faultCategoryIdSchema), |
| 67 | + }), |
| 68 | +); |
| 69 | + |
| 70 | +export const faultsSchema = z.record(z.unknown()).and( |
| 71 | + z.object({ |
| 72 | + totalNumber: z.number(), |
| 73 | + foundFaults: z.array(foundFaultSchema), |
| 74 | + }), |
| 75 | +); |
| 76 | + |
| 77 | +export const webFuzzingCommonsReportSchema = z.record(z.unknown()).and( |
| 78 | + z.object({ |
| 79 | + schemaVersion: z.string(), |
| 80 | + toolName: z.string(), |
| 81 | + toolVersion: z.string(), |
| 82 | + creationTime: z.string(), |
| 83 | + faults: faultsSchema, |
| 84 | + problemDetails: z.record(z.unknown()).and( |
| 85 | + z.object({ |
| 86 | + rest: rESTReportSchema.optional(), |
| 87 | + }), |
| 88 | + ), |
| 89 | + totalTests: z.number(), |
| 90 | + testFilePaths: z.array(testFilePathSchema), |
| 91 | + testCases: z.array(testCaseSchema), |
| 92 | + extra: z.array(coverageSchema).optional(), |
| 93 | + }), |
| 94 | +); |
0 commit comments