Add rules to generate java code from json schema#94
Add rules to generate java code from json schema#94
Conversation
|
do we need to onboard android-complete to the governance tool? (either that, or find another way to get a 3rd party library approval). |
| from components.java | ||
|
|
||
| pom { | ||
| name = 'common4j' |
There was a problem hiding this comment.
copy paste 😁 I'll fix it
| } | ||
|
|
||
| java { | ||
| sourceCompatibility = JavaVersion.VERSION_1_7 |
There was a problem hiding this comment.
not related to this PR, but we probably want to make this a variable (in the versioning file, to be consumed by everyone) at some point - if possible.
There was a problem hiding this comment.
yes....I've also done some work here in the plugin as well...to accept any Java version as opposed to just toggling between 7 & 8
It is in-progress here: #95 (mostly complete...just need to add javadocs before I make it live)
| * Map data type if the type of the field in schema was defined as an "object" AND the field did not | ||
| * have any properties on it. Otherwise, this rule will just delegate the operation to its parent. | ||
| */ | ||
| public class AuthClientJsonSchemaTypeRule extends TypeRule { |
There was a problem hiding this comment.
I think putting some example here might help. it's pretty hard to see the whole picture tbh.
There was a problem hiding this comment.
Or... maybe write tests/ add samples with a 'generic' json that this plugin supports. (i.e. this seems to be looking for "properties", but wouldn't support any other nested tags)
| * A {@link RuleFactory} that provides a custom implementation of the {@link org.jsonschema2pojo.rules.TypeRule} | ||
| * and also provides an additional {@link MapRule} as well. | ||
| */ | ||
| public class AuthClientJsonSchemaRuleFactory extends RuleFactory { |
There was a problem hiding this comment.
nit, add a brief comment on what is typerule, and objectrule.
Adding a new module that contains a rule factory to generate java code from json schemas. This is primarily needed for our upcoming broker project. See PR here: https://github.com/AzureAD/ad-accounts-for-android/pull/1573
That project is using jsonschema2pojo for doing code generation and in this module we have added some rules that will let us customize the code generation per our reads. Please read more details in this document here.
This package is published and consumed that way as a buildscript dependency. We only need to publish this package to the internal maven. It is already published here