multipart

This commit is contained in:
seb
2026-09-18 07:19:20 +02:00
parent 8c19388901
commit c2147de284
9 changed files with 224 additions and 47 deletions

View File

@@ -153,7 +153,6 @@ function renderRequestBody(requestBody) {
lines.push('');
lines.push(formatSchema(jsonSchema, spec.components));
lines.push('');
return lines;
}
// multipart/form-data — render fields as a table when properties are present
@@ -166,29 +165,30 @@ function renderRequestBody(requestBody) {
lines.push('| Field | Required | Type | Description |');
lines.push('|-------|----------|------|-------------|');
for (const [name, prop] of Object.entries(schema.properties)) {
const type = prop.format === 'binary' ? 'file' : (prop.type || '');
const type = prop.format === 'binary' || prop.items?.format === 'binary' ? 'file' : (prop.type || '');
lines.push(`| \`${name}\` | ${required.has(name) ? 'yes' : 'no'} | ${type} | ${prop.description || ''} |`);
}
lines.push('');
return lines;
}
lines.push('## Body');
lines.push('');
for (const type of types) {
const schema = requestBody.content[type]?.schema;
if (schema?.format === 'binary') {
lines.push(`Raw binary (\`${type}\`).`);
} else {
lines.push(`\`${type}\``);
if (schema) {
lines.push('');
lines.push(formatSchema(schema, spec.components));
}
}
if (!jsonSchema && !multipart?.schema?.properties) {
lines.push('## Body');
lines.push('');
for (const type of types) {
const schema = requestBody.content[type]?.schema;
if (schema?.format === 'binary') {
lines.push(`Raw binary (\`${type}\`).`);
} else {
lines.push(`\`${type}\``);
if (schema) {
lines.push('');
lines.push(formatSchema(schema, spec.components));
}
}
lines.push('');
}
}
return lines;
return lines.length ? lines : null;
}
function docsFileFor(apiPath, method) {