Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated argument names for custom types unexpectedly prefixed #108

Open
PeterJCLaw opened this issue Dec 21, 2024 · 1 comment
Open

Generated argument names for custom types unexpectedly prefixed #108

PeterJCLaw opened this issue Dec 21, 2024 · 1 comment

Comments

@PeterJCLaw
Copy link

Given a nested structure within an event, the name of the generated argument containing that nested structure will end up prefixed by the name of the containing event. This seems to follow from the these being matched to the name of the type which is generated (which is similarly prefixed).

I can understand the desire to predictably prefix the names of the types (though perhaps having a way to name them explicitly so that the same structure appearing in several events can be re-used rather than having several copies in the generated code would be nice), though it's less clear to me why the names of the fields should be prefixed. The casing conversion being applied isn't consistent between the two parts of the name, which suggests to me that this isn't happening purely as a result of naming the field for the type name.

Is this expected?

It would feel more natural to me for this to not be the case -- i.e. for the field names to remain unprefixed -- as that would enable greater consistency throughout the system.

plan.json
{
  "createdAt": "2024-12-09T17:00:00.000Z",
  "creationType": "Data catalog",
  "description": "",
  "id": "redacted",
  "name": "Test",
  "rules": {
    "events": [
      {
        "description": "",
        "eventType": "track",
        "name": "kitchen-sink",
        "rules": {
          "$defs": {},
          "$schema": "http://json-schema.org/draft-07/schema#",
          "description": "",
          "properties": {
            "properties": {
              "additionalProperties": false,
              "properties": {
                "nested_type_outer": {
                  "additionalProperties": false,
                  "properties": {
                    "nested_type_middle": {
                      "additionalProperties": false,
                      "properties": {
                        "nested_type_inner": {
                          "additionalProperties": false,
                          "properties": {
                            "nested_type_number_value": {
                              "type": ["number"]
                            }
                          },
                          "required": [],
                          "type": ["object"]
                        }
                      },
                      "required": [],
                      "type": ["object"]
                    }
                  },
                  "required": [],
                  "type": ["object"]
                }
              },
              "required": [],
              "type": "object"
            }
          },
          "type": "object"
        }
      }
    ]
  },
  "updatedAt": "2024-12-21T00:18:00.000Z",
  "version": 13,
  "workspaceId": "redacted"
}
export interface KitchenSinkNestedTypeInner {
  nested_type_number_value?: number
}

export interface KitchenSinkNestedTypeMiddle {
  kitchenSinkNested_type_inner?: KitchenSinkNestedTypeInner
}

export interface KitchenSinkNestedTypeOuter {
  kitchenSinkNested_type_middle?: KitchenSinkNestedTypeMiddle
}

export interface KitchenSink {
  kitchenSinkNested_type_outer?: KitchenSinkNestedTypeOuter
}
@contributor-support
Copy link

Thanks for opening this issue! We'll get back to you shortly. If it is a bug, please make sure to add steps to reproduce the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant