@@ -766,6 +766,35 @@ describe('api-publisher', () => {
766766 expect ( totalTasks ) . toBe ( 2 ) ;
767767 } ) ;
768768
769+ it ( 'should still re-publish explicitly named schemas in incremental mode after spec import' , async ( ) => {
770+ const client = createMockClient ( ) ;
771+ // 'my-explicit-schema' is not a 24-char hex ID so it must be re-published
772+ const children = [
773+ { type : ResourceType . ApiSchema , nameParts : [ 'petstore' , 'my-explicit-schema' ] } ,
774+ { type : ResourceType . ApiSchema , nameParts : [ 'petstore' , '69f15c3c10a45d29d855583a' ] } ,
775+ ] ;
776+ const store = createMockStore ( children ) ;
777+ store . readResource . mockImplementation ( async ( _dir : string , descriptor : ResourceDescriptor ) => {
778+ if ( descriptor . type === ResourceType . Api ) {
779+ return { name : 'petstore' , properties : { path : 'petstore' } } ;
780+ }
781+ return null ;
782+ } ) ;
783+ store . readContent . mockResolvedValue ( { content : 'openapi: "3.0.0"' , format : 'yaml' } ) ;
784+
785+ const apiDescriptor : ResourceDescriptor = { type : ResourceType . Api , nameParts : [ 'petstore' ] } ;
786+ const incrementalConfig : PublishConfig = { ...testConfig , commitId : 'abc123' } ;
787+
788+ await publishApi ( client , store , testContext , apiDescriptor , incrementalConfig ) ;
789+
790+ // Only the explicit schema should be published (auto-generated hex ID is skipped)
791+ const totalTasks = mockRunParallel . mock . calls . reduce ( ( sum , call ) => {
792+ const tasks = call [ 0 ] as unknown [ ] ;
793+ return sum + tasks . length ;
794+ } , 0 ) ;
795+ expect ( totalTasks ) . toBe ( 1 ) ;
796+ } ) ;
797+
769798 it ( 'should not re-publish schema-reference operations in incremental mode after spec import' , async ( ) => {
770799 const client = createMockClient ( ) ;
771800 const children = [
@@ -891,6 +920,20 @@ describe('api-publisher', () => {
891920 expect ( totalTasks ) . toBe ( 3 ) ;
892921 } ) ;
893922
923+ it ( 'should return skipped when root API resource file does not exist' , async ( ) => {
924+ const client = createMockClient ( ) ;
925+ const store = createMockStore ( [ ] ) ;
926+ store . readResource . mockResolvedValue ( null ) ;
927+ store . readContent . mockResolvedValue ( { content : 'openapi: "3.0.0"' , format : 'yaml' } ) ;
928+
929+ const apiDescriptor : ResourceDescriptor = { type : ResourceType . Api , nameParts : [ 'missing-api' ] } ;
930+
931+ const result = await publishApi ( client , store , testContext , apiDescriptor , testConfig ) ;
932+
933+ expect ( result . status ) . toBe ( 'skipped' ) ;
934+ expect ( client . putResource ) . not . toHaveBeenCalled ( ) ;
935+ } ) ;
936+
894937 it ( 'should not inject spec for GraphQL format' , async ( ) => {
895938 const client = createMockClient ( ) ;
896939 const children = [
0 commit comments