fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #2889 from hey-api/copilot/fix-valibot-time-format

authored by

Lubos and committed by
GitHub
128eb187 c6de6843

+78 -1
+5
.changeset/brown-bags-matter.md
··· 1 + --- 2 + "@hey-api/openapi-ts": patch 3 + --- 4 + 5 + fix(valibot): handle `time` string format
+8
packages/openapi-ts-tests/main/test/3.1.x.test.ts
··· 994 994 }), 995 995 description: 'anyOf string and binary string', 996 996 }, 997 + { 998 + config: createConfig({ 999 + input: 'time-format.yaml', 1000 + output: 'time-format', 1001 + plugins: ['valibot'], 1002 + }), 1003 + description: 'generates correct valibot schema for time format', 1004 + }, 997 1005 ]; 998 1006 999 1007 it.each(scenarios)('$description', async ({ config }) => {
+20
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/time-format/valibot.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as v from 'valibot'; 4 + 5 + export const vGetSearchData = v.object({ 6 + body: v.optional(v.never()), 7 + path: v.optional(v.never()), 8 + query: v.object({ 9 + start_time: v.optional(v.pipe(v.string(), v.isoTimeSecond())), 10 + end_time: v.pipe(v.string(), v.isoTimeSecond()) 11 + }) 12 + }); 13 + 14 + /** 15 + * Success 16 + */ 17 + export const vGetSearchResponse = v.object({ 18 + result: v.optional(v.string()), 19 + scheduled_time: v.optional(v.pipe(v.string(), v.isoTimeSecond())) 20 + });
+10 -1
packages/openapi-ts/src/plugins/valibot/v1/toAst/string.ts
··· 72 72 }), 73 73 ); 74 74 break; 75 + case 'time': 76 + pipes.push( 77 + tsc.callExpression({ 78 + functionName: tsc.propertyAccessExpression({ 79 + expression: v.placeholder, 80 + name: identifiers.actions.isoTimeSecond, 81 + }), 82 + }), 83 + ); 84 + break; 75 85 case 'uri': 76 86 pipes.push( 77 87 tsc.callExpression({ ··· 83 93 ); 84 94 break; 85 95 case 'email': 86 - case 'time': 87 96 case 'uuid': 88 97 pipes.push( 89 98 tsc.callExpression({
+35
specs/3.1.x/time-format.yaml
··· 1 + openapi: 3.1.0 2 + info: 3 + title: OpenAPI 3.1.0 time format example 4 + version: '1' 5 + paths: 6 + /search: 7 + get: 8 + summary: Search with time parameter 9 + parameters: 10 + - name: start_time 11 + in: query 12 + description: Start time in HH:MM:SS format 13 + schema: 14 + type: string 15 + format: time 16 + - name: end_time 17 + in: query 18 + description: End time in HH:MM:SS format 19 + required: true 20 + schema: 21 + type: string 22 + format: time 23 + responses: 24 + '200': 25 + description: Success 26 + content: 27 + application/json: 28 + schema: 29 + type: object 30 + properties: 31 + result: 32 + type: string 33 + scheduled_time: 34 + type: string 35 + format: time