Skip to content

Commit

Permalink
fix(angular): avoid Angular type error when nullable (#1200)
Browse files Browse the repository at this point in the history
  • Loading branch information
soartec-lab committed Feb 4, 2024
1 parent 84a9ac7 commit cd0a56e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/core/src/getters/scalar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SchemaObject } from 'openapi3-ts/oas30';
import { ContextSpecs, ScalarValue } from '../types';
import { ContextSpecs, ScalarValue, OutputClient } from '../types';
import { escape, isString } from '../utils';
import { getArray } from './array';
import { getObject } from './object';
Expand All @@ -20,7 +20,10 @@ export const getScalar = ({
name?: string;
context: ContextSpecs;
}): ScalarValue => {
const nullable = item.nullable ? ' | null' : '';
// NOTE: Angular client does not support nullable types
const isAngularClient = context.output.client === OutputClient.ANGULAR;
const nullable = item.nullable && !isAngularClient ? ' | null' : '';

const enumItems = item.enum?.filter((enumItem) => enumItem !== null);

if (!item.type && item.items) {
Expand Down

0 comments on commit cd0a56e

Please sign in to comment.