Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
throw new Error(`Media Type Object ${context.jsonPointer} with 'content' must have a 'schema'`);
}
// Find the schema object for the mediaType.
const schema = resolveRef(context.openApiDoc, `${context.jsonPointer}/schema`);
// The encoding object describes how parameters should be parsed from the document.
for(const parameterName of Object.keys(mediaType.encoding)) {
const encoding: oas3.EncodingPropertyObject = mediaType.encoding[parameterName];
const parameterSchemaPath = findProperty([], schema, parameterName);
if(!parameterSchemaPath) {
throw new Error(`Cannot find parameter ${parameterName} in schema for ${context.jsonPointer}`);
}
const parameterSchema = extractSchema(context.openApiDoc, jsonPtr.encodePointer(parameterSchemaPath));
let parameterDescriptor: ParameterDescriptor;
if(encoding.contentType) {
const parser = context.options.parameterParsers.get(encoding.contentType);
if(!parser) {
throw new Error(`No string parser found for ${encoding.contentType} in ${context.jsonPointer}`);
}
parameterDescriptor = {
contentType: encoding.contentType,
parser,
uriEncoded: true,
schema: parameterSchema
};
} else {
parameterDescriptor = {
style: encoding.style || 'form',
function normalize(path: string) : string {
return jsonPtr.encodePointer(jsonPtr.decode(path));
}
private _createProcessingStackTrace(scope: ScopeBase) {
let trace = "";
let currentScope = scope;
while (currentScope && !(currentScope instanceof GlobalScope)) {
const pathEncoded = jsonPtr.encodePointer(currentScope.propertyPath);
let filePath = "";
if (currentScope instanceof MergeFileScope || currentScope instanceof RootMergeFileScope) {
filePath = currentScope.sourceFilePath;
}
trace += ` at ${filePath}#${pathEncoded}\n`;
currentScope = currentScope.parent;
}
return trace;
}
}