Quick Start
After installing AutoAPI and registering your device, you can start using AutoAPI in your project.
Initialization
Execute the following command in the project root directory:
Global command:
shell
apisorcery init -f react -l tsshell
apisorcery init -f vue -l tsshell
apisorcery init -f svelte -l tsshell
apisorcery init -f angular -l tsshell
apisorcery init -f flutter -l dartLocal command:
shell
npx @apisorcery/cli init -f react -l tsshell
npx @apisorcery/cli init -f vue -l tsshell
npx @apisorcery/cli init -f svelte -l tsshell
npx @apisorcery/cli init -f angular -l tsshell
npx @apisorcery/cli init -f flutter -l dartThis command will generate the ApiSorcery configuration file 【.apisorceryrc.json】 in the project root directory. Using a Dart project as an example, the content is as follows:
json
{
"application": {
"framework": "flutter",
"language": "dart",
"outputDir": "./lib/apis/auto"
},
"services": [
{
"code": "product",
"source": "http://localhost:9002/swagger-json",
"version": 3
}
]
}For configuration details, please refer to: Application Configuration | Service Configuration
Generate APIs
shell
apisorcery generateThis command will generate the following content:
shell
### % apisorcery generate
Starting to parse configuration file
Configuration file location: ./.apisorceryrc.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
----------------------------------------