Closed codingmatty closed 5 months ago
Describe the bug When using an array as a body and using min/max items (either of both, doesn't matter) with group by tags the output is invalid.
After some debugging, it looks like the @key in the schemas block is the actual type with min/max applied and the actual type isn't emitted.
@key
schemas
min
max
Minimal reproduction
{ "openapi": "3.0.0", "info": { "title": "Test", "version": "1.0.1" }, "paths": { "/test": { "put": { "summary": "Test", "description": "Test", "tags": ["Test"], "requestBody": { "content": { "application/json": { "schema": { "type": "array", "items": { "type": "object", "properties": { "testItem": { "type": "string" } }, "additionalProperties": false }, "minItems": 1, "maxItems": 10 } } } }, "parameters": [], "responses": { "200": { "description": "Success", "content": { "application/json": {} } } } } } }, "components": {}, "tags": [] }
Expected behavior The emitted Type should be valid
Actual behvaior Invalid output:
import { makeApi, Zodios, type ZodiosOptions } from "@zodios/core"; import { z } from "zod"; const putTest_Body.min(1).max(10) = ; export const schemas = { putTest_Body.min(1).max(10), }; const endpoints = makeApi([ { method: "put", path: "/test", alias: "putTest", description: `Test`, requestFormat: "json", parameters: [ { name: "body", type: "Body", schema: putTest_Body.min(1).max(10) }, ], response: z.void(), }, ]); export const TestApi = new Zodios(endpoints); export function createApiClient(baseUrl: string, options?: ZodiosOptions) { return new Zodios(baseUrl, endpoints, options); }
Additional context This seems to work normally, but doesn't work with --group-strategy tag-file. I didn't test other group strategies
--group-strategy tag-file
Describe the bug When using an array as a body and using min/max items (either of both, doesn't matter) with group by tags the output is invalid.
After some debugging, it looks like the
@key
in theschemas
block is the actual type withmin
/max
applied and the actual type isn't emitted.Minimal reproduction
Expected behavior The emitted Type should be valid
Actual behvaior Invalid output:
Additional context This seems to work normally, but doesn't work with
--group-strategy tag-file
. I didn't test other group strategies