Angular

You should have an OpenApi specification and an Orval config where you define the mode as Angular.

Example with angular

module.exports = {
petstore: {
output: {
mode: 'tags-split',
target: 'src/petstore.ts',
schemas: 'src/model',
client: 'angular',
mock: true,
},
input: {
target: './petstore.yaml',
},
},
};

Checkout the orval config reference to see all available options.

The Angular mode will generate automatically two classes. One abstract with the definition and a service with the implementation. You should add the service inside a module and use it where you want.

You can checkout an example here

How to set a backend url

You can use an interceptor to automatically add the url of your API. Like you would do to add an authorization header.

How use mock

You should define your mock inside the environment file. If you don't do that you will add all the dependencies to your bundle.

You can for example add a property modules and add a MockModule inside which will setup your mocks. You can check an example here

You can also check the msw example here

Was this page helpful?

© 2020 Victor Bury. All rights reserved.