JKHeadley / rest-hapi

🚀 A RESTful API generator for Node.js
https://resthapi.com
MIT License
1.19k stars 152 forks source link

Add support for polymorphism (discriminators) #174

Open adupre opened 5 years ago

adupre commented 5 years ago

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

JKHeadley commented 5 years ago

Thanks! Glad to hear it!

I will try to look into this soon and see how feasible it is.

JKHeadley commented 5 years ago

@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:

Please let me know what you think.

JKHeadley commented 5 years ago

@adupre please let me know if you have any input here. I will try to integrate this feature with the next minor version.