Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/19276 extension of simple api about schemas AB#19276 #399

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions modules/azure/api_management_api_simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ provider "azurerm" {
}

locals {
do_schema = var.schema.file_location != null && var.schema.type != null && var.schema.schema_id != null ? true : false
}

#######################################################
Expand Down Expand Up @@ -239,3 +240,12 @@ resource "azurerm_api_management_product_api" "product_api" {
api_management_name = var.api_management_name
resource_group_name = var.resource_group_name
}

resource "azurerm_api_management_global_schema" "json" {
count = local.do_schema ? 1 : 0
schema_id = var.schema.schema_id
api_management_name = var.api_management_name
resource_group_name = var.resource_group_name
type = var.schema.type
value = file(var.schema.file_location)
}
21 changes: 21 additions & 0 deletions modules/azure/api_management_api_simple/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,24 @@ variable "custom_outbound_policy" {
description = "Additional outbound xml policies"
default = null
}

variable "schema" {
type = object({
file_location = optional(string),
type = optional(string),
schema_id = optional(string)
})

default = {
file_location = null
type = null
schema_id = null
}

validation {
condition = ((var.schema.file_location != null && var.schema.type != null && var.schema.schema_id != null) || (var.schema.file_location == null && var.schema.type == null && var.schema.schema_id == null))
error_message = "schema_id, file_location and type must be provided."
}

description = "Schema for validation of request"
}