# API Documentation (Swagger) {#api-documentation-swagger}


Auto-generated API documentation using Swagger/OpenAPI.


## Accessing Swagger UI {#accessing-swagger-ui}


When the API is running, Swagger UI is available at:

```
http://localhost:3000/swg
```


## Configuration {#configuration}


```bash
# Enable/disable Swagger
SWAGGER_ENABLED=true
```


## Swagger Setup {#swagger-setup}


```typescript
const config = new DocumentBuilder()
  .setTitle("Ever Gauzy API")
  .setDescription("Ever Gauzy Platform API Documentation")
  .setVersion("1.0")
  .addBearerAuth()
  .addTag("Auth", "Authentication endpoints")
  .addTag("Employee", "Employee management")
  .addTag("Organization", "Organization management")
  .addTag("TimeTracking", "Time tracking endpoints")
  .build();

const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup("swg", app, document);
```


## Decorating Controllers {#decorating-controllers}


```typescript
@ApiTags('Employee')
@ApiBearerAuth()
@Controller('/employee')
export class EmployeeController {
  @Get()
  @ApiOperation({ summary: 'Get all employees' })
  @ApiResponse({ status: 200, description: 'Employee list' })
  @ApiResponse({ status: 401, description: 'Unauthorized' })
  async findAll() { ... }
}
```


## DTO Documentation {#dto-documentation}


```typescript
export class CreateEmployeeDTO {
  @ApiProperty({ description: "First name", example: "John" })
  @IsString()
  firstName: string;

  @ApiProperty({ description: "Last name", example: "Doe" })
  @IsString()
  lastName: string;

  @ApiPropertyOptional({ description: "Bill rate" })
  @IsOptional()
  @IsNumber()
  billRateValue?: number;
}
```


## OpenAPI Spec Export {#openapi-spec-export}


```bash
# Export OpenAPI JSON spec
curl http://localhost:3000/swg-json > openapi.json
```


## Related Pages {#related-pages}


- [API Overview](https://sourcey-gauzy.pages.dev/api/overview/index.md)
- [REST API](https://sourcey-gauzy.pages.dev/api/rest-api/index.md)
