diff --git a/.changes/unreleased/BUG FIXES-20240417-171709.yaml b/.changes/unreleased/BUG FIXES-20240417-171709.yaml new file mode 100644 index 00000000..601ad09a --- /dev/null +++ b/.changes/unreleased/BUG FIXES-20240417-171709.yaml @@ -0,0 +1,6 @@ +kind: BUG FIXES +body: 'generate: fixed a bug where attribute titles were not being generated for nested + object attributes' +time: 2024-04-17T17:17:09.035512-04:00 +custom: + Issue: "357" diff --git a/cmd/tfplugindocs/testdata/scripts/schema-json/generate/framework_provider_success_all_framework_types.txtar b/cmd/tfplugindocs/testdata/scripts/schema-json/generate/framework_provider_success_all_framework_types.txtar new file mode 100644 index 00000000..040d727b --- /dev/null +++ b/cmd/tfplugindocs/testdata/scripts/schema-json/generate/framework_provider_success_all_framework_types.txtar @@ -0,0 +1,638 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +# Successful run of tfplugindocs on a Framework provider with a resource and function schema containing all framework types +[!unix] skip +exec tfplugindocs --provider-name=terraform-provider-scaffolding --providers-schema=schema.json +cmp stdout expected-output.txt +cmp docs/index.md expected-index.md +cmp docs/resources/example.md expected-resource.md +cmp docs/functions/scaffolding.md expected-function.md + +-- expected-output.txt -- +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 new template for function "scaffolding" +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 "functions/scaffolding.md.tmpl" +rendering "index.md.tmpl" +rendering "resources/example.md.tmpl" +-- expected-index.md -- +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "scaffolding Provider" +subcategory: "" +description: |- + Example provider +--- + +# scaffolding Provider + +Example provider + + + + +## Schema + +### Optional + +- `endpoint` (String) Example provider attribute +-- expected-resource.md -- +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "scaffolding_example Resource - terraform-provider-scaffolding" +subcategory: "" +description: |- + example resource +--- + +# scaffolding_example (Resource) + +example resource + + + + +## Schema + +### Optional + +- `bool_attribute` (Boolean) example bool attribute +- `float64_attribute` (Number) example float64 attribute +- `int64_attribute` (Number) example int64 attribute +- `list_attribute` (List of String) example list attribute +- `list_nested_block` (Block List) example list nested block (see [below for nested schema](#nestedblock--list_nested_block)) +- `list_nested_block_sensitive_nested_attribute` (Block List) (see [below for nested schema](#nestedblock--list_nested_block_sensitive_nested_attribute)) +- `map_attribute` (Map of String) example map attribute +- `number_attribute` (Number) example number attribute +- `object_attribute` (Object) example object attribute (see [below for nested schema](#nestedatt--object_attribute)) +- `object_attribute_with_nested_object_attribute` (Object) example object attribute with nested object attribute (see [below for nested schema](#nestedatt--object_attribute_with_nested_object_attribute)) +- `sensitive_bool_attribute` (Boolean, Sensitive) example sensitive bool attribute +- `sensitive_float64_attribute` (Number, Sensitive) example sensitive float64 attribute +- `sensitive_int64_attribute` (Number, Sensitive) example sensitive int64 attribute +- `sensitive_list_attribute` (List of String, Sensitive) example sensitive list attribute +- `sensitive_map_attribute` (Map of String, Sensitive) example sensitive map attribute +- `sensitive_number_attribute` (Number, Sensitive) example sensitive number attribute +- `sensitive_object_attribute` (Object, Sensitive) example sensitive object attribute (see [below for nested schema](#nestedatt--sensitive_object_attribute)) +- `sensitive_set_attribute` (Set of String, Sensitive) example sensitive set attribute +- `sensitive_string_attribute` (String, Sensitive) example sensitive string attribute +- `set_attribute` (Set of String) example set attribute +- `set_nested_block` (Block Set) example set nested block (see [below for nested schema](#nestedblock--set_nested_block)) +- `single_nested_block` (Block, Optional) example single nested block (see [below for nested schema](#nestedblock--single_nested_block)) +- `single_nested_block_sensitive_nested_attribute` (Block, Optional) example sensitive single nested block (see [below for nested schema](#nestedblock--single_nested_block_sensitive_nested_attribute)) +- `string_attribute` (String) example string attribute + +### Read-Only + +- `id` (String) The ID of this resource. +- `set_nested_block_sensitive_nested_attribute` (Block Set) example sensitive set nested block (see [below for nested schema](#nestedblock--set_nested_block_sensitive_nested_attribute)) + + +### Nested Schema for `list_nested_block` + +Optional: + +- `list_nested_block_attribute` (String) example list nested block attribute +- `list_nested_block_attribute_with_default` (String) example list nested block attribute with default +- `nested_list_block` (Block List) (see [below for nested schema](#nestedblock--list_nested_block--nested_list_block)) + + +### Nested Schema for `list_nested_block.nested_list_block` + +Optional: + +- `nested_block_string_attribute` (String) example nested block string attribute + + + + +### Nested Schema for `list_nested_block_sensitive_nested_attribute` + +Optional: + +- `list_nested_block_attribute` (String) example list nested block attribute +- `list_nested_block_sensitive_attribute` (String, Sensitive) example sensitive list nested block attribute + + + +### Nested Schema for `object_attribute` + +Optional: + +- `object_attribute_attribute` (String) + + + +### Nested Schema for `object_attribute_with_nested_object_attribute` + +Optional: + +- `nested_object` (Object) (see [below for nested schema](#nestedobjatt--object_attribute_with_nested_object_attribute--nested_object)) +- `object_attribute_attribute` (String) + + +### Nested Schema for `object_attribute_with_nested_object_attribute.nested_object` + +Optional: + +- `nested_object_attribute` (String) + + + + +### Nested Schema for `sensitive_object_attribute` + +Optional: + +- `object_attribute_attribute` (String) + + + +### Nested Schema for `set_nested_block` + +Optional: + +- `set_nested_block_attribute` (String) example set nested block attribute + + + +### Nested Schema for `single_nested_block` + +Optional: + +- `single_nested_block_attribute` (String) example single nested block attribute + + + +### Nested Schema for `single_nested_block_sensitive_nested_attribute` + +Optional: + +- `single_nested_block_attribute` (String) example single nested block attribute +- `single_nested_block_sensitive_attribute` (String, Sensitive) example sensitive single nested block attribute + + + +### Nested Schema for `set_nested_block_sensitive_nested_attribute` + +Read-Only: + +- `set_nested_block_attribute` (String) example set nested block attribute +- `set_nested_block_sensitive_attribute` (String, Sensitive) example sensitive set nested block attribute +-- expected-function.md -- +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "scaffolding function - terraform-provider-scaffolding" +subcategory: "" +description: |- + Echo a string test test +--- + +# function: scaffolding + +Given a string value, returns the same value. + + + +## Signature + + +```text +scaffolding(stringInput string, boolInput bool, float64Input number, int64Input number, listStringInput list of string, mapStringInput map of string, numberInput number, objectInput object, setStringInput set of string, variadicParam string...) string +``` + +## Arguments + + +1. `stringInput` (String) Value to echo testing +1. `boolInput` (Boolean) Value to echo testing +1. `float64Input` (Number) Float64 Value to echo +1. `int64Input` (Number) Int64 Value to echo +1. `listStringInput` (List of String) List of strings to echo +1. `mapStringInput` (Map of String) Map of strings to echo +1. `numberInput` (Number) Number to echo +1. `objectInput` (Object) Object to echo +1. `setStringInput` (Set of String) Set of strings to echo + +1. `variadicParam` (Variadic, String) Value to echo +-- schema.json -- +{ + "format_version": "1.0", + "provider_schemas": { + "registry.terraform.io/hashicorp/scaffolding": { + "provider": { + "version": 0, + "block": { + "attributes": { + "endpoint": { + "type": "string", + "description": "Example provider attribute", + "description_kind": "markdown", + "optional": true + } + }, + "description": "Example provider", + "description_kind": "markdown" + } + }, + "resource_schemas": { + "scaffolding_example": { + "version": 0, + "block": { + "attributes": { + "bool_attribute": { + "type": "bool", + "description": "example bool attribute", + "description_kind": "markdown", + "optional": true + }, + "float64_attribute": { + "type": "number", + "description": "example float64 attribute", + "description_kind": "markdown", + "optional": true + }, + "id": { + "type": "string", + "description_kind": "plain", + "computed": true + }, + "int64_attribute": { + "type": "number", + "description": "example int64 attribute", + "description_kind": "markdown", + "optional": true + }, + "list_attribute": { + "type": [ + "list", + "string" + ], + "description": "example list attribute", + "description_kind": "markdown", + "optional": true + }, + "map_attribute": { + "type": [ + "map", + "string" + ], + "description": "example map attribute", + "description_kind": "markdown", + "optional": true + }, + "number_attribute": { + "type": "number", + "description": "example number attribute", + "description_kind": "markdown", + "optional": true + }, + "object_attribute": { + "type": [ + "object", + { + "object_attribute_attribute": "string" + } + ], + "description": "example object attribute", + "description_kind": "markdown", + "optional": true + }, + "object_attribute_with_nested_object_attribute": { + "type": [ + "object", + { + "nested_object": [ + "object", + { + "nested_object_attribute": "string" + } + ], + "object_attribute_attribute": "string" + } + ], + "description": "example object attribute with nested object attribute", + "description_kind": "markdown", + "optional": true + }, + "sensitive_bool_attribute": { + "type": "bool", + "description": "example sensitive bool attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + }, + "sensitive_float64_attribute": { + "type": "number", + "description": "example sensitive float64 attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + }, + "sensitive_int64_attribute": { + "type": "number", + "description": "example sensitive int64 attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + }, + "sensitive_list_attribute": { + "type": [ + "list", + "string" + ], + "description": "example sensitive list attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + }, + "sensitive_map_attribute": { + "type": [ + "map", + "string" + ], + "description": "example sensitive map attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + }, + "sensitive_number_attribute": { + "type": "number", + "description": "example sensitive number attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + }, + "sensitive_object_attribute": { + "type": [ + "object", + { + "object_attribute_attribute": "string" + } + ], + "description": "example sensitive object attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + }, + "sensitive_set_attribute": { + "type": [ + "set", + "string" + ], + "description": "example sensitive set attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + }, + "sensitive_string_attribute": { + "type": "string", + "description": "example sensitive string attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + }, + "set_attribute": { + "type": [ + "set", + "string" + ], + "description": "example set attribute", + "description_kind": "markdown", + "optional": true + }, + "string_attribute": { + "type": "string", + "description": "example string attribute", + "description_kind": "markdown", + "optional": true + } + }, + "block_types": { + "list_nested_block": { + "nesting_mode": "list", + "block": { + "attributes": { + "list_nested_block_attribute": { + "type": "string", + "description": "example list nested block attribute", + "description_kind": "markdown", + "optional": true + }, + "list_nested_block_attribute_with_default": { + "type": "string", + "description": "example list nested block attribute with default", + "description_kind": "markdown", + "optional": true, + "computed": true + } + }, + "block_types": { + "nested_list_block": { + "nesting_mode": "list", + "block": { + "attributes": { + "nested_block_string_attribute": { + "type": "string", + "description": "example nested block string attribute", + "description_kind": "markdown", + "optional": true + } + }, + "description_kind": "plain" + } + } + }, + "description": "example list nested block", + "description_kind": "markdown" + } + }, + "list_nested_block_sensitive_nested_attribute": { + "nesting_mode": "list", + "block": { + "attributes": { + "list_nested_block_attribute": { + "type": "string", + "description": "example list nested block attribute", + "description_kind": "markdown", + "optional": true + }, + "list_nested_block_sensitive_attribute": { + "type": "string", + "description": "example sensitive list nested block attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + } + }, + "description_kind": "plain" + } + }, + "set_nested_block": { + "nesting_mode": "set", + "block": { + "attributes": { + "set_nested_block_attribute": { + "type": "string", + "description": "example set nested block attribute", + "description_kind": "markdown", + "optional": true + } + }, + "description": "example set nested block", + "description_kind": "markdown" + } + }, + "set_nested_block_sensitive_nested_attribute": { + "nesting_mode": "set", + "block": { + "attributes": { + "set_nested_block_attribute": { + "type": "string", + "description": "example set nested block attribute", + "description_kind": "markdown", + "computed": true + }, + "set_nested_block_sensitive_attribute": { + "type": "string", + "description": "example sensitive set nested block attribute", + "description_kind": "markdown", + "computed": true, + "sensitive": true + } + }, + "description": "example sensitive set nested block", + "description_kind": "markdown" + } + }, + "single_nested_block": { + "nesting_mode": "single", + "block": { + "attributes": { + "single_nested_block_attribute": { + "type": "string", + "description": "example single nested block attribute", + "description_kind": "markdown", + "optional": true + } + }, + "description": "example single nested block", + "description_kind": "markdown" + } + }, + "single_nested_block_sensitive_nested_attribute": { + "nesting_mode": "single", + "block": { + "attributes": { + "single_nested_block_attribute": { + "type": "string", + "description": "example single nested block attribute", + "description_kind": "markdown", + "optional": true + }, + "single_nested_block_sensitive_attribute": { + "type": "string", + "description": "example sensitive single nested block attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + } + }, + "description": "example sensitive single nested block", + "description_kind": "markdown" + } + } + }, + "description": "example resource", + "description_kind": "plain" + } + } + }, + "functions": { + "scaffolding": { + "description": "Given a string value, returns the same value.", + "summary": "Echo a string test test", + "return_type": "string", + "parameters": [ + { + "name": "stringInput", + "description": "Value to echo testing", + "type": "string" + }, + { + "name": "boolInput", + "description": "Value to echo testing", + "type": "bool" + }, + { + "name": "float64Input", + "description": "Float64 Value to echo", + "type": "number" + }, + { + "name": "int64Input", + "description": "Int64 Value to echo", + "type": "number" + }, + { + "name": "listStringInput", + "description": "List of strings to echo", + "type": [ + "list", + "string" + ] + }, + { + "name": "mapStringInput", + "description": "Map of strings to echo", + "type": [ + "map", + "string" + ] + }, + { + "name": "numberInput", + "description": "Number to echo", + "type": "number" + }, + { + "name": "objectInput", + "description": "Object to echo", + "type": [ + "object", + { + "attr1": "string", + "attr2": "number" + } + ] + }, + { + "name": "setStringInput", + "description": "Set of strings to echo", + "type": [ + "set", + "string" + ] + } + ], + "variadic_parameter": { + "name": "variadicParam", + "description": "Value to echo", + "type": "string" + } + } + } + } + } +} diff --git a/cmd/tfplugindocs/testdata/scripts/schema-json/generate/framework_provider_success_nested_blocks.txtar b/cmd/tfplugindocs/testdata/scripts/schema-json/generate/framework_provider_success_nested_blocks.txtar deleted file mode 100644 index ff93eef6..00000000 --- a/cmd/tfplugindocs/testdata/scripts/schema-json/generate/framework_provider_success_nested_blocks.txtar +++ /dev/null @@ -1,744 +0,0 @@ -# Copyright (c) HashiCorp, Inc. -# SPDX-License-Identifier: MPL-2.0 - -# Successful run of tfplugindocs on a Framework provider with a resource schema that contains nested types -[!unix] skip -exec tfplugindocs --provider-name=terraform-provider-scaffolding --providers-schema=schema.json -cmp stdout expected-output.txt -cmp docs/index.md expected-index.md -cmp docs/resources/example.md expected-resource.md - --- expected-output.txt -- -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" --- expected-index.md -- ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "scaffolding Provider" -subcategory: "" -description: |- - Example provider ---- - -# scaffolding Provider - -Example provider - - - - -## Schema - -### Optional - -- `endpoint` (String) Example provider attribute --- expected-resource.md -- ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "scaffolding_example Resource - terraform-provider-scaffolding" -subcategory: "" -description: |- - A certificate issued via a private certificate authority ---- - -# scaffolding_example (Resource) - -A certificate issued via a private certificate authority - - - - -## Schema - -### Required - -- `certificate_authority_arn` (String) -- `certificate_signing_request` (String) The certificate signing request (CSR) for the Certificate. -- `signing_algorithm` (String) The name of the algorithm that will be used to sign the Certificate. -- `validity` (Attributes) Validity for a certificate. (see [below for nested schema](#nestedatt--validity)) - -### Optional - -- `api_passthrough` (Attributes) Structure that specifies fields to be overridden in a certificate at the time of issuance. These requires an API Passthrough template be used or they will be ignored. (see [below for nested schema](#nestedatt--api_passthrough)) -- `template_arn` (String) -- `validity_not_before` (Attributes) Validity for a certificate. (see [below for nested schema](#nestedatt--validity_not_before)) - -### Read-Only - -- `arn` (String) -- `certificate` (String) The issued certificate in base 64 PEM-encoded format. -- `id` (String) Uniquely identifies the resource. - - -### Nested Schema for `validity` - -Required: - -- `type` (String) -- `value` (Number) - - - -### Nested Schema for `api_passthrough` - -Optional: - -- `extensions` (Attributes) Structure that contains X.500 extensions for a Certificate. (see [below for nested schema](#nestedatt--api_passthrough--extensions)) -- `subject` (Attributes) Structure that contains X.500 distinguished name information. (see [below for nested schema](#nestedatt--api_passthrough--subject)) - - -### Nested Schema for `api_passthrough.extensions` - -Optional: - -- `certificate_policies` (Attributes List) (see [below for nested schema](#nestedatt--api_passthrough--extensions--certificate_policies)) -- `extended_key_usage` (Attributes List) (see [below for nested schema](#nestedatt--api_passthrough--extensions--extended_key_usage)) -- `key_usage` (Attributes) Structure that contains X.509 KeyUsage information. (see [below for nested schema](#nestedatt--api_passthrough--extensions--key_usage)) -- `subject_alternative_names` (Attributes List) (see [below for nested schema](#nestedatt--api_passthrough--extensions--subject_alternative_names)) - - -### Nested Schema for `api_passthrough.extensions.certificate_policies` - -Required: - -- `cert_policy_id` (String) String that contains X.509 ObjectIdentifier information. - -Optional: - -- `policy_qualifiers` (Attributes List) (see [below for nested schema](#nestedatt--api_passthrough--extensions--certificate_policies--policy_qualifiers)) - - -### Nested Schema for `api_passthrough.extensions.certificate_policies.policy_qualifiers` - -Required: - -- `policy_qualifier_id` (String) -- `qualifier` (Attributes) Structure that contains a X.509 policy qualifier. (see [below for nested schema](#nestedatt--api_passthrough--extensions--certificate_policies--policy_qualifiers--qualifier)) - - -### Nested Schema for `api_passthrough.extensions.certificate_policies.policy_qualifiers.qualifier` - -Required: - -- `cps_uri` (String) - - - - - -### Nested Schema for `api_passthrough.extensions.extended_key_usage` - -Optional: - -- `extended_key_usage_object_identifier` (String) String that contains X.509 ObjectIdentifier information. -- `extended_key_usage_type` (String) - - - -### Nested Schema for `api_passthrough.extensions.key_usage` - -Optional: - -- `crl_sign` (Boolean) -- `data_encipherment` (Boolean) -- `decipher_only` (Boolean) -- `digital_signature` (Boolean) -- `encipher_only` (Boolean) -- `key_agreement` (Boolean) -- `key_cert_sign` (Boolean) -- `key_encipherment` (Boolean) -- `non_repudiation` (Boolean) - - - -### Nested Schema for `api_passthrough.extensions.subject_alternative_names` - -Optional: - -- `directory_name` (Attributes) Structure that contains X.500 distinguished name information. (see [below for nested schema](#nestedatt--api_passthrough--extensions--subject_alternative_names--directory_name)) -- `dns_name` (String) String that contains X.509 DnsName information. -- `edi_party_name` (Attributes) Structure that contains X.509 EdiPartyName information. (see [below for nested schema](#nestedatt--api_passthrough--extensions--subject_alternative_names--edi_party_name)) -- `ip_address` (String) String that contains X.509 IpAddress information. -- `other_name` (Attributes) Structure that contains X.509 OtherName information. (see [below for nested schema](#nestedatt--api_passthrough--extensions--subject_alternative_names--other_name)) -- `registered_id` (String) String that contains X.509 ObjectIdentifier information. -- `rfc_822_name` (String) String that contains X.509 Rfc822Name information. -- `uniform_resource_identifier` (String) String that contains X.509 UniformResourceIdentifier information. - - -### Nested Schema for `api_passthrough.extensions.subject_alternative_names.directory_name` - -Optional: - -- `common_name` (String) -- `country` (String) -- `distinguished_name_qualifier` (String) -- `generation_qualifier` (String) -- `given_name` (String) -- `initials` (String) -- `locality` (String) -- `organization` (String) -- `organizational_unit` (String) -- `pseudonym` (String) -- `serial_number` (String) -- `state` (String) -- `surname` (String) -- `title` (String) - - - -### Nested Schema for `api_passthrough.extensions.subject_alternative_names.edi_party_name` - -Required: - -- `name_assigner` (String) -- `party_name` (String) - - - -### Nested Schema for `api_passthrough.extensions.subject_alternative_names.other_name` - -Required: - -- `type_id` (String) String that contains X.509 ObjectIdentifier information. -- `value` (String) - - - - - -### Nested Schema for `api_passthrough.subject` - -Optional: - -- `common_name` (String) -- `country` (String) -- `distinguished_name_qualifier` (String) -- `generation_qualifier` (String) -- `given_name` (String) -- `initials` (String) -- `locality` (String) -- `organization` (String) -- `organizational_unit` (String) -- `pseudonym` (String) -- `serial_number` (String) -- `state` (String) -- `surname` (String) -- `title` (String) - - - - -### Nested Schema for `validity_not_before` - -Required: - -- `type` (String) -- `value` (Number) --- schema.json -- -{ - "format_version": "1.0", - "provider_schemas": { - "registry.terraform.io/hashicorp/scaffolding": { - "provider": { - "version": 0, - "block": { - "attributes": { - "endpoint": { - "type": "string", - "description": "Example provider attribute", - "description_kind": "markdown", - "optional": true - } - }, - "description": "Example provider", - "description_kind": "markdown" - } - }, - "resource_schemas": { - "scaffolding_example": { - "block": { - "attributes": { - "api_passthrough": { - "computed": true, - "description": "Structure that specifies fields to be overridden in a certificate at the time of issuance. These requires an API Passthrough template be used or they will be ignored.", - "description_kind": "plain", - "nested_type": { - "attributes": { - "extensions": { - "description": "Structure that contains X.500 extensions for a Certificate.", - "description_kind": "plain", - "nested_type": { - "attributes": { - "certificate_policies": { - "description_kind": "plain", - "nested_type": { - "attributes": { - "cert_policy_id": { - "description": "String that contains X.509 ObjectIdentifier information.", - "description_kind": "plain", - "required": true, - "type": "string" - }, - "policy_qualifiers": { - "description_kind": "plain", - "nested_type": { - "attributes": { - "policy_qualifier_id": { - "description_kind": "plain", - "required": true, - "type": "string" - }, - "qualifier": { - "description": "Structure that contains a X.509 policy qualifier.", - "description_kind": "plain", - "nested_type": { - "attributes": { - "cps_uri": { - "description_kind": "plain", - "required": true, - "type": "string" - } - }, - "nesting_mode": "single" - }, - "required": true - } - }, - "nesting_mode": "list" - }, - "optional": true - } - }, - "nesting_mode": "list" - }, - "optional": true - }, - "extended_key_usage": { - "description_kind": "plain", - "nested_type": { - "attributes": { - "extended_key_usage_object_identifier": { - "description": "String that contains X.509 ObjectIdentifier information.", - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "extended_key_usage_type": { - "description_kind": "plain", - "optional": true, - "type": "string" - } - }, - "nesting_mode": "list" - }, - "optional": true - }, - "key_usage": { - "description": "Structure that contains X.509 KeyUsage information.", - "description_kind": "plain", - "nested_type": { - "attributes": { - "crl_sign": { - "description_kind": "plain", - "optional": true, - "type": "bool" - }, - "data_encipherment": { - "description_kind": "plain", - "optional": true, - "type": "bool" - }, - "decipher_only": { - "description_kind": "plain", - "optional": true, - "type": "bool" - }, - "digital_signature": { - "description_kind": "plain", - "optional": true, - "type": "bool" - }, - "encipher_only": { - "description_kind": "plain", - "optional": true, - "type": "bool" - }, - "key_agreement": { - "description_kind": "plain", - "optional": true, - "type": "bool" - }, - "key_cert_sign": { - "description_kind": "plain", - "optional": true, - "type": "bool" - }, - "key_encipherment": { - "description_kind": "plain", - "optional": true, - "type": "bool" - }, - "non_repudiation": { - "description_kind": "plain", - "optional": true, - "type": "bool" - } - }, - "nesting_mode": "single" - }, - "optional": true - }, - "subject_alternative_names": { - "description_kind": "plain", - "nested_type": { - "attributes": { - "directory_name": { - "description": "Structure that contains X.500 distinguished name information.", - "description_kind": "plain", - "nested_type": { - "attributes": { - "common_name": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "country": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "distinguished_name_qualifier": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "generation_qualifier": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "given_name": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "initials": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "locality": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "organization": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "organizational_unit": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "pseudonym": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "serial_number": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "state": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "surname": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "title": { - "description_kind": "plain", - "optional": true, - "type": "string" - } - }, - "nesting_mode": "single" - }, - "optional": true - }, - "dns_name": { - "description": "String that contains X.509 DnsName information.", - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "edi_party_name": { - "description": "Structure that contains X.509 EdiPartyName information.", - "description_kind": "plain", - "nested_type": { - "attributes": { - "name_assigner": { - "description_kind": "plain", - "required": true, - "type": "string" - }, - "party_name": { - "description_kind": "plain", - "required": true, - "type": "string" - } - }, - "nesting_mode": "single" - }, - "optional": true - }, - "ip_address": { - "description": "String that contains X.509 IpAddress information.", - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "other_name": { - "description": "Structure that contains X.509 OtherName information.", - "description_kind": "plain", - "nested_type": { - "attributes": { - "type_id": { - "description": "String that contains X.509 ObjectIdentifier information.", - "description_kind": "plain", - "required": true, - "type": "string" - }, - "value": { - "description_kind": "plain", - "required": true, - "type": "string" - } - }, - "nesting_mode": "single" - }, - "optional": true - }, - "registered_id": { - "description": "String that contains X.509 ObjectIdentifier information.", - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "rfc_822_name": { - "description": "String that contains X.509 Rfc822Name information.", - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "uniform_resource_identifier": { - "description": "String that contains X.509 UniformResourceIdentifier information.", - "description_kind": "plain", - "optional": true, - "type": "string" - } - }, - "nesting_mode": "list" - }, - "optional": true - } - }, - "nesting_mode": "single" - }, - "optional": true - }, - "subject": { - "description": "Structure that contains X.500 distinguished name information.", - "description_kind": "plain", - "nested_type": { - "attributes": { - "common_name": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "country": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "distinguished_name_qualifier": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "generation_qualifier": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "given_name": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "initials": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "locality": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "organization": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "organizational_unit": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "pseudonym": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "serial_number": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "state": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "surname": { - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "title": { - "description_kind": "plain", - "optional": true, - "type": "string" - } - }, - "nesting_mode": "single" - }, - "optional": true - } - }, - "nesting_mode": "single" - }, - "optional": true - }, - "arn": { - "computed": true, - "description_kind": "plain", - "type": "string" - }, - "certificate": { - "computed": true, - "description": "The issued certificate in base 64 PEM-encoded format.", - "description_kind": "plain", - "type": "string" - }, - "certificate_authority_arn": { - "description_kind": "plain", - "required": true, - "type": "string" - }, - "certificate_signing_request": { - "description": "The certificate signing request (CSR) for the Certificate.", - "description_kind": "plain", - "required": true, - "type": "string" - }, - "id": { - "computed": true, - "description": "Uniquely identifies the resource.", - "description_kind": "plain", - "type": "string" - }, - "signing_algorithm": { - "description": "The name of the algorithm that will be used to sign the Certificate.", - "description_kind": "plain", - "required": true, - "type": "string" - }, - "template_arn": { - "computed": true, - "description_kind": "plain", - "optional": true, - "type": "string" - }, - "validity": { - "description": "Validity for a certificate.", - "description_kind": "plain", - "nested_type": { - "attributes": { - "type": { - "description_kind": "plain", - "required": true, - "type": "string" - }, - "value": { - "description_kind": "plain", - "required": true, - "type": "number" - } - }, - "nesting_mode": "single" - }, - "required": true - }, - "validity_not_before": { - "computed": true, - "description": "Validity for a certificate.", - "description_kind": "plain", - "nested_type": { - "attributes": { - "type": { - "description_kind": "plain", - "required": true, - "type": "string" - }, - "value": { - "description_kind": "plain", - "required": true, - "type": "number" - } - }, - "nesting_mode": "single" - }, - "optional": true - } - }, - "description": "A certificate issued via a private certificate authority", - "description_kind": "plain" - }, - "version": 1 - } - } - } - } -} \ No newline at end of file diff --git a/internal/schemamd/render.go b/internal/schemamd/render.go index 77e575d4..0b628f3c 100644 --- a/internal/schemamd/render.go +++ b/internal/schemamd/render.go @@ -408,6 +408,7 @@ func writeObjectAttribute(w io.Writer, path []string, att cty.Type, group groupF } anchorID := "nestedobjatt--" + strings.Join(path, "--") + pathTitle := strings.Join(path, ".") nestedTypes := []nestedType{} switch { case att.IsObjectType(): @@ -417,9 +418,10 @@ func writeObjectAttribute(w io.Writer, path []string, att cty.Type, group groupF } nestedTypes = append(nestedTypes, nestedType{ - anchorID: anchorID, - path: path, - object: &att, + anchorID: anchorID, + pathTitle: pathTitle, + path: path, + object: &att, group: group, }) @@ -431,9 +433,10 @@ func writeObjectAttribute(w io.Writer, path []string, att cty.Type, group groupF nt := att.ElementType() nestedTypes = append(nestedTypes, nestedType{ - anchorID: anchorID, - path: path, - object: &nt, + anchorID: anchorID, + pathTitle: pathTitle, + path: path, + object: &nt, group: group, }) diff --git a/internal/schemamd/render_test.go b/internal/schemamd/render_test.go index 6d46ecd4..18858292 100644 --- a/internal/schemamd/render_test.go +++ b/internal/schemamd/render_test.go @@ -43,6 +43,11 @@ func TestRender(t *testing.T) { "testdata/awscc_acmpca_certificate.schema.json", "testdata/awscc_acmpca_certificate.md", }, + { + "framework_types", + "testdata/framework_types.schema.json", + "testdata/framework_types.md", + }, } { c := c t.Run(c.name, func(t *testing.T) { diff --git a/internal/schemamd/testdata/framework_types.md b/internal/schemamd/testdata/framework_types.md new file mode 100644 index 00000000..06c04261 --- /dev/null +++ b/internal/schemamd/testdata/framework_types.md @@ -0,0 +1,126 @@ +## Schema + +### Optional + +- `bool_attribute` (Boolean) example bool attribute +- `float64_attribute` (Number) example float64 attribute +- `int64_attribute` (Number) example int64 attribute +- `list_attribute` (List of String) example list attribute +- `list_nested_block` (Block List) example list nested block (see [below for nested schema](#nestedblock--list_nested_block)) +- `list_nested_block_sensitive_nested_attribute` (Block List) (see [below for nested schema](#nestedblock--list_nested_block_sensitive_nested_attribute)) +- `map_attribute` (Map of String) example map attribute +- `number_attribute` (Number) example number attribute +- `object_attribute` (Object) example object attribute (see [below for nested schema](#nestedatt--object_attribute)) +- `object_attribute_with_nested_object_attribute` (Object) example object attribute with nested object attribute (see [below for nested schema](#nestedatt--object_attribute_with_nested_object_attribute)) +- `sensitive_bool_attribute` (Boolean, Sensitive) example sensitive bool attribute +- `sensitive_float64_attribute` (Number, Sensitive) example sensitive float64 attribute +- `sensitive_int64_attribute` (Number, Sensitive) example sensitive int64 attribute +- `sensitive_list_attribute` (List of String, Sensitive) example sensitive list attribute +- `sensitive_map_attribute` (Map of String, Sensitive) example sensitive map attribute +- `sensitive_number_attribute` (Number, Sensitive) example sensitive number attribute +- `sensitive_object_attribute` (Object, Sensitive) example sensitive object attribute (see [below for nested schema](#nestedatt--sensitive_object_attribute)) +- `sensitive_set_attribute` (Set of String, Sensitive) example sensitive set attribute +- `sensitive_string_attribute` (String, Sensitive) example sensitive string attribute +- `set_attribute` (Set of String) example set attribute +- `set_nested_block` (Block Set) example set nested block (see [below for nested schema](#nestedblock--set_nested_block)) +- `single_nested_block` (Block, Optional) example single nested block (see [below for nested schema](#nestedblock--single_nested_block)) +- `single_nested_block_sensitive_nested_attribute` (Block, Optional) example sensitive single nested block (see [below for nested schema](#nestedblock--single_nested_block_sensitive_nested_attribute)) +- `string_attribute` (String) example string attribute + +### Read-Only + +- `id` (String) The ID of this resource. +- `set_nested_block_sensitive_nested_attribute` (Block Set) example sensitive set nested block (see [below for nested schema](#nestedblock--set_nested_block_sensitive_nested_attribute)) + + +### Nested Schema for `list_nested_block` + +Optional: + +- `list_nested_block_attribute` (String) example list nested block attribute +- `list_nested_block_attribute_with_default` (String) example list nested block attribute with default +- `nested_list_block` (Block List) (see [below for nested schema](#nestedblock--list_nested_block--nested_list_block)) + + +### Nested Schema for `list_nested_block.nested_list_block` + +Optional: + +- `nested_block_string_attribute` (String) example nested block string attribute + + + + +### Nested Schema for `list_nested_block_sensitive_nested_attribute` + +Optional: + +- `list_nested_block_attribute` (String) example list nested block attribute +- `list_nested_block_sensitive_attribute` (String, Sensitive) example sensitive list nested block attribute + + + +### Nested Schema for `object_attribute` + +Optional: + +- `object_attribute_attribute` (String) + + + +### Nested Schema for `object_attribute_with_nested_object_attribute` + +Optional: + +- `nested_object` (Object) (see [below for nested schema](#nestedobjatt--object_attribute_with_nested_object_attribute--nested_object)) +- `object_attribute_attribute` (String) + + +### Nested Schema for `object_attribute_with_nested_object_attribute.nested_object` + +Optional: + +- `nested_object_attribute` (String) + + + + +### Nested Schema for `sensitive_object_attribute` + +Optional: + +- `object_attribute_attribute` (String) + + + +### Nested Schema for `set_nested_block` + +Optional: + +- `set_nested_block_attribute` (String) example set nested block attribute + + + +### Nested Schema for `single_nested_block` + +Optional: + +- `single_nested_block_attribute` (String) example single nested block attribute + + + +### Nested Schema for `single_nested_block_sensitive_nested_attribute` + +Optional: + +- `single_nested_block_attribute` (String) example single nested block attribute +- `single_nested_block_sensitive_attribute` (String, Sensitive) example sensitive single nested block attribute + + + +### Nested Schema for `set_nested_block_sensitive_nested_attribute` + +Read-Only: + +- `set_nested_block_attribute` (String) example set nested block attribute +- `set_nested_block_sensitive_attribute` (String, Sensitive) example sensitive set nested block attribute diff --git a/internal/schemamd/testdata/framework_types.schema.json b/internal/schemamd/testdata/framework_types.schema.json new file mode 100644 index 00000000..9aac7817 --- /dev/null +++ b/internal/schemamd/testdata/framework_types.schema.json @@ -0,0 +1,310 @@ +{ + "version": 0, + "block": { + "attributes": { + "bool_attribute": { + "type": "bool", + "description": "example bool attribute", + "description_kind": "markdown", + "optional": true + }, + "float64_attribute": { + "type": "number", + "description": "example float64 attribute", + "description_kind": "markdown", + "optional": true + }, + "id": { + "type": "string", + "description_kind": "plain", + "computed": true + }, + "int64_attribute": { + "type": "number", + "description": "example int64 attribute", + "description_kind": "markdown", + "optional": true + }, + "list_attribute": { + "type": [ + "list", + "string" + ], + "description": "example list attribute", + "description_kind": "markdown", + "optional": true + }, + "map_attribute": { + "type": [ + "map", + "string" + ], + "description": "example map attribute", + "description_kind": "markdown", + "optional": true + }, + "number_attribute": { + "type": "number", + "description": "example number attribute", + "description_kind": "markdown", + "optional": true + }, + "object_attribute": { + "type": [ + "object", + { + "object_attribute_attribute": "string" + } + ], + "description": "example object attribute", + "description_kind": "markdown", + "optional": true + }, + "object_attribute_with_nested_object_attribute": { + "type": [ + "object", + { + "nested_object": [ + "object", + { + "nested_object_attribute": "string" + } + ], + "object_attribute_attribute": "string" + } + ], + "description": "example object attribute with nested object attribute", + "description_kind": "markdown", + "optional": true + }, + "sensitive_bool_attribute": { + "type": "bool", + "description": "example sensitive bool attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + }, + "sensitive_float64_attribute": { + "type": "number", + "description": "example sensitive float64 attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + }, + "sensitive_int64_attribute": { + "type": "number", + "description": "example sensitive int64 attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + }, + "sensitive_list_attribute": { + "type": [ + "list", + "string" + ], + "description": "example sensitive list attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + }, + "sensitive_map_attribute": { + "type": [ + "map", + "string" + ], + "description": "example sensitive map attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + }, + "sensitive_number_attribute": { + "type": "number", + "description": "example sensitive number attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + }, + "sensitive_object_attribute": { + "type": [ + "object", + { + "object_attribute_attribute": "string" + } + ], + "description": "example sensitive object attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + }, + "sensitive_set_attribute": { + "type": [ + "set", + "string" + ], + "description": "example sensitive set attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + }, + "sensitive_string_attribute": { + "type": "string", + "description": "example sensitive string attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + }, + "set_attribute": { + "type": [ + "set", + "string" + ], + "description": "example set attribute", + "description_kind": "markdown", + "optional": true + }, + "string_attribute": { + "type": "string", + "description": "example string attribute", + "description_kind": "markdown", + "optional": true + } + }, + "block_types": { + "list_nested_block": { + "nesting_mode": "list", + "block": { + "attributes": { + "list_nested_block_attribute": { + "type": "string", + "description": "example list nested block attribute", + "description_kind": "markdown", + "optional": true + }, + "list_nested_block_attribute_with_default": { + "type": "string", + "description": "example list nested block attribute with default", + "description_kind": "markdown", + "optional": true, + "computed": true + } + }, + "block_types": { + "nested_list_block": { + "nesting_mode": "list", + "block": { + "attributes": { + "nested_block_string_attribute": { + "type": "string", + "description": "example nested block string attribute", + "description_kind": "markdown", + "optional": true + } + }, + "description_kind": "plain" + } + } + }, + "description": "example list nested block", + "description_kind": "markdown" + } + }, + "list_nested_block_sensitive_nested_attribute": { + "nesting_mode": "list", + "block": { + "attributes": { + "list_nested_block_attribute": { + "type": "string", + "description": "example list nested block attribute", + "description_kind": "markdown", + "optional": true + }, + "list_nested_block_sensitive_attribute": { + "type": "string", + "description": "example sensitive list nested block attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + } + }, + "description_kind": "plain" + } + }, + "set_nested_block": { + "nesting_mode": "set", + "block": { + "attributes": { + "set_nested_block_attribute": { + "type": "string", + "description": "example set nested block attribute", + "description_kind": "markdown", + "optional": true + } + }, + "description": "example set nested block", + "description_kind": "markdown" + } + }, + "set_nested_block_sensitive_nested_attribute": { + "nesting_mode": "set", + "block": { + "attributes": { + "set_nested_block_attribute": { + "type": "string", + "description": "example set nested block attribute", + "description_kind": "markdown", + "computed": true + }, + "set_nested_block_sensitive_attribute": { + "type": "string", + "description": "example sensitive set nested block attribute", + "description_kind": "markdown", + "computed": true, + "sensitive": true + } + }, + "description": "example sensitive set nested block", + "description_kind": "markdown" + } + }, + "single_nested_block": { + "nesting_mode": "single", + "block": { + "attributes": { + "single_nested_block_attribute": { + "type": "string", + "description": "example single nested block attribute", + "description_kind": "markdown", + "optional": true + } + }, + "description": "example single nested block", + "description_kind": "markdown" + } + }, + "single_nested_block_sensitive_nested_attribute": { + "nesting_mode": "single", + "block": { + "attributes": { + "single_nested_block_attribute": { + "type": "string", + "description": "example single nested block attribute", + "description_kind": "markdown", + "optional": true + }, + "single_nested_block_sensitive_attribute": { + "type": "string", + "description": "example sensitive single nested block attribute", + "description_kind": "markdown", + "optional": true, + "sensitive": true + } + }, + "description": "example sensitive single nested block", + "description_kind": "markdown" + } + } + }, + "description_kind": "plain" + } +} \ No newline at end of file