
Security News
Vite+ Joins the Push to Consolidate JavaScript Tooling
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
@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
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.
Security News
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
Security News
Ruby Central’s incident report on the RubyGems.org access dispute sparks backlash from former maintainers and renewed debate over project governance.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.