Open adupre opened 5 years ago
Thanks! Glad to hear it!
I will try to look into this soon and see how feasible it is.
@adupre I added some initial support for discriminators. You can test it out with this repo: https://github.com/JKHeadley/rest-hapi-demo/tree/feature/discriminators
Some notes:
OneOf
since it is not supported in hapi-swagger, however most of the documentation should be taken care of by rest-hapi directly.discriminatorKey
property is automatically queryable, which could result in useful filtering of parent models. Ex: with parent model: contract
and child models: salesContract
and purchaseContract
, the following query would return all child model documents but not parent model documents (assuming the discriminatorKey is kind
):
http://localhost:8080/contract?kind=salesContract&kind=purchaseContractPlease let me know what you think.
@adupre please let me know if you have any input here. I will try to integrate this feature with the next minor version.
I need to be able to leverage the polymorphism features of Mongoose (discriminators) to create schemas that inherit from one another (example: Contract, SalesContract, PurchaseContract)
Enhance the model and api generators to support discriminators. Leverage Swagger's support of OneOf for generation of api and documentation.
There are unfortunately no acceptable alternatives at the moment.
Btw, thank you for this awesome library, it's a true time saver. Cheers, Anthony