Skip to content

Commit

Permalink
require requestBody in all mutators (#153)
Browse files Browse the repository at this point in the history
* require requestBody in all mutators

I also did some light refactoring to reuse the 201 created headers and in the process added ETag to that response

* add ignore for redocly linter
  • Loading branch information
catkins-miso authored Aug 30, 2024
1 parent bfb278e commit 4bf73cd
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 39 deletions.
11 changes: 11 additions & 0 deletions .redocly.lint-ignore.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file instructs Redocly's linter to ignore the rules contained for specific parts of your API.
# See https://redoc.ly/docs/cli/ for more information.
docs/openapi.yaml:
no-unused-components:
# the created response's headers are used but
# since the bodies are not empty, the entire
# response is not used anywhere. However, for consistency
# and to keep the individual responses DRY, we want
# to keep the 201 in the root openapi file, so we
# disable the unused component rule for this response
- '#/components/responses/201'
13 changes: 12 additions & 1 deletion .spectral.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,15 @@ rules:
- field: "422"
function: truthy
- field: "422.content.application/problem+json"
function: truthy
function: truthy
overrides:
- files:
# the created response's headers are used but
# since the bodies are not empty, the entire
# response is not used anywhere. However, for consistency
# and to keep the individual responses DRY, we want
# to keep the 201 in the root openapi file, so we
# disable the unused component rule for this response
- "docs/openapi.yaml#/components/responses/201"
rules:
oas3-unused-component: "off"
21 changes: 0 additions & 21 deletions docs/_data/components/responses/read-head.yaml

This file was deleted.

8 changes: 7 additions & 1 deletion docs/_data/openapi-split.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,16 @@ components:
$ref: '#/components/headers/X-Rate-Limit-Reset'
'204':
description: Operation successful. No Content.
headers:
headers: &accepted-headers
<<: *rate-limited-headers
ETag:
$ref: "#/components/headers/ETag"
'201':
description: Created.
headers:
<<: *accepted-headers
Location:
$ref: "#/components/headers/Location"

# responses allowing content
'400-problem':
Expand Down
1 change: 1 addition & 0 deletions docs/_data/paths/rating-proposals_forecasts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ patch:
that is advantageous from a performance or reliable delivery perspective.
requestBody:
required: true
content:
application/vnd.trolie.rating-forecast-proposal.v1+json:
schema:
Expand Down
1 change: 1 addition & 0 deletions docs/_data/paths/rating-proposals_realtime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ post:
tags: *tags

requestBody:
required: true
content:
application/vnd.trolie.rating-realtime-proposal.v1+json:
schema:
Expand Down
10 changes: 2 additions & 8 deletions docs/_data/paths/seasonal-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ post:
summary: *post_desc
tags: *tags
requestBody:
required: true
content:
application/vnd.trolie.seasonal-override.v1+json:
schema:
Expand All @@ -74,14 +75,7 @@ post:
example:
$ref: ../../example-narratives/examples/seasonal-override-get.json
headers:
X-Rate-Limit-Limit:
$ref: '../openapi-split.yaml#/components/headers/X-Rate-Limit-Limit'
X-Rate-Limit-Remaining:
$ref: '../openapi-split.yaml#/components/headers/X-Rate-Limit-Remaining'
X-Rate-Limit-Reset:
$ref: '../openapi-split.yaml#/components/headers/X-Rate-Limit-Reset'
Location:
$ref: '../openapi-split.yaml#/components/headers/Location'
$ref: '../openapi-split.yaml#/components/responses/201/headers'

'400': *malformed
'401': *unauthorized-empty
Expand Down
1 change: 1 addition & 0 deletions docs/_data/paths/seasonal-overrides_{id}.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ put:
parameters:
- $ref: ../components/parameters/id.yaml
requestBody:
required: true
content:
application/vnd.trolie.seasonal-override.v1+json:
schema:
Expand Down
11 changes: 3 additions & 8 deletions docs/_data/paths/temporary-aar-exceptions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ post:
summary: *post_desc
tags: *tags
requestBody:
required: true
content:
application/vnd.trolie.temporary-aar-exception.v1+json:
schema:
Expand All @@ -72,14 +73,8 @@ post:
example:
$ref: ../../example-narratives/examples/temporary-aar-exception-get.json
headers:
X-Rate-Limit-Limit:
$ref: '../openapi-split.yaml#/components/headers/X-Rate-Limit-Limit'
X-Rate-Limit-Remaining:
$ref: '../openapi-split.yaml#/components/headers/X-Rate-Limit-Remaining'
X-Rate-Limit-Reset:
$ref: '../openapi-split.yaml#/components/headers/X-Rate-Limit-Reset'
Location:
$ref: '../openapi-split.yaml#/components/headers/Location'
$ref: '../openapi-split.yaml#/components/responses/201/headers'

'400': *malformed
'401': *unauthorized-empty
'403': *forbidden-empty
Expand Down
1 change: 1 addition & 0 deletions docs/_data/paths/temporary-aar-exceptions_{id}.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ put:
parameters:
- $ref: ../components/parameters/id.yaml
requestBody:
required: true
content:
application/vnd.trolie.temporary-aar-exception.v1+json:
schema:
Expand Down

0 comments on commit 4bf73cd

Please sign in to comment.