Skip to content

Commit 57dbff5

Browse files
committed
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]>
1 parent 6e6db26 commit 57dbff5

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
@@ -5994,7 +5994,7 @@ paths:
59945994
2.1.x and older in the `found_newest` return value).
59955995
schema:
59965996
$ref: "#/components/schemas/Anchor"
5997-
example: 43
5997+
example: "43"
59985998
- name: include_anchor
59995999
in: query
60006000
description: |
@@ -6863,7 +6863,7 @@ paths:
68636863
query, if any; otherwise, the most recent message.
68646864
schema:
68656865
$ref: "#/components/schemas/Anchor"
6866-
example: 43
6866+
example: "43"
68676867
required: true
68686868
- name: include_anchor
68696869
in: query
@@ -18147,13 +18147,7 @@ components:
1814718147
The event's type, relevant both for client-side dispatch and server-side
1814818148
filtering by event type in [POST /register](/api/register-queue).
1814918149
Anchor:
18150-
oneOf:
18151-
- type: string
18152-
enum:
18153-
- newest
18154-
- oldest
18155-
- first_unread
18156-
- type: integer
18150+
type: string
1815718151
Attachments:
1815818152
type: object
1815918153
description: |

0 commit comments

Comments
 (0)