How to use json-schema-deref-sync - 3 common examples

To help you get started, we’ve selected a few json-schema-deref-sync 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 anttiviljami / openapi-client-axios / src / client.ts View on Github external
if (this.validate) {
        // validate the document
        this.validateDefinition();
      }
    } catch (err) {
      if (this.strict) {
        // in strict-mode, fail hard and re-throw the error
        throw err;
      } else {
        // just emit a warning about the validation errors
        console.warn(err);
      }
    }

    // dereference the document into definition
    this.definition = dereference(this.inputDocument);

    // create axios instance
    this.instance = this.createAxiosInstance();

    // we are now initalized
    this.initalized = true;
    return this.instance as Client;
  };
github apiaryio / api-elements.js / src / adapters / swagger20.es6 View on Github external
function derefJsonSchema(jsonSchemaWithRefs) {
  let jsonSchema;

  // In case there are errors with `deref`, which can happen with circular $refs
  try {
    jsonSchema = deref(jsonSchemaWithRefs);
  } catch(error) {
    jsonSchema = jsonSchemaWithRefs;
  }

  return jsonSchema;
}
github carlansley / swagger2 / src / compiler.ts View on Github external
export function compile(document: Document): Compiled {
  // get the de-referenced version of the swagger document
  const swagger = deref(document);

  // add a validator for every parameter in swagger document
  Object.keys(swagger.paths).forEach(pathName => {
    const path = swagger.paths[pathName];
    Object.keys(path)
      .filter(name => name !== 'parameters')
      .forEach(operationName => {
        const operation = path[operationName];

        const parameters: any = {};
        const resolveParameter = (parameter: any) => {
          parameters[`${parameter.name}:${parameter.location}`] = parameter;
        };

        // start with parameters at path level
        (path.parameters || []).forEach(resolveParameter);

json-schema-deref-sync

Simple Node.js JSON Schema dereferencer

MIT
Latest version published 4 years ago

Package Health Score

56 / 100
Full package analysis

Popular json-schema-deref-sync functions