{"id":49477,"library":"swagger-test","title":"swagger-test","description":"Specification-driven REST API testing tool that validates HTTP responses against Swagger/OpenAPI specifications. Version 0.8.0 is the latest stable release (as of 2016+), with no active maintenance. It offers both CLI and programmatic usage, supports explicit x-amples extension and automatic inference of test cases. Unlike broader API testing frameworks (e.g., Postman, Dredd), swagger-test focuses purely on Swagger spec conformance with no built-in HTTP client.","status":"abandoned","version":"0.8.0","language":"javascript","source_language":"en","source_url":"https://github.com/earldouglas/swagger-test","tags":["javascript","swagger","specification","spec","testing","test"],"install":[{"cmd":"npm install swagger-test","lang":"bash","label":"npm"},{"cmd":"yarn add swagger-test","lang":"bash","label":"yarn"},{"cmd":"pnpm add swagger-test","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used in examples as HTTP client for testing","package":"preq","optional":true}],"imports":[{"note":"Package uses CommonJS, not ESM. No TypeScript typings.","wrong":"import swaggerTest from 'swagger-test';","symbol":"default","correct":"const swaggerTest = require('swagger-test');"},{"note":"parse() is a method on the default export. Do not try to call the module directly.","wrong":"swaggerTest(spec);","symbol":"parse","correct":"swaggerTest.parse(spec, options);"},{"note":"CLI reads Swagger spec from stdin and tests against a running server; base URL must be configured via environment or spec.","wrong":"","symbol":"CLI","correct":"npm install -g swagger-test; swagger-test"}],"quickstart":{"code":"const swaggerTest = require('swagger-test');\nconst preq = require('preq');\nconst assert = require('assert');\n\n// Load Swagger specification (e.g., from file)\nconst spec = require('./swagger.json');\n\n// Parse to get test examples\nconst xamples = swaggerTest.parse(spec, { inferXamples: true });\n\n// Run tests (assuming server is running)\ndescribe('Swagger tests', function() {\n  xamples.forEach(function(xample) {\n    it(xample.description, function() {\n      return preq[xample.request.method](xample.request)\n        .then(function(response) {\n          assert.deepEqual(response, xample.responses[response.status]);\n        });\n    });\n  });\n});","lang":"javascript","description":"Shows how to parse a Swagger spec, infer test cases, and run them against a live server using preq and mocha."},"warnings":[{"fix":"Consider migrating to Dredd or another active API testing tool.","message":"Package is abandoned; no updates since 2016. May not work with newer Node.js versions or OpenAPI 3.x.","severity":"breaking","affected_versions":">=0.8.0"},{"fix":"Set the x-amples.base-url property in your Swagger spec or configure via environment.","message":"CLI reads from stdin but requires base URL; if not set, requests may fail or hit wrong host.","severity":"gotcha","affected_versions":"*"},{"fix":"Add explicit x-amples to generate meaningful test cases.","message":"Inferred examples use default values from spec; if your spec lacks examples, tests may be minimal or fail.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'0.8.0':19 '2016':27 'activ':30 'ampl':43 'api':8,53 'automat':46 'broader':52 'built':71 'built-in':70 'case':50 'cli':35 'client':74 'conform':67 'dredd':58 'driven':6 'e.g':56 'explicit':40 'extens':44 'focus':62 'framework':55 'http':13,73 'infer':47 'javascript':75 'latest':22 'mainten':31 'offer':33 'postman':57 'programmat':37 'pure':63 'releas':24 'respons':14 'rest':7 'spec':66,78 'specif':5,17,77 'specification-driven':4 'stabl':23 'support':39 'swagger':2,60,65,76 'swagger-test':1,59 'swagger/openapi':16 'test':3,9,49,54,61,79,80 'tool':10 'unlik':51 'usag':38 'valid':12 'version':18 'x':42 'x-ampl':41","created_at":"2026-06-07T17:01:58.415508+00:00","updated_at":"2026-06-07T17:01:58.415508+00:00","problems":[{"fix":"npm install swagger-test","cause":"Package not installed or not in node_modules","error":"Error: Cannot find module 'swagger-test'"},{"fix":"const xamples = swaggerTest.parse(spec);","cause":"Calling the module directly instead of using .parse()","error":"TypeError: swaggerTest is not a function"},{"fix":"Fix your server's response or update the specification.","cause":"Actual HTTP response does not conform to the Swagger spec's expected response","error":"response did not match specification"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/earldouglas/swagger-test","github":"https://github.com/earldouglas/swagger-test","docs":null,"changelog":null,"pypi":null,"npm":"swagger-test","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}