-
Notifications
You must be signed in to change notification settings - Fork 10
Regel voor gebruik RFC 9457 #251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API-Design-Rules/linter/spectral.yml
Line 159 in b6f040a
nlgov:use-problem-schema: |
Co-authored-by: Tim van der Lippe <[email protected]>
Besproken om de volgende velden als verplicht voor te stellen:
Optioneel zijn de velden
Er mogen geen andere velden gespecificeerd worden. De linter moet daarom geupdate worden dat het JSON object de verplichte velden bevat, en als er meer velden zijn enkel die optioneel zijn. Elk ander veld moet een error opleveren. |
Co-authored-by: Tim van der Lippe <[email protected]>
linter/spectral.yml
Outdated
|
||
nlgov:problem-schema-members: | ||
severity: warn | ||
message: "These fields are required: status, title and detail. Additionally, only type and instance are allowed." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Laten we nog testen of het toevoegen van {{value}}
ook laat zien dat bijvoorbeeld het veld "extra" niet toegestaan is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{{value}}
gaf [object Object]
.
{{error}}
geeft een mooie zin met de value erin, zoals Property "extra" is not expected to be here
.
Hiermee kwam ook aan het licht dat de test een niveau te hoog aan het kijken was voor de verwachte velden.
<dt>Statement</dt> | ||
<dd> | ||
<p>Error responses with HTTP status codes <code>4xx</code> or <code>5xx</code> MUST use either <code>application/problem+json</code> or <code>application/problem+xml</code> as the <code>Content-Type</code> header, and the response body MUST conform to the structure defined in [[rfc9457]].</p> | ||
<p>The following fields MUST be present: <code>status</code>, <code>title</code>, and <code>detail</code>. Additionally, only these fields MAY be present: <code>type</code> and <code>instance</code>.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Er moet ook ruimte zijn voor additionele details, bijv validatie-feedback van de request body waarbij je vaak per property een validatie-boodschap wil teruggeven. Dit zouden we ook kunnen standaardiseren of evt additionele properties toestaan.
<dl> | ||
<dt>Statement</dt> | ||
<dd> | ||
<p>Error responses with HTTP status codes <code>4xx</code> or <code>5xx</code> MUST use either <code>application/problem+json</code> or <code>application/problem+xml</code> as the <code>Content-Type</code> header, and the response body MUST conform to the structure defined in [[rfc9457]].</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hoe verhouden de media types zich tot content negotiation? Wat als ik Accept: application/json
heb meegestuurd in mijn request, maar een fout-response krijg? Wordt deze dan "overruled"? En wat als ik zowel JSON als XML problem responses ondersteun, wanneer krijg je welke? Etc etc...
De linter bevatte reeds een regel voor het verschaffen van "problem details". Hier wordt het ook als design rule toegevoegd.
fixes #188