Skip to content
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

Modify Rule#apply signature to include parent node (allows context-aware rules) #917

Merged

Conversation

jrehwaldt
Copy link
Contributor

Add JsonNode parent to rules.

This is required in order to implement context-aware rules, e.g. such as gh-910.

Breaking change.

This is required in order to implement context-aware rules, e.g. such as joelittlejohngh-910.
jrehwaldt added a commit to jrehwaldt/jsonschema2pojo that referenced this pull request Sep 17, 2018
This depends on joelittlejohngh-917 in order to know if a rule is applied top-level or sub-level.
Alternatively, if joelittlejohngh-906 is fixed by providing sub-schemas for sub-levels
this could be used to check nesting.
@jrehwaldt
Copy link
Contributor Author

jrehwaldt commented Sep 17, 2018

This also helps implementing gh-909 and fixing gh-906. I've also seen previous PRs requiring similar functionality (e.g. gh-622).

I am open to implement another approach if you are in favor of another solution.

@joelittlejohn joelittlejohn added this to the 1.0.0-beta1 milestone Sep 17, 2018
@joelittlejohn
Copy link
Owner

I think you're right that it would be good to get this change added before 1.0.0 is released 👍

@joelittlejohn joelittlejohn merged commit 02c6d4b into joelittlejohn:master Sep 17, 2018
@jrehwaldt
Copy link
Contributor Author

Another refinement would be to add a general Context argument instead, which could then be extended further in the future. Part of this would be this parent, or maybe the whole branch (parent->parent's parent->...). Just putting it out as suggestion. Not sure if this would be better.

Something along the lines of

interface Context {
	JsonNode parent()
	JsonNode current()
    // extensible in future
}

@jrehwaldt
Copy link
Contributor Author

Thanks for considering and merging! :)

@jrehwaldt jrehwaldt deleted the add-parent-node-to-rules-apply branch September 18, 2018 07:26
jrehwaldt added a commit to jrehwaldt/jsonschema2pojo that referenced this pull request Sep 18, 2018
No interfaces are added to enums.

This depends on joelittlejohngh-917 in order to know if a rule is applied top-level or sub-level.

Contains integration tests. Introduces new config option `additionalInterfaces`.
@joelittlejohn joelittlejohn changed the title Enable development of context-aware rules. Modify Rule#apply signature to include parent node (allows context-aware rules) Sep 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants