persona-community-5/.pnpm-store/v3/files/c8/579913138ebc21064e5551cfe0d3431754f71053624af552e6c34fef69a983f6a6401303e3b55b8b84a146129c669d94c047d687c8cda8280a0ac9f3fb1d6c
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

43 lines
1.5 KiB
Plaintext

import { escapePointer } from '@redocly/openapi-core/lib/ref-utils.js';
import ts from 'typescript';
import { tsModifiers, tsPropertyIndex, addJSDocComment, UNKNOWN } from '../lib/ts.mjs';
import { getEntries } from '../lib/utils.mjs';
import transformMediaTypeObject from './media-type-object.mjs';
import transformSchemaObject from './schema-object.mjs';
function transformHeaderObject(headerObject, options) {
if (headerObject.schema) {
return transformSchemaObject(headerObject.schema, options);
}
if (headerObject.content) {
const type = [];
for (const [contentType, mediaTypeObject] of getEntries(headerObject.content ?? {}, options.ctx)) {
const nextPath = `${options.path ?? "#"}/${escapePointer(contentType)}`;
const mediaType = "$ref" in mediaTypeObject ? transformSchemaObject(mediaTypeObject, {
...options,
path: nextPath
}) : transformMediaTypeObject(mediaTypeObject, {
...options,
path: nextPath
});
const property = ts.factory.createPropertySignature(
/* modifiers */
tsModifiers({ readonly: options.ctx.immutable }),
/* name */
tsPropertyIndex(contentType),
/* questionToken */
void 0,
/* type */
mediaType
);
addJSDocComment(mediaTypeObject, property);
type.push(property);
}
return ts.factory.createTypeLiteralNode(type);
}
return UNKNOWN;
}
export { transformHeaderObject as default };
//# sourceMappingURL=header-object.mjs.map