terraform/internal/command/jsonprovider
Brian Flad 3b4964270f
internal/command/jsonprovider: Remove root jsonfunction object from function output (#34536)
Previously, the `providers schema -json` output would include the root object from `metadata functions -json`. This object had its own `format_version` property, which would be confusing with the root `format_version` property already present.

This change still uses the `jsonfunction` package for consistency between cty and provider function JSON handling, but removes that extra object, instead making `functions` directly a mapping of names to signatures/definitions. This also adds a code comment to hint maintainers that jsonprovider format versioning is tied to jsonfunction format versioning.

Example output prior to change:

```jsonc
{
  "format_version": "1.0",
  "provider_schemas": {
    "registry.terraform.io/bflad/framework": {
      // ...
      "functions": {
        "format_version": "1.0",
        "function_signatures": {
          "example": {
            "description": "Echoes given argument as result",
            "summary": "Example function",
            "return_type": "string",
            "parameters": [
              {
                "name": "input",
                "description": "String to echo",
                "type": "string"
              }
            ]
          }
        }
      }
    }
  }
}
```

Example output after change:

```jsonc
{
  "format_version": "1.0",
  "provider_schemas": {
    "registry.terraform.io/bflad/framework": {
      // ...
      "functions": {
        "example": {
          "description": "Echoes given argument as result",
          "summary": "Example function",
          "return_type": "string",
          "parameters": [
            {
              "name": "input",
              "description": "String to echo",
              "type": "string"
            }
          ]
        }
      }
    }
  }
}
```
2024-01-18 15:48:07 -05:00
..
attribute.go Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
attribute_test.go Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
block.go Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
block_test.go Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
doc.go Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
provider.go internal/command/jsonprovider: Remove root jsonfunction object from function output (#34536) 2024-01-18 15:48:07 -05:00
provider_test.go marshal provider functions into the json schemas 2023-12-22 09:56:15 -05:00
schema.go Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
schema_test.go Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00