ScaCap / spring-auto-restdocs

Spring Auto REST Docs is an extension to Spring REST Docs
https://scacap.github.io/spring-auto-restdocs/
Apache License 2.0
310 stars 86 forks source link

#424: added "hal+json" as compatible content type for ArrayLimitingJsonContentModifier #425

Closed mustaphazorgati closed 3 years ago

mustaphazorgati commented 3 years ago

Since I didn't find any existing test class I didn't bother writing a test..

mustaphazorgati commented 3 years ago

I just did some research about media types and their compatibility. According to RFC6839:

The suffix "+json" MAY be used with any media type whose representation follows that established for "application/json"

Your incentive that a spring utility must provide it made me stumple across this issue. According to that issue some other RFCs (not listed) define that "application/hal+json" is not compatible with "application/json". Even tho they share the same syntax (stated in RFC6839). I suggest changing the predicate to the recommended one within that issue.

How does that sound?

jmisur commented 3 years ago

Thanks for digging into this. That suggestion on the linked issue sounds like it will solve it.

mustaphazorgati commented 3 years ago

@jmisur PR is ready for review :)

jmisur commented 3 years ago

Please check the Travis log - ResponseModifyingPreprocessorsTest failed.

mustaphazorgati commented 3 years ago

My bad. I didn't read properly earlier today. In order to support any +json structured Syntax Suffix (which is something else using the json syntax) we have to test two compatiblities: Without any suffix application/json and with any suffix application/*+json. The referenced issue said that according to the RFCs application/*+json is compatible to application/hal+json.

mustaphazorgati commented 3 years ago

I added some tests to explicitly show the new compatibility for both cases. I hope this is fine with you.