hashicorp / terraform-plugin-codegen-openapi

OpenAPI to Terraform Provider Code Generation Specification
Mozilla Public License 2.0
50 stars 9 forks source link

Support OAS maxItems/minItems Properties as Attribute Validators #22

Closed bflad closed 1 year ago

bflad commented 1 year ago

Reference: https://json-schema.org/draft/2020-12/json-schema-validation.html#name-maxItems Reference: https://json-schema.org/draft/2020-12/json-schema-validation.html#name-minItems

When maxItems is defined, should generate the following specification (depending on type):

"validators": [
  {
    "custom": {
      "import": "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator",
      "schema_definition": "listvalidator.SizeAtMost(/* ... */)"
    }
  }
]

When minItems is defined, should generate the following specification (depending on type):

"validators": [
  {
    "custom": {
      "import": "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator",
      "schema_definition": "listvalidator.SizeAtLeast(/* ... */)"
    }
  }
]

If both maxItems and minItems are defined, we could consider simplifying the specification to use a single listvalidator.SizeBetween() validator.

github-actions[bot] commented 3 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.