Skip to content

[Management] OpenAPI specs

Weidong Xu edited this page Sep 10, 2025 · 19 revisions

Generate SDK

Automation in azure-rest-api-specs

In PR on azure-rest-api-specs or azure-rest-api-specs-pr, it is easy to enable the automation for management SDK.

As resource provider, one only need to ensure - repo: azure-sdk-for-java is added to swagger-to-sdk yaml section in readme.md, so that Java SDK automation is enabled. Here is the sample readme.md.

Reference

Use Python script

A Python script in Azure SDK for Java can help generate a management SDK from OpenAPI specs.

Please see Working with AutoRest for the installation of autorest CLI. It also requires the installation of Node.js 16 or above, Java 11 or above, and Python 3.

Python package PyYAML and requests is required to be installed, e.g. via pip3 install --upgrade PyYAML requests.

As an example, if the spec is resourcegraph, one can call below command line to generate Java management SDK for it.

python eng/mgmt/automation/generate.py --readme=resourcegraph

This will generate or update the SDK under sdk/resourcegraph/azure-resourcemanager-resourcegraph.

--tag option can be used if one wish to use a specific tag in spec readme.

Use pipeline

There is an internal pipeline java - lite generation - mgmt, which calls the above Python script and create pull request of the generated SDK.

It takes similar input parameters as the script, e.g. README variable for readme option, TAG variable for tag option.

Test SDK

Local test

Build and install the package to your local maven repository. Run this in your project folder (e.g. under sdk/resourcegraph/azure-resourcemanager-resourcegraph).

mvn install

Then, create an empty Maven project

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-test-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

And follow the guidance in README.md (example) and SAMPLE.md (example) in project folder to test the SDK.

Add live test

Follow this guide to add live test that runs end-to-end for the service in CI.

Clone this wiki locally