|
1 | | -# terraform-plugin-codegen-openapi |
| 1 | +# OpenAPI Provider Spec Generator |
2 | 2 |
|
3 | | -_Experimental: This code is under active development and not intended for production usage._ |
| 3 | +> _[Terraform Provider Code Generation](https://developer.hashicorp.com/terraform/plugin/code-generation) is currently in tech preview._ |
4 | 4 |
|
5 | | -## Running an example spec |
6 | | -```sh |
7 | | -make build |
| 5 | +## Overview |
8 | 6 |
|
9 | | -# Pass generator config to --config and OpenAPI spec (JSON or YML) as positional argument |
10 | | -# Outputs to STDOUT |
11 | | -./tfplugingen-openapi generate --config ./internal/cmd/testdata/petstore3/tfopenapigen_config.yml ./internal/cmd/testdata/petstore3/openapi_spec.json |
| 7 | +The OpenAPI Provider Spec Generator is a CLI tool that transforms an [OpenAPI 3.x](https://www.openapis.org/) Specification (OAS) into a [Provider Code Specification](https://developer.hashicorp.com/terraform/plugin/code-generation/specification). |
| 8 | + |
| 9 | +A Provider Code Specification can be used to generate [Terraform Provider](https://developer.hashicorp.com/terraform/plugin) code, for example, with the [Plugin Framework Code Generator](https://developer.hashicorp.com/terraform/plugin/code-generation/framework-generator). |
| 10 | + |
| 11 | +## Documentation |
| 12 | + |
| 13 | +Full usage info, examples, and config file documentation live on the HashiCorp developer site: https://developer.hashicorp.com/terraform/plugin/code-generation/openapi-generator |
| 14 | + |
| 15 | +For more in-depth details about the design and internals of the OpenAPI Provider Spec Generator, see [`DESIGN.md`](./DESIGN.md). |
| 16 | + |
| 17 | +## Usage |
| 18 | + |
| 19 | +### Installation |
| 20 | + |
| 21 | +The CLI tool can be installed with the Go toolchain, via go install: |
| 22 | + |
| 23 | +```shell-session |
| 24 | +go install github.com/hashicorp/terraform-plugin-codegen-openapi/cmd/tfplugingen-openapi@latest |
| 25 | +``` |
| 26 | + |
| 27 | +### Generate |
| 28 | + |
| 29 | +The primary `generate` command requires a [generator config](https://developer.hashicorp.com/terraform/plugin/code-generation/openapi-generator#generator-config) and an OpenAPI 3.x specification: |
| 30 | + |
| 31 | +```shell-session |
| 32 | +tfplugingen-openapi generate \ |
| 33 | + --config <path/to/generator_config.yml> \ |
| 34 | + --output <output/for/provider_code_spec.json> \ |
| 35 | + <path/to/openapi_spec.json> |
12 | 36 | ``` |
| 37 | + |
| 38 | +### Examples |
| 39 | + |
| 40 | +Example generator configs, OpenAPI specifications, and Provider Code Specification output can be found in the [`./internal/cmd/testdata/`](./internal/cmd/testdata/) folder. Here is an example running `petstore3`, built from source: |
| 41 | + |
| 42 | +```shell-session |
| 43 | +go run ./cmd/tfplugingen-openapi generate \ |
| 44 | + --config ./internal/cmd/testdata/petstore3/generator_config.yml \ |
| 45 | + --output ./internal/cmd/testdata/petstore3/provider_code_spec.json \ |
| 46 | + ./internal/cmd/testdata/petstore3/openapi_spec.json |
| 47 | +``` |
| 48 | + |
| 49 | +## License |
| 50 | + |
| 51 | +Refer to [Mozilla Public License v2.0](./LICENSE). |
0 commit comments