How to use the json-ptr.encodePointer function in json-ptr

To help you get started, we’ve selected a few json-ptr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github exegesis-js / exegesis / src / oas3 / urlEncodedBodyParser.ts View on Github external
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',
github exegesis-js / exegesis / src / utils / jsonPaths.ts View on Github external
function normalize(path: string) : string {
    return jsonPtr.encodePointer(jsonPtr.decode(path));
}
github boschni / json-merger / src / MergerError.ts View on Github external
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;
    }
}

json-ptr

A complete implementation of JSON Pointer (RFC 6901) for nodejs and modern browsers.

MIT
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis