Skip to content
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

Consider allowing extension of the provider code specification #75

Open
austinvalle opened this issue Dec 18, 2023 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@austinvalle
Copy link
Member

Context

As the code generation ecosystem grows with more use-cases it's likely that tools will want to store additional data that may not be applicable to Terraform concepts, but rather, specific to a generating/consuming tool (like OpenAPI).

Currently, the provider code specification does not allow additional fields certain levels of the schema, with the usage of additionalProperties: false:

{
  // ...
  "datasource_string_attribute": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
      "name": {
        "$ref": "#/$defs/valid_identifier"
      },
      "string": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          // allowed properties
        },
        "required": [
          "computed_optional_required"
        ]
      }
    }
  }
}

Proposal

We don't want to remove this restriction completely, but we should add a designated prefix for custom fields and document it's intended use. We could follow OpenAPI's pattern of allowing properties prefixed with x- at different levels of the schema such as:

  • Root level, sibling to version string and resources/datasources/provider objects
  • Sibling to the attribute data (name, {type})
  • Sibling to the resource/data source/provider schema

Example w/ Petstore

{
  "provider": {
    "name": "petstore"
  },
  "resources": [
    {
      "name": "pet",
      "schema": {
        "attributes": [
          {
            "name": "photo_urls",
            "x-tfplugingen-openapi": {
              // This is the original OpenAPI spec property name
              "oas_property": "photoURLs",
              // This is the OpenAPI type format, for denoting specific types of data
              "oas_format": "date-time"
            },
            "list": {
              "computed_optional_required": "required",
              "element_type": {
                "string": {}
              }
            }
          }
        ]
      }
    }
  ],
  "version": "0.1"
}
@austinvalle austinvalle added the enhancement New feature or request label Dec 18, 2023
@raphaelfff
Copy link

The lack of ability to add extra info to the spec makes it impossible to write a TF provider generator from OAS that is actually end-to-end, is there any plan to move this forward ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants