Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions packages/openapi-generator/src/knownImports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,14 @@ export const KNOWN_IMPORTS: KnownImports = {
if (schema.type !== 'object') {
return E.left('httpRoute parameter must be object');
}
const props = Object.entries(schema.properties).reduce((acc, [key, prop]) => {
const derefedE = deref(prop);
const props: Record<string, Schema> = {};
for (const [key, value] of Object.entries(schema.properties)) {
const derefedE = deref(value);
if (E.isLeft(derefedE)) {
return acc;
return derefedE;
}
return { ...acc, [key]: derefedE.right };
}, {});
props[key] = derefedE.right;
}
return E.right({
type: 'object',
properties: props,
Expand Down
25 changes: 25 additions & 0 deletions packages/openapi-generator/test/apiSpec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,28 @@ test('api spec comment parser', async () => {

assert(commentParsed);
});

const MISSING_REFERENCE = {
'/index.ts': `
import * as t from 'io-ts';
import * as h from '@api-ts/io-ts-http';

import { Foo } from 'foo';

export const test = h.apiSpec({
'api.test': {
get: h.httpRoute({
path: '/test',
method: 'GET',
request: Foo,
response: {
200: t.string,
},
})
}
});`,
};

testCase('missing reference', MISSING_REFERENCE, '/index.ts', {}, [
"Cannot find 'Foo' from 'foo'",
]);