Convert your JSON or YAML OpenAPI schema file to Akamai API endpoint JSON.

Run terraform plan or terraform validate to check the structure of your schema file and terraform apply to get the converted schema into your state file.

Use the returned api attribute as a local variable in the api resource to register your API.

data "akamai_apidefinitions_openapi" "my_api" {
  file_path = "./my-api-schema.json"
}

output "my_api" {
  value = data.akamai_apidefinitions_openapi.my_api
}
my_schema = {
  api       = jsonencode(
    {
      enableApiGateway   = true
      hostnames      = [
        "my_api_definition.com",
      ]
      matchCaseSensitive = true
      name         = "Pet Store"
      resources      = {
        "/pets" = {
          description = <<-EOT
            GET: List all pets
            POST: Create a pet
          EOT
          get     = {
            parameters = [
              {
                description = "How many items to return at one time (max 100)."
                in      = "query"
                maximum   = 1000
                name    = "limit"
                type    = "integer"
              },
            ]
          }
          name    = "/pets"
          post    = {
            requestBody = {
              json = {
                name     = "Pet"
                properties = [
                  {
                    name   = "id"
                    required = true
                    type   = "integer"
                  },
                  {
                    name   = "name"
                    required = true
                    type   = "string"
                  },
                  {
                    name = "tag"
                    type = "string"
                  },
                ]
                required   = true
                type     = "object"
              }
            }
          }
        }
      }
    }
  )
  api_file_name = null
  file_path   = "./my-openapi.yml"
}
// local
api = data.akamai_apidefinitions_openapi.myapi.api

Argument

Pass a full or relative path to your API collection's schema.

ArgumentRequiredDescription
file_path✔️The full or relative path to your flattened OpenAPI schema file. Schema can be JSON or YAML.
api_file_nameThe root file name for a compressed file.
apiJSON-formatted information about your API configuration.

Attributes

There is no standard output for this resource. Changes are reflected in your state file.

AttributeDescription
apiThe JSON-formatted conversion of your OpenAPI schema returned from the API Definitions data source. Contains:
  • name. The name of your collection. The value reflects your schema's info.title field.
  • hostnames. Your API's root path. The value reflects your schema's servers.url field.
  • matchCaseSensitive. Whether the URLs and parameters within the endpoint are case sensitive.
  • enableApiGateway. Whether the API Gateway product should be enabled for the endpoint.
  • resources. The path and method information about each of your endpoints. Maps to the resources property in your schema.
file_pathThe path to your API file.
api_file_nameThe root file name for a compressed file.