Skip to content
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

Error in this example: Hypermedia Root Controller #37

Open
ccit-spence opened this issue Dec 18, 2020 · 2 comments
Open

Error in this example: Hypermedia Root Controller #37

ccit-spence opened this issue Dec 18, 2020 · 2 comments

Comments

@ccit-spence
Copy link

In this example I can't get this to work without an error RepresentationModel Needs a T.

RepresentationModel model = new RepresentationModel();

What is the right way to do this without a T in the context of a Root Controller?

/**
 * @author Greg Turnquist
 */
@RestController
class RootController {

	@GetMapping("/")
	ResponseEntity<RepresentationModel> root() {

		RepresentationModel model = new RepresentationModel();

		model.add(linkTo(methodOn(RootController.class).root()).withSelfRel());
		model.add(linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"));
		model.add(linkTo(methodOn(EmployeeController.class).findAllDetailedEmployees()).withRel("detailedEmployees"));
		model.add(linkTo(methodOn(ManagerController.class).findAll()).withRel("managers"));

		return ResponseEntity.ok(model);
	}
}
@gregturn
Copy link
Contributor

gregturn commented Dec 18, 2020

I only get a warning about using a raw parameterized type. In fact, I ran api-evolution/original-server and was able to ping the server...

{
  "_links": {
    "self": {
      "href": "http://localhost:9000/"
    },
    "employees": {
      "href": "http://localhost:9000/employees"
    }
  }
}

@ccit-spence
Copy link
Author

Sorry, should have been more specific about the error. I was talking about the warning about the raw parameterized type.

Since RepresentationModel. only exist with parameterized types. Wanted to know how we should be calling it when we don't have a type, such as creating a Root Controller. EntityModel has somewhat the same issue. If you are trying to do something with generics. Multiple DTOs for the same class as an example.

Getting the warning feels like I am doing something wrong. I don't see how to get around it.

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

No branches or pull requests

2 participants