JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
Bad links with engine mounted as root
Nessuno ha ancora preso questa issue.
- Lingua principale
- Ruby
- Stelle
- 2.3k
- Fork
- 546
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
This issue is a (choose one):
- Problem/bug report.
- Feature request.
- Request for support. Note: Please try to avoid submitting issues for support requests. Use Gitter instead.
Checklist before submitting:
- I've searched for an existing issue.
- I've asked my question on Gitter and have not received a satisfactory answer.
- I've included a complete bug report template. This step helps us and allows us to see the bug without trying to reproduce the problem from your description. It helps you because you will frequently detect if it's a problem specific to your project.
- The feature I'm asking for is compliant with the JSON:API spec.
Description
As described on lib/jsonapi/link_builder.rb#L139,
def resource_url(source)
"#{ base_url }#{ engine_mount_point }#{ resource_path(source) }"
end
But in this case:
constraints subdomain: 'api' do
mount MyEngine::Engine, at: '/' if defined?(MyEngine::Engine)
end
This creates a double / due to root value of engine_mount_point.
I guess a little update of:
@engine_mount_point = @engine ? @engine.routes.find_script_name({}) : ""
should be enough.
Current result:
{
"data": {
"id": "ed526d56-cc7e-41f4-8e99-fccf73fb7500",
"type": "users",
"links": {
"self": "//v1/users/ed526d56-cc7e-41f4-8e99-fccf73fb7500"
},
"attributes": {
"first_name": null,
"last_name": null,
"email": "some@thing.io"
}
}
}
//v1/users/ed526d56-cc7e-41f4-8e99-fccf73fb7500 should be /v1/users/ed526d56-cc7e-41f4-8e99-fccf73fb7500
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia in lib/jsonapi/link_builder.rb, in resource_url, quindi esamina come viene calcolato engine_mount_point per un'engine montata su '/'. Riproduci il caso segnalato di mount alla radice e verifica che il self link generato abbia una sola barra iniziale invece di '//v1/users/...'; il comportamento esistente di costruzione dei link deve rimanere corretto per i mount non alla radice.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- rails, ruby
- Ambito
- api, backend
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 45/100