lagom / sbt-lagom-descriptor-generator

Lagom API code generator
Apache License 2.0
23 stars 12 forks source link

Support additional properties of incoming messages #16

Open ignasi35 opened 7 years ago

ignasi35 commented 7 years ago

Applying Postel's Law parsing a message should be liberal. JsonSchema supports setting up the additonalProperties flag to control that. Enumerated fields may also increase the set of valid values ("male"/"female" v "male"/"female"/"won't disclose").

There are three possible scenarios:

  1. strict parsing fails when new fields arrive
  2. liberal parsing doesn't fail
  3. liberal parsing doesn't fail and includes the additionalFields as an extra data in the parsed objects (final Map<String,Object> additionalFields)

As a general rule, the generated code should be robust to exta fields arriving on a message (options 2 and 3). This issue is to implement code generators that are liberal and also to discuss whether extra info should be made available to users (3) or simply swallowed (2).