mirsaeedi / dotnet-apim

dotnet-apim is a cross-platform dotnet tool which streamlines the CI/CD process of deploying APIs into Azure API Management
MIT License
31 stars 10 forks source link

Error when openApiSpec references a yaml open api specification file #3

Closed andrewdmoreno closed 4 years ago

andrewdmoreno commented 4 years ago

Specifying a yaml file as the value for openApiSpec results in the following exception:

System.AggregateException: One or more errors occurred. (Unexpected character encountered while parsing value: o. Path '', line 0, position 0.) ---> Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: o. Path '', line 0, position 0.
   at Newtonsoft.Json.JsonTextReader.ParseValue()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.OpenAPISpecReader.GetOpenApiVersion() in C:\Users\u6104652\source\repos\azure-api-management-devops-resource-kit\src\apimtemplate\Core\Infrastructure\OpenAPISpecReader.cs:line 20
   at Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.OpenAPISpecReader.GetOpenApiFormat() in C:\Users\u6104652\source\repos\azure-api-management-devops-resource-kit\src\apimtemplate\Core\Infrastructure\OpenAPISpecReader.cs:line 43
   at Microsoft.Azure.Management.ApiManagement.ArmTemplates.Create.ApiTemplateCreator.CreateApiTemplateResourceAsync(ApiDeploymentDefinition api, Boolean isInitial) in C:\Users\u6104652\source\repos\azure-api-management-devops-resource-kit\src\apimtemplate\ApimEntities\Api\APITemplateCreator.cs:line 118
   at Microsoft.Azure.Management.ApiManagement.ArmTemplates.Create.ApiTemplateCreator.CreateApiTemplateAsync(ApiDeploymentDefinition api, Boolean isInitial) in C:\Users\u6104652\source\repos\azure-api-management-devops-resource-kit\src\apimtemplate\ApimEntities\Api\APITemplateCreator.cs:line 53
   at Microsoft.Azure.Management.ApiManagement.ArmTemplates.Create.ApiTemplateCreator.CreateApiTemplatesAsync(ApiDeploymentDefinition api) in C:\Users\u6104652\source\repos\azure-api-management-devops-resource-kit\src\apimtemplate\ApimEntities\Api\APITemplateCreator.cs:line 41

It appears that the GetOpenApiVersion method, which only supports json, is getting called even for yaml files.

mirsaeedi commented 4 years ago

Thanks. We don't plan to add it to the tool for now. However, now the tool throws exception with appropriate message "Unsupported OpenApi format. The OpenApi document should be provided in json format. Version 2 and 3 of OpenApi are supported"