## File: README.md

# Swagger TypeScript API

- Support for OpenAPI 3.0, 2.0, JSON and YAML
- Generate the API Client for Fetch or Axios from an OpenAPI Specification

Any questions you can ask here: <https://github.com/acacode/swagger-typescript-api/discussions>

## Examples

All examples you can find here: <https://github.com/acacode/swagger-typescript-api/tree/main/tests>

## Usage

You can use this package in two ways:

### CLI

```bash
npx swagger-typescript-api generate --path ./swagger.json
```

Or install locally in your project:

```bash
npm install --save-dev swagger-typescript-api
npx swagger-typescript-api generate --path ./swagger.json
```

### Library

```bash
npm install --save-dev swagger-typescript-api
```

```typescript
import * as path from "node:path";
import * as process from "node:process";
import { generateApi } from "swagger-typescript-api";

await generateApi({ input: path.resolve(process.cwd(), "./swagger.json") });
```

For more detailed configuration options, please consult the documentation.

## Mass media

- [5 Lessons learned about swagger-typescript-api](https://christo8989.medium.com/5-lessons-learned-about-swagger-typescript-api-511240b34c1)
- [Why Swagger schemes are needed in frontend development ?](https://dev.to/js2me/why-swagger-schemes-are-needed-in-frontend-development-2cb4)
- [Migration en douceur vers TypeScript (French)](https://www.premieroctet.com/blog/migration-typescript/)
- [swagger-typescript-api usage (Japanese)](https://zenn.dev/watahaya/articles/2f4a716c47903b)
- [Working with REST APIs using swagger-typescript-api (Russian)](https://habr.com/ru/articles/799853/)
- [Using custom templates and configs for swagger-typescript-api (Russian)](https://habr.com/ru/articles/802097/)

## License

Licensed under the [MIT License](https://github.com/acacode/swagger-typescript-api/blob/main/LICENSE).

---

## File: templates/modular/README.md

# swagger-typescript-api

# templates/modular

This templates use for multiple api files (`--modular` option)

path prefix `@modular`

---

## File: templates/default/README.md

# swagger-typescript-api

# templates/default

This templates use for single api file (without `--modular` option)

path prefix `@default`

---

## File: templates/base/README.md

# swagger-typescript-api

# templates/base

This templates use both for multiple api files and single api file

path prefix `@base`

---

## File: templates/README.md

# swagger-typescript-api

# templates

Templates:

- `api.ejs` - _(generates file)_ Api class module (locations: [default](https://github.com/acacode/swagger-typescript-api/tree/main/templates/default/api.ejs), [modular](https://github.com/acacode/swagger-typescript-api/tree/main/templates/modular/api.ejs))
- `data-contracts.ejs` - _(generates file)_ all types (data contracts) from swagger schema (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/main/templates/base/data-contracts.ejs))
- `http-client.ejs` - _(generates file)_ HttpClient class module (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/main/templates/base/http-client.ejs))
- `procedure-call.ejs` - _(subtemplate)_ route in Api class (locations: [default](https://github.com/acacode/swagger-typescript-api/tree/main/templates/default/procedure-call.ejs), [modular](https://github.com/acacode/swagger-typescript-api/tree/main/templates/modular/procedure-call.ejs))
- `route-docs.ejs` - _(generates file)_ documentation for route in Api class (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/main/templates/base/route-docs.ejs))
- `route-name.ejs` - _(subtemplate)_ route name for route in Api class (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/main/templates/base/route-name.ejs))
- `route-type.ejs` - _(`--route-types` option)_ _(subtemplate)_ (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/main/templates/base/route-type.ejs))
- `route-types.ejs` - _(`--route-types` option)_ _(subtemplate)_ (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/main/templates/base/route-types.ejs)) - `data-contract-jsdoc.ejs` - _(subtemplate)_ generates JSDOC for data contract (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/main/templates/base/data-contract-jsdoc.ejs))

[//]: # "- `enum-data-contract.ejs` - *(subtemplate)* generates `enum` data contract (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/main/templates/base/enum-data-contract.ejs))"
[//]: # "- `interface-data-contract.ejs` - *(subtemplate)* generates `interface` data contract (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/main/templates/base/interface-data-contract.ejs))"
[//]: # "- `type-data-contract.ejs` - *(subtemplate)* generates `type` data contract (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/main/templates/base/type-data-contract.ejs))"