mirror of
				https://github.com/zoriya/Kyoo.git
				synced 2025-10-30 18:22:41 -04:00 
			
		
		
		
	Use kind guards in registerExamples
This commit is contained in:
		
							parent
							
								
									cfe6ce9c7e
								
							
						
					
					
						commit
						b0dac24eea
					
				| @ -1,16 +1,17 @@ | ||||
| import type { TSchema } from "elysia"; | ||||
| import { KindGuard } from "@sinclair/typebox" | ||||
| 
 | ||||
| export const registerExamples = <T extends TSchema>( | ||||
| 	schema: T, | ||||
| 	...examples: (T["static"] | undefined)[] | ||||
| ) => { | ||||
| 	if ("anyOf" in schema) { | ||||
| 	if (KindGuard.IsUnion(schema)) { | ||||
| 		for (const union of schema.anyOf) { | ||||
| 			registerExamples(union, ...examples); | ||||
| 		} | ||||
| 		return; | ||||
| 	} | ||||
| 	if ("allOf" in schema) { | ||||
| 	if (KindGuard.IsIntersect(schema)) { | ||||
| 		for (const intersec of schema.allOf) { | ||||
| 			registerExamples(intersec, ...examples); | ||||
| 		} | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user