Skip to content

Commit 53de768

Browse files
committed
Refactor resolveOpenAPIModels
1 parent 9e57dfe commit 53de768

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

packages/react-openapi/src/models/resolveOpenAPIModels.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { fromJSON, toJSON } from 'flatted';
2-
31
import {
42
type Filesystem,
53
type OpenAPIV3,
@@ -10,33 +8,18 @@ import {
108
import { memoDereferenceFilesystem } from '../resolveOpenAPIOperation';
119
import type { OpenAPIModelsData } from '../types';
1210

13-
export { fromJSON, toJSON };
11+
//!!TODO: We should return only the models that are used in the block. Still a WIP awaiting future work.
1412

1513
/**
1614
* Resolve an OpenAPI models from a file and compile it to a more usable format.
1715
* Models are extracted from the OpenAPI components.schemas
1816
*/
1917
export async function resolveOpenAPIModels(
2018
filesystem: Filesystem<OpenAPIV3xDocument>
21-
// operationDescriptor: {
22-
// path: string;
23-
// method: string;
24-
// }
2519
): Promise<OpenAPIModelsData | null> {
26-
// const { path, method } = operationDescriptor;
2720
const schema = await memoDereferenceFilesystem(filesystem);
2821

29-
if (
30-
!schema.components ||
31-
!schema.components.schemas ||
32-
!Object.keys(schema.components.schemas).length
33-
) {
34-
return null;
35-
}
36-
37-
let models: OpenAPIModelsData['models'] = [];
38-
39-
models = getOpenAPIComponents(schema);
22+
const models = getOpenAPIComponents(schema);
4023

4124
return { models };
4225
}

0 commit comments

Comments
 (0)