File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,11 @@ export const buildRestOperations: OperationsBuilder<OpenAPIV3.Document> = async
6666
6767 const componentsHashMap = new Map < string , string > ( )
6868 for ( const path of Object . keys ( paths ) ) {
69+ // Validate path parameters: empty parameter names are not allowed
70+ if ( path . includes ( '{}' ) ) {
71+ throw new Error ( `Invalid path '${ path } ': path parameter name could not be empty` )
72+ }
73+
6974 const pathData = paths [ path ]
7075 if ( typeof pathData !== 'object' || ! pathData ) { continue }
7176
Original file line number Diff line number Diff line change 1717import { API_AUDIENCE_INTERNAL , API_KIND } from '../src'
1818import { Editor , LocalRegistry } from './helpers'
1919
20+ import { describe , test , expect } from '@jest/globals'
21+
2022const bugsPackage = LocalRegistry . openPackage ( 'bugs' )
2123const swaggerPackage = LocalRegistry . openPackage ( 'basic_swagger' )
2224const migrationBug = LocalRegistry . openPackage ( 'migration_bug' )
@@ -357,4 +359,16 @@ describe('Operation Bugs', () => {
357359 const operationKeys = Array . from ( result . operations . keys ( ) )
358360 expect ( operationKeys [ 0 ] ) . toEqual ( 'paths1-get' )
359361 } )
362+
363+ test ( 'Should throw error if path parameter name is empty' , async ( ) => {
364+ const pkg = LocalRegistry . openPackage ( 'empty-path-parameter' )
365+
366+ await expect ( pkg . publish ( pkg . packageId , {
367+ packageId : pkg . packageId ,
368+ version : 'v1' ,
369+ files : [
370+ { fileId : 'spec.json' } ,
371+ ] ,
372+ } ) ) . rejects . toThrow ( 'Invalid path \'/res/data/{}\': path parameter name could not be empty' )
373+ } )
360374} )
You can’t perform that action at this time.
0 commit comments