
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
@nrk/expect-openapi
Advanced tools
Expect objects to match OpenAPI documents
yarn add -D @nrk/expect-openapi
# or
npm add --dev @nrk/expect-openapi
jest.setup.ts
:
import { toMatchApiResponse, toMatchRef$ } from "@nrk/expect-openapi";
import expect from "expect";
expect.extend({ toMatchApiResponse, toMatchRef$ });
update the jest config:
setupFiles: ["<rootDir>/jest.setup.ts"],
import superagent from "superagent";
import openapi from "./openapi.json"; // OpenAPI 3 schema
describe("my api", () => {
it("should have valid /fantastic response, according to spec", async () => {
const url = `http://paspi.nrk.no/some/fantastic/path`;
const response = await superagent.get(url).accept("application/json");
// Asserts that:
// - mime-type matches
// - response code exists (or default)
// - the schema matches the response body (assumes it is JSON)
await expect(response).toMatchApiResponse(openapi, "get", "/fantastic");
});
});
import openapi from "./openapi.json"; // OpenAPI 3 schema
describe("my complex api", () => {
it("should match SimpleLink", async () => {
const myLink = { href: "/my/fantastic/link" };
// Asserts that:
// - the reference can be resolved
// - the resolved schema matches expected value
await expect(myLink).toMatchRef$(
openapi,
"#/components/schemas/SimpleLink"
);
});
});
FAQs
Expect objects to match OpenAPI documents
The npm package @nrk/expect-openapi receives a total of 46 weekly downloads. As such, @nrk/expect-openapi popularity was classified as not popular.
We found that @nrk/expect-openapi demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 144 open source maintainers collaborating on the project.
Did you know?
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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.