Skip to content

stackql/stackql-azure-openapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure OpenAPI Doc Generator

Generates a single OpenAPI document for each Azure Resource Manager service from a set of OpenAPI specifications sourced from azure-rest-api-specs.

This project uses autorest via JavaScript to emit the latest set of OpenAPI specifications for each service, then dereferences and combines the documents into a single YAML OpenAPI specification using APIDevTools/json-schema-ref-parser.

a complete set of specs for each service is available here

a set of specs for each service used to generate the azure and azure_extras stackql provider is available here

Usage

use the prereq.sh script or the equivalent to download the latest api documentation from azure-rest-api-specs

use run.sh script or the equivalent to run all the stackql-azure-openapi commands in a batch

The main entrypoint to the program is:

bin/stackql-azure-openapi

This can be run without any arguments to get command line usage and help. The stackql-azure-openapi commands include:

  • generate : uses autorest to generate initial OpenAPI3 specs for one or many services
  • dereference : dereferences all external JSON pointers in the generated OpenAPI specs
  • combine : combines all the generated OpenAPI specs into a single OpenAPI spec
  • tag : replaces existing tags for operations with the stackql resource name (optional)

These commands are intended to be run in sequence with the output of each command being the input to the next. The flow is summarized below:

IMAGE

stackql_azure_openapi

Specific details about each command are provided in the sections below.

generate command

Uses autorest to generate initial OpenAPI3 specs for one or many services using the autorest configuration data in the readme.md in each service specification directory from the main branch of the azure-rest-api-specs repo. Conceptually this would be similar to running the following command in each subdirectory of the specification folder:

autorest ./resource-manager/readme.md \
--openapi-type=arm \
--output-converted-oai3

The output of this command is a directory structure (n-levels deep) containing OpenAPI JSON documents with references to each other (using JSON $refs), the union of which forms a complete specification for the service.

To generate specs for a single service (the compute service in this example), run the following command:

bin/stackql-azure-openapi generate compute

To generate specs for all services, run the following command:

bin/stackql-azure-openapi generate

dereference command

Takes the output from the generated command, enumerates all JSON documents nested at any level in the directory structure, and dereferences all JSON pointers in each document, outputting a flat structure containing a document for each generated document found for each service with no external references.

To dereference a set of autorest generated specs for a single service (the compute service in this example), run the following command:

bin/stackql-azure-openapi dereference compute

To dereference specs for all services, run the following command:

bin/stackql-azure-openapi dereference

combine command

Takes the output from the dereference command, and combines all the generated documents into a single OpenAPI spec, outputting a single, self contained YAML document (removing the examples for brevity).

To create a single OpenAPI document for a single service (the compute service in this example), run the following command:

bin/stackql-azure-openapi combine compute

To create a single OpenAPI document for all services, run the following command:

bin/stackql-azure-openapi combine

tag command (Optional)

Takes the output from the combine command, generates the stackql resource name from stemming the operationId for each operation, pushes this value to the beginning of the tags array for each operation, and outputs the resulting document.

To update tags for a single OpenAPI document for a single service (the compute service in this example), run the following command:

bin/stackql-azure-openapi tag compute

To tags fo all OpenAPI documents for all services, run the following command:

bin/stackql-azure-openapi tag

About

Generates a single OpenAPI document for each Azure Resource Manager service from a set of OpenAPI specifications sourced from Azure REST API specs

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages