@@ -623,7 +623,7 @@ test('/api/v1/docs should display index html with correct asset urls', async (t)
623623 t . plan ( 13 )
624624 const fastify = Fastify ( )
625625 await fastify . register ( fastifySwagger , swaggerOption )
626- await fastify . register ( fastifySwaggerUi , { prefix : '/api/v1/docs' , theme : { js : [ { filename : 'theme-js.js' } ] } } )
626+ await fastify . register ( fastifySwaggerUi , { routePrefix : '/api/v1/docs' , theme : { js : [ { filename : 'theme-js.js' } ] } } )
627627
628628 const res = await fastify . inject ( {
629629 method : 'GET' ,
@@ -750,3 +750,21 @@ test('/docs/ should display index html with correct asset urls when documentatio
750750 t . assert . strictEqual ( res . payload . includes ( 'href="./index.css"' ) , false )
751751 t . assert . strictEqual ( res . payload . includes ( 'src="./theme/theme-js.js"' ) , false )
752752} )
753+
754+ test ( 'should ignore prefix when register plugin' , async ( t ) => {
755+ t . plan ( 4 )
756+ const fastify = Fastify ( )
757+ await fastify . register ( fastifySwagger , swaggerOption )
758+ await fastify . register ( fastifySwaggerUi , { routePrefix : '/v1/documentation' , prefix : '/' } )
759+
760+ fastify . get ( '/' , ( ) => { } )
761+
762+ const res = await fastify . inject ( {
763+ method : 'GET' ,
764+ url : '/v1/documentation'
765+ } )
766+ t . assert . deepStrictEqual ( res . statusCode , 200 )
767+ t . assert . deepStrictEqual ( res . headers . location , undefined )
768+ t . assert . deepStrictEqual ( typeof res . payload , 'string' )
769+ t . assert . deepStrictEqual ( 'text/html; charset=utf-8' , res . headers [ 'content-type' ] )
770+ } )
0 commit comments