fork of hey-api/openapi-ts because I need some additional things
1import { ConfigError, getInput } from '@hey-api/shared';
2
3import type { Job } from './expand';
4import { getOutput } from './output/config';
5
6export type ValidationResult = {
7 errors: Array<ConfigError>;
8 job: Job;
9};
10
11export function validateJobs(jobs: ReadonlyArray<Job>): ReadonlyArray<ValidationResult> {
12 return jobs.map((job) => {
13 const errors: Array<ConfigError> = [];
14 const { config } = job;
15
16 const inputs = getInput(config);
17 if (!inputs.length) {
18 errors.push(
19 new ConfigError(
20 'missing input - which OpenAPI specification should we use to generate your output?',
21 ),
22 );
23 }
24
25 const output = getOutput(config);
26 if (!output.path) {
27 errors.push(new ConfigError('missing output - where should we generate your output?'));
28 }
29
30 return { errors, job };
31 });
32}