How to use the json-refs.pathFromPtr function in json-refs

To help you get started, we’ve selected a few json-refs 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 ruojs / ruo / src / swagger / parameter-value.js View on Github external
constructor (parameterObject, raw) {
    let pPath = JsonRefs.pathFromPtr(parameterObject.ptr)
    let processed = false
    let schema = parameterObject.schema
    let error
    let isValid
    let processedValue

    this.parameterObject = parameterObject
    this.raw = raw

    // Use Object.defineProperty for 'value' to allow for lazy processing of the raw value
    Object.defineProperties(this, {
      error: {
        enumerable: true,
        get: function () {
          // Always call this.valid to ensure we validate the value prior to returning any values
          if (this.valid === true) {
github apigee-127 / swagger-tools / lib / specs.js View on Github external
_.each(documentMetadata.definitions, function (metadata, id) {
    var defPath = JsonRefs.pathFromPtr(id);
    var defType = defPath[0].substring(0, defPath[0].length - 1);
    var displayId = documentMetadata.swaggerVersion === '1.2' ? defPath[defPath.length - 1] : id;
    var code = defType === 'securityDefinition' ? 'SECURITY_DEFINITION' : defType.toUpperCase();
    var msgPrefix = defType === 'securityDefinition' ?
                             'Security definition' :
                             defType.charAt(0).toUpperCase() + defType.substring(1);

    if (metadata.references.length === 0 && !metadata.inline) {
      // Swagger 1.2 authorization scope
      if (metadata.scopePath) {
        code += '_SCOPE';
        msgPrefix += ' scope';
        defPath = metadata.scopePath;
      }

      createUnusedErrorOrWarning(displayId, code, msgPrefix, defPath, results.warnings);
github apigee-127 / swagger-tools / lib / specs.js View on Github external
_.each(results.refs, function (refDetails, refPtr) {
          if (refDetails.circular) {
            _.set(results.resolved, JsonRefs.pathFromPtr(refPtr), {});
          }
        });
github apigee-127 / swagger-tools / lib / specs.js View on Github external
var respond = function (document) {
    if (_.isString(ptr)) {
      return callback(undefined, traverse(document).get(JsonRefs.pathFromPtr(ptr)));
    } else {
      return callback(undefined, document);
    }
  };
github apigee-127 / swagger-tools / lib / specs.js View on Github external
_.each(documentMetadata.referencesMetadata, function (refDetails, refPtr) {
    if (isRemotePtr(refDetails) && refDetails.missing === true) {
      results.errors.push({
        code: 'UNRESOLVABLE_REFERENCE',
        message: 'Reference could not be resolved: ' + sanitizeRef(documentMetadata.swaggerVersion, refDetails.uri),
        path: JsonRefs.pathFromPtr(refPtr).concat('$ref')
      });
    }
  });
};
github apigee-127 / swagger-tools / lib / specs.js View on Github external
var getDisplayId = function (id) {
    return swaggerVersion === '1.2' ? JsonRefs.pathFromPtr(id).pop() : id;
  };
  var jsonRefsOptions = {
github apigee-127 / swagger-tools / lib / specs.js View on Github external
}), function (refDetails, refPtr) {
        var dMetadata = documentMetadata.definitions[refDetails.uri];
        var path = JsonRefs.pathFromPtr(refPtr);

        if (dMetadata.lineage.length > 0) {
          traverse(property).set(path, getOrComposeSchema(documentMetadata, refDetails.uri));
        } else {
          traverse(property).set(path.concat('title'), 'Composed ' + sanitizeRef(documentMetadata.swaggerVersion,
                                                                                 refDetails.uri));
        }
      });
    });
github apigee-127 / swagger-tools / lib / specs.js View on Github external
var addReference = function (cacheEntry, defPathOrPtr, refPathOrPtr, results, omitError) {
  var result = true;
  var swaggerVersion = helpers.getSwaggerVersion(cacheEntry.resolved);
  var defPath = _.isArray(defPathOrPtr) ? defPathOrPtr : JsonRefs.pathFromPtr(defPathOrPtr);
  var defPtr = _.isArray(defPathOrPtr) ? JsonRefs.pathToPtr(defPathOrPtr) : defPathOrPtr;
  var refPath = _.isArray(refPathOrPtr) ? refPathOrPtr : JsonRefs.pathFromPtr(refPathOrPtr);
  var refPtr = _.isArray(refPathOrPtr) ? JsonRefs.pathToPtr(refPathOrPtr) : refPathOrPtr;
  var code;
  var def;
  var displayId;
  var i;
  var msgPrefix;
  var type;

  def = cacheEntry.definitions[defPtr];
  type = defPath[0];
  code = type === 'securityDefinitions' ?
    'SECURITY_DEFINITION' :
    type.substring(0, type.length - 1).toUpperCase();
  displayId = swaggerVersion === '1.2' ? defPath[defPath.length - 1] : defPtr;
  msgPrefix = type === 'securityDefinitions' ?
    'Security definition' :
github andrglo / koa-swagger-router / src / index.js View on Github external
Object.keys(refs).forEach(key => {
      const values = jsonRefs.pathFromPtr(refs[key].uri)
      const definition = values[1]
      definitions[definition] = spec.definitions[definition]
    })

json-refs

Various utilities for JSON References (http://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03).

MIT
Latest version published 5 years ago

Package Health Score

71 / 100
Full package analysis