Skip to content

Commit

Permalink
Merge branch 'master' of github.com:anymaniax/orval
Browse files Browse the repository at this point in the history
  • Loading branch information
anymaniax committed Jul 13, 2021
2 parents c9b4096 + 6979fae commit 7a982ee
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 53 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
You can find below some samples on codesandbox

- [react app](https://github.com/anymaniax/orval/tree/master/samples/react-app)
- [react app with react query](https://github.com/anymaniax/orval/tree/master/samples/react-app-with-react-query)
- [react app with React query](https://github.com/anymaniax/orval/tree/master/samples/react-app-with-react-query)
- [angular app](https://github.com/anymaniax/orval/tree/master/samples/angular-app)
4 changes: 2 additions & 2 deletions docs/src/pages/guides/angular.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: angular
title: Angular
---

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

#### Example with angular

Expand All @@ -26,7 +26,7 @@ module.exports = {

Checkout the [orval config](../reference/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.
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 <a href="https://github.com/anymaniax/orval/tree/master/samples/angular-app" target="_blank">here</a>

Expand Down
23 changes: 11 additions & 12 deletions docs/src/pages/guides/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ id: basics
title: Basics
---

You should define a OpenApi specification like <a href="https://github.com/anymaniax/orval/blob/master/samples/basic/petstore.yaml" target="_blank">this</a>

And then create a file orval.config.js at root of your project.
You should define a OpenApi specification (example <a href="https://github.com/anymaniax/orval/blob/master/samples/basic/petstore.yaml" target="_blank"> petstore.yaml</a>).

And then create a file `orval.config.js` at root of your project:
#### Example of orval.config.js

```js
Expand All @@ -27,15 +26,15 @@ module.exports = {

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 - is only one file with everything)
- target is where the generated will be written by default
- schemas 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 <a href="https://mswjs.io/" target="_blank">msw</a> to setup them correctly
- `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 default
- `schemas` 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 <a href="https://mswjs.io/" target="_blank">MSW</a> to setup them correctly

The input options configure the imported specification and also what you want to override on it.
The input options configures the imported specification and also what you want to override on it.

- target is the specification file
- override is to quickly override the input
- transformer to transform the specification like add a param to every call.
- `target` is the specification file
- `override` is to quickly override the input
- `transformer` to transform the specification like add a param to every call.

Checkout the [orval config](../reference/orval-config) reference to see all available options.
Checkout the [orval config](../reference/orval-config) to see all available options.
8 changes: 4 additions & 4 deletions docs/src/pages/guides/react-query.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ id: react-query
title: React query
---

You should have an OpenApi specification and an orval config where you define the mode as react-query.
You should have an OpenApi specification and an Orval config where you define the mode as react-query.

#### Example with react query
#### Example with React query

```js
module.exports = {
Expand All @@ -26,7 +26,7 @@ module.exports = {

Checkout the [orval config](../reference/configuration/full-example) reference to see all available options.

The react query model will generate an implementation file with one custom hook per path in your OpenApi Specification.
The React query model will generate an implementation file with one custom hook per path in your OpenApi Specification.

Like the following example from this <a href="https://github.com/anymaniax/orval/blob/master/samples/react-app-with-react-query/petstore.yaml" target="_blank">swagger</a>:

Expand Down Expand Up @@ -77,7 +77,7 @@ export const useShowPetById = <

### How use other query

With the following example orval will generate a useQuery and useInfinteQuery with a nextId queryparam. You can also override the config for each one with the options props.
With the following example Orval will generate a useQuery and useInfinteQuery with a nextId queryparam. You can also override the config for each one with the options props.

```js
module.exports = {
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/guides/svelte-query.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: svelte-query
title: Svelte query
---

You should have an OpenApi specification and an orval config where you define the mode as svelte-query.
You should have an OpenApi specification and an Orval config where you define the mode as svelte-query.

#### Example with svelte query

Expand Down Expand Up @@ -77,7 +77,7 @@ export const useShowPetById = <

### How use other query

With the following example orval will generate a useQuery and useInfinteQuery with a nextId queryparam. You can also override the config for each one with the options props.
With the following example Orval will generate a useQuery and useInfinteQuery with a nextId queryparam. You can also override the config for each one with the options props.

```js
module.exports = {
Expand Down
3 changes: 1 addition & 2 deletions docs/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ const Home = () => {
<span>with appropriate type-signatures</span>
</h1>
<p className="mt-3 text-base text-gray-700 sm:mt-5 sm:text-xl lg:text-lg xl:text-xl">
Generate, valid, cache and mock in your React and Angular
applications all with your OpenAPI specification.
Generate, valid, cache and mock in your frontend applications all with your OpenAPI specification.
</p>

<div className="mt-5 mx-auto sm:flex sm:justify-center lg:justify-start lg:mx-0 md:mt-8">
Expand Down
11 changes: 6 additions & 5 deletions docs/src/pages/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ id: installation
title: Installation
---

You can install orval with <a href="https://npmjs.com" target="_blank">NPM</a>,
<a href="https://yarnpkg.com" target="_blank">Yarn</a>.

### NPM
You can install Orval with <a href="https://npmjs.com" target="_blank">NPM</a> or <a href="https://yarnpkg.com" target="_blank">Yarn</a>.

Using NPM:
```bash
$ npm i -g orval
# or
```

Using Yarn:
```
$ yarn global add orval
```
6 changes: 3 additions & 3 deletions docs/src/pages/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ title: Overview

## Motivation

I often use a swagger as contract between the frontend and backend team. And before orval, I used the <a href="editor.swagger.io" target="_blank">swagger editor</a> or <a href="https://swagger.io/tools/swagger-codegen" target="_blank">swagger codegen</a> but that wasn't enough for my need. That's why I started orval.
I often use a swagger as contract between the frontend and backend team. And before Orval, I used the <a href="editor.swagger.io" target="_blank">swagger editor</a> or <a href="https://swagger.io/tools/swagger-codegen" target="_blank">swagger codegen</a> but that wasn't enough for my need. That's why I started Orval.

Main goals:

- Generate typescript models
- Generate HTTP Calls
- Generate Mocks with <a href="https://mswjs.io/" target="_blank">MSW</a>

The default generated client use axios and can be used by your favourite Javascript framework like angular, react or vue. It's just a function who takes an instance of axios in argument and return an object where each key is a function who setup a call HTTP. [Learn more](./guides/basics)
The default generated client use axios and can be used by your favourite Javascript framework like Angular, React or Vue. It's just a function who takes an instance of axios in argument and return an object where each key is a function who setup a call HTTP. [Learn more](./guides/basics)

orval can also generate the following client:
Orval can also generate the following client:

- [React query with axios](./guides/react-query)
- [Angular with HttpClient](./guides/angular)
7 changes: 4 additions & 3 deletions docs/src/pages/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ title: Quick Start
$ orval --input ./petstore.yaml --output ./src/petstore.ts
```

The --input can take a yaml or a json
The --output is the file where you want to generate your models and HTTP calls.
The `--input` can take a yaml or a json.

The `--output` is the file where you want to generate your models and HTTP calls.

## Example with config:

Expand All @@ -20,7 +21,7 @@ $ orval --config ./orval.config.js
$ orval
```

#### File orval.config.js
**File orval.config.js**

```js
module.exports = {
Expand Down
14 changes: 7 additions & 7 deletions docs/src/pages/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ id: cli
title: CLI
---

## orval reference
## Orval reference

orval provides a set of options that allow you to generate your models or the API calls of your application. This page contains a complete list of all orval options available.
Orval provides a set of options that allow you to generate your models or the API calls of your application. This page contains a complete list of all Orval options available.

To download and install orval, [follow the instructions here](../installation).
To download and install Orval, [follow the instructions here](../installation).

### Basic Usage

The `orval` command is used to generate client with appropriate type-signatures. By default search for an orval.config.js file.
The `orval` command is used to generate client with appropriate type-signatures. By default search for an `orval.config.js` file.

```bash
$ orval
Expand All @@ -35,15 +35,15 @@ $ orval --output ./api/endpoints/petstoreFromFileSpec.ts"
### Config
The `--config` option, shorthand `-c`, can be used to set the path to an orval config.
The `--config` option, shorthand `-c`, can be used to set the path to your Orval config.
```bash
$ orval --config ./api/orval.config.js
```
### Projet
### Project
The `--project` option, shorthand `-p`, can be used to focus on one project of your orval config.
The `--project` option, shorthand `-p`, can be used to focus on one project of your Orval config.
```bash
$ orval --project petstore
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/reference/configuration/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Type: `Object`.

Default Value: `{ resolve: { github: githubResolver }, }`.

Orval use a parser to handle multiple files specification. You can use the parserOptions property to provide custom config for that parser. Check [here](https://apitools.dev/swagger-parser/docs/options.html) available options. Be default orval add a github parser but you can add own if you have a private specification or other requirement.
Orval use a parser to handle multiple files specification. You can use the parserOptions property to provide custom config for that parser. Check [here](https://apitools.dev/swagger-parser/docs/options.html) available options. Be default Orval add a github parser but you can add own if you have a private specification or other requirement.

```js
module.exports = {
Expand Down
12 changes: 6 additions & 6 deletions docs/src/pages/reference/configuration/output.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ Here depending on the configuration, you will have multiple files named petstore
- petstore.ts
- petstore.msw.ts

For angular:
For Angular:

=> petstore.ts is petstore.service.ts

#### Value: tags

Use this mode if you want one file by tag. Tag is a reference of the OpenApi specification tag. If you have a `pets` tag for all your pet calls then orval will generate a file pets.ts in the target folder
Use this mode if you want one file by tag. Tag is a reference of the OpenApi specification tag. If you have a `pets` tag for all your pet calls then Orval will generate a file pets.ts in the target folder

```js
module.exports = {
Expand All @@ -156,15 +156,15 @@ my-app
└── petstore.schemas.ts
```

For angular:
For Angular:

=> petstore.ts is petstore.service.ts

If you don't use the `schemas` property only one file will be created with all the models for every tag.

#### Value: tags-split

This mode is a combination of the tags and split mode. orval will generate a folder for every tag in the target folder and split into multiple files in those folders.
This mode is a combination of the tags and split mode. Orval will generate a folder for every tag in the target folder and split into multiple files in those folders.

```js
module.exports = {
Expand Down Expand Up @@ -277,7 +277,7 @@ interface RequestConfig {
}
```

- The second is only provided for the angular client and give an instance of HttpClient
- The second is only provided for the Angular client and give an instance of HttpClient

Example:

Expand Down Expand Up @@ -403,7 +403,7 @@ module.exports = {

Type: `Object`.

Give you the possibility to put a value for a `format`. In your specification, if you put a `format: email` to a property orval will automatically generate a random email for you. See <a href="https://github.com/anymaniax/orval/blob/next/src/constants/format.mock.ts" target="_blank">here</a> the default available format.
Give you the possibility to put a value for a `format`. In your specification, if you put a `format: email` to a property Orval will automatically generate a random email for you. See <a href="https://github.com/anymaniax/orval/blob/next/src/constants/format.mock.ts" target="_blank">here</a> the default available format.

```js
module.exports = {
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/reference/configuration/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ id: configuration
title: Configuration
---

This page is a reference to the different ways of configuring your orval projects.
This page is a reference to the different ways of configuring your Orval projects.

Using an orval.config.js configuration file, placed at the root of a project, you can provide a list of options that changes the default behaviour of the orval generated files.
Using an `orval.config.js` configuration file, placed at the root of a project, you can provide a list of options that changes the default behaviour of the Orval generated files.

Configuration options for the following are described on this page:

Expand Down
11 changes: 8 additions & 3 deletions docs/src/pages/reference/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ id: integration
title: Integration
---

Give you the possibility to use orval with a script.
### Import script

Orval expose a function which takes a path to the orval config as an argument.
Orval gives you the possibility to import Orval.

It expose a function which takes a path to the Orval config as the argument.

```js
import orval from 'orval';

orval('./orval.config.js');
```

It's use for the <a href="https://marketplace.visualstudio.com/items?itemName=orval.orval-vscode" target="_blank">vscode orval extension</a>

### VS Code extension

The Visual Studio Code <a href="https://marketplace.visualstudio.com/items?itemName=orval.orval-vscode" target="_blank">Orval</a> extension will look for the Orval config file in your opened workspace and run Orval.

0 comments on commit 7a982ee

Please sign in to comment.