hashicorp / terraform-plugin-codegen-openapi

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

Petstore workflow example from code-gen documentation is generating incorrect schema #152

Closed austinvalle closed 3 months ago

austinvalle commented 3 months ago

Originally discovered here: https://discuss.hashicorp.com/t/sdk-provider-development-anyone-ever-used-code-generation-or-other-tools-to-simplify-their-provider-development/20301/8

tfplugingen-openapi CLI version

tfplugingen-openapi module: v0.3.0

OpenAPI Spec File

https://petstore3.swagger.io/api/v3/openapi.json

Generator Config

provider:
  name: petstore
resources:
  pet:
    create:
      path: /pet
      method: POST
    read:
      path: /pet/{petId}
      method: GET
    schema:
      attributes:
        aliases:
          petId: id

Expected Behavior

N/A

Actual Behavior

Recently, the swagger JSON example we use in our workflow example from https://petstore3.swagger.io/api/v3/openapi.json has been updated to include a couple recursions of the category property. This results in generating invalid provider code when attempting to build:

image

Apparently this is related to a known issue and is currently being investigated: https://github.com/swagger-api/swagger-petstore/issues/125

Additional Information

https://developer.hashicorp.com/terraform/plugin/code-generation/workflow-example#generate-pet-schema-from-openapi-spec

Code of Conduct

bflad commented 3 months ago

I am able to confirm that after the upstream updates yesterday, the workflow example steps are working again as-is. I'm not sure if you want to keep this issue open to potentially switch the example to a known-good petstore OpenAPI definition file URL, so I will not close this out myself.

austinvalle commented 3 months ago

I'm cool with keeping it as-is for now... If it breaks upstream again then we can reconsider 😆

github-actions[bot] commented 1 month ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.