Comments (2)
Thanks @rahul-malik! Very good points.
#1, yep, either subset of or full json-schema spec is a good idea;
#2, I don't think we need inheritance in Plank at all. JSON is not primarily designed for that. I like the idea of flattening properties, as that's what allOf
is supposed to do: look up properties till root and flatten them.
allOf
is slightly different than extends
, which will be flatten and is useful for in abstracting common data without a base class or protocol.
Also, I may misunderstood and i don't think polymorphicTypeIdentifier
/ADT
has to do with extends
or allOf
. I thought it is a solution to union
(doesn't seem to be valid keyword in json-schema) or oneOf
. I don't have strong opinion around that and I think they should continue to work after flattened.
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 extended
type but:
- that might be overhead in code generating if there're many immediate protocols. Unlikely in real word though.
- once we support that, we can't get rid of that.
Having said that, this seems to be the best path moving forward. To summarize:
- Support
allOf
keyword - Add build option to treat
extends
asallOf
and also generate protocol forextended
type - Deprecate methods in generated protocols to expedite migration
- Remove 'extends` support from Plank, also the build option.
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!
from plank.
I think there are two distinct points here:
- The
extends
keyword is not documented in JSON Schema making Plank divergent from the open specification. Should this be changed and should we enforce its aligned with the open specification?
Plank occasionally has taken liberties with the schema syntax to make our migration to immutable models earlier. The extends
keyword was added as well as a few others like polymorphicTypeIdentifier
to support ADT types. I don't have a strong opinion around switching to allOf
but it likely will open it up to more of a mix-in style schema where you could "inherit" from multiple types which can be powerful but also will change how we consider code generation.
Additionally, there are missing attributes of JSON schema outside of allOf
and we should figure out if we should attempt to support these as well. Alternatively, we could also use JSON schema to write a schema definition for what Plank accepts which could be another path forward here.
- How should code generation handle cases like
allOf
orextends
? Should inheritance be supported at all or should we migrate towards composing models?
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.
from plank.
Related Issues (20)
- Update Maven Bazel integration to new rules
- Add support for AndroidX nullability annotations HOT 1
- required fields don't do anything in Java HOT 2
- Java model _bits property should be transient HOT 2
- Java model's Builder-setters should annotate parameter with @Nullable or @NonNull
- Java model Builder.build() method should be annotated with @NonNull HOT 1
- Java model - mergeFrom should be annotated with @NonNull
- Java model Builders should apply @NonNull annotation to its getter methods if appropriate HOT 1
- Java model builders should order the fields checked in `equals()`
- Make it easier to detect use of outdated Plank binary HOT 3
- Custom merge strategies (Java) HOT 2
- Use Kotlin-friend Java method names for Boolean accessors
- Support nested object definitions
- Source code checksum changed HOT 6
- Java documentation is outdated
- Title field is not save when creating Pin from a direct link
- Any plans for dart/flutter support? HOT 1
- iOS plank -initWithModelDictionary:error: assumes dictionary is dictionary
- [Security] Workflow ci.yml is using vulnerable action actions/checkout
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plank.