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
I am hoping to use Pkl to define AWS Cloudformation templates for creating infrastructure as an alternative to defining them in JSON or using CDK. I saw the new JSON schema generator and received the following output:
The generation looks great, but it produces an output that looks like (unimportant fields omitted):
...
/// Configuration for the transfer acceleration state.AccelerateConfiguration: Mapping<String, Any>?...
classAccelerateConfiguration {
/// Configures the transfer acceleration state for an Amazon S3 bucket.AccelerationStatus: "Enabled"|"Suspended"=Undefined()
}
Because in Cloudformation all fields are capitalized pascal case, there is a conflict between the type and the property name in the module. If I try to import the generated pkl file, I receive the following error on render:
Documents/pkl-test » pkl eval test.pkl
–– Pkl Error ––
Duplicate definition of member `AccelerateConfiguration`.
10 | AccelerateConfiguration: Mapping<String, Any>?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at test#AwsS3Bucket (file:///Users/markasp/Documents/pkl-test/cfnpkl/AwsS3Bucket.pkl, line 10)
5 | ["MyBucket"] = new AwsS3Bucket {
^^^^^^^^^^^
at test#resources["MyBucket"] (file:///Users/markasp/Documents/pkl-test/test.pkl, line 5)
106 | text = renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (https://github.com/apple/pkl/blob/0.25.1/stdlib/base.pkl#L106)
There also seems to be a tangential bug where the property name is not associated with the type correctly. The JSON schema looks like:
"definitions": {
"AccelerateConfiguration" : {
"type" : "object",
"additionalProperties" : false,
"properties" : {
"AccelerationStatus" : {
"description" : "Configures the transfer acceleration state for an Amazon S3 bucket.",
"type" : "string",
"enum" : [ "Enabled", "Suspended" ]
}
},
"required" : [ "AccelerationStatus" ]
},
},
..."properties": {
"AccelerateConfiguration" : {
"$ref" : "#/definitions/AccelerateConfiguration",
"description" : "Configuration for the transfer acceleration state."
},
}
Proposed Fix
Ideally, I'd like the property names to be lowercased and the class names to be capitalized like they are. This would make the definitions very ergonomic:
and then I can define a converter to make it capitalized in the JSON output. Maybe a parameter on generate that allows it to transform key names in the output similar to the syntax for converters in rendering:
Context
I am hoping to use Pkl to define AWS Cloudformation templates for creating infrastructure as an alternative to defining them in JSON or using CDK. I saw the new JSON schema generator and received the following output:
Command
Error
The generation looks great, but it produces an output that looks like (unimportant fields omitted):
Because in Cloudformation all fields are capitalized pascal case, there is a conflict between the type and the property name in the module. If I try to import the generated pkl file, I receive the following error on render:
test.pkl
There also seems to be a tangential bug where the property name is not associated with the type correctly. The JSON schema looks like:
Proposed Fix
Ideally, I'd like the property names to be lowercased and the class names to be capitalized like they are. This would make the definitions very ergonomic:
and then I can define a converter to make it capitalized in the JSON output. Maybe a parameter on generate that allows it to transform key names in the output similar to the syntax for converters in rendering:
The text was updated successfully, but these errors were encountered: