# saif-utilities / examples / openapi-parser

This example demonstrates how to use the `openapi_parser` module to parse an OpenAPI specification and extract useful information about the API.

## Overview

The example shows how to:
- Parse a complete OpenAPI 3.0 specification
- Extract server configurations (production vs mocking)
- Process security settings at service and operation levels
- Handle mocking overrides at the operation level
- Extract OAuth2 scopes and roles

## Usage

1. **Set up authentication** (if deploying to Azure):
   ```bash
   az login
   ```

2. **Initialize Terraform**:
   ```bash
   terraform init
   ```

3. **Plan the deployment**:
   ```bash
   terraform plan
   ```

4. **Apply the configuration**:
   ```bash
   terraform apply
   ```

## What This Example Does

This example:
1. Creates a resource group (for demonstration purposes)
2. Parses a comprehensive OpenAPI specification for a Pet Store API
3. Demonstrates various OpenAPI features:
   - Multiple servers (production and mocking)
   - Global and operation-specific security settings
   - Mocking overrides at the operation level
   - OAuth2 security schemes with different scopes

## Expected Outputs

After running `terraform apply`, you'll see outputs showing:
- The parsed API title and version
- Separated production and mocking servers
- Extracted security scopes
- All operations with their security and mocking configurations

## OpenAPI Specification Features Demonstrated

The example OpenAPI spec includes:
- **Global mocking disabled** with operation-level override
- **Multiple servers** with mocking server identification
- **OAuth2 security** with various scopes
- **Operation-specific security** overrides
- **Mixed security requirements** across operations

## Clean Up

To remove the created resources:
```bash
terraform destroy
```

---

[View source on GitHub](https://github.com/saif-corp/forge/blob/main/src/terraform/saif-utilities/examples/openapi-parser/README.md)
