@@ -26,7 +26,7 @@ describe('openapi-format core API', () => {
2626 expect ( result . data . tags ) . toEqual ( [ { name : 'pets' } ] ) ;
2727 } ) ;
2828
29- it ( 'openapiFilter inverseFlags + stripFlags currently removes previously kept operations after recurse ' , async ( ) => {
29+ it ( 'openapiFilter should keep inverseFlags-matched operations when stripFlags removes the same key ' , async ( ) => {
3030 const doc = {
3131 openapi : '3.0.0' ,
3232 info : { title : 'API' , version : '1.0.0' } ,
@@ -42,17 +42,28 @@ describe('openapi-format core API', () => {
4242 expect ( onlyInverse . data . paths ) . toHaveProperty ( '/pets.get' ) ;
4343
4444 const inverseAndStrip = await openapiFilter ( doc , { filterSet : { inverseFlags : [ 'x-public' ] , stripFlags : [ 'x-public' ] } } ) ;
45- expect ( inverseAndStrip . data . paths ) . toBeUndefined ( ) ;
45+ expect ( inverseAndStrip . data . paths ) . toHaveProperty ( '/pets.get' ) ;
46+ expect ( inverseAndStrip . data . paths [ '/pets' ] . get [ 'x-public' ] ) . toBeUndefined ( ) ;
47+ expect ( inverseAndStrip . data . paths [ '/pets' ] . post ) . toBeUndefined ( ) ;
4648 } ) ;
4749
48- it ( 'adding responses to unusedComponents does not change inverseFlags+stripFlags outcome ' , async ( ) => {
50+ it ( 'adding responses to unusedComponents should not remove still-referenced schemas ' , async ( ) => {
4951 const doc = {
5052 openapi : '3.0.0' ,
5153 info : { title : 'API' , version : '1.0.0' } ,
5254 paths : {
5355 '/pets' : {
54- get : { 'x-public' : true , responses : { '200' : { description : 'ok' } } } ,
55- post : { responses : { '200' : { description : 'ok' } } }
56+ get : {
57+ 'x-public' : true ,
58+ responses : {
59+ '200' : { description : 'ok' , content : { 'application/json' : { schema : { $ref : '#/components/schemas/Pet' } } } }
60+ }
61+ } ,
62+ post : {
63+ responses : {
64+ '200' : { description : 'ok' , content : { 'application/json' : { schema : { $ref : '#/components/schemas/Pet' } } } }
65+ }
66+ }
5667 }
5768 } ,
5869 components : {
@@ -73,7 +84,8 @@ describe('openapi-format core API', () => {
7384 const resultWithResponses = await openapiFilter ( doc , { filterSet : withResponses } ) ;
7485
7586 expect ( resultBase . data ) . toEqual ( resultWithResponses . data ) ;
76- expect ( resultWithResponses . data . paths ) . toBeUndefined ( ) ;
87+ expect ( resultWithResponses . data . paths ) . toHaveProperty ( '/pets.get' ) ;
88+ expect ( resultWithResponses . data . components . schemas ) . toHaveProperty ( 'Pet' ) ;
7789 } ) ;
7890
7991 it ( 'openapiChangeCase should apply summary, description and securitySchemes ref casing' , async ( ) => {
0 commit comments