orval icon indicating copy to clipboard operation
orval copied to clipboard

feat: added output.overrides.namingConvention param to orval config, …

Open dlohvinov opened this issue 6 months ago • 7 comments

…added enum functionality depending on namingConvention config param

Status

WIP

Fix #2126 Fix #2120

Description

Added output.overrides.namingConvention -> output.overrides.namingConvention.enum config options and implemented generated enum keys conversion depending on this config parameter.

Related PRs

--

Todos

  • [ ] Implement feature
  • [ ] Test feature manually
  • [ ] Tests
  • [ ] Documentation
  • [ ] Changelog Entry (unreleased)

Steps to Test or Reproduce

// TODO

dlohvinov avatar May 29 '25 18:05 dlohvinov

@melloware FYI, based on this discussion I've written feature code, but haven't tested it yet. So, now creating a draft PR. Still working on it.

Also, writing this new config parameter as 6th function parameter looks like a bad idea to me, but I didn't came up with a better solution considering existing params 🥲

dlohvinov avatar May 29 '25 18:05 dlohvinov

add @AllieJonsson as the most recent committer in this area of code!

melloware avatar May 29 '25 18:05 melloware

ok looks like the build is failing

melloware avatar May 29 '25 18:05 melloware

yep, I haven't ran or test it yet. had some issues with packages installation or so, so decided to continue tomorrow.

dlohvinov avatar May 29 '25 18:05 dlohvinov

@dlohvinov bump?

melloware avatar Jun 03 '25 14:06 melloware

@melloware, yep, I remember. Sorry, I'm having too much job workload and just haven't had enough time yet 🫠🫠 Anyway, I'm still planning to continue and complete this PR.

Are there any other issues or feature requests related to this feature and it would be great for me to speed up, or I can take some time?

dlohvinov avatar Jun 03 '25 20:06 dlohvinov

@dlohvinov just checking in and can you comment on this ticket so I can assign it to you: https://github.com/orval-labs/orval/issues/2126

melloware avatar Jun 12 '25 10:06 melloware

@melloware , hi! I've:

  • fixed type errors which were causing build errors,
  • tested manually,
  • added a unit test

Had some issues with package installation, generated samples formatting, so I'm not sure, should I commit my manual testing diffs.

Manually I've tested using samples/basic. I've commented 'petstore-file' orval.config.ts entry, and added my config param to petstore-file-transfomer

// samples/basic/orval.config.ts

export default defineConfig({
/* 
   not sure why, but 2nd config entry override didn't work 
without commenting 1nd entry (guess, that's not a bug but I'm just lucking understanding, yet) 🤔

  'petstore-file': {
    input: './petstore.yaml',
    output: './api/endpoints/petstoreFromFileSpecWithConfig.ts',
  },
*/
  'petstore-file-transfomer': {
    output: {
// ...
      override: {
        namingConvention: {
          enum: 'PascalCase', // !!
        },
// ...

dlohvinov avatar Jun 21 '25 18:06 dlohvinov

btw, key "People's_Republic_of_China" converts to PeopleSRepublicOfChina. again, not sure if this is correct, but I've used already existing conventionName function, so, guess this is rather a utility function issue 🤔

image

dlohvinov avatar Jun 21 '25 18:06 dlohvinov

Running build

melloware avatar Jun 21 '25 19:06 melloware

@melloware , thanks! ran reformatting, pushed fix 🙂

dlohvinov avatar Jun 22 '25 11:06 dlohvinov

Looking good now I think all you need to do is update the /docs for this new configuration explaining the options and what it does!

melloware avatar Jun 23 '25 11:06 melloware

@melloware , thanks! Added docs.

Btw, had some issues with md links: output.namingConvention conflicts with output.override.namingConvention, so I've added cringy "for property keys" to my docs entry title. Not sure about this decision 😬

What do you think, maybe should I rename config param, or change title like: namingConvention -> override/namingConvention? 🤔

dlohvinov avatar Jul 06 '25 13:07 dlohvinov

@melloware, thanks! So, what are the next steps?

dlohvinov avatar Jul 08 '25 19:07 dlohvinov

thanks for the reminder. Merged!

melloware avatar Jul 08 '25 19:07 melloware

great, thank you! ❤️

dlohvinov avatar Jul 08 '25 19:07 dlohvinov