diff --git a/package.json b/package.json index a50b406f32..31570d394d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "openapi-workspaces", "license": "MIT", "private": true, - "version": "0.53.16", + "version": "0.53.17", "workspaces": [ "projects/json-pointer-helpers", "projects/openapi-io", diff --git a/projects/fastify-capture/package.json b/projects/fastify-capture/package.json index 0da12a3364..7a20bf5387 100644 --- a/projects/fastify-capture/package.json +++ b/projects/fastify-capture/package.json @@ -2,7 +2,7 @@ "name": "@useoptic/fastify-capture", "license": "MIT", "packageManager": "yarn@4.0.2", - "version": "0.53.16", + "version": "0.53.17", "main": "build/index.js", "types": "build/index.d.ts", "files": [ diff --git a/projects/json-pointer-helpers/package.json b/projects/json-pointer-helpers/package.json index 834edacc6f..1fc2b1519b 100644 --- a/projects/json-pointer-helpers/package.json +++ b/projects/json-pointer-helpers/package.json @@ -2,7 +2,7 @@ "name": "@useoptic/json-pointer-helpers", "license": "MIT", "packageManager": "yarn@4.0.2", - "version": "0.53.16", + "version": "0.53.17", "main": "build/index.js", "types": "build/index.d.ts", "files": [ diff --git a/projects/openapi-io/package.json b/projects/openapi-io/package.json index 29a67584fd..6ad4e96cdb 100644 --- a/projects/openapi-io/package.json +++ b/projects/openapi-io/package.json @@ -2,7 +2,7 @@ "name": "@useoptic/openapi-io", "license": "MIT", "packageManager": "yarn@4.0.2", - "version": "0.53.16", + "version": "0.53.17", "main": "build/index.js", "types": "build/index.d.ts", "files": [ diff --git a/projects/openapi-utilities/package.json b/projects/openapi-utilities/package.json index b00d8afff3..55afb5694e 100644 --- a/projects/openapi-utilities/package.json +++ b/projects/openapi-utilities/package.json @@ -2,7 +2,7 @@ "name": "@useoptic/openapi-utilities", "license": "MIT", "packageManager": "yarn@4.0.2", - "version": "0.53.16", + "version": "0.53.17", "main": "build/index.js", "types": "build/index.d.ts", "files": [ diff --git a/projects/optic/package.json b/projects/optic/package.json index 165df47d94..b8c009e9df 100644 --- a/projects/optic/package.json +++ b/projects/optic/package.json @@ -2,7 +2,7 @@ "name": "@useoptic/optic", "license": "MIT", "packageManager": "yarn@4.0.2", - "version": "0.53.16", + "version": "0.53.17", "main": "build/index.js", "types": "build/index.d.ts", "files": [ diff --git a/projects/optic/src/__tests__/integration/__snapshots__/capture.test.ts.snap b/projects/optic/src/__tests__/integration/__snapshots__/capture.test.ts.snap index 4caa4e9aed..90c669f188 100644 --- a/projects/optic/src/__tests__/integration/__snapshots__/capture.test.ts.snap +++ b/projects/optic/src/__tests__/integration/__snapshots__/capture.test.ts.snap @@ -2201,6 +2201,8 @@ GET /books $workspace$/openapi.yml ...and 1 endpoint that did not receive traffic +Unmatched endpoints: + POST /books 66.7% coverage of your documented operations. 5 requests did not match a documented path (6 total requests). 9 diffs detected in documented operations diff --git a/projects/optic/src/commands/capture/capture.ts b/projects/optic/src/commands/capture/capture.ts index 25069aef65..64a464834b 100644 --- a/projects/optic/src/commands/capture/capture.ts +++ b/projects/optic/src/commands/capture/capture.ts @@ -554,6 +554,16 @@ export async function processCaptures( ); options.bufferLogs ? bufferedOutput.push(txt) : logger.info(txt); } + if (options.verbose) { + const text = [chalk.gray(`Unmatched endpoints:`)]; + for (const endpoint of endpointCounts.paths.unmatched) { + text.push( + ` ${chalk.gray(`${endpoint.method.toUpperCase()} ${endpoint.path}`)}` + ); + } + for (const line of text) + options.bufferLogs ? bufferedOutput.push(line) : logger.info(line); + } } // document new endpoints diff --git a/projects/optic/src/commands/capture/interactions/grouped-interactions.ts b/projects/optic/src/commands/capture/interactions/grouped-interactions.ts index 60dc2e3238..597321772d 100644 --- a/projects/optic/src/commands/capture/interactions/grouped-interactions.ts +++ b/projects/optic/src/commands/capture/interactions/grouped-interactions.ts @@ -1,5 +1,9 @@ import { jsonPointerHelpers } from '@useoptic/json-pointer-helpers'; -import { OpenAPIV3, getEndpointId } from '@useoptic/openapi-utilities'; +import { + OpenAPIV3, + getEndpointId, + getPathAndMethodFromEndpointId, +} from '@useoptic/openapi-utilities'; import crypto from 'crypto'; import fs from 'node:fs/promises'; import path from 'path'; @@ -269,17 +273,29 @@ export class GroupedCaptures { counts() { let total = 0; let unmatched = 0; + const unmatchedPaths: { method: string; path: string }[] = []; + const matchedPaths: { method: string; path: string }[] = []; let matched = 0; for (const [, node] of this.paths) { total++; - if (node.hars.length === 0 && node.interactions.length === 0) unmatched++; - if (node.hars.length !== 0 || node.interactions.length !== 0) matched++; + if (node.hars.length === 0 && node.interactions.length === 0) { + unmatched++; + unmatchedPaths.push(node.endpoint); + } + if (node.hars.length !== 0 || node.interactions.length !== 0) { + matched++; + matchedPaths.push(node.endpoint); + } } return { total, unmatched, matched, + paths: { + unmatched: unmatchedPaths, + matched: matchedPaths, + }, }; } diff --git a/projects/rulesets-base/package.json b/projects/rulesets-base/package.json index aec9f63ff1..5b05a884ca 100644 --- a/projects/rulesets-base/package.json +++ b/projects/rulesets-base/package.json @@ -2,7 +2,7 @@ "name": "@useoptic/rulesets-base", "license": "MIT", "packageManager": "yarn@4.0.2", - "version": "0.53.16", + "version": "0.53.17", "main": "build/index.js", "types": "build/index.d.ts", "files": [ diff --git a/projects/standard-rulesets/package.json b/projects/standard-rulesets/package.json index 6c6387fe44..0cb81230cb 100644 --- a/projects/standard-rulesets/package.json +++ b/projects/standard-rulesets/package.json @@ -2,7 +2,7 @@ "name": "@useoptic/standard-rulesets", "license": "MIT", "packageManager": "yarn@4.0.2", - "version": "0.53.16", + "version": "0.53.17", "main": "build/index.js", "types": "build/index.d.ts", "files": [