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

Plese clarify how multiple inheritance should work #691

Open
alvassin opened this issue Aug 24, 2018 · 3 comments
Open

Plese clarify how multiple inheritance should work #691

alvassin opened this issue Aug 24, 2018 · 3 comments

Comments

@alvassin
Copy link

alvassin commented Aug 24, 2018

Each type has a lot of facets, e.g. displayName and others. What should happen if we create derived type? Should we inherit only fields, that affect validation result?

I mean should derived type inherit required and default options? In which order?

I used workbench, that uses raml-js-parser2 under the hood and i see that required and default fields are not inherited (as all other facets like example, examples, displayName, etc.).

If that is desired behaviour, that should be explicitly declared in the spec.
But from my point this is not valid behaviour.

Imagine i have two type of logins:

CorporateEmail:
  type: string
  required: true
PersonalEmail:
  type: string
  required: true
UserEmail: [CorporateEmail, PersonalEmail]

I would have to define that UserEmail is required explicitly. Perhaps that is really ok, but that should be clarified in the spec then.

For Union that is quite obvious for me - just validate each type, if any is valid - Union is valid. But multiple inheritance raises a lot of questions.

@alvassin alvassin changed the title Definition is not clear for multiple inheritance Plese clarify how multiple inheritance should work Aug 24, 2018
@alvassin
Copy link
Author

Also, what about patterns in strings? If i derive from two parents, where each has pattern - i should
raise an exception?

Spec does not cover that case (only when parent and derived class have pattern definition):

If a sub-type inherits properties having the same name from at least two of its parent types, the sub-type keeps all restrictions applied to those properties with two exceptions: 1) a "pattern" facet when a parent type already declares a "pattern" facet 2) a user-defined facet when another user-defined facet has the same value. In these cases, an invalid type declaration occurs.

From my point of view, it is better to imagine that we create derived type in two steps:

  1. Create derived type with inherited options
  2. Override options with provided by user

So, from my point of view, it is valid when we define Parent type string with pattern, derive from it and also define pattern. This is explicit re-assignment.

But it is not valid when we have two parents with different patterns - there would be a conflict.

@alvassin
Copy link
Author

alvassin commented Aug 27, 2018

The same for multipleOf and format facets for numbers. Please clarify what parsers should do with multiple definitions in parent classes.

What should happen if i define number type with minimum, maximum and multipleOf float values facets, and then make derived integer type class. Should all values be implicitly rounded?

@alvassin
Copy link
Author

What should happen with enum facet of string type when using multiple inheritance? Conflict?

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

No branches or pull requests

2 participants