ng-openapi-gen icon indicating copy to clipboard operation
ng-openapi-gen copied to clipboard

OneOf (from official doc) not working

Open dgilsonAfelio opened this issue 3 years ago • 3 comments
trafficstars

Using this example: https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/

Using the latest version of ng-openapi-gen.

image

image

What I got: image

What I expect: image

dgilsonAfelio avatar Aug 09 '22 09:08 dgilsonAfelio

It works if I add this into model.js: image

And this into gen-util.js: image image

dgilsonAfelio avatar Aug 09 '22 12:08 dgilsonAfelio

Workaround: Use oneOf alone into an object and use allOf to inherit this object. image

dgilsonAfelio avatar Aug 09 '22 12:08 dgilsonAfelio

Same problem. I simply add hasOneOf to model.js as in example above

const hasOneOf = schema.oneOf && schema.oneOf.length > 0;
this.isObject = (type === 'object' || !!schema.properties) && !schema.nullable && !hasAllOf  && !hasOneOf;

@luisfpg could please fix this next release

BrothersWar avatar Oct 19 '22 15:10 BrothersWar

is it like this ? @luisfpg @BrothersWar @dgilsonAfelio

image

RPS044 avatar Dec 01 '23 11:12 RPS044

Any updated ? @luisfpg @BrothersWar @dgilsonAfelio

RPS044 avatar Dec 04 '23 07:12 RPS044