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 mapping JSON schema ipv4 and ipv6 formats to iptypes custom types #103

Open
1 task done
austinvalle opened this issue Dec 13, 2023 · 0 comments
Open
1 task done
Labels
enhancement New feature or request

Comments

@austinvalle
Copy link
Member

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 IPv4 or IPv6 address string via the format field: https://json-schema.org/understanding-json-schema/reference/string#ip-addresses.

Recently, HashiCorp has published terraform-plugin-framework-nettypes, which contains an iptypes package with IPv4Address and IPv6Address custom string types, which provide validation and semantic equality handling (for IPv6) that are often required for IP address strings. The Provider code specification already supports custom types.

Proposal

Proposal

  • For any string types that define a format of ipv4, add the iptypes.IPv4AddressType type and iptypes.IPv4Address value to the custom type in the outputted provider code spec.

Schema

ipv4_prop:
  description: IPv4 address string!
  type: string
  format: ipv4

IR Attribute

{
  "name": "ipv4_prop",
  "string": {
    "computed_optional_required": "computed",
    "description": "IPv4 address string!",
    "custom_type": {
      "import": {
        "path": "github.com/hashicorp/terraform-plugin-framework-nettypes/iptypes"
      },
      "type": "iptypes.IPv4AddressType",
      "value_type": "iptypes.IPv4Address"
    }
  }
}
  • For any string types that define a format of ipv6, add the iptypes.IPv6AddressType type and iptypes.IPv6Address value to the custom type in the outputted provider code spec.

Schema

ipv6_prop:
  description: IPv6 address string!
  type: string
  format: ipv6

IR Attribute

{
  "name": "ipv6_prop",
  "string": {
    "computed_optional_required": "computed",
    "description": "IPv6 address string!",
    "custom_type": {
      "import": {
        "path": "github.com/hashicorp/terraform-plugin-framework-nettypes/iptypes"
      },
      "type": "iptypes.IPv6AddressType",
      "value_type": "iptypes.IPv6Address"
    }
  }
}

Additional Information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@austinvalle austinvalle added the enhancement New feature or request label Dec 13, 2023
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

1 participant