This repo support a Github Action that creates a Pydantic model from Strava's Swagger API definition.
The script is run via a nightly cron job in this GitHub action. The action creates an new module called strava_model.py module that represents the most recent version of Strava's swagger.json file.
- First, make sure you have all of the necessary requirements installed. We are using the datamodel-code-generator package to generate the model.
pip install requirements.txt
- Once the requirements are installed, you are ready to run the script.
This module takes one input environment variable - the name of the
output module. You can either store this value as an environment variable
called MODEL_FILE
on your computer. Or you can define it in place as
follows:
# Run this in the terminal with your python environment activated
$ MODEL_FILE="output_model.py" python swagger2pydantic.py
In the example above, the script will run, creating a new module called output_model.py in your current working directory.