Skip to content

Commit

Permalink
fix(core): add unknown[] when items is not defined (#1757)
Browse files Browse the repository at this point in the history
  • Loading branch information
AllieJonsson authored Dec 19, 2024
1 parent 1853e1b commit 5be5cd4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/core/src/getters/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SchemaObject as SchemaObject31 } from 'openapi3-ts/oas31';
import { ContextSpecs, ScalarValue } from '../types';
import { resolveObject } from '../resolvers/object';
import { resolveExampleRefs } from '../resolvers';
import { compareVersions } from '../utils';

/**
* Return the output type from an array
Expand Down Expand Up @@ -80,6 +81,18 @@ export const getArray = ({
example: schema.example,
examples: resolveExampleRefs(schema.examples, context),
};
} else if (
compareVersions(context.specs[context.specKey].openapi, '3.1', '>=')
) {
return {
value: 'unknown[]',
imports: [],
schemas: [],
isEnum: false,
type: 'array',
isRef: false,
hasReadonlyProps: false,
};
} else {
throw new Error(
`All arrays must have an \`items\` key defined (name=${name}, schema=${JSON.stringify(schema)})`,
Expand Down

0 comments on commit 5be5cd4

Please sign in to comment.