JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
Incorrect `links` URL
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Ruby
- Sterne
- 2.3k
- Forks
- 546
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
We need to omit the api out of the links URLs (eg: http://localhost:3001/api/v3/people). Our valid URL should look like this: http://localhost:3001/v3/people.
Here's a sample of how our routes.rb file is built:
Our routes.rb:
Rails.application.routes.draw do
scope module: :api do
namespace :v3 do
jsonapi_resources :people
jsonapi_resources :providers
end
end
end
According to the rake routes task on our person model:
v3_people GET /v3/people(.:format) api/v3/people#index
POST /v3/people(.:format) api/v3/people#create
v3_person GET /v3/people/:id(.:format) api/v3/people#show
PATCH /v3/people/:id(.:format) api/v3/people#update
PUT /v3/people/:id(.:format) api/v3/people#update
DELETE /v3/people/:id(.:format) api/v3/people#destroy
But the response output looks like this:
{
"data": {
"id": "1",
"type": "people",
"links": {
"self": "http://localhost:3001/api/v3/people/1"
},
"attributes": {
"full-name": "Chad Taylor",
"first-name": "Chad",
"last-name": "Taylor",
"uuid": "dab4e5e6-ba50-42b4-9633-50a952d2e811"
},
"relationships": {
"providers": {
"links": {
"self": "http://localhost:3001/api/v3/people/1/relationships/providers",
"related": "http://localhost:3001/api/v3/people/1/providers"
}
}
}
}
}
If we can get the /api omitted from the links, all will be golden.
Thanks in advance.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem routes.rb-Beispiel und der Generierung der Ressourcenlinks für das person-Modell. Reproduziere die Antwort, die /api/v3-URLs zeigt, und verfolge, wie diese Links relativ zu den /v3-Routen zusammengesetzt werden. Als erledigt gilt, wenn Ressourcen- und Beziehungslinks das Präfix /api weglassen und weiterhin auf die deklarierten Routen aufgelöst werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- rails, ruby
- Bereich
- api, backend
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100