-
Notifications
You must be signed in to change notification settings - Fork 6k
[JAVA][#5172] Allow vendor json media types #5189
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
Conversation
|
Could you rebase your branch onto current master, and possibly regenerate the samples afterwards? I think some of the changes in the generated samples are already incorporated there, and this would make it easier to see what actually changed. |
| */ | ||
| public boolean isJsonMime(String mime) { | ||
| return mime != null && mime.matches("(?i)application\\/json(;.*)?"); | ||
| String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"; |
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.
Are tab characters really allowed in media type names?
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.
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.
Okay, thanks.
| assertTrue(apiClient.isJsonMime("example/foo+bar+json")); | ||
| assertTrue(apiClient.isJsonMime("example/foo+json;x;y")); | ||
| assertTrue(apiClient.isJsonMime("example/foo+json\t;")); | ||
| assertTrue(apiClient.isJsonMime("Example/fOO+JSON")); |
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.
If you want a real-live example, application/problem+json (from RFC 7807) is often used in APIs.
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.
Sure thing, I'll update these tests with some real-live example.
|
Looks like the failed test is fixed here: #5243 |
|
Yes, sorry for the update proposal, I didn't mean to cause more issues by that, but simply forgot that current master is "broken" (for sample generation) until #5243 is merged. |
|
no worries :) |
| public boolean isJsonMime(String mime) { | ||
| return mime != null && mime.matches("(?i)application\\/json(;.*)?"); | ||
| String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"; | ||
| return mime != null && mime.matches(jsonMime); |
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.
Later I will file a PR to put these 2 lines into one without declaring a temporary variable.
| assertTrue(apiClient.isJsonMime("example/foo+bar+json")); | ||
| assertTrue(apiClient.isJsonMime("example/foo+json;x;y")); | ||
| assertTrue(apiClient.isJsonMime("example/foo+json\t;")); | ||
| assertTrue(apiClient.isJsonMime("Example/fOO+JSON")); |
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.
We'll leverage these test cases in other API clients' unit tests
|
@ePaul thanks for reviewing the change. @davidharrigan thanks for the contribution, which has been merged into master. |
) * [swagger-api#5172] Allow vendor json media types * Revert unnecessary diffs * Update petstore sample * Didn't run mvn after some edits * Rerun ' ./bin/java-petstore-all.sh' and './bin/security/java-petstore-okhttp-gson.sh' * Added more realistic test cases for isJsonMime
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shand./bin/security/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates)2.3.0branch for breaking (non-backward compatible) changes.Description of the PR
Adds support for vendor media type JSON (ends with
+json) as specified in RFC-3839.PR made against master since the change is non-breaking and backwards compatible (still has the same support for
application/json).More details in the issue here: #5172