Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@swagger-api/apidom-ns-openapi-3-1

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swagger-api/apidom-ns-openapi-3-1

OpenAPI 3.1.x namespace for ApiDOM.

  • 1.0.0-beta.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
471K
decreased by-9.11%
Maintainers
1
Weekly downloads
 
Created

What is @swagger-api/apidom-ns-openapi-3-1?

@swagger-api/apidom-ns-openapi-3-1 is an npm package designed to work with the OpenAPI 3.1 specification. It provides tools for parsing, validating, and manipulating OpenAPI documents, making it easier for developers to work with API definitions.

What are @swagger-api/apidom-ns-openapi-3-1's main functionalities?

Parsing OpenAPI Documents

This feature allows you to parse an OpenAPI 3.1 document from a string format into a JavaScript object. This is useful for programmatically accessing and manipulating the contents of an OpenAPI document.

const { parse } = require('@swagger-api/apidom-ns-openapi-3-1');

const openApiDoc = `
openapi: 3.1.0
info:
  title: Sample API
  version: 1.0.0
paths:
  /pets:
    get:
      summary: List all pets
      responses:
        '200':
          description: A list of pets.
`;

const parsedDoc = parse(openApiDoc);
console.log(parsedDoc);

Validating OpenAPI Documents

This feature allows you to validate an OpenAPI 3.1 document to ensure it adheres to the specification. This is useful for catching errors and ensuring the document is correctly formatted.

const { validate } = require('@swagger-api/apidom-ns-openapi-3-1');

const openApiDoc = `
openapi: 3.1.0
info:
  title: Sample API
  version: 1.0.0
paths:
  /pets:
    get:
      summary: List all pets
      responses:
        '200':
          description: A list of pets.
`;

const validationResult = validate(openApiDoc);
console.log(validationResult);

Manipulating OpenAPI Documents

This feature allows you to manipulate an OpenAPI 3.1 document by parsing it into a JavaScript object, making changes, and then serializing it back into a string format. This is useful for programmatically updating API definitions.

const { parse, serialize } = require('@swagger-api/apidom-ns-openapi-3-1');

const openApiDoc = `
openapi: 3.1.0
info:
  title: Sample API
  version: 1.0.0
paths:
  /pets:
    get:
      summary: List all pets
      responses:
        '200':
          description: A list of pets.
`;

let parsedDoc = parse(openApiDoc);
parsedDoc.info.title = 'Updated API Title';
const updatedDoc = serialize(parsedDoc);
console.log(updatedDoc);

Other packages similar to @swagger-api/apidom-ns-openapi-3-1

FAQs

Package last updated on 25 Nov 2024

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