To begin using the OpenAPI Generator, follow these steps:
-
Install or download the latest OpenAPI Generator JAR file:
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.2.1/openapi-generator-cli-6.2.1.jar -O .openapi/generator/openapi-generator-cli.jar
-
Set the API version as an environmental variable:
API_VERSION="v1.39.0"
-
Download the specified version of the Meraki OpenAPI spec:
wget https://github.com/meraki/openapi/archive/refs/tags/$API_VERSION.zip && unzip -j $API_VERSION.zip '*/spec3.json'
Note: A few API endpoints had to be manually removed from the spec to avoid generator errors. Both the modified
spec3.json
and the original are included in this repository. -
Remove any existing client code:
rm -rf proto/
-
Run the code generator JAR:
java -jar .openapi/generator/openapi-generator-cli.jar generate \ -i spec3.json \ -g protobuf-schema \ -o ${PWD}/proto \ -p enumClassPrefix=true \ -p structPrefix=true
-
Cleanup the build files:
rm $API_VERSION.zip
You are now set up to generate protocol buffer schema files based on the Meraki OpenAPI specification.