Skip to content

Commit cd0a56e

Browse files
authoredFeb 4, 2024
fix(angular): avoid Angular type error when nullable (#1200)
1 parent 84a9ac7 commit cd0a56e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed
 

‎packages/core/src/getters/scalar.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { SchemaObject } from 'openapi3-ts/oas30';
2-
import { ContextSpecs, ScalarValue } from '../types';
2+
import { ContextSpecs, ScalarValue, OutputClient } from '../types';
33
import { escape, isString } from '../utils';
44
import { getArray } from './array';
55
import { getObject } from './object';
@@ -20,7 +20,10 @@ export const getScalar = ({
2020
name?: string;
2121
context: ContextSpecs;
2222
}): ScalarValue => {
23-
const nullable = item.nullable ? ' | null' : '';
23+
// NOTE: Angular client does not support nullable types
24+
const isAngularClient = context.output.client === OutputClient.ANGULAR;
25+
const nullable = item.nullable && !isAngularClient ? ' | null' : '';
26+
2427
const enumItems = item.enum?.filter((enumItem) => enumItem !== null);
2528

2629
if (!item.type && item.items) {

0 commit comments

Comments
 (0)
Please sign in to comment.