Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: REST Builder (OpenAPI) YAML "allOf" inheritance is not working as expec
BuildREST task in LIferay 7.2 is not generating the DTO stubs as expected if base class properties are extended in the child class using "allOf". This is quite breaking the inheritance and creates as a composite schema.Have attached allOf.png for your reference; We have a parent class called Car and a child class called Honda. The idea here is we want to extend the parent class (Car) properties in the child class (Honda) by making parent class as a 'allOf' reference, such that the child class shall have the properties - id (inherited from parent class), parts and modelNumber.But when buildREST is generating the stubs for this allOf schema, we do see two different DTO classes without an extends. Parent Class (Car) is generated with its own properties and Child Class (Honda) is generated with its own properties and also has an extra property as Car (with its relevant getter, setter).Our expectation is that the Child Class should be alike Honda extends Car; but it is not as expected.
Attachments:
Yes, you are right. We plan to change it before the final release of 7.3 (mid sept) and it'll be available for all versions.
AllOf/Any/One are not very well supported right now... but if you need inheritance you can use anyOf with the *exact* syntax (sorry, rest builder is very picky at the moment) explained here: https://help.liferay.com/hc/en-us/articles/360039425731-Support-for-oneOf-anyOf-and-allOf
AllOf/Any/One are not very well supported right now... but if you need inheritance you can use anyOf with the *exact* syntax (sorry, rest builder is very picky at the moment) explained here: https://help.liferay.com/hc/en-us/articles/360039425731-Support-for-oneOf-anyOf-and-allOf
Hi Javier ,
Thanks for your prompt response.
The documentation provided in the url is having few discrepancies. Below anyOf section, the sample syntax is provided for oneOf. Please kindly suggest how to achieve inheritance with the scenario that we have explained. Understand that that the current allOf support generates stubs based on model composition. But would need to get the inheritance working (within the scope of existing rest builder plugin). Also please let us know what is the latest version of rest builder plugin that we can leverage for our implementation (using 1.0.22 currently - would moving to a higher / latest version would help?
One last query; if rest builder plugin is under going enhancements & will be released in mid-sept as part of 7.3 roll out; would there be fixpacks available to assist the same in 7.2 ?
Looking forward for your response.
Thanks
Amit
Thanks for your prompt response.
The documentation provided in the url is having few discrepancies. Below anyOf section, the sample syntax is provided for oneOf. Please kindly suggest how to achieve inheritance with the scenario that we have explained. Understand that that the current allOf support generates stubs based on model composition. But would need to get the inheritance working (within the scope of existing rest builder plugin). Also please let us know what is the latest version of rest builder plugin that we can leverage for our implementation (using 1.0.22 currently - would moving to a higher / latest version would help?
One last query; if rest builder plugin is under going enhancements & will be released in mid-sept as part of 7.3 roll out; would there be fixpacks available to assist the same in 7.2 ?
Looking forward for your response.
Thanks
Amit
Below anyOf section, the sample syntax is provided for oneOf.
=> It's a typo, should say anyOf, the example is the one valid for anyOf. But it does not let you to reuse schemas (use a ref), you have to define properties.Also please let us know what is the latest version of rest builder plugin that we can leverage for our implementation (using 1.0.22 currently - would moving to a higher / latest version would help?
=> we are currently in the 1xx range but no current versions support inheritance
(and there are limits to what version you can use depending on the fixpack you are on): https://github.com/javierdearcos/rest-builder-docs/blob/master/Version%20Matrix.md
But if you can avoid using inheritance I'll recommend doing so, inheritance with JAX-RS/jackson is a bit messy, everything is fine in GET methods but in POST/PUT you have to pass an extra attribute to identify which object Jackson has to create (because it can't infer if you want to create an Honda or a BMW).
Everything in the API space (APIs, REST Builder, GraphQL and REST infrastructure) is backported to 7.2 and 7.1.
=> It's a typo, should say anyOf, the example is the one valid for anyOf. But it does not let you to reuse schemas (use a ref), you have to define properties.Also please let us know what is the latest version of rest builder plugin that we can leverage for our implementation (using 1.0.22 currently - would moving to a higher / latest version would help?
=> we are currently in the 1xx range but no current versions support inheritance

But if you can avoid using inheritance I'll recommend doing so, inheritance with JAX-RS/jackson is a bit messy, everything is fine in GET methods but in POST/PUT you have to pass an extra attribute to identify which object Jackson has to create (because it can't infer if you want to create an Honda or a BMW).
Everything in the API space (APIs, REST Builder, GraphQL and REST infrastructure) is backported to 7.2 and 7.1.
HI Javier,
Thanks for your response .anyOf is not matching our requirement we want to reuse the schema using $ref.
For our scenario we have defined inheritance to the relevant schema for GET operation, allOf should support inheritance ( as per Open API Spec v3 ) and model composition .i am currently using Liferay DXP 7.2 FP6 please let know when inheritance support using allOf will be made available ?
Looking forward to hear from you.
Thanks,
Amit
Thanks for your response .anyOf is not matching our requirement we want to reuse the schema using $ref.
For our scenario we have defined inheritance to the relevant schema for GET operation, allOf should support inheritance ( as per Open API Spec v3 ) and model composition .i am currently using Liferay DXP 7.2 FP6 please let know when inheritance support using allOf will be made available ?
Looking forward to hear from you.
Thanks,
Amit
Hi Javier ,
Awaiting for your favorable response on the above (support of allOf for inheritance).
Also,appreciate your expert suggestions on the below queries that I have ;
1. Are the Rest API's built using Rest Builder also a microservice (or) adheres to microservice design ?
2. Can these services be published /hosted to API gateway ?
3. Can these services be deployed independent into a non-liferay environment ?
Thanks
Amit.
Awaiting for your favorable response on the above (support of allOf for inheritance).
Also,appreciate your expert suggestions on the below queries that I have ;
1. Are the Rest API's built using Rest Builder also a microservice (or) adheres to microservice design ?
2. Can these services be published /hosted to API gateway ?
3. Can these services be deployed independent into a non-liferay environment ?
Thanks
Amit.
About inheritance, we haven't started yet.
1 - They adhere to a modularity design, one of the underlying ideas behind microservices.
2 - They can be served by an API Gateway.
3 - No, right now they are coupled with Liferay utilities and dependencies.
1 - They adhere to a modularity design, one of the underlying ideas behind microservices.
2 - They can be served by an API Gateway.
3 - No, right now they are coupled with Liferay utilities and dependencies.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™