Skip to content

trojs/openapi-dereference

Repository files navigation

OpenAPI dereference

NPM version Coverage Quality Gate Status Bugs Code Smells Technical Debt Vulnerabilities Maintainability Rating Reliability Rating Security Rating

Dereference $ref pointers in JSONSchema or OpenAPI documents.

Zero dependencies. Synchronous core. Handles circular refs.

Installation

npm install @trojs/openapi-dereference or yarn add @trojs/openapi-dereference

Test the package

npm run test or yarn test

How to use

npm i @trojs/openapi-dereference
import { dereferenceSync } from '@trojs/openapi-dereference';

const schemaWithRefs = {
  schemas: {
    Person: {
      type: 'object',
      properties: {
        name: {
          $ref: '#/schemas/Name',
        },
      },
    },
    Name: {
      type: 'string',
    },
  },
};

const schemaWithNoRefs = dereferenceSync(schemaWithRefs);