File tree Expand file tree Collapse file tree 1 file changed +2
-19
lines changed
packages/react-openapi/src/models Expand file tree Collapse file tree 1 file changed +2
-19
lines changed Original file line number Diff line number Diff line change 1
- import { fromJSON , toJSON } from 'flatted' ;
2
-
3
1
import {
4
2
type Filesystem ,
5
3
type OpenAPIV3 ,
@@ -10,33 +8,18 @@ import {
10
8
import { memoDereferenceFilesystem } from '../resolveOpenAPIOperation' ;
11
9
import type { OpenAPIModelsData } from '../types' ;
12
10
13
- export { fromJSON , toJSON } ;
11
+ //!!TODO: We should return only the models that are used in the block. Still a WIP awaiting future work.
14
12
15
13
/**
16
14
* Resolve an OpenAPI models from a file and compile it to a more usable format.
17
15
* Models are extracted from the OpenAPI components.schemas
18
16
*/
19
17
export async function resolveOpenAPIModels (
20
18
filesystem : Filesystem < OpenAPIV3xDocument >
21
- // operationDescriptor: {
22
- // path: string;
23
- // method: string;
24
- // }
25
19
) : Promise < OpenAPIModelsData | null > {
26
- // const { path, method } = operationDescriptor;
27
20
const schema = await memoDereferenceFilesystem ( filesystem ) ;
28
21
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 ) ;
40
23
41
24
return { models } ;
42
25
}
You can’t perform that action at this time.
0 commit comments