mirror of
https://github.com/Sea-Haven-Industries/meal-order-manager.git
synced 2026-10-07 15:08:55 +00:00
fix(api): fail Redocly on missing 4xx and 2xx/3xx (DEV-289)
Promote operation-4xx-response and the 2xx-or-3xx success rule to error. Replace unused health and roster 400s with 403, matching portal health. Form-status keeps its real 400 for invalid week. Co-authored-by: Adam Moussa <amoussa1229@users.noreply.github.com>
This commit is contained in:
parent
49cbd585eb
commit
a51251b000
3 changed files with 17 additions and 4 deletions
|
|
@ -1,15 +1,18 @@
|
||||||
# Same Redocly recommended ruleset as internal-portal (DEV-223 / DEV-289).
|
# Same Redocly recommended ruleset as internal-portal (DEV-223 / DEV-289).
|
||||||
# Login-style redirects succeed with 302. Recommended only counts 2XX.
|
# Recommended operation-2xx-response does not count 302. Login-style redirects
|
||||||
|
# succeed with 302, so that rule is replaced by operation-2xx-or-3xx-response
|
||||||
|
# at error. operation-4xx-response is promoted to error so missing 4xx fails CI.
|
||||||
extends:
|
extends:
|
||||||
- recommended
|
- recommended
|
||||||
|
|
||||||
rules:
|
rules:
|
||||||
operation-2xx-response: off
|
operation-2xx-response: off
|
||||||
|
operation-4xx-response: error
|
||||||
rule/operation-2xx-or-3xx-response:
|
rule/operation-2xx-or-3xx-response:
|
||||||
subject:
|
subject:
|
||||||
type: Responses
|
type: Responses
|
||||||
message: Operation must define a 2XX or 3XX response.
|
message: Operation must define a 2XX or 3XX response.
|
||||||
severity: warn
|
severity: error
|
||||||
assertions:
|
assertions:
|
||||||
requireAny:
|
requireAny:
|
||||||
- "200"
|
- "200"
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ paths:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/Health"
|
$ref: "#/components/schemas/Health"
|
||||||
"400":
|
"403":
|
||||||
$ref: "#/components/responses/StringError"
|
$ref: "#/components/responses/StringError"
|
||||||
|
|
||||||
/api/menu/{week}:
|
/api/menu/{week}:
|
||||||
|
|
@ -264,7 +264,7 @@ paths:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FormRoster"
|
$ref: "#/components/schemas/FormRoster"
|
||||||
"400":
|
"403":
|
||||||
$ref: "#/components/responses/StringError"
|
$ref: "#/components/responses/StringError"
|
||||||
|
|
||||||
/api/publish/settings:
|
/api/publish/settings:
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,17 @@ def test_openapi_uses_redocly_recommended():
|
||||||
assert "extends:" in redocly
|
assert "extends:" in redocly
|
||||||
assert "- recommended" in redocly
|
assert "- recommended" in redocly
|
||||||
assert "operation-2xx-response: off" in redocly
|
assert "operation-2xx-response: off" in redocly
|
||||||
|
assert "operation-4xx-response: error" in redocly
|
||||||
assert "rule/operation-2xx-or-3xx-response" in redocly
|
assert "rule/operation-2xx-or-3xx-response" in redocly
|
||||||
|
assert "severity: error" in redocly
|
||||||
|
health = spec.split("/api/health:", 1)[1].split("\n /", 1)[0]
|
||||||
|
assert '"403":' in health
|
||||||
|
assert '"400":' not in health
|
||||||
|
roster = spec.split("/api/roster:", 1)[1].split("\n /", 1)[0]
|
||||||
|
assert '"403":' in roster
|
||||||
|
assert '"400":' not in roster
|
||||||
|
form_status = spec.split("/api/form-status/{week}:", 1)[1].split("\n /", 1)[0]
|
||||||
|
assert '"400":' in form_status
|
||||||
assert "root: openapi.yaml" in redocly
|
assert "root: openapi.yaml" in redocly
|
||||||
assert '"openapi:lint"' in package
|
assert '"openapi:lint"' in package
|
||||||
assert '"@redocly/cli": "2.52.1"' in package
|
assert '"@redocly/cli": "2.52.1"' in package
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue