Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 60x 1080x 1080x | import { OpenAPIV3 } from 'openapi-types'; import { FromSchema } from 'json-schema-to-ts'; import { DeepMutable } from '../types/mutable'; // Admin paths must have the "admin" tag. export interface AdminApiOperation extends Omit<OpenAPIV3.OperationObject, 'tags'> { tags: ['admin']; } // Client paths must have the "client" tag. export interface ClientApiOperation extends Omit<OpenAPIV3.OperationObject, 'tags'> { tags: ['client']; } // Create a type from a const schema object. export type CreateSchemaType<T> = FromSchema< T, { definitionsPath: 'components/schemas'; deserialize: [ { pattern: { type: 'string'; format: 'date'; }; output: Date; }, ]; } >; // Create an OpenAPIV3.SchemaObject from a const schema object. // Make sure the schema contains an object of refs for type generation. // Pass an empty 'components/schemas' object if there are no refs in the schema. // Note: The order of the refs must match the order they are present in the object export const createSchemaObject = < T extends { 'components/schemas': { [key: string]: object } }, >( schema: T, ): DeepMutable<Omit<T, 'components/schemas'>> => { const { 'components/schemas': schemas, ...rest } = schema; return rest; }; |