11import { sortMethods } from '../../utils/sort' ;
22import { generateWorkflowSecurityInputs } from './generate-workflow-security-inputs' ;
3- import { type OperationMethod , type Workflow , type Step } from '../../types' ;
43import { generateWorkflowSecurityParameters } from './generate-workflow-security-parameters' ;
4+ import {
5+ type Oas3SecurityScheme ,
6+ type Oas3SecurityRequirement ,
7+ type Oas3PathItem ,
8+ type Oas3_1Schema ,
9+ type Oas3Operation ,
10+ } from 'core/src/typings/openapi' ;
11+ import { type OperationMethod , type Workflow , type Step } from '../../types' ;
12+ import {
13+ type ArazzoDefinition ,
14+ type ExtendedOperation ,
15+ } from '@redocly/openapi-core/lib/typings/arazzo' ;
16+
17+ type HttpMethod = Lowercase < ExtendedOperation [ 'method' ] > ;
518
619export type WorkflowsFromDescriptionInput = {
7- descriptionPaths : any ;
20+ descriptionPaths : {
21+ [ name : string ] : Oas3PathItem < Oas3_1Schema > & {
22+ connect ?: Oas3Operation < Oas3_1Schema > ;
23+ query ?: Oas3Operation < Oas3_1Schema > ;
24+ } ;
25+ } ;
826 sourceDescriptionName : string ;
9- rootSecurity : any ;
10- inputsComponents : any ;
11- securitySchemes : any ;
27+ rootSecurity : Oas3SecurityRequirement [ ] ;
28+ inputsComponents : NonNullable < ArazzoDefinition [ 'components' ] > ;
29+ securitySchemes : Record < string , Oas3SecurityScheme > ;
1230} ;
1331
1432export function generateWorkflowsFromDescription ( {
@@ -22,7 +40,7 @@ export function generateWorkflowsFromDescription({
2240
2341 for ( const pathItemKey in descriptionPaths ) {
2442 for ( const pathItemObjectKey of Object . keys ( descriptionPaths [ pathItemKey ] ) . sort ( sortMethods ) ) {
25- const methodToCheck = pathItemObjectKey . toLocaleLowerCase ( ) ;
43+ const methodToCheck = pathItemObjectKey . toLocaleLowerCase ( ) as HttpMethod ;
2644
2745 if (
2846 [
@@ -44,7 +62,7 @@ export function generateWorkflowsFromDescription({
4462 . split ( '/' )
4563 . join ( '-' ) ;
4664
47- const operation = descriptionPaths [ pathItemKey ] [ method ] ;
65+ const operation = descriptionPaths [ pathItemKey ] [ methodToCheck . toLowerCase ( ) as HttpMethod ] ;
4866 const operationSecurity = operation ?. security || undefined ;
4967 const operationId = operation ?. operationId || generateOperationId ( pathItemKey , method ) ;
5068 const workflowSecurityInputs = generateWorkflowSecurityInputs (
@@ -68,7 +86,7 @@ export function generateWorkflowsFromDescription({
6886 stepId : pathKey ? `${ method } -${ pathKey } -step` : `${ method } -step` ,
6987 operationId : `$sourceDescriptions.${ sourceDescriptionName } .${ operationId } ` ,
7088 ...generateParametersWithSuccessCriteria (
71- descriptionPaths [ pathItemKey ] [ method ] . responses
89+ descriptionPaths [ pathItemKey ] [ methodToCheck . toLowerCase ( ) as HttpMethod ] ? .responses
7290 ) ,
7391 } as unknown as Step ,
7492 ] ,
0 commit comments