You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Provider Schema support with new schema_ref config option (#40)
* move name property to mapper
* add validation and config
* add schema proxy to explorer
* implemented basics of provider + fixed resolving bug with nested refs
* update library dep
* cleanup from merged PRs
* switch collection to use validators
* add map validators
* upgrade and convert float values
* move function
* add docs
* copywrite!
Copy file name to clipboardExpand all lines: DESIGN.md
+41-2Lines changed: 41 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,12 +19,38 @@ Users of the generator can adjust their OAS to match these assumptions, or sugge
19
19
## Determining the OAS Schema to map from operations
20
20
21
21
### Provider
22
-
<!-- TODO: Update this when we have the provider schema mapping :) -->
23
-
Currently, there is no option in the OpenAPI generator to define the mapping for a provider schema. The `provider.name` property is directly copied to the Framework IR.
22
+
For generating Provider schema code, the [generator config file](./README.md) defines:
23
+
-`provider.name` - required property, which is directly copied to the Framework IR as the name of the Provider.
24
+
-`provider.schema_ref` - optional property, which is a [JSON schema reference](https://json-schema.org/understanding-json-schema/structuring.html#ref) to an existing schema in your OpenAPI spec, typically in the [`components.schema` section](https://spec.openapis.org/oas/v3.1.0#fixed-fields-5). This will be used to [map](#mapping-oas-schema-to-plugin-framework-types) the Provider's schema to Framework IR.
The [generator config file](./README.md) defines the CRUD (`Create`, `Read`, `Update`, `Delete`) operations for a resource in an OAS. In those operations, the generator will search `Create` and `Read` operations for schemas to map to Framework IR. Multiple schemas will be [deep merged](#deep-merge-of-schemas-resources) and the final result will be the Resource schema represented in Framework IR.
- `requestBody`is the only schema **required** for resources, if not present will log a warning and skip the resource without mapping.
@@ -48,6 +74,14 @@ All schemas found will be deep merged together, with the `requestBody` schema fr
48
74
### Data Sources
49
75
The [generator config file](./README.md) defines the `Read` operation for a data source in an OAS. In that operation, the generator will search for a response body schema to map to Framework IR. The response body will be [deep merged](#deep-merge-of-schemas-data-sources) with the query parameters and path parameters of the same `Read` operation and the final result will be the Data Source schema represented in Framework IR.
- `response`is the only schema **required** for data sources, if not present will log a warning and skip the data source without mapping.
@@ -110,6 +144,11 @@ For attributes that don't have additional schema information (`ListAttribute`, `
110
144
111
145
### Required, Computed, and Optional
112
146
147
+
#### Provider
148
+
For the provider, all fields in the provided JSON schema (`provider.schema_ref`) marked as [required](https://json-schema.org/understanding-json-schema/reference/object.html#required-properties) will be mapped as a [Required](https://developer.hashicorp.com/terraform/plugin/framework/handling-data/schemas#required) attribute.
149
+
150
+
If not required, then the field will be mapped as [Optional](https://developer.hashicorp.com/terraform/plugin/framework/handling-data/schemas#optional).
151
+
113
152
#### Resources
114
153
For resources, all fields, in the `Create` operation `requestBody` OAS schema, marked as [required](https://json-schema.org/understanding-json-schema/reference/object.html#required-properties) will be mapped as a [Required](https://developer.hashicorp.com/terraform/plugin/framework/handling-data/schemas#required) attribute.
0 commit comments