Closed austinvalle closed 11 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.
Background
Currently, when an OAS is mapped to provider code specification, we use the property names directly from the JSON schema properties as the attribute name. Example:
OAS
Provider Code Spec
Here,
photoUrls
is not a valid Terraform attribute identifier and must match the regex^[a-z_][a-z0-9_]*$
:Solution
It seems unrealistic to expect an OpenAPI spec to account for Terraform attribute naming, so we should attempt to normalize property names before serializing. This could prove tricky as the configuration has some options that reference OAS attributes, such as
schema -> attributes -> aliases
andschema -> attributes -> overrides
.As for how/what to normalize, we'll need to make pragmatic decisions on how far to go with the normalization, but an initial proposal:
camelCase
->camel_case
PascalCase
->pascal_case
UPPERCASE
->uppercase
snake_case
->snake_case
We should also consider how to handle special characters that can't be normalized, like
<extra_key>
, and whether we want to remove those characters ->extra_key
We will also run into the problem of potential conflicts when normalizing a property name: