# saif-utilities / openapi_parser

This module parses OpenAPI specifications and extracts useful information such as operations, security settings, servers, and mocking configurations. It's designed to facilitate the analysis and processing of OpenAPI documents within Terraform configurations.

## Features

- **OpenAPI Parsing**: Decodes and processes OpenAPI YAML specifications
- **Security Analysis**: Extracts OAuth2 scopes and roles from security definitions
- **Server Configuration**: Separates production and mocking servers
- **Operation Processing**: Provides detailed information about API operations including security overrides
- **Mocking Support**: Identifies and handles mocking configurations at service and operation levels

## Usage

```hcl
module "openapi_parser" {
  source = "path/to/openapi_parser"
  
  file = file("${path.module}/openapi.yaml")
  
  tags = {
    Environment = "production"
    Project     = "api-gateway"
  }
}
```

## Examples

See the [examples](examples/openapi-parser.md) directory for complete usage examples.

<!-- BEGIN_TF_DOCS -->
## Providers

No providers.

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_file"></a> [file](#input\_file) | The OpenAPI file to parse | `string` | n/a | yes |
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to assign to the resources | `map(string)` | `{}` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_file"></a> [file](#output\_file) | The original OpenAPI file content |
| <a name="output_mocking"></a> [mocking](#output\_mocking) | Whether mocking is enabled for the service |
| <a name="output_mocking_servers"></a> [mocking\_servers](#output\_mocking\_servers) | List of mocking servers from the OpenAPI specification |
| <a name="output_operations"></a> [operations](#output\_operations) | Parsed operations from the OpenAPI specification with security and mocking information |
| <a name="output_servers"></a> [servers](#output\_servers) | List of non-mocking servers from the OpenAPI specification |
| <a name="output_service_roles"></a> [service\_roles](#output\_service\_roles) | Default security roles for the service |
| <a name="output_service_scopes"></a> [service\_scopes](#output\_service\_scopes) | Default security scopes for the service |
| <a name="output_title"></a> [title](#output\_title) | The title of the OpenAPI specification |
| <a name="output_version"></a> [version](#output\_version) | The version of the OpenAPI specification |

## Resources
    
<!-- END_TF_DOCS -->

---

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