File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed
packages/react-openapi/src Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,10 @@ export async function resolveOpenAPIOperation(
55
55
}
56
56
}
57
57
58
- const components = flattenComponents ( schema ) ;
58
+ let components : OpenAPIOperationData [ 'components' ] = [ ] ;
59
+ if ( schema . components ) {
60
+ components = getOpenAPIComponents ( schema ) ;
61
+ }
59
62
60
63
return {
61
64
servers,
@@ -167,15 +170,10 @@ function flattenSecurities(security: OpenAPIV3.SecurityRequirementObject[]) {
167
170
} ) ;
168
171
}
169
172
170
- function flattenComponents (
173
+ function getOpenAPIComponents (
171
174
schema : OpenAPIV3 . Document | OpenAPIV3_1 . Document
172
175
) : [ string , OpenAPIV3 . SchemaObject ] [ ] {
173
- const components = Object . keys ( schema ?. components ?. schemas ?? { } ) . length
174
- ? schema ?. components ?. schemas
175
- : { } ;
176
-
177
- return Object . entries ( components ?? { } )
178
- . filter ( ( [ , schema ] ) => ! shouldIgnoreEntity ( schema ) )
179
- . sort ( ( a , b ) => a [ 0 ] . localeCompare ( b [ 0 ] ) )
180
- . map ( ( [ name , schema ] ) => [ name , schema ] ) ;
176
+ const schemas = schema . components ?. schemas ?? { } ;
177
+
178
+ return Object . entries ( schemas ) . filter ( ( [ , schema ] ) => ! shouldIgnoreEntity ( schema ) ) ;
181
179
}
You can’t perform that action at this time.
0 commit comments