You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@swagger-api/apidom-reference

Package Overview
Dependencies
Maintainers
1
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swagger-api/apidom-reference

Advanced algorithms for semantic ApiDOM manipulations like dereferencing or resolution.

1.0.0-beta.45
latest
Source
npmnpm
Version published
Weekly downloads
618K
-0.31%
Maintainers
1
Weekly downloads
 
Created

What is @swagger-api/apidom-reference?

@swagger-api/apidom-reference is a package designed to facilitate the handling and manipulation of API documentation models. It provides tools for referencing, dereferencing, and resolving API documentation elements, making it easier to work with complex API specifications.

What are @swagger-api/apidom-reference's main functionalities?

Dereferencing

Dereferencing resolves all $ref pointers in the API documentation, replacing them with the actual referenced content. This is useful for working with a fully expanded version of the API documentation.

const { dereference } = require('@swagger-api/apidom-reference');

const apiDoc = {
  openapi: '3.0.0',
  info: {
    title: 'Sample API',
    version: '1.0.0'
  },
  paths: {
    '/pets': {
      get: {
        summary: 'List all pets',
        operationId: 'listPets',
        responses: {
          '200': {
            description: 'An paged array of pets',
            content: {
              'application/json': {
                schema: {
                  $ref: '#/components/schemas/Pets'
                }
              }
            }
          }
        }
      }
    }
  },
  components: {
    schemas: {
      Pets: {
        type: 'array',
        items: {
          $ref: '#/components/schemas/Pet'
        }
      },
      Pet: {
        type: 'object',
        properties: {
          id: {
            type: 'integer',
            format: 'int64'
          },
          name: {
            type: 'string'
          }
        }
      }
    }
  }
};

(async () => {
  const dereferencedDoc = await dereference(apiDoc);
  console.log(JSON.stringify(dereferencedDoc, null, 2));
})();

Resolving

Resolving processes the API documentation to identify and prepare all references for dereferencing. This step is often used before dereferencing to ensure all references are correctly identified.

const { resolve } = require('@swagger-api/apidom-reference');

const apiDoc = {
  openapi: '3.0.0',
  info: {
    title: 'Sample API',
    version: '1.0.0'
  },
  paths: {
    '/pets': {
      get: {
        summary: 'List all pets',
        operationId: 'listPets',
        responses: {
          '200': {
            description: 'An paged array of pets',
            content: {
              'application/json': {
                schema: {
                  $ref: '#/components/schemas/Pets'
                }
              }
            }
          }
        }
      }
    }
  },
  components: {
    schemas: {
      Pets: {
        type: 'array',
        items: {
          $ref: '#/components/schemas/Pet'
        }
      },
      Pet: {
        type: 'object',
        properties: {
          id: {
            type: 'integer',
            format: 'int64'
          },
          name: {
            type: 'string'
          }
        }
      }
    }
  }
};

(async () => {
  const resolvedDoc = await resolve(apiDoc);
  console.log(JSON.stringify(resolvedDoc, null, 2));
})();

Other packages similar to @swagger-api/apidom-reference

FAQs

Package last updated on 01 Aug 2025

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.