-
Notifications
You must be signed in to change notification settings - Fork 15
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
Make JsonApiModel public #59
Conversation
I had lots of discussion with the HATEOAS team about that and the recommendation was to not expose concrete representation models for custom media types as public API. I will discuss this again and let you know about the outcome. |
Codecov Report
@@ Coverage Diff @@
## master #59 +/- ##
=========================================
Coverage 93.81% 93.81%
Complexity 377 377
=========================================
Files 31 31
Lines 1100 1100
Branches 196 196
=========================================
Hits 1032 1032
Misses 22 22
Partials 46 46
Continue to review full report at Codecov.
|
After considering your suggestion I decided to leave the visibility of JsonApiModel as it is right now. The main reasons are not not expose the implementation details as public API and to go only with the Spring HATEOAS public API when it comes to representation models, which is the recommended behavior for custom Spring HATEOAS media types. I would suggest that you implement your very own If I find the time, I will try to provide an example in https://github.com/toedter/spring-hateoas-jsonapi-examples |
@toedter My colleague may wasn't specific enough - below is the example of trying to implement import com.toedter.spring.hateoas.jsonapi.JsonApiModelBuilder;
import org.springframework.hateoas.CollectionModel;
import org.springframework.hateoas.RepresentationModel;
import org.springframework.hateoas.server.reactive.ReactiveRepresentationModelAssembler;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
public class JavaAssembler extends ReactiveRepresentationModelAssembler<MyStupidDto, RepresentationModel<?>> {
@Override
public Mono<RepresentationModel<?>> toModel(final MyStupidDto entity, final ServerWebExchange exchange) {
return Mono.just(JsonApiModelBuilder.jsonApiModel().model(entity).build());
}
@Override
public Mono<CollectionModel<RepresentationModel<?>>> toCollectionModel(final Flux<? extends MyStupidDto> entities, final ServerWebExchange exchange) {
throw new UnsupportedOperationException("not implemented");
}
} |
Just fyi, I filed an issue at Spring HATEOAS: |
Hey there. We were using
JsonApiModel
in our company to implementRepresentationModelAssembler
which takes as a generics object we want to represent as a model and representation model as aD extends RepresentationModel<?>
. Now we are rewriting the module into reactive web flux so we implementingReactiveRepresentationModelAssembler
where the model is represented byD extends RepresentationModel<D>
. This specifiedD
inRepresentationModel<D>
forces us to use some representation model instead of?
, so we wanted to useJsonApiModel
, but it is package-private. Is there any possibility that this model will be changed topublic
?