JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
Aliased Attribute Names Are Not Used In Error Responses
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Ruby
- Sterne
- 2.3k
- Forks
- 546
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
This issue is a (choose one):
- [X ] Problem/bug report.
- Feature request.
- Request for support. Note: Please try to avoid submitting issues for support requests. Use Gitter instead.
Checklist before submitting:
- [ X] 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.
- [ X] The feature I'm asking for is compliant with the JSON:API spec.
Description
I have a model with an attribute named status_is_active. In the API we want this to render as active so do the following in the resource:
attribute :active, delegate: :status_is_active
If there is an API error related to this attribute, the error reports the name from the model rather than the name from the resource. For example:
{
"errors": [
{
"title": "is not included in the list",
"detail": "status_is_active - is not included in the list",
"code": "100",
"source": {
"pointer": "/data/attributes/status_is_active"
},
"status": "422"
}
]
}
Expected: the error uses the name of the attribute in the resource rather than the name used in the model. For example:
{
"errors": [
{
"title": "is not included in the list",
"detail": "active - is not included in the list",
"code": "100",
"source": {
"pointer": "/data/attributes/active"
},
"status": "422"
}
]
}
Rationale: users of the API only know about what's in the API - returning a value from the model that is aliased in the API is confusing/wrong.
Thanks!
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
Es werden keine Implementierungsdateien oder Tests genannt. Stelle den delegierten Fall attribute :active, delegate: :status_is_active nach und verfolge, wie Validierungsfehler serialisiert werden; fertig ist die Aufgabe, wenn sowohl das Fehlerdetail als auch der JSON:API-Quellzeiger active anstelle von status_is_active verwenden.
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
- 38/100