Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(openapi/inspect): small url formatting error #855

Merged
merged 3 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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