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

@scalar/import

Package Overview
Dependencies
Maintainers
0
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scalar/import

Import any file, URL or content to get an OpenAPI document

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Scalar Import

Version Downloads License Discord

Pass an URL to an OpenAPI document, a Swagger document, a Postman collection, a Scalar API reference, a Scalar Sandbox link … basically anything, and retrieve an OpenAPI document.

Installation

npm install @scalar/import

Usage

Find any OpenAPI/Swagger document URL in any content:

import { resolve } from '@scalar/import'

// Get the raw file URL from a GitHub link
const result = await resolve(
  'https://github.com/outline/openapi/blob/main/spec3.yml',
)

// https://raw.githubusercontent.com/outline/openapi/refs/heads/main/spec3.yml

Features

  • Resolves URLs to OpenAPI specifications from various sources
  • Supports JSON and YAML formats (.json, .yaml, .yml)
  • Extracts OpenAPI specification URLs from HTML content, including:
    • Scalar API Reference <script> tags
    • Redoc HTML and JavaScript implementations
  • Works with different quote styles and data attribute formats
  • Robust error handling for various HTML structures
  • Transforms GitHub URLs to raw file URLs
  • Handles Scalar Sandbox URLs

Examples

InputOutputDescription
https://cdn.jsdelivr.net/npm/@scalar/galaxy/dist/latest.jsonSame as inputReturns JSON URLs as-is
https://cdn.jsdelivr.net/npm/@scalar/galaxy/dist/latest.yaml or *.ymlSame as inputReturns YAML URLs as-is
https://sandbox.scalar.com/p/dlw8vhttps://sandbox.scalar.com/files/dlw8v/openapi.yamlResolves sandbox URLs to specific file paths
https://github.com/owner/repo/blob/main/openapi.yamlhttps://raw.githubusercontent.com/owner/repo/refs/heads/main/openapi.yamlTransforms GitHub URLs to raw file URLs
HTML with data-url attributeURL from data-url attributeExtracts URL from HTML script tag with data-url attribute
HTML with relative URL /openapi.yamlhttps://example.com/openapi.yamlResolves relative URLs to absolute URLs
HTML with JSON configurationURL from JSON configurationExtracts URL from JSON configuration in data-configuration attribute
Redoc HTMLURL from spec-url attributeExtracts URL from Redoc's spec-url attribute
HTML with embedded OpenAPIParsed OpenAPI objectExtracts and parses embedded OpenAPI JSON from HTML

Community

We are API nerds. You too? Let’s chat on Discord: https://discord.gg/scalar

License

The source code in this repository is licensed under MIT.

Keywords

FAQs

Package last updated on 24 Oct 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