Skip to content

Commit 70d2876

Browse files
authored
Improve not found spec error (#765)
1 parent f6cd69e commit 70d2876

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.changeset/curvy-moles-happen.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@gitbook/integration-openapi': patch
3+
---
4+
5+
Improve spec not found error message

integrations/openapi/src/contentSources/generate.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from '@gitbook/runtime';
88
import { assertNever } from '../utils';
99
import type { OpenAPIRuntimeContext } from '../types';
10-
import { getLatestOpenAPISpecContent } from '../parser/spec';
10+
import { getLatestOpenAPISpecContent, type OpenAPISpecContent } from '../parser/spec';
1111
import { getRevisionFromSpec } from '../parser/revision';
1212
import { getOpenAPIPageDocument } from '../parser/page';
1313
import { getModelsDocument } from '../parser/models';
@@ -96,7 +96,7 @@ export const generateContentSource = createContentSource<
9696
async function getOpenAPISpecFromDependencies(
9797
dependencies: ContentSourceDependenciesValueFromRef<OpenAPIContentSource['dependencies']>,
9898
ctx: OpenAPIRuntimeContext,
99-
) {
99+
): Promise<OpenAPISpecContent> {
100100
const { api } = ctx;
101101
const { installation } = ctx.environment;
102102
const specValue = dependencies.spec.value;
@@ -106,7 +106,7 @@ async function getOpenAPISpecFromDependencies(
106106
}
107107

108108
if (specValue?.object !== 'openapi-spec') {
109-
throw new ExposableError('Invalid spec');
109+
throw new ExposableError('OpenAPI specification not found', 404);
110110
}
111111

112112
return getLatestOpenAPISpecContent({

0 commit comments

Comments
 (0)