Repository navigation
Copy properties from parent models defined with allOf - #946
Conversation
|
Does this mean the end result would be flattened classes rather than one exhibiting inheritance? |
|
@webron Yes, the end result would be flattened classes as all properties of parents would be copied and made as if they are the current model's own properties. For other clients that do handle it, e.g. Java client uses something like |
|
Thanks for the clarification. This is a tricky part of the spec, and may have a different effect on clients VS server. If we want to keep a 1:1 representation of spec:code, this may not fully work for servers, however, for it to work we need to have better support for it in the server libraries (I'm thinking of swagger-core but it applies to others as well). For clients, it may be less of an issue. Composition, at least for now, can (and probably should) be translated to a flattened structure in most languages. Inheritance (which is based on the discriminator field) needs to be represented eventually as actual extended classes, although the tricky part here is with multiple inheritance which JSON Schema allows but some languages don't. Obviously there are limitations now, but it would be useful to keep the metadata of the origin of the property in the property itself to allow more flexibility in the future. I'm okay with it as-is right now. :) |
Copy properties from parent models defined with allOf
Pull request swagger-api#946 broke the TypeScript generation with inheritance where a superclass defined an enum. This makes it up to each language to decide the behavior appropriate for the language.
as per swagger-api#1015 (and swagger-api#946) this is now optional and disabled by default. this results in extra unnecessary code, masking fields in some cases, and breaks code generated for jax-rs in certain cases (enums with inheritance). (not having inheritance
as per swagger-api#1015 (and swagger-api#946) this is now optional and disabled by default. this results in extra unnecessary code, masking fields in some cases, and breaks code generated for jax-rs in certain cases (enums with inheritance). (not having inheritance
as per swagger-api#1015 (and swagger-api#946) this is now optional and disabled by default. this results in extra unnecessary code, masking fields in some cases, and breaks code generated for jax-rs in certain cases (enums with inheritance).
as per swagger-api#1015 (and swagger-api#946) this is now optional and disabled by default. this results in extra unnecessary code, masking fields in some cases, and breaks code generated for jax-rs in certain cases (enums with inheritance).
as per swagger-api#1015 (and swagger-api#946) this is now optional and disabled by default. this results in extra unnecessary code, masking fields in some cases, and breaks code generated for jax-rs in certain cases (enums with inheritance).
This PR copies model properties of the parent models that are defined with the
allOfkey (with value of either$reforproperties), i.e. for composed models.It also fixes #936.