Skip to content

Quick Start

Initialization

Execute the following command in the project root directory:

Global command:

shell
autoapi init -l dart
shell
autoapi init -l ts

Local command:

shell
npx autoapi init -l dart
shell
npx autoapi init -l ts

This command will generate the AutoAPI configuration file [.autoapirc.json] in the project root directory. Using a Dart project as an example, the content is as follows:

json
{
  "application": {
    "name": "AutoAPI Test Application",
    "language": "dart",
    "outputDir": "./lib/apis/auto"
  },
  "services": [
    {
      "code": "product",
      "name": "Product Service",
      "token": "682db637-0f31-4847-9cdf-3232432dfsfd",
      "version": 3,
      "enabled": true,
      "source": "http://localhost:9002/swagger-json",
      "returnLevel": "second",
      "returnSecondField": "data",
      "tagNameMap": {
        "User Management": "User",
        "User Authentication": "Auth",
        "Application Management": "Application"
      }
    }
  ]
}

For configuration details, please refer to: Application Configuration | Service Configuration

Generate APIs

shell
autoapi generate

This command will generate the following content:

shell
### % autoapi generate
Starting to parse configuration file
Configuration file location: ./.autoapirc.json
Configuration file parsing completed: 1 service found
----------------------------------------
Starting to process service 1
----------------------------------------

Starting to parse Swagger file
Swagger file parsing completed

Starting to generate Model files
Starting to generate custom classes
Starting to generate request parameter classes
Starting to generate response parameter classes
Starting to generate schema classes
Starting to output model files
Output file location: ./src/api/auto/product/model.ts
Model file generation completed

Starting to generate Base files
Output file location: ./src/api/auto/product/base.ts
Base file generation completed

Starting to generate API files
Output directory: ./src/api/auto/product
Starting to generate API class: ApiUser
Starting to generate API class: ApiAuth
Starting to generate API class: ApiApplication
Starting to generate API class: ApiServer
Starting to generate API class: ApiReport
API file generation completed

----------------------------------------
Service 1 processing completed
----------------------------------------