JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
URL host name is not generated properly in self link with serializer
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 2.3k
- Forks
- 546
- PR merge metrics
- No merged PRs in 30d
Description
I sometime use the serializer to render the reply from some API request like below.
In controller
result = Hoge.find(1)
resource = Object.const_get('HogeResource')
serializer = JSONAPI::ResourceSerializer.new('HogeResource')
body = serializer.serialize_to_hash(resource.new(result, nil))
render json: body, status: 20
and the result is
http://localhost:3000/hoges/1
{
"data": {
"id": "1",
"type": "hoges",
"links": {
"self": "/hoges/1"
},
"attributes": {
self should have the hostname like http://localhost:3000/amc/hoges/1
Any idea how to fix this?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the controller example with JSONAPI::ResourceSerializer and inspect how it builds the resource's self link. Verify the serialized link includes the request hostname and the /amc path, then add or update coverage for the expected absolute URL.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100