Code Monkey home page Code Monkey logo

Comments (2)

serpro69 avatar serpro69 commented on May 22, 2024 1

I found a "kind of working thing". If I set the header of the rest template request to prs.hal-forms+json via headers.add("Accept", MediaTypes.HAL_FORMS_JSON_VALUE);, then it works so long as I don't explicitly set what the endpoint produces.

If I set produces in the GetMapping to hal+json like so: @GetMapping(produces = MediaTypes.HAL_JSON_VALUE), and update the Accept header to also accept hal+json: headers.add("Accept", MediaTypes.HAL_JSON_VALUE);, then the mapping from the response breaks and I get empty content.

from spring-data-commons.

serpro69 avatar serpro69 commented on May 22, 2024

I've updated my comment above. It still looks a bit weird to me and feels like something is broken here (probably my code :D but who knows)
Would really appreciate some help on this.

It does make sense in a way that setting Accept to hal-forms actually produces

{
  "links": [...],
  "content": [...]
}

which has exactly same structure as CollectionModel, so no wonder object mapper is able to handle it automatically

The question is there an automatic way to process CollectionModel as hal+json ? Or do I need to write my own object mapper logic?
Because the controller returns CollectionModel and produces hal+json by default unless explicitly changed via @GetMapper(produces = ...).
But consuming it via ParameterizedTypeReference<CollectionModel<EntityModel<>>> doesn't seem to work in the same way.

from spring-data-commons.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.