Add support for maps based on additionalProperties field#27
Merged
Conversation
commit dd5627e Author: Austin Valle <austinvalle@gmail.com> Date: Fri Jun 23 16:01:17 2023 -0400 match openapi spec to name commit 4696790 Author: Austin Valle <austinvalle@gmail.com> Date: Fri Jun 23 15:46:11 2023 -0400 update to latest commit commit b41fedc Author: Austin Valle <austinvalle@gmail.com> Date: Fri Jun 23 15:41:12 2023 -0400 update design doc for sets commit bc38b31 Author: Austin Valle <austinvalle@gmail.com> Date: Fri Jun 23 15:30:54 2023 -0400 implement set and run `make testdata` commit 6315b97 Author: Austin Valle <austinvalle@gmail.com> Date: Fri Jun 23 15:28:37 2023 -0400 add resource example commit 2aa0bce Author: Austin Valle <austinvalle@gmail.com> Date: Fri Jun 23 15:27:48 2023 -0400 update test to include resources commit 60b134e Author: Austin Valle <austinvalle@gmail.com> Date: Fri Jun 23 12:26:01 2023 -0400 Add test before changes commit 9a8bdd3 Author: Austin Valle <austinvalle@gmail.com> Date: Fri Jun 23 12:04:07 2023 -0400 update go mod with latest `codegen-spec`
bflad
approved these changes
Jun 26, 2023
bflad
left a comment
Contributor
There was a problem hiding this comment.
This seems reasonable to me 🚀 We can always have our own configuration/annotations if the additionalProperties data model does not work in practice.
|
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
RFC: https://docs.google.com/document/d/15PJokoO7mkMYsc2Z7DN1copykQgH5Kt7nnzb-mcNcTo/edit#heading=h.4syvri1n60bk
References:
This PR adds support for:
MapNestedAttributeMapAttributeMapType(only possible under a collection type,ListAttribute,SetAttribute, orMapAttribute)I also added documentation to the design doc and added unit/integration tests to cover since this there aren't any use-cases in existing OAS tests.
Details
additionalPropertiesindicates that key names in a schema can be any string, with a value defined by the schema defined inadditionalProperties.type.Examples
This works for simple maps that have primitive element types (
MapAttribute)This also works for more complex maps that have objects (
MapNestedAttribute)Finally, it can also exist as a
MapTypein an array:I wrote integration tests to cover this specific functionality as the existing OAS do not cover this use-case 👍🏻
Notes:
additionalPropertieswill override any existingpropertiesthat are set. In JSON schema,additionalPropertiesis "in addition" to the definedproperties, however we cannot represent that in a TF Plugin Framework schema.additionalProperties, ifadditionalProperties: falseis found (indicating that NO additional properties are allowed), it will treat the schema like an object.