New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@safetyculture/api-json-schemas

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@safetyculture/api-json-schemas

SafetyCulture API JSON schemas

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

SafetyCulture API JSON schemas

JSON schemas of data structures exposed by the SafetyCulture public API.

They are useful e.g. to integrators wishing to validate data exported by the SafetyCulture API.

For more details see the SafetyCulture developer portal.

Usage

npm install @safetyculture/api-json-schemas
const safetyCultureApiJsonSchemas = require('@safetyculture/api-json-schemas');

// Outputs the audit public JSON schema
console.log(safetyCultureApiJsonSchemas.audit);

// Outputs common definition schemas used in the audit public JSON schema
console.log(safetyCultureApiJsonSchemas.definitions);

// Outputs the geometry schema used to represent audit location properties
console.log(safetyCultureApiJsonSchemas.geometry);

Validation example

Add a file to your project that exposes a validator like this:

const Validator = require('jsonschema').Validator;
const publicApiJsonSchema = require('@safetyculture/api-json-schemas');

function createValidator() {
  const validator = new Validator();

  const SUB_SCHEMAS = [
    publicApiJsonSchema.definitions,
    publicApiJsonSchema.geometry
  ];

  SUB_SCHEMAS.forEach((subSchema) => {
    validator.addSchema(subSchema);
  });

  return validator;
}

/**
 * Checks if 'doc' is in a valid API audit JSON format.
 *
 * @param doc {Object} to check
 * @param options {Object} see json-schema.org for configuration options
 * @return {ValidatorResult} the result of validation against the schema (see the jsonschema NPM module for details)
 */
module.exports = function validate(doc, options) {
  if (!doc || typeof doc !== 'object') {
    throw new Error('Input to API schema validation function is not an object');
  }

  const validator = createValidator();
  return validator.validate(doc, publicApiJsonSchema.audit, options);
};

Keywords

FAQs

Package last updated on 29 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc