This script processes a OAS file, recursively downloads and updates its dependencies specified by $ref URLs, and saves the modified Swagger file.
- Python 3
requestslibrary (install usingpip install requests)
-
Clone the repository:
git clone https://github.com/yourusername/your-repository.git cd your-repository -
Install the required dependencies:
pip install requests
-
Run the script:
python your_script_name.py
-
The script will process the main Swagger file and its dependencies, downloading any missing files, updating
$refURLs, and saving the modified Swagger file.
-
Input: The main Swagger file should be named
swaggerfile.jsonand placed in the same directory as the script. Update the script if your main file has a different name or location. -
Output: The modified Swagger file will be saved in the
local_dependenciesfolder. If this folder doesn't exist, it will be created.
-
The script processes
$refURLs that start withhttp. If your Swagger file uses a different prefix, modify theprocess_referencefunction accordingly. -
The downloaded files are saved with relative paths in the
local_dependenciesfolder, except for the main Swagger file that uses/local_dependenciesprefix.