-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add rules to generate java code from json schema #94
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
common4j?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy paste 😁 I'll fix it
} | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_1_7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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