New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The plugin has issue with id field. It marks all id fields as readonly #335
Comments
Hi @komalkadam-dc 👋 Thank you for reporting this issue and sorry for the trouble here. Looking at the internal logic, there is some special handling for |
Reference: #335 Previously, the automatic `id` attribute handling intended for root level schema blocks was applied to all blocks, causing the generator to errantly set the grouping to `Read-Only` and the description to `The ID of this resource`. This was captured via a new integration test: ``` --- FAIL: Test_SchemaJson_GenerateAcceptanceTests (0.00s) --- FAIL: Test_SchemaJson_GenerateAcceptanceTests/nested_id_attribute (0.25s) testscript.go:558: # Copyright (c) HashiCorp, Inc. # SPDX-License-Identifier: MPL-2.0 # Ensure only root level id attribute receives automatic description (0.236s) > [!unix] skip > exec tfplugindocs --provider-name=terraform-provider-scaffolding --providers-schema=schema.json [stdout] rendering website for provider "terraform-provider-scaffolding" (as "terraform-provider-scaffolding") exporting schema from JSON file getting provider schema generating missing templates generating missing resource content generating new template for "scaffolding_example" generating missing data source content generating missing function content generating missing provider content generating new template for "terraform-provider-scaffolding" rendering static website cleaning rendered website dir rendering templated website to static markdown rendering "index.md.tmpl" rendering "resources/example.md.tmpl" > cmp stdout expected-output.txt > cmp docs/index.md expected-index.md > cmp docs/resources/example.md expected-resource.md diff docs/resources/example.md expected-resource.md --- docs/resources/example.md +++ expected-resource.md @@ -48,17 +48,17 @@ <a id="nestedblock--list_nested_block_optional_id"></a> ### Nested Schema for `list_nested_block_optional_id` -Read-Only: - -- `id` (String) The ID of this resource. +Optional: + +- `id` (String) <a id="nestedblock--list_nested_block_required_id"></a> ### Nested Schema for `list_nested_block_required_id` -Read-Only: - -- `id` (String) The ID of this resource. +Required: + +- `id` (String) <a id="nestedatt--optional_object_attribute"></a> @@ -72,33 +72,33 @@ <a id="nestedblock--set_nested_block_optional_id"></a> ### Nested Schema for `set_nested_block_optional_id` -Read-Only: - -- `id` (String) The ID of this resource. +Optional: + +- `id` (String) <a id="nestedblock--set_nested_block_required_id"></a> ### Nested Schema for `set_nested_block_required_id` -Read-Only: - -- `id` (String) The ID of this resource. +Required: + +- `id` (String) <a id="nestedblock--single_nested_block_optional_id"></a> ### Nested Schema for `single_nested_block_optional_id` -Read-Only: - -- `id` (String) The ID of this resource. +Optional: + +- `id` (String) <a id="nestedblock--single_nested_block_required_id"></a> ### Nested Schema for `single_nested_block_required_id` -Read-Only: - -- `id` (String) The ID of this resource. +Required: + +- `id` (String) <a id="nestedatt--computed_object_attribute"></a> @@ -114,7 +114,7 @@ Read-Only: -- `id` (String) The ID of this resource. +- `id` (String) <a id="nestedblock--set_nested_block_computed_id"></a> @@ -122,7 +122,7 @@ Read-Only: -- `id` (String) The ID of this resource. +- `id` (String) <a id="nestedblock--single_nested_block_computed_id"></a> @@ -130,4 +130,4 @@ Read-Only: -- `id` (String) The ID of this resource. +- `id` (String) FAIL: testdata/scripts/schema-json/generate/nested_id_attribute.txtar:9: docs/resources/example.md and expected-resource.md differ ``` The schema rendering logic could likely use a full refactoring as it has very high code complexity, but this change is only a very targeted fix for the acute and errant `id` attribute handling behavior.
Reference: #335 Previously, the automatic `id` attribute handling intended for root level schema blocks was applied to all blocks, causing the generator to errantly set the grouping to `Read-Only` and the description to `The ID of this resource`. This was captured via a new integration test: ``` --- FAIL: Test_SchemaJson_GenerateAcceptanceTests (0.00s) --- FAIL: Test_SchemaJson_GenerateAcceptanceTests/nested_id_attribute (0.25s) testscript.go:558: # Copyright (c) HashiCorp, Inc. # SPDX-License-Identifier: MPL-2.0 # Ensure only root level id attribute receives automatic description (0.236s) > [!unix] skip > exec tfplugindocs --provider-name=terraform-provider-scaffolding --providers-schema=schema.json [stdout] rendering website for provider "terraform-provider-scaffolding" (as "terraform-provider-scaffolding") exporting schema from JSON file getting provider schema generating missing templates generating missing resource content generating new template for "scaffolding_example" generating missing data source content generating missing function content generating missing provider content generating new template for "terraform-provider-scaffolding" rendering static website cleaning rendered website dir rendering templated website to static markdown rendering "index.md.tmpl" rendering "resources/example.md.tmpl" > cmp stdout expected-output.txt > cmp docs/index.md expected-index.md > cmp docs/resources/example.md expected-resource.md diff docs/resources/example.md expected-resource.md --- docs/resources/example.md +++ expected-resource.md @@ -48,17 +48,17 @@ <a id="nestedblock--list_nested_block_optional_id"></a> ### Nested Schema for `list_nested_block_optional_id` -Read-Only: - -- `id` (String) The ID of this resource. +Optional: + +- `id` (String) <a id="nestedblock--list_nested_block_required_id"></a> ### Nested Schema for `list_nested_block_required_id` -Read-Only: - -- `id` (String) The ID of this resource. +Required: + +- `id` (String) <a id="nestedatt--optional_object_attribute"></a> @@ -72,33 +72,33 @@ <a id="nestedblock--set_nested_block_optional_id"></a> ### Nested Schema for `set_nested_block_optional_id` -Read-Only: - -- `id` (String) The ID of this resource. +Optional: + +- `id` (String) <a id="nestedblock--set_nested_block_required_id"></a> ### Nested Schema for `set_nested_block_required_id` -Read-Only: - -- `id` (String) The ID of this resource. +Required: + +- `id` (String) <a id="nestedblock--single_nested_block_optional_id"></a> ### Nested Schema for `single_nested_block_optional_id` -Read-Only: - -- `id` (String) The ID of this resource. +Optional: + +- `id` (String) <a id="nestedblock--single_nested_block_required_id"></a> ### Nested Schema for `single_nested_block_required_id` -Read-Only: - -- `id` (String) The ID of this resource. +Required: + +- `id` (String) <a id="nestedatt--computed_object_attribute"></a> @@ -114,7 +114,7 @@ Read-Only: -- `id` (String) The ID of this resource. +- `id` (String) <a id="nestedblock--set_nested_block_computed_id"></a> @@ -122,7 +122,7 @@ Read-Only: -- `id` (String) The ID of this resource. +- `id` (String) <a id="nestedblock--single_nested_block_computed_id"></a> @@ -130,4 +130,4 @@ Read-Only: -- `id` (String) The ID of this resource. +- `id` (String) FAIL: testdata/scripts/schema-json/generate/nested_id_attribute.txtar:9: docs/resources/example.md and expected-resource.md differ ``` The schema rendering logic could likely use a full refactoring as it has very high code complexity, but this change is only a very targeted fix for the acute and errant `id` attribute handling behavior.
Terraform CLI and terraform-plugin-docs Versions
terraform version Terraform v1.6.6 on darwin_arm64
github.com/hashicorp/terraform-plugin-docs v0.18.0
Provider Code
Expected Behavior
Marking the fields
id
as read only even if the are nestedhttps://registry.terraform.io/providers/duplocloud/duplocloud/latest/docs/resources/plan_certificates#id
Actual Behavior
https://registry.terraform.io/providers/duplocloud/duplocloud/latest/docs/resources/plan_certificates#id
Steps to Reproduce
tfplugindocs generate --flags
How much impact is this issue causing?
Low
Logs
No response
Additional Information
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: