orval
orval copied to clipboard
feat: allow index files customization
Status
READY
Related
Fix https://github.com/orval-labs/orval/issues/2044
Description
add a way to customize index files:
export default defineConfig({
output: {
// ....rest of the config
indexFiles: {
schema: (schema) => schemaPaths.filter(schema => schema.name === "Dog"),
workspace: (implementationPaths) => implementationPaths.filter(path => path.includes('do-not-expose-this-file')),
},
},
});
add a way to expose custom files:
export default defineConfig({
output: {
// ....rest of the config
client() {
return {
// ... client definition
extraFiles() {
return [
{
path: 'src/file-to-expose.ts',
content: 'export default function () {}',
exposeIndexFile: true,
},
{
path: 'src/file-to-not-expose.ts',
content: 'export default function () {}',
exposeIndexFile: false,
},
{
path: 'src/file-to-not-expose-2.ts',
content: 'export default function () {}',
}
]
}
}
}
});
Steps to Test or Reproduce
> git pull --prune
> git checkout feat/customize-index-files
> grunt jasmine
> yarn
> yarn build
> cd tests
> yarn
> yarn generate:multi-client
- check generated clients in
generated/multi-client/* - check
index.tsin each client, it should only include files that were exposed (no models) - check zod client and see exports for
./extrafiles/index
I've an update for the readme if you want me to add it in the pull request 👀
Sure
Hey @melloware, I've pushed it with my last commit https://github.com/orval-labs/orval/pull/2058/commits/b1b956fe66cc3680227d985b52eb5a84152126e3
OK i have added some others for review