JKHeadley / JKHeadley/rest-hapi

Add support for polymorphism (discriminators)

Open
#174 3 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
1.2k
Forks
155
PR merge metrics
No merged PRs in 30d

Description

I need to be able to leverage the polymorphism features of [Mongoose (discriminators)](https://mongoosejs.com/docs/discriminators.html) 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](https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/) 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

Contributor guide

Open the contributing guide

Research direction

Start by tracing the model and API generator entry points and reading the linked Mongoose discriminator and Swagger OneOf documentation. Determine how inherited schemas should be represented in generated APIs and documentation, then verify that Contract, SalesContract, and PurchaseContract can be generated with the intended polymorphic relationships.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, backend, documentation
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.