Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 12 12:49

    odrotbohm on 2.0.1

    (compare)

  • Jan 12 12:49

    odrotbohm on 2.0.x

    #1897 - Release version 2.0.1. #1897 - Prepare next developmen… (compare)

  • Jan 12 12:45

    odrotbohm on release

    #1881 - Prepare next developmen… #1887 - Avoid trailing slash fo… #1888 - Upgrade to Spring Asci… and 10 more (compare)

  • Jan 12 11:48

    odrotbohm on 2.0.x

    #1897 - Update changelog. (compare)

  • Jan 12 11:22

    odrotbohm on 2.0.x

    #1888 - Upgrade to Spring Asci… #1889 - Upgrade to Logback 1.4.… #1890 - Upgrade to Jackson 2.14… and 6 more (compare)

  • Jan 12 08:05

    odrotbohm on 2.0.x

    #1887 - Avoid trailing slash fo… (compare)

  • Jan 12 08:03

    odrotbohm on main

    #1886 - Avoid trailing slash fo… (compare)

  • Jan 12 08:02

    odrotbohm on 2.0.x

    #1886 - Avoid trailing slash fo… (compare)

  • Jan 12 08:00

    odrotbohm on 2.0.x

    #1881 - Prepare next developmen… (compare)

  • Dec 30 2022 00:58
    Lance-Inman opened #41
  • Dec 08 2022 00:29

    odrotbohm on 1446-html

    Hacking. (compare)

  • Dec 04 2022 10:12
    reda-alaoui synchronize #1312
  • Nov 16 2022 19:36

    odrotbohm on 2.0.0

    (compare)

  • Nov 16 2022 19:36

    odrotbohm on main

    #1881 - Release version 2.0.0. #1881 - Prepare next developmen… (compare)

  • Nov 16 2022 19:28

    odrotbohm on release

    #1881 - Release version 2.0.0. (compare)

  • Nov 16 2022 19:26

    odrotbohm on main

    #1882 - Fix settings.xml to use… (compare)

  • Nov 16 2022 19:19

    odrotbohm on release

    #1881 - Release version 2.0.0. (compare)

  • Nov 16 2022 19:19

    odrotbohm on release

    (compare)

  • Nov 16 2022 19:17

    odrotbohm on main

    #1881 - Configure Maven Release… (compare)

  • Nov 16 2022 17:53

    odrotbohm on main

    #1881 - Fix flaky test. (compare)

Greg L. Turnquist
@gregturn
See my deck for "Building Flexible APIs with Spring HATEOAS" => https://twitter.com/gregturn/status/1301634849376268294
Okay, that's the Tweet with a link to the deck and the code.
Jiri Mikulasek
@jimirocks

Hello folks, I just wanted to use spring-hateos-jsonapi lib for my project, but found I can't, I raised the issue toedter/spring-hateoas-jsonapi#8 where @toedter pointed me to discuss the things here. Please could you take a look at my arguments and revisit the decision?

To sum up:

  • package private config can't be used in simple non-boot test like WebMvcTest
  • package private config makes the library unusable without spring-boot unless the user copy the config into it's own code

Since neither spring-hateos nor spring-hateoas-jsonapi declare they are spring-boot -only, I believe the configurations could be public.

Greg L. Turnquist
@gregturn
I responded to the ticket. @toedter, can we reopen the ticket to at least hammer out the discussion?
Ingo Griebsch
@ingogriebsch

I’m pleased to announce the release of Spring HATEOAS Siren 1.0.0-M2!
The library is accessible through Maven Central or one of it’s proxies.

Source: https://github.com/ingogriebsch/spring-hateoas-siren
Documentation: https://ingogriebsch.github.io/spring-hateoas-siren

Every feedback is very welcome! :)

Ingo Griebsch
@ingogriebsch
Hey @gregturn I would like to ask if there are any plans to allow to implement custom TraversonDefaults? I would like to be able to use Traverson with my custom hypermedia type Sirem! :)
Greg L. Turnquist
@gregturn
@ingogriebsch We should certainly patch Traverson to run with any registered hypermedia types. (Why ask users to do that?)
Ingo Griebsch
@ingogriebsch

We should certainly patch Traverson to run with any registered hypermedia types

Should I create an issue?

Why ask users to do that?

I don't understand the question!

Greg L. Turnquist
@gregturn
Yes, we should open an issue. Users shouldn't have to deal with that.
Ingo Griebsch
@ingogriebsch

Yes, we should open an issue

@gregturn Is this sufficient? Or do you have another summary/description in mind? spring-projects/spring-hateoas#1374

Greg L. Turnquist
@gregturn
Perfect. I have tweaked it to link it back to spring-projects/spring-hateoas#1224 and spring-projects/spring-hateoas#1223.
If anything, the library should provided consistent client-side support on all fronts.
Ingo Griebsch
@ingogriebsch
I agree!
Means you want to introduce a HypermediaTraversonConfigurer ?
Greg L. Turnquist
@gregturn

Presumably.

I need to look at Traverson and see if this is really suitable. We basically designed the WebClient and RestTemplate APIs configurers top down like that, and backed in the details. No user should be messing around with message converters and what not.

But we also have to maintain Traverson in a backward compatible way. So I'm hoping there isn't in our way.
Spring HATEOAS 2.0 would be the place we can make some major breaking changes, like forking off media type implementations into submodules.
Ingo Griebsch
@ingogriebsch
Chapter 6.3 to 6.5 of the reference documentation sounds like I do not need to do anything in addition to get my custom hypermedia type usable. Yet I have to prove through some samples.

But we also have to maintain Traverson in a backward compatible way.

Would it not be sufficient to remove the check that only one TraversonDefaults is available?

Greg L. Turnquist
@gregturn
I don't know.
Mateusz Kaczmarek
@cyberbob

Hello, I have a problem with the configuration of my project in which I use Kotlin+Coroutines. When I put @EnableHypermediaSupport(type = [EnableHypermediaSupport.HypermediaType.HAL_FORMS], stacks = [WebStack.WEBFLUX]) I started to get an exception:

java.lang.NoSuchMethodError: 'reactor.core.publisher.Mono reactor.core.publisher.Mono.contextWrite(java.util.function.Function)'
    at org.springframework.web.filter.reactive.ServerWebExchangeContextFilter.filter(ServerWebExchangeContextFilter.java:50) ~[spring-web-5.3.0-RC1.jar:5.3.0-RC1]
    at org.springframework.web.server.handler.DefaultWebFilterChain.invokeFilter(DefaultWebFilterChain.java:127) ~[spring-web-5.3.0-RC1.jar:5.3.0-RC1]
    at org.springframework.web.server.handler.DefaultWebFilterChain.lambda$filter$0(DefaultWebFilterChain.java:121) ~[spring-web-5.3.0-RC1.jar:5.3.0-RC1]
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:44) ~[reactor-core-3.3.10.RELEASE.jar:3.3.10.RELEASE]
    ...

What I'm doing wrong ?

Greg L. Turnquist
@gregturn
You must have mismatched versions in your build file. Are you using Spring Boot to manage all dependencies?
Mateusz Kaczmarek
@cyberbob
Think so, I'm using gradle, but with Spring Boot BOM:
dependencies {
    implementation platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}")

    implementation("org.springframework.boot:spring-boot-starter-webflux")
    implementation("org.springframework.boot:spring-boot-starter-actuator")
    implementation("org.springframework.boot:spring-boot-starter-hateoas") {
        exclude(group: "org.springframework.boot", module: "spring-boot-starter-web")
    }
    constraints {
        implementation("org.springframework.hateoas:spring-hateoas:1.2.0-RC1")
    }
Mateusz Kaczmarek
@cyberbob
aaaaa now I see that hateoas forced a higher version of basic Spring's modules. I will try to force a stable version that comes from the BOM. BTW. is using annotation correct ? In most of the sample repositories it is not used. But it is probably because I do not use Spring Data Rest ?
Greg L. Turnquist
@gregturn
Spring Boot's autoconfiguration automatically applies @EnableHypermediaSupport (with HAL).
Knut Schleßelmann
@kschlesselmann
How do you test HAL responses using Spring HATEOAS? The HalResponseModel (which could take the _embedded) is not public and all other representation classes simply do not use all HAL properties. What am I supposed to do with my WebTestClient if I want to check for all links, embeds, … in my response?
Ingo Griebsch
@ingogriebsch
@kschlesselmann I simply put a json file that contains the expected result on the classpath, read that file and compare the content of the file with the response generated through the test. :)
43 replies
Knut Schleßelmann
@kschlesselmann
@gregturn Since we're already in the flow – we're using the reactive API of Spring HATEOAS. Is there something like ResourceAssemblerSupport planned for the reactive stack as well? Right now we try to stick to the passtern and simply create our own @Components for such purposes.
Greg L. Turnquist
@gregturn
ReactiveRepresentationModelAssembler and SimpleReactiveRepresentationModelAssembler are the two we have for WebFlux.
8 replies
So...nothing directly tied to a WebFlux controller class. But I think they get you a lot of the way.
Greg L. Turnquist
@gregturn
This is among our test cases...
    class ResourceAssemblerWithCustomLinkSimple implements SimpleReactiveRepresentationModelAssembler<Employee> {

        @Override
        public EntityModel<Employee> addLinks(EntityModel<Employee> resource,
                ServerWebExchange exchange) {
            return resource.add(Link.of("/employees").withRel("employees"));
        }

        @Override
        public CollectionModel<EntityModel<Employee>> addLinks(
                CollectionModel<EntityModel<Employee>> resources, ServerWebExchange exchange) {
            return resources.add(Link.of("/").withRel("root"));
        }
    }
Knut Schleßelmann
@kschlesselmann

@gregturn Yeah … right now we do something along

    val model = mock<DraftResponseModel>()
    fun links(): Mono<List<Link>> = TODO()
    fun previewForSomething(): Mono<Tuple2<Link, DraftResponseModel>> = TODO()

    model.toMono()
            .zipWith(links()) { model, links ->
                HalModelBuilder.halModelOf(model)
                        .links(links)
            }
            .zipWith(previewForSomething()) { builder, (link, preview) -> 
                builder.preview(preview)
                        .forLink(link)
            }
            .map { it.build() }

what do you think?

Greg L. Turnquist
@gregturn
Nice! (My Kotlin is a bit rusty.)
Greg L. Turnquist
@gregturn
Heads up, I updated Spring HATEOAS Examples to use Spring Boot 2.3.4.RELEASE. Replaced some of the deprecated APIs with new stuff. Enjoy!
Ingo Griebsch
@ingogriebsch
I created a repository that contains examples for Spring HATEOAS Siren to showcase how to use the features provided by the library.
https://github.com/ingogriebsch/spring-hateoas-siren-samples
Some examples are already available, more will follow soon.
Every feedback is very welcome! 🙂
Kai Toedter
@toedter
If a HATEOAS user wants to add things to the ObjectMapper used for a specific MediaType configuration, what would be the best practice for doing that? For instance, adding thinks like
mapper.registerModule(new JavaTimeModule());
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
Kai Toedter
@toedter

One way wuld be something like

    @Configuration
    @WebAppConfiguration
    @EnableWebMvc
    @EnableHypermediaSupport(type = HAL)
    static class TestConfig {
        @Bean
        JsonApiMediaTypeConfiguration jsonApiMediaTypeConfiguration(ObjectProvider<JsonApiConfiguration> configuration,
                                                                    AutowireCapableBeanFactory beanFactory) {
            return new JsonApiMediaTypeConfiguration(configuration, beanFactory) {
                @Override
                ObjectMapper configureObjectMapper(ObjectMapper mapper, JsonApiConfiguration configuration) {
                    ObjectMapper objectMapper = super.configureObjectMapper(mapper, configuration);

                    objectMapper.registerModule(new JavaTimeModule());
                    objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
                    return objectMapper;
                }
            };
        }
    }

But may there there is a better/easier way.

Greg L. Turnquist
@gregturn
@toedter I think we honor Spring Boot's contracts for applying changes to ALL ObjectMappers. Don't think there's really an API to get apply customizations for a single one based on media type.
The thing we DO have is HalConfig and HalFormsConfig, which provides some user-facing APIs to apply tweaks deep inside the relevant serializers.
But nothing as direct as ObjectMapper settings.
If we were to add a hook, I'd imagine it being there.
To me, a ObjectMapperCustomizer sort of lambda function added to HalConfig would be the simplest way. But I'd also question granting users that much access to the internals.
Kai Toedter
@toedter
Thx Greg, I think that many users want to use additional Jackson modules, like the JavaTimeModule. I would prefer the possibility that a user could add some configuration, like how to serialize LocalDateTime or Instant on a Spring HATEOAS level, and then apply this to all media types.
Greg L. Turnquist
@gregturn

Something like...

public interface ObjectMapperCustomizer extends Consumer<ObjectMapper> {
}

You provide new HalConfig().customizeObjectMapper(objectMapper -> { /* insert customizations here */}), and the serializer, after getting/creating the ObjectMapper, could then invoke halConfig.objectMapperCustomizer.accept(theObjectMapper).

Yeah?

I could see this applied to the others as well.

I've opened spring-projects/spring-hateoas#1382 to track this discussion.
Greg L. Turnquist
@gregturn
Greg L. Turnquist
@gregturn
Woot!