Skip to content

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

module "openapi_parser" {
  source = "path/to/openapi_parser"

  file = file("${path.module}/openapi.yaml")

  tags = {
    Environment = "production"
    Project     = "api-gateway"
  }
}

Examples

See the examples directory for complete usage examples.

Providers

No providers.

Inputs

Name Description Type Default Required
file The OpenAPI file to parse string n/a yes
tags A map of tags to assign to the resources map(string) {} no

Outputs

Name Description
file The original OpenAPI file content
mocking Whether mocking is enabled for the service
mocking_servers List of mocking servers from the OpenAPI specification
operations Parsed operations from the OpenAPI specification with security and mocking information
servers List of non-mocking servers from the OpenAPI specification
service_roles Default security roles for the service
service_scopes Default security scopes for the service
title The title of the OpenAPI specification
version The version of the OpenAPI specification

Resources


View source on GitHub