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

add camelcase option to schema type generation #215

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MbBrainz
Copy link

@MbBrainz MbBrainz commented Jan 5, 2024

This pr is regarding the implementation of the feature request in this issue: #213

This pr adds the following features:

  • optional config parameter useCamelCasedProps
  • camelcasing of schema type parameters.

The new config param useCamelCasedProps has the following effect on the schema:

    const schema: SchemaObject = {
      type: "object",
      properties: {
        ["foo_bar"]: {
          type: "string",
        },
      },
    };

// resulting type for `useCamelCasedProps == false` (as usual)
export type Test = {
          foo_bar?: string;
}

// resulting type for `useCamelCasedProps == true` with the new addition
export type Test = {
          fooBar?: string;
}

This pr is still in DRAFT because:

With the current state of this pr the fetchers will fail to get parse the received json correctly, as the received data will be in snake_case and the types to cast to would be in camelCase. A solution to make this work, would be a configurable adjustment to the fetcher template (./plugins/typescript/src/core/templates/fetcher.ts) that applies camelCase to incoming request data and that applies snake_case to outgoing data. (exact implementation is still to be figured out)

@fabien0102 Please let me know whether you would be interested in having this feature added, and if so i can try to spend the additional time needed to make this work. Any tips/comments/improvements are very welcome!

@MbBrainz
Copy link
Author

@fb55 @fabien0102 @micha-f What do you think about this feature

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

Successfully merging this pull request may close these issues.

None yet

1 participant