Knetic / presilo

Generates code for many languages from a single schema
Apache License 2.0
9 stars 1 forks source link

Additional properties #6

Open Knetic opened 9 years ago

Knetic commented 9 years ago

Object schemas, currently, only support well-defined properties. JSON-Schema defines a key "additionalProperties" as a boolean, expressing whether or not the data may include unorganized extras along with the normal data.

This should be supported. Dynamic languages (ruby, python, js) should just attach further data onto their instances without question. Typed languages (Go, Java, C#) should include a generic "getAttribute" and "setAttribute" method (with appropriately vague interface{}, or Object types for return/set), and have a protected/unexported member associative array which can be modified underneath.

This isn't a good design pattern, but it may have uses (such as when forwarding unknown data in a payload).

Knetic commented 8 years ago

After deliberation, this may be part of the json-schema spec, but it really doesn't fit with the project as it stands. The project aims to bring good, reliable, predictable generated code to multiple languages. This won't help that, it will be a hack for poor schemas to produce the kind of code this project is meant to avoid.

It may be a feature later, but seems contrary to goals for now.