[BUG] Publishing OpenAPI v3 JSON fails - publishing the same specifications in YAML works
See original GitHub issueRelease version
4.1.0
Describe the bug
In my APIM lab I have a sample API called Echo API. I exported the API through the Azure Portal and chose the OpenAPI v3 JSON format, deleted the API and tried to publish the API with APIOps through a pipeline in Azure DevOps. I get an error message in the pipeline. See below for details.
If I try the same thing, but choosing to export OpenAPI v3 YAML and publishing with APIOps, it works.
If I try to import the JSON file to APIM through Azure Portal the import works as expected.
Expected behavior
APIOps should treat JSON and YAML the same.
Actual behavior
When trying to publish the API with the JSON file, the publisher gives the following error in the pipeline (resource names replaced with ***
):
crit: Publisher[0]
System.Net.Http.HttpRequestException: HTTP request to URI https://management.azure.com/subscriptions/***/resourceGroups/***/providers/Microsoft.ApiManagement/service/***/apis/echo-api?api-version=2022-04-01-preview&asyncId=6411cd42217d200cac3f6dff&asyncCode=201 failed with status code 400. Content is '{"error":{"code":"ValidationError","message":"One or more fields contain incorrect values:","details":[{"code":"ValidationError","target":"path","message":"'path' must not be empty."}]}}'.
at common.HttpPipelineExtensions.Validate(Response response, Uri requestUri)
at common.HttpPipelineExtensions.WaitForLongRunningOperation(HttpPipeline pipeline, Response response, CancellationToken cancellationToken)
at common.HttpPipelineExtensions.PutResource(HttpPipeline pipeline, Uri uri, JsonObject resource, CancellationToken cancellationToken)
at publisher.Program.<>c__DisplayClass12_0.<<GetPutRestResource>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at publisher.Api.PutApi(ApiName apiName, ApiInformationFile apiInformationFile, ApiSpecificationFile specificationFile, JsonObject configurationApiJson, ServiceUri serviceUri, PutRestResource putRestResource, ILogger logger, CancellationToken cancellationToken)
at publisher.Api.<>c__DisplayClass23_0.<<ProcessArtifactsToPut>b__4>d.MoveNext()
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.<>c__50`1.<<ForEachAsync>b__50_0>d.MoveNext()
--- End of stack trace from previous location ---
at common.IEnumerableExtensions.ForEachParallel[T](IEnumerable`1 enumerable, Func`2 action, CancellationToken cancellationToken)
at publisher.Api.ProcessArtifactsToPut(IReadOnlyCollection`1 files, JsonObject configurationJson, ServiceDirectory serviceDirectory, ServiceUri serviceUri, PutRestResource putRestResource, ILogger logger, CancellationToken cancellationToken)
at publisher.Service.ProcessArtifactsToPut(IReadOnlyCollection`1 files, JsonObject configurationJson, ServiceDirectory serviceDirectory, ServiceUri serviceUri, ListRestResources listRestResources, PutRestResource putRestResource, DeleteRestResource deleteRestResource, ILogger logger, CancellationToken cancellationToken)
at publisher.Publisher.ProcessCommitIdFilesToPut(IReadOnlyCollection`1 commitIdFilesToPut, CancellationToken cancellationToken)
at publisher.Publisher.RunWithCommitId(CommitId commitId, CancellationToken cancellationToken)
at publisher.Publisher.Run(CancellationToken cancellationToken)
at publisher.Publisher.ExecuteAsync(CancellationToken cancellationToken)
info: Microsoft.Hosting.Lifetime[0]
Application is shutting down...
fail: Microsoft.Extensions.Hosting.Internal.Host[9]
BackgroundService failed
When formatting the error message from the text above it’s a bit more readable:
{
"error": {
"code": "ValidationError",
"message": "One or more fields contain incorrect values:",
"details": [
{
"code": "ValidationError",
"target": "path",
"message": "'path' must not be empty."
}
]
}
}
Reproduction Steps
Try to publish the following file JSON file: https://gist.github.com/robertbrandso/01d5a5f40876956b24a2b191357eb368
Try to publish the following YAML file: https://gist.github.com/robertbrandso/01bb4c3ec776dfe64788aea17bddbef1
The following apiInformation.json were used: https://gist.github.com/robertbrandso/62dd66880a35d9d8f88b53f2a57ef981
Issue Analytics
- State:
- Created 6 months ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Just a slight correction. Can you please update your repository to state that the APIOPS is actually created as an open source project by people who happen to work at Microsoft and it’s by no means supported by the product team.
@waelkdouh @guythetechie I wasn’t sure on how to reach you, so I’ll try to post it here as it is partly related on what we discussed in the thread.
Just wanted to let you know I have created an alternative APIOps, which is declarative, highly inspired by your APIOps project🙂 Thank you for great inspiration. Feel free check it out here:
https://github.com/robertbrandso/terraform-azurerm-apim-apiops/wiki