hashicorp / terraform-plugin-codegen-openapi

OpenAPI to Terraform Provider Code Generation Specification
Mozilla Public License 2.0
48 stars 6 forks source link

Cannot generate resources if provider is not defined #154

Open remyleone opened 3 months ago

remyleone commented 3 months ago

tfplugingen-openapi CLI version

$ tfplugingen-openapi --version
tfplugingen-openapi module: v0.3.0

OpenAPI Spec File

Not useful

Generator Config

resources:
  container:
    create:
      path: /containers/v1beta1/regions/{region}/containers
      method: post
    read:
      path: /containers/v1beta1/regions/{region}/containers/{container_id}
      method: get

Expected Behavior

I would expect only the resource files to be created

Actual Behavior

tfplugingen-openapi generate --config terraform_generator_config.yml --output ./generated/terraform/scaleway.containers.v1beta1.Api.json ./generated/scaleway-openapi/openapi/scaleway.containers.v1beta1.Api.yml
time=2024-03-28T16:42:15.314+01:00 level=ERROR msg="error executing command" err="error parsing generator config file: config validation error(s):\n\tprovider must have a 'name' property"
make: *** [tf-schemas] Error 1

Additional Information

I would like to have different files, that are targeting different part of the generation. We have many APIs and having everything bundled in a single file is not very interesting. Also if we are forced to declare provider definition while not being interested in the output it seems to be inefficient

Code of Conduct

bflad commented 2 months ago

Hi @remyleone 👋

The reason why the provider name is necessary in this tool's configuration is because that name is needed to generate the full resource type names, e.g. {provider}_{resource}.

Per the tool documentation, I believe you should only need:

provider:
  name: xxx

Not the full schema or anything. Can you please try that and let us know if you have further trouble? Thanks.