Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(angular): avoid Angular type error when nullable #1200

Merged
Merged
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
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