Closed agakam closed 3 years ago
Hi!
@luisfpg thanks for the quick fix! Your changes fixed above example, but it doesn't work in more complex case:
Abc:
type: object
required:
- nullableObject
- inlinedNullableObject
- withNullableProperty
properties:
nullableObject:
$ref: "#/components/schemas/NullableObject"
withNullableProperty:
type: object
required:
- someProperty
properties:
someProperty:
$ref: "#/components/schemas/NullableObject"
inlinedNullableObject:
type: object
nullable: true
required:
- someProperty
properties:
someProperty:
type: string
I've added property with nullable property and this is the outcome:
/* tslint:disable */
import { NullableObject } from './nullable-object';
export interface Abc {
inlinedNullableObject: null | { 'someProperty': string };
nullableObject: NullableObject | null;
withNullableProperty: { 'someProperty': NullableObject };
}
Can you reopen this issue?
I've got an idea how to handle those nullable objects. It could be created as type:
interface NullableObjectInterface {
someProperty: string
}
type NullableObject = NullableObjectInterface | null;
What do you think about that?
BR, Aga
So, in the example, the only error is actually withNullableProperty
, right?
The expected output would be:
/* tslint:disable */
import { NullableObject } from './nullable-object';
export interface Abc {
inlinedNullableObject: null | { 'someProperty': string };
nullableObject: NullableObject | null;
withNullableProperty: { 'someProperty': NullableObject | null };
}
Yes, exactly. The only error is withNullableProperty
and the expected output should look like this.
Sorry for the delay. Can you, please, @agakam, still test the master branch to make sure it works in all cases you've tested?
I have defined API as follows:
when I generate API using
ng-openapi-gen
nullable object defined under $ref is no longer nullable. This issue not exists with inlined nullable object.Generated files:
and
as you can see
nullableObject
is defined as NullableObject interface, so it can't be nulled.