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

Add option to specify custom fragment path delimiters #697

Merged
merged 2 commits into from
Mar 2, 2017

Conversation

tovkal
Copy link
Contributor

@tovkal tovkal commented Mar 1, 2017

This adds the option suggested in #688, so nonstandard JSON Pointers found in $ref can be split correctly.

The option's default is the current value, #/., so it should not break any existing projects.

Let me know if something is missing and needs to be done before merging, also let me know if the wording of the descriptions is a bit weird.

@joelittlejohn
Copy link
Owner

Thanks for submitting this. I'll add some comments.

@@ -146,6 +146,7 @@

private boolean formatDateTimes = false;

private String customSeparatorCharacters = "#/.";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename this property everywhere to refFragmentPathDelimiters? I think this makes it clear where this property will actually be used. We also have another 'delimiters' config option so I feel like we should use that word in preference for consistency.

@@ -408,6 +408,12 @@
</td>
<td align="center" valign="top">No (default <code>false</code>)</td>
</tr>
<tr>
<td valign="top">customSeparatorCharacters</td>
<td valign="top">Separators characters to be used to split JSON Pointers ($ref).
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a small typo here ("Separators characters"). To make it clear that this is not an array or list, I think this text should mention that it's a string. How about this as a description:

A string containing any characters that should act as path delimiters when resolving $ref fragments. By default, #, / and . are used in an attempt to support JSON Pointer and JSON Path.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description can be used in a variety of places.

@@ -418,4 +421,9 @@ public boolean isFormatDateTimes() {
return formatDateTimes;
}

@Override
public String isCustomSeparatorCharacters() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few getters in this and other classes that have an incorrect is prefix instead of get. This and others should be get.

ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/properties/nonStandardRef.json", "com.example",
config("customSeparatorCharacters", "#/"));

assertThat(resultsClassLoader.loadClass("com.example.Foo").getName(), is("com.example.Foo"));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These assertions are redundant, two plain calls to loadClass will suffice as this will throw an exception if the class is missing.

@tovkal
Copy link
Contributor Author

tovkal commented Mar 1, 2017

Applied the requested changes, let me know if there's anything else.

@joelittlejohn joelittlejohn merged commit 2736b8c into joelittlejohn:master Mar 2, 2017
@joelittlejohn joelittlejohn changed the title Add option to specify custom separator characters Add option to specify custom fragment path delimiters Mar 2, 2017
@joelittlejohn
Copy link
Owner

Thanks! 👍

@joelittlejohn joelittlejohn added this to the 0.4.32 milestone Mar 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants