This is a React + TypeScript + Vite example application that demonstrates API integration using AutoAPI.
- ✅ User Management (CRUD operations)
- ✅ Search and Filter
- ✅ Pagination
- ✅ Form Validation
- ✅ Image Upload
- ✅ Status Management
- ✅ Type-safe API calls with AutoAPI
- React 18 - UI framework
- TypeScript - Type safety
- Vite - Build tool
- Ant Design - UI component library
- Axios - HTTP client
- Day.js - Date formatting
- AutoAPI - API code generation
- Node.js >= 22.0.0
- npm >= 10.0.0
npm installnpm run swaggerThis will generate TypeScript API client code from the OpenAPI specification.
npm run devThe application will be available at: http://localhost:9528/react/
npm run dev- Start development servernpm run build- Build for productionnpm run preview- Preview production buildnpm run type-check- Run TypeScript type checkingnpm run lint- Run ESLintnpm run format- Format code with Prettiernpm run swagger- Generate API client code
autoapi-example-react/
├── src/
│ ├── apis/
│ │ └── auto/ # Auto-generated API code
│ ├── components/
│ │ ├── CommonQuery/ # Search/filter component
│ │ ├── CommonTable/ # Data table component
│ │ └── CommonForm/ # Form component
│ ├── views/
│ │ └── user/ # User management page
│ ├── types/
│ │ └── common.ts # TypeScript type definitions
│ ├── utils/
│ │ └── dayjs.ts # Date utility
│ ├── App.tsx # Root component
│ ├── main.tsx # Application entry
│ └── index.scss # Global styles
├── .autoapirc.json # AutoAPI configuration
├── .env # Environment variables
├── vite.config.ts # Vite configuration
├── tsconfig.json # TypeScript configuration
└── package.json # Project dependencies
The application uses AutoAPI to generate type-safe API client code. Configuration is in .autoapirc.json:
{
"application": {
"language": "ts",
"outputDir": "./src/apis/auto"
},
"servers": [
{
"code": "demo",
"source": "https://apisorcery.com/demo-api/swagger-json",
"version": 3,
"enabled": true,
}
]
}VITE_PORT- Development server port (default: 9528)VITE_GLOB_PUBLIC_PATH- Application base path (default: /react/)VITE_GLOB_BASE_API- API base path (default: /demo-api)
- Generate/update API client code:
npm run swagger - Create components in
src/components/ - Create views in
src/views/ - Update types in
src/types/
- Follow TypeScript best practices
- Use functional components with hooks
- Use Ant Design components
- Format code with Prettier before committing
npm run buildThe built files will be in the dist/ directory.
MIT