@@ -189,10 +189,7 @@ export type operations = Record<string, never>;
189
189
"/post/{id}" : {
190
190
get : {
191
191
operationId : "getPost" ,
192
- parameters : [
193
- { name : "format" , in : "query" , schema : { type : "string" } } ,
194
- { $ref : "#/components/parameters/post_id" } ,
195
- ] ,
192
+ parameters : [ { name : "format" , in : "query" , schema : { type : "string" } } , { $ref : "#/components/parameters/post_id" } ] ,
196
193
responses : {
197
194
200 : {
198
195
description : "OK" ,
@@ -447,11 +444,7 @@ export type operations = Record<string, never>;
447
444
components : {
448
445
schemas : {
449
446
Pet : {
450
- oneOf : [
451
- { $ref : "#/components/schemas/Cat" } ,
452
- { $ref : "#/components/schemas/Dog" } ,
453
- { $ref : "#/components/schemas/Lizard" } ,
454
- ] ,
447
+ oneOf : [ { $ref : "#/components/schemas/Cat" } , { $ref : "#/components/schemas/Dog" } , { $ref : "#/components/schemas/Lizard" } ] ,
455
448
discriminator : {
456
449
propertyName : "petType" ,
457
450
mapping : {
@@ -539,10 +532,7 @@ export type operations = Record<string, never>;
539
532
} ,
540
533
} ,
541
534
AllOf : {
542
- allOf : [
543
- { $ref : "#/components/schemas/Entity/properties/foo" } ,
544
- { $ref : "#/components/schemas/Thingy/properties/bar" } ,
545
- ] ,
535
+ allOf : [ { $ref : "#/components/schemas/Entity/properties/foo" } , { $ref : "#/components/schemas/Thingy/properties/bar" } ] ,
546
536
} ,
547
537
} ,
548
538
} ,
@@ -730,7 +720,7 @@ export type operations = Record<string, never>;
730
720
} ,
731
721
put : {
732
722
parameters : [ { name : "user_id" , in : "path" } ] ,
733
- }
723
+ } ,
734
724
} ,
735
725
} ,
736
726
} ;
@@ -982,6 +972,30 @@ export type operations = Record<string, never>;
982
972
} ) ;
983
973
} ) ;
984
974
975
+ it ( "does not mutate original reference" , async ( ) => {
976
+ const schema : OpenAPI3 = {
977
+ openapi : "3.1" ,
978
+ info : { title : "test" , version : "1.0" } ,
979
+ components : { } ,
980
+ paths : {
981
+ "/" : {
982
+ get : {
983
+ responses : {
984
+ 200 : {
985
+ description : "ok" ,
986
+ $ref : "#/components/schemas/OKResponse" ,
987
+ } ,
988
+ } ,
989
+ } ,
990
+ } ,
991
+ } ,
992
+ } ;
993
+ const before = JSON . stringify ( schema ) ;
994
+ await openapiTS ( schema ) ;
995
+ const after = JSON . stringify ( schema ) ;
996
+ expect ( before ) . toBe ( after ) ;
997
+ } ) ;
998
+
985
999
// note: this tests the Node API; the snapshots in cli.test.ts test the CLI
986
1000
describe ( "snapshots" , ( ) => {
987
1001
const EXAMPLES_DIR = new URL ( "../examples/" , import . meta. url ) ;
0 commit comments