Skip to content

Commit cf034cf

Browse files
andersktimabbott
authored andcommitted
openapi: Loosen anchor parameter specification to string.
Real requests would not validate against the previous version. There seems to be no consistent way to determine whether a string parameter should be coerced to an integer for validation against an allOf schema (which works at the level of JSON objects, not strings). See also python-openapi/openapi-core#698. Signed-off-by: Anders Kaseorg <[email protected]> (cherry picked from commit 0514f92)
1 parent 9fd5e9a commit cf034cf

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

zerver/openapi/openapi.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,11 @@ def validate_request(
486486
# against the OpenAPI documentation.
487487
assert isinstance(data, dict)
488488
mock_request = MockRequest(
489-
"http://localhost:9991/", method, "/api/v1" + url, headers=http_headers, args=data
489+
"http://localhost:9991/",
490+
method,
491+
"/api/v1" + url,
492+
headers=http_headers,
493+
args={k: str(v) for k, v in data.items()},
490494
)
491495
try:
492496
openapi_spec.spec().validate_request(mock_request)

zerver/openapi/zulip.yaml

+3-9
Original file line numberDiff line numberDiff line change
@@ -5989,7 +5989,7 @@ paths:
59895989
2.1.x and older in the `found_newest` return value).
59905990
schema:
59915991
$ref: "#/components/schemas/Anchor"
5992-
example: 43
5992+
example: "43"
59935993
- name: include_anchor
59945994
in: query
59955995
description: |
@@ -6858,7 +6858,7 @@ paths:
68586858
query, if any; otherwise, the most recent message.
68596859
schema:
68606860
$ref: "#/components/schemas/Anchor"
6861-
example: 43
6861+
example: "43"
68626862
required: true
68636863
- name: include_anchor
68646864
in: query
@@ -18137,13 +18137,7 @@ components:
1813718137
The event's type, relevant both for client-side dispatch and server-side
1813818138
filtering by event type in [POST /register](/api/register-queue).
1813918139
Anchor:
18140-
oneOf:
18141-
- type: string
18142-
enum:
18143-
- newest
18144-
- oldest
18145-
- first_unread
18146-
- type: integer
18140+
type: string
1814718141
Attachments:
1814818142
type: object
1814918143
description: |

0 commit comments

Comments
 (0)