0.4.9 • Published 6 months ago

@scalar/import v0.4.9

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

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.

0.4.9

6 months ago

0.4.8

6 months ago

0.2.27

10 months ago

0.2.26

10 months ago

0.2.25

10 months ago

0.2.24

10 months ago

0.2.23

10 months ago

0.2.22

10 months ago

0.2.21

10 months ago

0.2.20

10 months ago

0.2.19

11 months ago

0.2.18

11 months ago

0.2.17

11 months ago

0.3.20

7 months ago

0.2.16

11 months ago

0.3.27

7 months ago

0.2.15

12 months ago

0.3.26

7 months ago

0.2.14

12 months ago

0.3.25

7 months ago

0.2.13

12 months ago

0.3.24

7 months ago

0.2.12

12 months ago

0.3.23

7 months ago

0.2.11

12 months ago

0.3.22

7 months ago

0.2.10

12 months ago

0.3.21

7 months ago

0.1.0

1 year ago

0.3.0

9 months ago

0.1.2

1 year ago

0.1.1

1 year ago

0.3.19

8 months ago

0.3.18

8 months ago

0.3.6

8 months ago

0.3.5

9 months ago

0.3.8

8 months ago

0.3.7

8 months ago

0.3.2

9 months ago

0.3.1

9 months ago

0.3.4

9 months ago

0.3.3

9 months ago

0.3.9

8 months ago

0.3.17

8 months ago

0.3.16

8 months ago

0.3.15

8 months ago

0.3.14

8 months ago

0.3.13

8 months ago

0.3.12

8 months ago

0.3.11

8 months ago

0.3.10

8 months ago

0.2.30

9 months ago

0.2.36

9 months ago

0.2.35

9 months ago

0.2.34

9 months ago

0.2.33

9 months ago

0.2.31

9 months ago

0.2.0

1 year ago

0.2.29

9 months ago

0.2.28

9 months ago

0.4.5

6 months ago

0.2.7

12 months ago

0.4.4

6 months ago

0.2.6

12 months ago

0.4.7

6 months ago

0.2.9

12 months ago

0.4.6

6 months ago

0.4.1

7 months ago

0.2.3

1 year ago

0.0.5

1 year ago

0.2.2

1 year ago

0.4.3

6 months ago

0.2.5

12 months ago

0.4.2

7 months ago

0.2.4

12 months ago

0.0.6

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago