Skip to content

Commit 6978cf0

Browse files
committed
Inline /files response definitions so Mintlify renders them correctly
1 parent 830a859 commit 6978cf0

2 files changed

Lines changed: 85 additions & 32 deletions

File tree

openapi-public.yml

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,15 +1787,37 @@ paths:
17871787
- $ref: '#/components/parameters/SignatureExpiration'
17881788
responses:
17891789
'200':
1790-
$ref: '#/components/responses/DownloadSuccess'
1790+
description: Entire file downloaded successfully.
1791+
content:
1792+
application/octet-stream:
1793+
schema:
1794+
type: string
1795+
format: binary
1796+
description: The file content
17911797
'401':
1792-
$ref: '#/components/responses/InvalidUser'
1798+
description: Invalid user
1799+
content:
1800+
application/json:
1801+
schema:
1802+
$ref: '#/components/schemas/Error'
17931803
'400':
1794-
$ref: '#/components/responses/InvalidPath'
1804+
description: Invalid path
1805+
content:
1806+
application/json:
1807+
schema:
1808+
$ref: '#/components/schemas/Error'
17951809
'404':
1796-
$ref: '#/components/responses/FileNotFound'
1810+
description: File not found
1811+
content:
1812+
application/json:
1813+
schema:
1814+
$ref: '#/components/schemas/Error'
17971815
'500':
1798-
$ref: '#/components/responses/InternalServerError'
1816+
description: Internal server error
1817+
content:
1818+
application/json:
1819+
schema:
1820+
$ref: '#/components/schemas/Error'
17991821
'502': *id003
18001822
operationId: downloadFile
18011823
post:
@@ -1814,15 +1836,37 @@ paths:
18141836
$ref: '#/components/requestBodies/File'
18151837
responses:
18161838
'200':
1817-
$ref: '#/components/responses/UploadSuccess'
1839+
description: The file was uploaded successfully.
1840+
content:
1841+
application/json:
1842+
schema:
1843+
type: array
1844+
items:
1845+
$ref: '#/components/schemas/EntryInfo'
18181846
'400':
1819-
$ref: '#/components/responses/InvalidPath'
1847+
description: Invalid path
1848+
content:
1849+
application/json:
1850+
schema:
1851+
$ref: '#/components/schemas/Error'
18201852
'401':
1821-
$ref: '#/components/responses/InvalidUser'
1853+
description: Invalid user
1854+
content:
1855+
application/json:
1856+
schema:
1857+
$ref: '#/components/schemas/Error'
18221858
'500':
1823-
$ref: '#/components/responses/InternalServerError'
1859+
description: Internal server error
1860+
content:
1861+
application/json:
1862+
schema:
1863+
$ref: '#/components/schemas/Error'
18241864
'507':
1825-
$ref: '#/components/responses/NotEnoughDiskSpace'
1865+
description: Not enough disk space
1866+
content:
1867+
application/json:
1868+
schema:
1869+
$ref: '#/components/schemas/Error'
18261870
'502': *id003
18271871
operationId: uploadFile
18281872
servers:

scripts/generate_openapi_reference.py

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
from __future__ import annotations
2727

28+
import copy
2829
import os
2930
import re
3031
import subprocess
@@ -886,29 +887,37 @@ def _singularize(word: str) -> str:
886887
health_get["tags"] = ["health"]
887888
fixes.append("/health: added 'health' tag")
888889

889-
# 15. /files responses: YAML anchor overlay hides actual response schemas
890-
# Remove the overlaid empty content block so $ref responses are used
891-
for files_ep in ("/files",):
892-
fpath = paths.get(files_ep, {})
893-
for method in ("get", "post"):
894-
op = fpath.get(method)
895-
if not op:
890+
# 15. /files responses: inline $ref responses so Mintlify renders them correctly
891+
# The upstream spec uses YAML anchors that cause issues, and some renderers
892+
# don't resolve response-level $refs properly.
893+
comp_responses = spec.get("components", {}).get("responses", {})
894+
files_path = paths.get("/files", {})
895+
for method in ("get", "post"):
896+
op = files_path.get(method)
897+
if not op:
898+
continue
899+
responses = op.get("responses", {})
900+
for status_code, resp in list(responses.items()):
901+
if not isinstance(resp, dict):
896902
continue
897-
responses = op.get("responses", {})
898-
for status_code, resp in responses.items():
899-
if not isinstance(resp, dict):
900-
continue
901-
# If the response has both $ref and content with an empty schema,
902-
# the empty content overlay was from the YAML anchor bug — remove it
903-
if "$ref" in resp and "content" in resp:
904-
content = resp["content"]
905-
for ct, media in list(content.items()):
906-
s = media.get("schema", {})
907-
if s.get("description") == "Empty response":
908-
del content[ct]
909-
if not content:
910-
del resp["content"]
911-
fixes.append(f"{files_ep} {method.upper()}: removed anchor-overlaid empty content")
903+
# Inline any $ref to components/responses
904+
ref = resp.get("$ref", "")
905+
if ref.startswith("#/components/responses/"):
906+
ref_name = ref.split("/")[-1]
907+
resolved = comp_responses.get(ref_name)
908+
if resolved:
909+
# Replace with a copy so we don't mutate the shared component
910+
responses[status_code] = copy.deepcopy(resolved)
911+
# Also clean up any anchor-overlaid empty content
912+
elif "$ref" not in resp and "content" in resp:
913+
content = resp["content"]
914+
for ct, media in list(content.items()):
915+
s = media.get("schema", {})
916+
if s.get("description") == "Empty response":
917+
del content[ct]
918+
if not content:
919+
del resp["content"]
920+
fixes.append("/files: inlined response definitions for GET and POST")
912921

913922
# 16. Missing type: object on schemas that have properties
914923
obj_fixed = 0

0 commit comments

Comments
 (0)