Skip to content

Consider mapping JSON schema date-time format to timetypes.RFC3339 custom type #102

Open
@austinvalle

Description

@austinvalle

Use Cases or Problem Statement

JSON schema (the backbone of all the request/response body schemas in OpenAPI 3.0/3.1) supports designating a type: string as an RFC3339 string via format: date-time: https://json-schema.org/understanding-json-schema/reference/string#dates-and-times.

Recently, HashiCorp has published terraform-plugin-framework-timetypes, which contains an RFC3339 custom string type, which provides validation and semantic equality handling that is often required for RFC3339 strings. The Provider code specification already supports custom types.

Proposal

For any string types that define a format of date-time, add the timetypes.RFC3339Type type and timetypes.RFC3339 value to the custom type in the outputted provider code spec.

Schema

rfc3339_prop:
  description: RFC3339 date-time string!
  type: string
  format: date-time

IR Attribute

{
  "name": "rfc3339_prop",
  "string": {
    "computed_optional_required": "computed",
    "description": "RFC3339 date-time string!",
    "custom_type": {
      "import": {
        "path": "github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes"
      },
      "type": "timetypes.RFC3339Type",
      "value_type": "timetypes.RFC3339"
    }
  }
}

Additional Information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions