npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@suss/contract-openapi

v0.3.2

Published

Generate suss behavioral summaries from OpenAPI 3.x specifications.

Readme

@suss/contract-openapi

Generate suss BehavioralSummary[] from an OpenAPI 3.x specification. Lets you check TypeScript consumers against a published API contract, or your own provider against a contract you publish, without having extracted summaries from the provider's source code.

What this package is

@suss/contract-openapi reads an OpenAPI document and emits one BehavioralSummary per operation. Each summary carries:

  • A kind: "handler" provider-side shape
  • boundaryBinding: { protocol: "http", method, path, framework: "openapi" }: pairs with extracted handlers/clients via the checker's path normalization (:id{id})
  • One transition per declared response status, with body shapes converted from OpenAPI Schema → suss TypeShape
  • confidence: { source: "derived", level: "high" }: declared rather than inferred

The summaries plug into suss check exactly like extracted ones.

Minimal usage

import { openApiFileToSummaries } from "@suss/contract-openapi";
import fs from "node:fs";

const summaries = openApiFileToSummaries("openapi.yaml");
fs.writeFileSync("provider.json", JSON.stringify(summaries, null, 2));

Then pair against a consumer extracted from your TS code:

suss check provider.json consumer.json

Or programmatically:

import { openApiToSummaries } from "@suss/contract-openapi";
import type { OpenApiSpec } from "@suss/contract-openapi";

const spec: OpenApiSpec = { openapi: "3.0.3", paths: { /* ... */ } };
const summaries = openApiToSummaries(spec);

What's covered

  • All standard HTTP methods on paths.<path>.<method>
  • Numeric status codes ("200", "404", etc.) and default
  • Response body schemas under content.<media-type>.schema (first content type wins)
  • Path, query, header, and cookie parameters mapped to Input.role
  • Request body schemas mapped to a single requestBody input
  • $ref to #/components/schemas/<Name> with cycle protection (recursive schemas resolve to a { type: "ref", name } placeholder)
  • Schema features: object/array/string/integer/number/boolean, enum, oneOf/anyOf, allOf (object merge), nullable, additionalProperties (as dictionary)

Limitations (v0)

  • Range status codes like "2XX" are skipped; checker pairing requires concrete status values.
  • Headers, links, callbacks, webhooks sections are not modeled.
  • Security schemes are not represented as transitions (no synthetic 401/403).
  • Multiple content types per response: only the first one is used for the body shape.
  • Polymorphism via discriminator is not modeled (the union shape is correct, but the discriminator field isn't called out).
  • Spec validation is not strict; invalid specs may produce odd summaries rather than errors.

Where it sits in suss

Depends only on @suss/behavioral-ir (for the IR types it produces) and yaml (for spec parsing). It is independent of the language adapter and pattern packs; it doesn't extract from source.

Coverage

coverage

License

Licensed under Apache 2.0. See LICENSE.


For the format the summaries conform to, see docs/behavioral-summary-format.md.