-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Allow file names in mappings to end in .json5 #2405
base: master
Are you sure you want to change the base?
Conversation
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.
Looks good to me, thank you!
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.
Could we expand this to confirm support for all the JSON5 features documented at json5.org?
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.
Uh-oh! It doesn't seem every feature is supported with the current ObjectMapper configuration.
A quick read through Jackson's documentation seems to indicate that most (though not all) JSON5 features are supported. Is it okay if I mess with WireMock's ObjectMapper to enable the missing options, and maybe document the current limitations?
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.
Yeah, I think let's write tests for each and enable everything we can. IIRC it's only one or two things that aren't supported by Jackson.
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've covered all the JSON5 features I could get working. A few notes:
- In accordance to this StackOverflow answer, I've found that quite a few JSON5 features are not yet supported by Jackson. I couldn't find any kind of roadmap suggesting that'll change anytime soon
- Perhaps we should upgrade from configuring JsonParser.Feature to enabling JsonReadFeature according to the jackson docs, but I guess that's another PR
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 feel like these are likely to be lesser used features. I think it would be reasonable to make a note in the docs about these caveats but still claim support for JSON5.
Please can you do a |
Uhhh nothing appears to have changed.. might be related to #2333? |
@samueldcs Maybe :( I am not a huge fan of spotless, but fixing it until it passes seems to be the only way. Or one could add a github action that applies Spotless to an arbitrary pull request (with a risk of royal mess if it goes wrong) |
@@ -320,7 +320,7 @@ void reportsErrorFromSubMatcher() { | |||
.match("<something>{ bad json</something>"); | |||
checkJsonError( | |||
matchResult, | |||
"Unexpected character ('b' (code 98)): was expecting double-quote to start field name\n at [Source: (String)\"{ bad json\"; line: 1, column: 4]"); | |||
"Unexpected character ('j' (code 106)): was expecting a colon to separate field name and value\n at [Source: (String)\"{ bad json\"; line: 1, column: 8]"); |
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 we shouldn't change the way we parse user-supplied JSON in requests/responses, just stub mappings. I think maintaining a separate parser configuration and switching into it in the mappings loader (and possibly the API) might be the way forward here.
Addresses #2397.
WireMock already supports json5, but files ending in extensions other than
json
are ignored. I've changed this behavior to also load json5 files, both from remote and local sources.Submitter checklist
#help-contributing
or a project-specific channel like#wiremock-java