Orange-OpenSource / angular-swagger-ui

An angularJS implementation of Swagger UI
http://orange-opensource.github.io/angular-swagger-ui/
MIT License
135 stars 74 forks source link

Make a copy of swagger input before modifying it #60

Closed zbriscoe closed 7 years ago

zbriscoe commented 7 years ago

Currently there are modifications being done to the swagger object being supplied via input. This can cause adverse affects if these objects are used outside of the directive. To solve this, make a copy of the swagger object in watchData().


For one of our projects, we have several swagger.json files. We navigate to each of them (one directive per swagger.json), and store a list of the swagger objects. As we switch back and forth between them, the directives get re-initialized with the swagger object that was previously modified. Every re-initialization appends tags and causes the operations in the resources to duplicate (which are then being displayed). By copying the input before modifying the tag list, we guarantee to keep the changes isolated.