Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

doc(Usage of discriminator): polymorphism and inheritance #255

Conversation

patrice-conil
Copy link
Contributor

@patrice-conil patrice-conil commented Jun 30, 2023

Clarify things between polymorphis and inheritance.
Give preference on inheritance over polymorphism to simplify usage of Camara APIs from strongly typed languages.
Discourage usage of multiple inheritance.

…heritance. Discourage usage of multiple inheritance.
Copy link
Contributor

@hdamker hdamker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Supportive for the PR, just some corrections within the example suggested.

Commonalities/documentation/API-design-guidelines.md Outdated Show resolved Hide resolved
Commonalities/documentation/API-design-guidelines.md Outdated Show resolved Hide resolved
Commonalities/documentation/API-design-guidelines.md Outdated Show resolved Hide resolved
Commonalities/documentation/API-design-guidelines.md Outdated Show resolved Hide resolved
Copy link

@jlurien jlurien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As commented in camaraproject/QualityOnDemand#177, I think that the new model is not aligned with the way that inheritance is meant to be described in OAS3 as shown in all the examples in the spec, which include all objects composing the child object as elements of the allOf array. This is not multiple inheritance, as there is only one single base object, the one with the discriminator. These examples have not changed since the times of Swagger 2, so I guess they are representing what the authors of the spec meant.

Problems with some generators and languages may happen, but they are limitations of the tools, not the spec or coding language. We have no guarantee that other tools may complain with the new model, and it is safer to be as close to official specification as possible.

In particular, if you use openapi-generator with Java, there was this known limitation, submitted indeed as bug many years ago. In this thread the model you proposed here is also proposed there as a mitigation. BTW, it seems that they have finally solved the root cause, as recently as 3 weeks ago,

@patrice-conil
Copy link
Contributor Author

@jlurien,
I'm not the only one interpreting it as multiple inheritance as the guys at openapi-generator also translated it that way but it's probably a better idea to follow the examples in the spec to the letter. I will also fix it in QoD and Device Status proposals.

Copy link
Contributor

@hdamker hdamker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/LGTM

@shilpa-padgaonkar shilpa-padgaonkar self-requested a review July 4, 2023 06:58
@shilpa-padgaonkar
Copy link
Contributor

@patrice-conil : I am currently in the process of moving docs from wg to comm repo.

Could you kindly open an issue and this PR in the new repo, once my housekeeping activity is done? We agreed in the last commonalities meeting that after PR #244 has been merged, we will only start new PRs in the new repo https://github.com/camaraproject/Commonalities.

If I simply merge your PR now with 1 approval, this will not allow other interested members from commonalities a chance to review your PR.

Regret the inconvenience.

@patrice-conil
Copy link
Contributor Author

Hi @shilpa-padgaonkar ,
Sorry to have missed this point, I will move this PR to the new repository.

Regards

@shilpa-padgaonkar
Copy link
Contributor

Thanks a lot @patrice-conil for your support. I will close this PR now and will look forward to your PR in the new comms repo soon!

@patrice-conil
Copy link
Contributor Author

patrice-conil commented Jul 4, 2023 via email

@shilpa-padgaonkar
Copy link
Contributor

@patrice-conil : Thanks a lot for your link :)
Yes, I am aware of mirroring, and we use it between our internal repo and provider implementation repo for QoD.
However, the working group repo is a mix of lot of things in addition to commonalities and in addition I wanted to do some cleanup and restructuring along the way.
But now it's almost done. I am just waiting to get the PR merged :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants