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 https://github.com/python-openapi/openapi-core/issues/698.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-10-21 12:13:12 -07:00 committed by Anders Kaseorg
parent 0dd92d2116
commit 0514f92bdb
2 changed files with 8 additions and 10 deletions

View File

@ -486,7 +486,11 @@ def validate_request(
# against the OpenAPI documentation.
assert isinstance(data, dict)
mock_request = MockRequest(
"http://localhost:9991/", method, "/api/v1" + url, headers=http_headers, args=data
"http://localhost:9991/",
method,
"/api/v1" + url,
headers=http_headers,
args={k: str(v) for k, v in data.items()},
)
try:
openapi_spec.spec().validate_request(mock_request)

View File

@ -5994,7 +5994,7 @@ paths:
2.1.x and older in the `found_newest` return value).
schema:
$ref: "#/components/schemas/Anchor"
example: 43
example: "43"
- name: include_anchor
in: query
description: |
@ -6863,7 +6863,7 @@ paths:
query, if any; otherwise, the most recent message.
schema:
$ref: "#/components/schemas/Anchor"
example: 43
example: "43"
required: true
- name: include_anchor
in: query
@ -18147,13 +18147,7 @@ components:
The event's type, relevant both for client-side dispatch and server-side
filtering by event type in [POST /register](/api/register-queue).
Anchor:
oneOf:
- type: string
enum:
- newest
- oldest
- first_unread
- type: integer
type: string
Attachments:
type: object
description: |