Skip to content

Commit

Permalink
fix(openapi/inspect): small url formatting error (#855)
Browse files Browse the repository at this point in the history
* fix(openapi/inspect): small url formatting error

* test: snapshot

* chore: better fallback text
  • Loading branch information
kanadgupta authored Aug 10, 2023
1 parent 63eaf81 commit c54e289
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions __tests__/cmds/openapi/__snapshots__/inspect.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ OpenAPI Features
│ webhooks │ │ Webhooks allow you to describe out of band requests that may be initiated by │
│ │ │ your users. │
│ │ │ │
│ │ │ [object Object]
│ │ │ 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. │
Expand Down Expand Up @@ -307,7 +307,7 @@ OpenAPI Features
│ webhooks │ │ Webhooks allow you to describe out of band requests that may be initiated by │
│ │ │ your users. │
│ │ │ │
│ │ │ [object Object]
│ │ │ 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. │
Expand Down Expand Up @@ -417,7 +417,7 @@ OpenAPI Features
│ webhooks │ │ Webhooks allow you to describe out of band requests that may be initiated by │
│ │ │ your users. │
│ │ │ │
│ │ │ [object Object]
│ │ │ 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. │
Expand Down
11 changes: 5 additions & 6 deletions src/cmds/openapi/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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'] || 'This feature is not available on OpenAPI v3.0.';
} else if (this.definitionVersion.startsWith('3.1')) {
return feature.url?.['3.1'] || 'This feature is not available on OpenAPI v3.1.';
}
return '';
}

return feature.url;
Expand Down

0 comments on commit c54e289

Please sign in to comment.