Documentation for Zarv Developers - A comprehensive guide and API reference for developers using Zarv services.
This project uses VitePress to generate static documentation from markdown files.
First, make sure you have pnpm installed on your system. If you don't have it, you can install it globally:
npm install -g pnpmThen, install the project dependencies:
pnpm installStarts the VitePress development server with hot reload functionality.
pnpm devThis will start a local development server, typically at http://localhost:5173, where you can preview your documentation changes in real-time.
Builds the documentation for production deployment.
pnpm buildThis command generates optimized static files in the docs/.vitepress/dist directory, ready for deployment to any static hosting service.
Serves the built documentation locally for testing before deployment.
pnpm previewUse this command after running pnpm build to preview the production build locally and ensure everything works correctly.
Formats all code files using Prettier according to the project's style guidelines.
pnpm formatThis ensures consistent code formatting across all markdown, configuration, and other project files.
docs/- Contains all documentation source filesdocs/.vitepress/- VitePress configuration and theme filesdocs/api/- API documentationdocs/detran/- Detran-specific documentationdocs/public/- Static assets (images, icons, etc.)
To add a new API to the documentation, follow these steps:
First, ensure you have your OpenAPI specification file (JSON format) ready. Place it in the docs/public/openapi/ directory:
docs/public/openapi/your-api-name.json
Create a new directory under docs/api/ for your API:
mkdir docs/api/your-api-nameInside your new API directory, create the following files:
---
aside: false
outline: false
title: Your API Name
---
<script setup lang="ts">
import { useOpenapi } from 'vitepress-openapi'
import spec from '../../public/openapi/your-api-name.json'
const openapi = useOpenapi({ spec })
</script>
# Your API Name
<OASpec :spec="openapi" />---
aside: false
outline: false
---
<script setup lang="ts">
import { useOpenapi } from 'vitepress-openapi'
import spec from '../../public/openapi/your-api-name.json'
const openapi = useOpenapi({ spec })
</script>
<OAOperation :openapi="openapi" />import spec from '../../public/openapi/your-api-name.json'
export default {
paths() {
return Object.keys(spec.paths || {}).flatMap((path) => {
return Object.keys(spec.paths[path] || {}).map((method) => {
const operation = spec.paths[path][method]
return {
params: {
operationId: operation.operationId,
},
}
})
})
},
}# Autenticação
Descreva aqui como a autenticação funciona para sua API.
## Exemplo de Uso
```bash
curl -H "Authorization: Bearer YOUR_TOKEN" \
https://api.zarv.com/your-endpoint
### 4. Update VitePress Configuration
Edit `docs/.vitepress/config.mts` to include your new API:
1. **Import the specification:**
```typescript
import yourApiSpec from "../public/openapi/your-api-name.json" with { type: "json" };
- Create sidebar configuration:
const yourApiSidebar = useSidebar({
spec: yourApiSpec,
linkPrefix: "/api/your-api-name/",
});- Add to sidebar configuration:
sidebar: {
// ... existing sidebars
"/api/your-api-name/": [
{
text: "Autenticação",
link: "/api/your-api-name/authentication",
},
{
text: "Referência da API",
link: "/api/your-api-name",
},
...yourApiSidebar.generateSidebarGroups(),
],
}Add your new API to the main API index page at docs/api/index.md by adding a new card to the existing grid.
Run the development server to test your new API documentation:
pnpm devNavigate to /api/your-api-name to verify everything is working correctly.
- VitePress - Static site generator for documentation
- Vue.js - Frontend framework (used by VitePress)
- Prettier - Code formatter
- vitepress-openapi - OpenAPI documentation integration