Use shared model folder #756
Unanswered
gavinthomas-valtech
asked this question in
Q&A
Replies: 1 comment
-
You could specify a "temp" folder in the orval config and use the import { defineConfig } from 'orval'
import fs from 'fs'
import path from 'path'
const TEMP_FOLDER = 'temp'
const afterAllFilesWrite = (files: string[]) => {
for (const file of files) {
const content = fs.readFileSync(file, 'utf8')
const newPath = file.replace(TEMP_FOLDER, 'generated')
fs.writeFileSync(newPath, content)
}
// delete the temp folder afterwards
if (files[0] !== undefined) {
const temporaryFolderPath = path.resolve(files[0], '../')
fs.rmdirSync(temporaryFolderPath, { recursive: true })
}
}
export default defineConfig({
sampleApi: {
hooks: {
afterAllFilesWrite,
},
output: {
target: `${TEMP_FOLDER}/orval.ts`,
},
},
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a project which is going to use multiple yaml files. However they are going to all used shared types. Is it possible to get the process to generate all types into 1 folder. Overwrite anything that has the same filename but allow the existing files from the previous yaml file codegen exist
I've just tried it out and it only retains the last written files to the folder
Beta Was this translation helpful? Give feedback.
All reactions