self-href urls are not proper in rest api
See original GitHub issueI was trying to run spring-petclinic-rest in my local. I was able to run and build properly. But when I hit the URL http://localhost:9966/petclinic/ This shows me below response
{ "_links" : { "petTypes" : { "href" : "http://localhost:9966/petclinic/petTypes" }, "vets" : { "href" : "http://localhost:9966/petclinic/vets" }, "users" : { "href" : "http://localhost:9966/petclinic/users" }, "visits" : { "href" : "http://localhost:9966/petclinic/visits" }, "pets" : { "href" : "http://localhost:9966/petclinic/pets" }, "specialties" : { "href" : "http://localhost:9966/petclinic/specialties" }, "owners" : { "href" : "http://localhost:9966/petclinic/owners" }, "profile" : { "href" : "http://localhost:9966/petclinic/profile" } } }
Upon clicking vets link from above, I got below response -
{ "firstName" : "Helena", "lastName" : "Leary", "_links" : { "self" : { "href" : "http://localhost:9966/petclinic/vets/1" }, "vet" : { "href" : "http://localhost:9966/petclinic/vets/1" }, "specialties" : { "href" : "http://localhost:9966/petclinic/vets/1/specialties" } } }
But when I click on the self href url- it end up in being GET method not supported exception.
Actual URL for getting vets by id is http://localhost:9966/petclinic/api/vets/1
In code I could not find where it is configured or from where these links are coming. Can someone suggest how to add api in self href urls.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Spring Data Rest exports Spring Data repositories as REST resources with HAL. It may not uses the @RestController. Thus we have 2 API in a single war. If you set
spring.data.rest.basePath=/datarest
, at startup, you will see 2 endpoints for retrieving a pet by its ID:/api/pets/{petId}],methods=[GET]
{[/datarest/{repository}/{id}],methods=[GET]
For my point of view, the Spring Petclinic Rest application could have a branch or a fork with Spring Data Rest. And the
swagger-ui.html
should be the hompepage of the master branch.Yes. Agree. swagger-ui.html should be homepage. As of now it shows REST resources info on homepage at
http://localhost:9966/petclinic/
People can get confused seeing the REST URLs and try to retrieve resources using those.