Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit da1ae65

Browse files
bremnesRupengLiu
authored andcommitted
#264 Fixed generated ARM resource for schemas of type OpenAPI so that definitions will survive extract+deployment. (#280)
1 parent 8d69848 commit da1ae65

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/APIM_ARMTemplate/apimtemplate/Common/TemplateModels/SchemaTemplateResource.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public class SchemaTemplateProperties
1515
public class SchemaTemplateDocument
1616
{
1717
public string value { get; set; }
18+
19+
public dynamic components { get; set; }
1820
}
1921

2022
public class RESTReturnedSchemaTemplate : APITemplateSubResource

src/APIM_ARMTemplate/apimtemplate/Extractor/EntityExtractors/APIExtractor.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,14 +494,21 @@ private async Task<List<TemplateResource>> GenerateSchemasARMTemplate(string api
494494

495495
private string GetSchemaValueBasedOnContentType(RESTReturnedSchemaTemplateProperties schemaTemplateProperties)
496496
{
497+
var contentType = schemaTemplateProperties.contentType.ToLowerInvariant();
498+
if (contentType.Equals("application/vnd.oai.openapi.components+json"))
499+
{
500+
// for OpenAPI "value" is not used, but "components" which is resolved during json deserialization
501+
return null;
502+
}
503+
497504
if (!(schemaTemplateProperties.document is JToken))
498505
{
499506
return JsonConvert.SerializeObject(schemaTemplateProperties.document);
500507
}
501508

502509
var schemaJson = schemaTemplateProperties.document as JToken;
503510

504-
switch (schemaTemplateProperties.contentType.ToLowerInvariant())
511+
switch (contentType)
505512
{
506513
case "application/vnd.ms-azure-apim.swagger.definitions+json":
507514
if (schemaJson["definitions"] != null && schemaJson.Count() == 1)

0 commit comments

Comments
 (0)