Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit 2565ffb

Browse files
committed
fix: types
1 parent 06a1177 commit 2565ffb

File tree

4 files changed

+23
-31
lines changed

4 files changed

+23
-31
lines changed

packages/openapi-parser/src/pipeline.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import type {
2-
AnyObject,
3-
DereferenceResult,
4-
DetailsResult,
5-
Filesystem,
6-
OpenAPI,
7-
} from './types'
1+
import type { AnyObject, DetailsResult, Filesystem } from './types'
82
import {
93
dereference,
104
details,

packages/openapi-parser/src/types/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ERRORS } from '../configuration'
1+
import { ERRORS, OpenApiVersion } from '../configuration'
22
import type { OpenAPI } from './openapi-types'
33

44
export type {
@@ -32,7 +32,7 @@ export type FilterResult = {
3232
}
3333

3434
export type DetailsResult = {
35-
version: string
35+
version: OpenApiVersion
3636
specificationType: string
3737
specificationVersion: string
3838
}

packages/openapi-parser/src/utils/details.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function details(specification: AnyObject): DetailsResult {
1111

1212
if (typeof value === 'string' && value.startsWith(version)) {
1313
return {
14-
version: version as OpenApiVersion,
14+
version: version,
1515
specificationType,
1616
specificationVersion: value,
1717
}
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
import type { Queue } from '../pipeline'
2-
import type { DereferenceResult, Filesystem } from '../types'
3-
import { makeFilesystem } from './makeFilesystem'
2+
import type {
3+
DereferenceResult,
4+
Filesystem,
5+
FilterResult,
6+
LoadResult,
7+
UpgradeResult,
8+
ValidateResult,
9+
} from '../types'
10+
11+
type WorkThroughQueueResult = Partial<
12+
LoadResult &
13+
DereferenceResult &
14+
ValidateResult &
15+
UpgradeResult &
16+
FilterResult & {
17+
filesystem: Filesystem
18+
}
19+
>
420

521
/**
622
* Run through a queue of tasks
723
*/
824
export async function workThroughQueue(queue: Queue): // TODO: Better type
9-
Promise<
10-
Partial<
11-
DereferenceResult & {
12-
filesystem: Filesystem
13-
}
14-
>
15-
> {
25+
Promise<WorkThroughQueueResult> {
1626
let specification = queue.specification
1727

18-
// TODO: Be more specific
1928
let result: any
2029

2130
// Run through all tasks in the queue
@@ -40,16 +49,5 @@ Promise<
4049
}
4150
}
4251

43-
/**
44-
* TODO: This is a terrible hack. All functions should return the same format, but they don’t.
45-
* The dereference function returns a DereferenceResult, but others return a Filesystem.
46-
*/
47-
// const isMoreThanJustTheSpecification = Object.keys(specification).includes(
48-
// 'specificationVersion',
49-
// )
50-
5152
return result
52-
// return isMoreThanJustTheSpecification
53-
// ? (specification as any)
54-
// : makeFilesystem(specification as Filesystem)
5553
}

0 commit comments

Comments
 (0)