From b4fe4b0aedefd9d23b5062aa3362a17a8f4a2adb Mon Sep 17 00:00:00 2001 From: Kanad Gupta Date: Wed, 9 Aug 2023 15:55:28 -0500 Subject: [PATCH 1/3] fix(openapi/inspect): small url formatting error --- src/cmds/openapi/inspect.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/cmds/openapi/inspect.ts b/src/cmds/openapi/inspect.ts index 977245d70..af109bef3 100644 --- a/src/cmds/openapi/inspect.ts +++ b/src/cmds/openapi/inspect.ts @@ -57,7 +57,7 @@ export default class OpenAPIInspectCommand extends Command { .reduce((prev, next) => Object.assign(prev, next)); } - getFeatureDocsURL(feature: AnalyzedFeature) { + getFeatureDocsURL(feature: AnalyzedFeature): string { if (!feature.url) { return undefined; } @@ -66,12 +66,11 @@ export default class OpenAPIInspectCommand extends Command { // We don't need to do any Swagger or Postman determination here because this command // always converts their spec to OpenAPI 3.0. if (this.definitionVersion.startsWith('3.0')) { - if (feature.url?.['3.0']) { - return feature.url['3.0']; - } - } else { - return feature.url['3.1']; + return feature.url?.['3.0']; + } else if (this.definitionVersion.startsWith('3.1')) { + return feature.url?.['3.1']; } + return ''; } return feature.url; From b26cb2f71ee122c57abe1ba776d7afad5799812b Mon Sep 17 00:00:00 2001 From: Kanad Gupta Date: Wed, 9 Aug 2023 15:55:54 -0500 Subject: [PATCH 2/3] test: snapshot --- __tests__/cmds/openapi/__snapshots__/inspect.test.ts.snap | 6 ------ 1 file changed, 6 deletions(-) diff --git a/__tests__/cmds/openapi/__snapshots__/inspect.test.ts.snap b/__tests__/cmds/openapi/__snapshots__/inspect.test.ts.snap index c679f9e75..01333616b 100644 --- a/__tests__/cmds/openapi/__snapshots__/inspect.test.ts.snap +++ b/__tests__/cmds/openapi/__snapshots__/inspect.test.ts.snap @@ -196,8 +196,6 @@ OpenAPI Features ├──────────────────────┼───────┼──────────────────────────────────────────────────────────────────────────────────┤ │ webhooks │ │ Webhooks allow you to describe out of band requests that may be initiated by │ │ │ │ your users. │ -│ │ │ │ -│ │ │ [object Object] │ ├──────────────────────┼───────┼──────────────────────────────────────────────────────────────────────────────────┤ │ xml │ ✅ │ Any parameter and/or request body that accepts XML or responses that return XML │ │ │ │ payloads. │ @@ -306,8 +304,6 @@ OpenAPI Features ├──────────────────────┼───────┼──────────────────────────────────────────────────────────────────────────────────┤ │ webhooks │ │ Webhooks allow you to describe out of band requests that may be initiated by │ │ │ │ your users. │ -│ │ │ │ -│ │ │ [object Object] │ ├──────────────────────┼───────┼──────────────────────────────────────────────────────────────────────────────────┤ │ xml │ │ Any parameter and/or request body that accepts XML or responses that return XML │ │ │ │ payloads. │ @@ -416,8 +412,6 @@ OpenAPI Features ├──────────────────────┼───────┼──────────────────────────────────────────────────────────────────────────────────┤ │ webhooks │ │ Webhooks allow you to describe out of band requests that may be initiated by │ │ │ │ your users. │ -│ │ │ │ -│ │ │ [object Object] │ ├──────────────────────┼───────┼──────────────────────────────────────────────────────────────────────────────────┤ │ xml │ │ Any parameter and/or request body that accepts XML or responses that return XML │ │ │ │ payloads. │ From bc1fdfa50072abb5d94a6230437d45bcf63c0a72 Mon Sep 17 00:00:00 2001 From: Kanad Gupta Date: Wed, 9 Aug 2023 16:22:21 -0500 Subject: [PATCH 3/3] chore: better fallback text --- __tests__/cmds/openapi/__snapshots__/inspect.test.ts.snap | 6 ++++++ src/cmds/openapi/inspect.ts | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/__tests__/cmds/openapi/__snapshots__/inspect.test.ts.snap b/__tests__/cmds/openapi/__snapshots__/inspect.test.ts.snap index 01333616b..136924d36 100644 --- a/__tests__/cmds/openapi/__snapshots__/inspect.test.ts.snap +++ b/__tests__/cmds/openapi/__snapshots__/inspect.test.ts.snap @@ -196,6 +196,8 @@ OpenAPI Features ├──────────────────────┼───────┼──────────────────────────────────────────────────────────────────────────────────┤ │ webhooks │ │ Webhooks allow you to describe out of band requests that may be initiated by │ │ │ │ your users. │ +│ │ │ │ +│ │ │ This feature is not available on OpenAPI v3.0. │ ├──────────────────────┼───────┼──────────────────────────────────────────────────────────────────────────────────┤ │ xml │ ✅ │ Any parameter and/or request body that accepts XML or responses that return XML │ │ │ │ payloads. │ @@ -304,6 +306,8 @@ OpenAPI Features ├──────────────────────┼───────┼──────────────────────────────────────────────────────────────────────────────────┤ │ webhooks │ │ Webhooks allow you to describe out of band requests that may be initiated by │ │ │ │ your users. │ +│ │ │ │ +│ │ │ This feature is not available on OpenAPI v3.0. │ ├──────────────────────┼───────┼──────────────────────────────────────────────────────────────────────────────────┤ │ xml │ │ Any parameter and/or request body that accepts XML or responses that return XML │ │ │ │ payloads. │ @@ -412,6 +416,8 @@ OpenAPI Features ├──────────────────────┼───────┼──────────────────────────────────────────────────────────────────────────────────┤ │ webhooks │ │ Webhooks allow you to describe out of band requests that may be initiated by │ │ │ │ your users. │ +│ │ │ │ +│ │ │ This feature is not available on OpenAPI v3.0. │ ├──────────────────────┼───────┼──────────────────────────────────────────────────────────────────────────────────┤ │ xml │ │ Any parameter and/or request body that accepts XML or responses that return XML │ │ │ │ payloads. │ diff --git a/src/cmds/openapi/inspect.ts b/src/cmds/openapi/inspect.ts index af109bef3..a0dff4411 100644 --- a/src/cmds/openapi/inspect.ts +++ b/src/cmds/openapi/inspect.ts @@ -66,9 +66,9 @@ export default class OpenAPIInspectCommand extends Command { // We don't need to do any Swagger or Postman determination here because this command // always converts their spec to OpenAPI 3.0. if (this.definitionVersion.startsWith('3.0')) { - return feature.url?.['3.0']; + return feature.url?.['3.0'] || 'This feature is not available on OpenAPI v3.0.'; } else if (this.definitionVersion.startsWith('3.1')) { - return feature.url?.['3.1']; + return feature.url?.['3.1'] || 'This feature is not available on OpenAPI v3.1.'; } return ''; }