-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'extends' isn't not a keyword in JSON-schema spec #277
Comments
I think there are two distinct points here:
Plank occasionally has taken liberties with the schema syntax to make our migration to immutable models earlier. The Additionally, there are missing attributes of JSON schema outside of
The ObjC generation is the only one I'm aware of that actually uses inheritance. The Java output from what I remember actually flattens the inherited set of properties and I think we can do the same on the ObjC side. We should consider generating protocols for the specific properties on each type (unflattened) though to allow for APIs to be migrated where they specified a base class type. |
Thanks @rahul-malik! Very good points. #1, yep, either subset of or full json-schema spec is a good idea;
Also, I may misunderstood and i don't think Yeah, migration is always the most difficult part. Usually NSObject should be good enough unless their codebase replies on properties of base class like we do (PIModel 😄 ). I like the idea of generating protocol for
Having said that, this seems to be the best path moving forward. To summarize:
I've not looked into source code or java implementation yet. I am more than happy to spend some time on this. Very interesting stuff! |
Currently extends is used for models inheritance in Plank schema.
Pros:
Cons:
It is really "allOf" other than having a base class.
In the generated models, for common methods, it may confuses the complier. I.e,
`Class A :
Class B : ClassA
`
This pattern is either explicitly not allowed or behaving unexpectedly in most programing languages.
Its not a standard keyword thus most existing JSON schema validators don't support that, or we have to make/use Plank's own validator tools on both provider-consumer sides.
It may encourages 'polymorphicTypeIdentifier' or similar kind of field in the schema to tell real type of model.
AFAIK, Inheritance isn't supported in most popular model-gen(GraphQL, protoBuf, and etc) tools. I guess the main reasons is that IDL is more for defining constraints on model, not primarily on OOP.
Possible solutions:
support allOf then deprecate extends
This shouldn't lose any property or method from the base class but base class itself.
A new build option to treat extends as allOf
For existing extends users, they may assume base class of the models, this is a breaking change in that case. A possible workaround is to specify a base class in the build option mentioned above? And users of "extend" would take care of the base class and its compliance in their code base.
I created this issue to capture what @jparise and me discussed a while go.
Your thoughts are appreciated.
The text was updated successfully, but these errors were encountered: