You should define a OpenApi specification (example petstore.yaml).
And then create a file orval.config.js
at root of your project:
module.exports = {'petstore-file-transfomer': {output: {mode: 'single',target: './src/petstore.ts',schemas: './src/model',mock: true,},input: {target: './petstore.yaml',},},};
The output options configure what and where you want to write the generated code.
mode
is where you define the way you want to generate your files (default: single
- only one file with everything)target
is where the generated will be written by defaultschemas
is where the models will be written.mock
is when you want to generate mocks with MSW. he will be generated in the target file. You can check MSW to setup them correctlyThe input options configures the imported specification and also what you want to override on it.
target
is the specification fileoverride
is to quickly override the inputtransformer
to transform the specification like add a param to every call.Checkout the orval config to see all available options.