hashicorp / terraform-plugin-codegen-openapi

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

Add support for common parameters for resources and data sources #114

Closed randomswdev closed 6 months ago

randomswdev commented 6 months ago

The current parameters overriding logic has two flaws:

  1. The openapi specification allows to define "Common Parameters" for a path, that apply to all the operations (GET, PUT, ...). The openapi generator do not consider these parameters, but only the ones explicitly specified in an operation.
  2. It is currently impossible to associate a parameter to a nested attribute, like for example the name parameter of a kubernetes resource to the metadata.name attribute.

This pull request attempts to address both these issues.

randomswdev commented 6 months ago

Hi @austinvalle I simplified the pull request, keeping only the changes required for supporting Common Parameters. I added some tests for the new methods.

What do I have to do for the changelog and the docemantation?

randomswdev commented 6 months ago

@austinvalle

As you'll see below, I think the common parameters issue is pretty cut and dry, but I need some clarification on the "overriding nested attributes with parameters" issue that I think would be best discussed first in a GitHub issue before opening a PR.

I just opened an issue describing the problem and plan to submit later today a pull request containing just the related changes. The issue is: https://github.com/hashicorp/terraform-plugin-codegen-openapi/issues/117

austinvalle commented 6 months ago

Another note, the kubernetes spec was incorrectly not apart of the test suite, which I just added back in #121.

Your changes will likely update that golden file, so you'll want to run make testdata and commit the changes to your PR 👍🏻

randomswdev commented 6 months ago

@austinvalle I should have addressed all the review comments. Let me know if additional changes are required.

github-actions[bot] commented 1 month ago

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