@typespec/openapi3
Version:
TypeSpec library for emitting OpenAPI 3.0 and OpenAPI 3.1 from the TypeSpec REST protocol binding and converting OpenAPI3 to TypeSpec
23 lines • 920 B
JavaScript
import { applyEncoding as baseApplyEncoding } from "./encoding.js";
import { isScalarExtendsBytes } from "./util.js";
function getEncodingFieldName(typespecType) {
// In Open API 3.1, `contentEncoding` is used for encoded binary data instead of `format`.
const typeIsBytes = isScalarExtendsBytes(typespecType.kind === "ModelProperty" ? typespecType.type : typespecType);
if (typeIsBytes) {
return "contentEncoding";
}
return "format";
}
export const applyEncoding = (program, typespecType, target, options) => {
return baseApplyEncoding(program, typespecType, target, getEncodingFieldName, options);
};
export const getRawBinarySchema = (contentType) => {
if (contentType) {
return { contentMediaType: contentType };
}
return {};
};
export const isRawBinarySchema = (schema) => {
return schema.type === undefined;
};
//# sourceMappingURL=openapi-helpers-3-1.js.map