hashicorp / hashicorp/terraform-plugin-codegen-openapi
Consider mapping JSON schema `date-time` format to `timetypes.RFC3339` custom type
- Dominant language
- Go
- Stars
- 91
- Forks
- 20
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 1
Description
### 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](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-timetypes@v0.3.0/timetypes#RFC3339), which contains an `RFC3339` [custom string type](https://developer.hashicorp.com/terraform/plugin/framework/handling-data/types/custom), which provides validation and semantic equality handling that is often required for RFC3339 strings. The Provider code specification already supports [custom types](https://developer.hashicorp.com/terraform/plugin/code-generation/specification#custom_type).
### 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
```yaml
rfc3339_prop:
description: RFC3339 date-time string!
type: string
format: date-time
```
#### IR Attribute
```json
{
"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
- [X] I agree to follow this project's Code of Conduct
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.