Skip to content

Commit

Permalink
docs: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
solufa committed Jul 30, 2020
1 parent 76dde8d commit 1906088
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 55 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
node_modules
dist
test2
reference
aspida.taichi.config.js
external_refs_sample
60 changes: 9 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
<a href="https://codecov.io/gh/aspida/aspida">
<img src="https://img.shields.io/codecov/c/github/aspida/openapi2aspida.svg" alt="Codecov" />
</a>
<a href="https://dependabot.com">
<img src="https://api.dependabot.com/badges/status?host=github&repo=aspida/openapi2aspida" alt="Dependabot Status" />
</a>
<a href="https://github.com/aspida/openapi2aspida/LICENSE">
<img src="https://img.shields.io/npm/l/openapi2aspida" alt="License" />
</a>
Expand All @@ -35,68 +32,29 @@

## Getting Started

Create config file in project root

`aspida.config.js`

```js
module.exports = {
input: "apis", // "input" of aspida is "output" for openapi2aspida
outputEachDir: true, // Generate $api.ts in each endpoint directory
openapi: { inputFile: "https://petstore.swagger.io/v2/swagger.json" } // Compatible with yaml/json of OpenAPI3.0/Swagger2.0
}
```

`tarminal`
Compatible with yaml/json of OpenAPI3.0/Swagger2.0

```sh
$ npx openapi2aspida --build
# apis/$api.ts was built successfully.
$ npx openapi2aspida -i https://petstore.swagger.io/v2/swagger.json
# api/$api.ts was built successfully.
```

## Getting Started with aspida-mock
## Build from config file

Installation ([@aspida/axios](https://github.com/aspida/aspida/tree/master/packages/aspida-axios) only mock compatible)

- Using [npm](https://www.npmjs.com/):

```sh
$ npm install @aspida/axios axios
$ npm install aspida-mock --save-dev
```

- Using [Yarn](https://yarnpkg.com/):

```sh
$ yarn add @aspida/axios axios
$ yarn add aspida-mock --dev
```

`package.json`

```json
{
"scripts": {
"build": "aspida-mock --build"
}
}
```
Create config file in project root

`aspida.config.js`

```js
module.exports = {
openapi: { inputFile: "https://petstore.swagger.io/v2/swagger.json", mock: true }
input: "api", // "input" of aspida is "output" for openapi2aspida
outputEachDir: true, // Generate $api.ts in each endpoint directory
openapi: { inputFile: "https://petstore.swagger.io/v2/swagger.json" }
}
```

`tarminal`

```sh
$ npx openapi2aspida --build
# apis/$api.ts was built successfully.
$ npm run build
# apis/$mock.ts was built successfully.
$ npx openapi2aspida
```

## License
Expand Down
2 changes: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ export const run = (args: string[]) => {
argv.version !== undefined
? console.log(`v${require('../package.json').version}`)
: argv.input
? build({ openapi: { inputFile: argv.input } })
? build({ outputEachDir: true, openapi: { inputFile: argv.input } })
: build(argv.config)
}

0 comments on commit 1906088

Please sign in to comment.