hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.46k stars 4.54k forks source link

azurerm_api_management_api_schema adding double quotes to already json formatted value #26515

Open manuel9nunez opened 1 week ago

manuel9nunez commented 1 week ago

Is there an existing issue for this?

Community Note

Terraform Version

1.9.0

AzureRM Provider Version

3.109.0

Affected Resource(s)/Data Source(s)

azurerm_api_management_api_schema

Terraform Configuration Files

resource "azurerm_api_management_api_schema" "my_schema" {
  api_name            = azurerm_api_management_api.api.name
  api_management_name = azurerm_api_management_api.api.api_management_name
  resource_group_name = azurerm_api_management_api.api.resource_group_name
  schema_id           = "my_schema"
  content_type        = "application/vnd.oai.openapi.components+json"
  components             =  file("${path.module}/contracts/Request.json")
}

Debug Output/Panic Output

No errors

Expected Behaviour

Looking at another schema created by the UI

image

Actual Behaviour

This is the result wiht the one created in terraform

image

Steps to Reproduce

1.terraform apply

Important Factoids

Running in Azure Pipeline/local pointing to Azure US same result

References

https://github.com/hashicorp/terraform-provider-azurerm/issues/3980

teowa commented 4 days ago

Hi @manuel9nunez , thanks for submitting this issue! I am working on a PR to fix this. I can make API schema created by Terraform looks like in the first provided screenshot, but I am unable to find any documents on how to create the API schema on Azure Portal, so I am unable to validate my PR really work in real scenario. Do you know how I can play with some demo of API schema, so that I can validate my PR really fix the issue?

manuel9nunez commented 4 days ago

Sure heres some examples you should be able to spin up a free tiered one

https://learn.microsoft.com/en-us/azure/api-management/add-api-manually

Here they show how to create the representation in the UI

https://learn.microsoft.com/en-us/azure/api-management/mock-api-responses?tabs=azure-portal