0.8.3 • Published 5 years ago

json-resolver v0.8.3

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

JSON Resolver

Parse and resolve complex JSON Documents. Designed for Open API Specification.

Features

  • Resolves external references to files and their sub-schemas
  • Supports nested references and bidirectional references between files
  • Detects circular references
  • Reads both JSON and YAML files

Getting Started

Installation

  1. Install with npm or yarn:

    # via npm
    npm install json-resolver
    # via yarn
    yarn add json-resolver
  2. Then import in your code

    // via ECMAScript
    import JsonResolver from 'json-resolver'
    // via commonJS
    var JsonResolver = require('swagger-parser');

Usage

JsonResolver.resolveRef(filePath, function(err, result) {
  if (err) {
    console.error(err.message)
  } else {
    console.log(JSON.stringify(result))
  }
})

Example

# Original
components:
  schemas:
    Pet:
      required:
        - id
        - name
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        tag:
          type: string
    Pets:
      type: array
      items:
        $ref: "#/components/schemas/Pet"

# Dereferenced
components:
  schemas:
    Pet:
      required:
      - id
      - name
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        tag:
          type: string
    Pets:
      type: array
      items:
        required:
        - id
        - name
        properties:
          id:
            type: integer
            format: int64
          name:
            type: string
          tag:
            type: string

Unsupported Features

0.8.3

5 years ago

0.8.2

6 years ago

0.8.1

6 years ago

0.8.0

6 years ago

0.7.2

6 years ago

0.7.1

6 years ago

0.7.0

6 years ago

0.6.0

6 years ago

0.5.0

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago