Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Merged
wing328 merged 9 commits into swagger-api:master from davidharrigan:FIX-5172
Mar 30, 2017
Merged

[JAVA][#5172] Allow vendor json media types #5189

wing328 merged 9 commits into swagger-api:master from davidharrigan:FIX-5172
Mar 30, 2017

Conversation

@davidharrigan
Copy link
Contributor

@davidharrigan davidharrigan commented Mar 24, 2017
edited
Loading

PR checklist

  • Read the contribution guidelines.
  • Ran the shell/batch script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates)
  • Filed the PR against the correct branch: master for non-breaking changes and 2.3.0 branch 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

@davidharrigan davidharrigan changed the title (削除) [Fixes #5172] Allow vendor json media types (削除ここまで) (追記) [JAVA][#5172] Allow vendor json media types (追記ここまで) Mar 24, 2017
Copy link
Contributor

ePaul commented Mar 29, 2017

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.

davidharrigan reacted with thumbs up emoji

*/
public boolean isJsonMime(String mime) {
return mime != null && mime.matches("(?i)application\\/json(;.*)?");
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
Copy link
Contributor

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?

Copy link
Contributor Author

@davidharrigan davidharrigan Mar 29, 2017

Choose a reason for hiding this comment

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

Yes, according to the grammar described here in RFC-7230. You can see that HTAB corresponds to horizontal tab here in RFC-5234.

Copy link
Contributor

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"));
Copy link
Contributor

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.

wing328 reacted with thumbs up emoji
Copy link
Contributor Author

@davidharrigan davidharrigan Mar 29, 2017

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.

Copy link
Contributor Author

Looks like the failed test is fixed here: #5243

Failed tests: testApiClient(io.swagger.client.api.PetApiTest): expected:<.../petstore.swagger.io[]/v2> but was:<.../petstore.swagger.io[:80]/v2>

Copy link
Contributor

ePaul commented Mar 29, 2017

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.

Copy link
Contributor Author

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);
Copy link
Contributor

@wing328 wing328 Mar 30, 2017
edited
Loading

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"));
Copy link
Contributor

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

@wing328 wing328 merged commit fc01457 into swagger-api:master Mar 30, 2017
Copy link
Contributor

wing328 commented Mar 30, 2017

@ePaul thanks for reviewing the change.

@davidharrigan thanks for the contribution, which has been merged into master.

@ePaul ePaul mentioned this pull request Apr 1, 2017
3 tasks
@davidharrigan davidharrigan deleted the FIX-5172 branch May 6, 2017 15:44
davidgri pushed a commit to davidgri/swagger-codegen that referenced this pull request May 11, 2017
)
* [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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

2 more reviewers

@ePaul ePaul ePaul left review comments

@wing328 wing328 wing328 left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

v2.2.3

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /