Skip to content

Commit b7259d8

Browse files
Merge pull request #529 from bitgopatmcl/add-missing-codecs
Add missing codecs to openapi-generator
2 parents ee9d522 + e07064c commit b7259d8

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

packages/openapi-generator/src/knownImports.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@ export const KNOWN_IMPORTS: KnownImports = {
5353
}, {});
5454
return E.right({ type: 'object', properties: props, required: [] });
5555
},
56+
strict: (_, schema) => E.right(schema),
57+
exact: (_, schema) => {
58+
if (schema.type !== 'object') {
59+
return E.left('exactC parameter must be object');
60+
}
61+
const props = Object.entries(schema.properties).reduce((acc, [key, prop]) => {
62+
return { ...acc, [key]: prop };
63+
}, {});
64+
return E.right({
65+
type: 'object',
66+
properties: props,
67+
required: Object.keys(props),
68+
});
69+
},
5670
record: (_, _domain, codomain) => {
5771
if (!codomain) {
5872
return E.left('Codomain of record must be specified');
@@ -96,11 +110,19 @@ export const KNOWN_IMPORTS: KnownImports = {
96110
brand: (_, arg) => E.right(arg),
97111
},
98112
'io-ts-types': {
113+
BigIntFromString: () => E.right({ type: 'primitive', value: 'string' }),
114+
BooleanFromNumber: () => E.right({ type: 'primitive', value: 'number' }),
115+
BooleanFromString: () => E.right({ type: 'primitive', value: 'string' }),
116+
DateFromISOString: () => E.right({ type: 'primitive', value: 'string' }),
117+
DateFromNumber: () => E.right({ type: 'primitive', value: 'number' }),
118+
DateFromUnixTime: () => E.right({ type: 'primitive', value: 'number' }),
119+
IntFromString: () => E.right({ type: 'primitive', value: 'string' }),
120+
JsonFromString: () => E.right({ type: 'primitive', value: 'string' }),
99121
nonEmptyArray: (_, innerSchema) => E.right({ type: 'array', items: innerSchema }),
100122
NonEmptyString: () => E.right({ type: 'primitive', value: 'string' }),
101-
DateFromISOString: () => E.right({ type: 'primitive', value: 'string' }),
102-
NumberFromString: () => E.right({ type: 'primitive', value: 'number' }),
103-
BooleanFromString: () => E.right({ type: 'primitive', value: 'boolean' }),
123+
NumberFromString: () => E.right({ type: 'primitive', value: 'string' }),
124+
readonlyNonEmptyArray: (_, innerSchema) =>
125+
E.right({ type: 'array', items: innerSchema }),
104126
UUID: () => E.right({ type: 'primitive', value: 'string' }),
105127
},
106128
'@api-ts/io-ts-http': {

0 commit comments

Comments
 (0)