Skip to content

Fix custom media type parser documentation #1475

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

kylehoehns
Copy link
Contributor

Noticed a slight error with the documentation while implementing my own custom media type for a project recently. Thanks!

@kylehoehns kylehoehns force-pushed the feature/media-types-documentation branch from 3a0d086 to 47181fe Compare February 19, 2021 01:49
Copy link
Contributor

@gregturn gregturn left a comment

Choose a reason for hiding this comment

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

Actually, if it's a single media type, then parseMediaType() is the one you want. parseMediaTypes is for handling a comma-separated list of media types.

@kylehoehns
Copy link
Contributor Author

Thanks for the feedback @gregturn. The HypermediaMappingInformation interface declares a List<MediaType> getMediaTypes() method that consumers have to implement. It looks like parseMediaType() only returns a single MediaType so we'd need to put it into a collection before returning.

Would you rather I change it to something like this?

return Collections.singletonList(MediaType.parseMediaType("application/vnd-acme-media-type"));

@kylehoehns kylehoehns requested a review from gregturn March 16, 2021 02:28
@gregturn gregturn changed the base branch from master to main April 7, 2021 18:20
@gregturn gregturn self-assigned this Jun 29, 2021
@gregturn gregturn added the in: documentation Reference documentation label Jun 29, 2021
@gregturn gregturn added this to the 1.4 M1 milestone Jun 29, 2021
gregturn pushed a commit that referenced this pull request Jun 29, 2021
Documentation for `HypermediaMappingInformation.getMediaTypes` expects to return a `List<MediaType>` which is not shown in the ref docs. Amend it with a proper parsing API as well as formatting.
@gregturn
Copy link
Contributor

Thanks @kylehoehns for bringing this up. We'll take it from here.

@gregturn
Copy link
Contributor

Resolved via ce36fee.

@gregturn gregturn closed this Jun 29, 2021
gregturn pushed a commit that referenced this pull request Jun 29, 2021
Documentation for `HypermediaMappingInformation.getMediaTypes` expects to return a `List<MediaType>` which is not shown in the ref docs. Amend it with a proper parsing API as well as formatting.

See: #1475.
@ingogriebsch
Copy link

@kylehoehns Would you mind to share with us which media-type you implement and if it will be available for the public? :)

@kylehoehns
Copy link
Contributor Author

@ingogriebsch I was implementing a custom media type for an internal application that just dealt with versioning. We ended up registering media types for v1 and v2 of our API and as a part of that I believe I needed to register those different version's media types so everything serialized/deserialized correctly. No fun public media types coming from me 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: documentation Reference documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants