New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

@apifreaks/openapi-specs

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apifreaks/openapi-specs

Public OpenAPI 3.1 specifications for all APIFreaks API products.

latest
Source
npmnpm
Version
0.4.2
Version published
Weekly downloads
463
107.62%
Maintainers
2
Weekly downloads
 
Created
Source

@apifreaks/openapi-specs

npm License: MIT

npm package and source repo for the public OpenAPI 3.1 specifications of APIFreaks products.

The specs (catalog, authentication, and how to open them in Swagger, Postman, or a code generator) are in specs/README.md. This README is the package: install, the typed lookup API, and how the repo is built.

Install

npm install @apifreaks/openapi-specs

Node.js 18 or later. ESM and CommonJS are both supported.

Usage

Importing anything from @apifreaks/openapi-specs (the package entry) loads every spec. Use that when you need to list or look up specs at runtime. For a single product, import the JSON file (see below) so you do not go through that entry.

Lookup

import {
  getSpecJson,
  getSpecYaml,
  getSpecsByCategory,
  SpecSlug,
  SpecCategory,
} from "@apifreaks/openapi-specs";

const spec = getSpecJson(SpecSlug.IP_LOCATOR);
const yaml = getSpecYaml(SpecSlug.IP_LOCATOR);
const ipSlugs = getSpecsByCategory(SpecCategory.IP_INTELLIGENCE);

SpecSlug and SpecCategory are generated from specs/. If you write SpecSlug.IP_LOCATOR and that file is later renamed or removed, TypeScript fails at compile time. Raw strings (getSpecJson("ip-locator")) still typecheck; unknown slugs return undefined at runtime. Unknown categories return [].

getSpec is a deprecated alias for getSpecJson and will be removed in the next major version.

Single spec

JSON is published from specs/. TypeScript JSON imports need "resolveJsonModule": true.

import ipLocator from "@apifreaks/openapi-specs/specs/ip-intelligence/ip-locator.json";

YAML copies are also generated at build time into dist/specs/ (not in the GitHub specs/ folder) and published as files, but the YAML text is also embedded in the manifest — reading it through getSpecYaml(slug) at runtime, rather than importing the .yaml file, works from any module system (Node can't import .yaml) and needs no filesystem access.

CommonJS

const { getSpecJson, getSpecYaml, SpecSlug } = require("@apifreaks/openapi-specs");

Exports

Importing any of these from @apifreaks/openapi-specs loads every spec.

ExportTypeDescription
getSpecJson(slug)(string) => OpenAPISpec | undefinedSpec object for a slug
getSpecYaml(slug)(string) => string | undefinedPre-rendered YAML text for a slug
getSpec(slug)(string) => OpenAPISpec | undefinedDeprecated. Alias for getSpecJson, removed in the next major version
getSpecsByCategory(category)(string) => string[]Slugs in a category, or []
SpecSlug{ IP_LOCATOR: "ip-locator", … }Enumerated slugs
SpecCategory{ IP_INTELLIGENCE: "ip-intelligence", … }Enumerated categories
SPEC_SLUGSstring[]All slugs
SPEC_CATEGORIESstring[]All category names
SPECSRecord<string, OpenAPISpec>Spec objects keyed by slug
SPECS_YAMLRecord<string, string>Pre-rendered YAML text keyed by slug
SPECS_BY_CATEGORYRecord<string, string[]>Slugs grouped by category
import type {
  OpenAPISpec,
  SpecSlugValue,
  SpecCategoryValue,
} from "@apifreaks/openapi-specs";

OpenAPISpec is a typed envelope (openapi, info, paths, …), not a full OpenAPI 3.1 schema.

Development

specs/                     # OpenAPI JSON. See specs/README.md
src/
  index.ts                 # Public API
  types.ts                 # OpenAPISpec
  manifest.ts              # AUTO-GENERATED. Do not edit.
scripts/
  generate-manifest.ts     # Walks specs/, writes src/manifest.ts (embeds JSON + YAML)
  generate-yaml.ts         # JSON → dist/specs/**/*.yaml (published files)
  yaml.ts                  # Shared JSON->YAML dump used by both scripts
test/
  validate.test.ts         # JSON well-formedness; YAML round-trip after build
npm install
npm run generate      # regenerate src/manifest.ts from specs/
npm run build         # generate + bundle + YAML
npm run typecheck
npm test

src/manifest.ts is produced by npm run generate. It imports every spec and builds SPECS, SPECS_YAML, SPEC_SLUGS, SpecSlug, and SpecCategory.

Adding a spec

  • Add a complete OpenAPI 3.1 document at specs/<category>/<slug>.json. Use the same security schemes as the existing files: header X-apiKey and query apiKey.
  • Run npm run generate. Do not edit src/manifest.ts by hand.
  • Run npm test, then npm run build.

Maintainers

prepublishOnly runs the build. The published tarball includes dist/, specs/, package.json, README, and LICENSE.

Pushing a tag matching v* publishes to npm via GitHub Actions. The bump scripts test, commit a version, tag, and push; they will trigger that publish:

npm run bump:patch
npm run bump:minor
npm run bump:major

License

MIT

Keywords

openapi

FAQs

Package last updated on 10 Sep 2026

Related posts