@@ -426,7 +426,7 @@ public async Task SerializeAsV32JsonWithQueryAndAdditionalOperationsWorks()
426426 [ new HttpMethod ( "Query" ) ] = new OpenApiOperation
427427 {
428428 Summary = "query operation" ,
429- Description = "query description" ,
429+ Description = "query description" ,
430430 OperationId = "queryOperation" ,
431431 Responses = new OpenApiResponses
432432 {
@@ -440,7 +440,7 @@ public async Task SerializeAsV32JsonWithQueryAndAdditionalOperationsWorks()
440440 {
441441 Summary = "notify operation" ,
442442 Description = "notify description" ,
443- OperationId = "notifyOperation" ,
443+ OperationId = "notifyOperation" ,
444444 Responses = new OpenApiResponses
445445 {
446446 [ "200" ] = new OpenApiResponse
@@ -530,7 +530,7 @@ public async Task SerializeV32FeaturesAsExtensionsInV31Works()
530530 var pathItem = new OpenApiPathItem
531531 {
532532 Summary = "summary" ,
533- Description = "description" ,
533+ Description = "description" ,
534534 Operations = new Dictionary < HttpMethod , OpenApiOperation >
535535 {
536536 [ HttpMethod . Get ] = new OpenApiOperation
@@ -569,7 +569,7 @@ public async Task SerializeV32FeaturesAsExtensionsInV31Works()
569569 }
570570 }
571571 } ,
572-
572+
573573 }
574574 } ;
575575
@@ -589,7 +589,7 @@ public async Task SerializeV32FeaturesAsExtensionsInV3Works()
589589 {
590590 var pathItem = new OpenApiPathItem
591591 {
592- Summary = "summary" ,
592+ Summary = "summary" ,
593593 Description = "description" ,
594594 Operations = new Dictionary < HttpMethod , OpenApiOperation >
595595 {
@@ -749,4 +749,149 @@ public void CopyConstructorCopiesQueryAndAdditionalOperations()
749749
750750 Assert . Equal ( originalNotifyOp . Summary , copyNotifyOp . Summary ) ;
751751 }
752+
753+ [ Fact ]
754+ public async Task SerializeV32PathItemToV31ProducesExtensions ( )
755+ {
756+ // Arrange
757+ var pathItem = new OpenApiPathItem
758+ {
759+ Summary = "Test path" ,
760+ Operations = new Dictionary < HttpMethod , OpenApiOperation >
761+ {
762+ [ HttpMethod . Get ] = new OpenApiOperation
763+ {
764+ Summary = "Get operation" ,
765+ OperationId = "getOp" ,
766+ Responses = new OpenApiResponses
767+ {
768+ [ "200" ] = new OpenApiResponse { Description = "Success" }
769+ }
770+ } ,
771+ [ new HttpMethod ( "Query" ) ] = new OpenApiOperation
772+ {
773+ Summary = "Query operation" ,
774+ OperationId = "queryOp" ,
775+ Responses = new OpenApiResponses
776+ {
777+ [ "200" ] = new OpenApiResponse { Description = "Success" }
778+ }
779+ } ,
780+ [ new HttpMethod ( "notify" ) ] = new OpenApiOperation
781+ {
782+ Summary = "Notify operation" ,
783+ OperationId = "notifyOp" ,
784+ Responses = new OpenApiResponses
785+ {
786+ [ "200" ] = new OpenApiResponse { Description = "Success" }
787+ }
788+ }
789+ }
790+ } ;
791+
792+ // Act
793+ var yaml = await pathItem . SerializeAsYamlAsync ( OpenApiSpecVersion . OpenApi3_1 ) ;
794+
795+ // Assert
796+ Assert . Contains ( "Query:" , yaml ) ;
797+ Assert . Contains ( "x-oai-additionalOperations:" , yaml ) ;
798+ Assert . Contains ( "queryOp" , yaml ) ;
799+ Assert . Contains ( "notifyOp" , yaml ) ;
800+ }
801+
802+ [ Fact ]
803+ public async Task SerializeV32PathItemToV3ProducesExtensions ( )
804+ {
805+ // Arrange
806+ var pathItem = new OpenApiPathItem
807+ {
808+ Summary = "Test path" ,
809+ Operations = new Dictionary < HttpMethod , OpenApiOperation >
810+ {
811+ [ HttpMethod . Get ] = new OpenApiOperation
812+ {
813+ Summary = "Get operation" ,
814+ OperationId = "getOp" ,
815+ Responses = new OpenApiResponses
816+ {
817+ [ "200" ] = new OpenApiResponse { Description = "Success" }
818+ }
819+ } ,
820+ [ new HttpMethod ( "Query" ) ] = new OpenApiOperation
821+ {
822+ Summary = "Query operation" ,
823+ OperationId = "queryOp" ,
824+ Responses = new OpenApiResponses
825+ {
826+ [ "200" ] = new OpenApiResponse { Description = "Success" }
827+ }
828+ } ,
829+ [ new HttpMethod ( "notify" ) ] = new OpenApiOperation
830+ {
831+ Summary = "Notify operation" ,
832+ OperationId = "notifyOp" ,
833+ Responses = new OpenApiResponses
834+ {
835+ [ "200" ] = new OpenApiResponse { Description = "Success" }
836+ }
837+ }
838+ }
839+ } ;
840+
841+ // Act
842+ var yaml = await pathItem . SerializeAsYamlAsync ( OpenApiSpecVersion . OpenApi3_0 ) ;
843+
844+ // Assert
845+ Assert . Contains ( "Query:" , yaml ) ;
846+ Assert . Contains ( "x-oai-additionalOperations:" , yaml ) ;
847+ Assert . Contains ( "queryOp" , yaml ) ;
848+ Assert . Contains ( "notifyOp" , yaml ) ;
849+ }
850+
851+ [ Fact ]
852+ public void PathItemShallowCopyIncludesV32Fields ( )
853+ {
854+ // Arrange
855+ var original = new OpenApiPathItem
856+ {
857+ Summary = "Original" ,
858+ Operations = new Dictionary < HttpMethod , OpenApiOperation >
859+ {
860+ [ HttpMethod . Get ] = new OpenApiOperation
861+ {
862+ Summary = "Get operation" ,
863+ OperationId = "getOp" ,
864+ Responses = new OpenApiResponses ( )
865+ } ,
866+ [ new HttpMethod ( "Query" ) ] = new OpenApiOperation
867+ {
868+ Summary = "Query operation" ,
869+ OperationId = "queryOp"
870+ } ,
871+ [ new HttpMethod ( "notify" ) ] = new OpenApiOperation
872+ {
873+ Summary = "Notify operation" ,
874+ OperationId = "notifyOp"
875+ }
876+ }
877+ } ;
878+
879+ // Act
880+ var copy = original . CreateShallowCopy ( ) ;
881+
882+ // Assert
883+ Assert . NotNull ( original . Operations ) ;
884+ Assert . NotNull ( copy . Operations ) ;
885+ Assert . Contains ( HttpMethod . Get , original . Operations ) ;
886+ Assert . Contains ( HttpMethod . Get , copy . Operations ) ;
887+
888+ var copyQueryOp = Assert . Contains ( new HttpMethod ( "Query" ) , copy . Operations ) ;
889+ Assert . Contains ( new HttpMethod ( "Query" ) , original . Operations ) ;
890+ Assert . Equal ( "Query operation" , copyQueryOp . Summary ) ;
891+ Assert . Equal ( "queryOp" , copyQueryOp . OperationId ) ;
892+ Assert . Contains ( new HttpMethod ( "notify" ) , original . Operations ) ;
893+ var copyNotifyOp = Assert . Contains ( new HttpMethod ( "notify" ) , copy . Operations ) ;
894+ Assert . Equal ( "Notify operation" , copyNotifyOp . Summary ) ;
895+ Assert . Equal ( "notifyOp" , copyNotifyOp . OperationId ) ;
896+ }
752897}
0 commit comments