fork of hey-api/openapi-ts because I need some additional things
at feat/skip-token 36 lines 1.0 kB view raw
1import type { Input } from '../../config/input/types'; 2import { heyApiRegistryBaseUrl, inputToHeyApiPath } from './heyApi'; 3import { inputToReadmePath } from './readme'; 4import { inputToScalarPath } from './scalar'; 5 6export function inputToApiRegistry( 7 input: Input & { 8 path: string; 9 }, 10) { 11 if (input.path.startsWith('readme:')) { 12 Object.assign(input, inputToReadmePath(input.path)); 13 return; 14 } 15 16 if (input.path.startsWith('scalar:')) { 17 Object.assign(input, inputToScalarPath(input.path)); 18 return; 19 } 20 21 if (input.path.startsWith('.')) { 22 return; 23 } 24 25 if (input.path.startsWith(heyApiRegistryBaseUrl)) { 26 input.path = input.path.slice(heyApiRegistryBaseUrl.length + 1); 27 Object.assign(input, inputToHeyApiPath(input as Input & { path: string })); 28 return; 29 } 30 31 const parts = input.path.split('/'); 32 if (parts.length === 2 && parts.filter(Boolean).length === 2) { 33 Object.assign(input, inputToHeyApiPath(input as Input & { path: string })); 34 return; 35 } 36}