Client can't run autorest on the platform itself - FATAL: System.ArgumentNullException: Value cannot be null

If you run autorest after migrating our solution to 3.218*, you can try to run autorest on all modules which seems to work fine.

Issue: Can’t run autorest on the platform itself.

The following command is executed:
autoRest VirtoCommerce.Storefront\AutoRestClients\array-in-query-fix.yml --version=3.0.6274 --v3 --debug --input-file=http://localhost:10645/docs/VirtoCommerce.Platform/swagger.json --output-folder=.\VirtoCommerce.Storefront\AutoRestClients --output-file=PlatformModuleApi.cs --namespace=VirtoCommerce.Storefront.AutoRestClients.PlatformModuleApi --override-client-name=PlatformModuleClient --add-credentials --csharp --verbose

Which leads to the following output:

node.exe : FATAL: System.ArgumentNullException: Value cannot be null.
At C:\Program Files\nodejs\autorest.ps1:12 char:3
+ & "$basedir/node$exe" "$basedir/node_modules/autorest/entrypoints/ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (FATAL: System.A...cannot be null.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

Parameter name: source
at System.Linq.Enumerable.Select[TSource,TResult](IEnumerable1 source, Func2 selector)
at AutoRest.Modeler.Model.RequestBody.AsParameters() in /opt/vsts/work/1/s/src/Model/RequestBody.cs:line 38
at AutoRest.Modeler.SwaggerModeler.Unwrap(SwaggerParameter swaggerParameter) in /opt/vsts/work/1/s/src/SwaggerModeler.cs:line 452
at AutoRest.Modeler.OperationBuilder.BuildMethodParameters(Method method) in /opt/vsts/work/1/s/src/OperationBuilder.cs:line 255
at AutoRest.Modeler.OperationBuilder.BuildMethod(HttpMethod httpMethod, String url, String methodName, String methodGroup) in /opt/vsts/work/1/s/src/OperationBuilder.cs:line 100
at AutoRest.Modeler.SwaggerModeler.BuildMethod(HttpMethod httpMethod, String url, String name, Operation operation) in /opt/vsts/work/1/s/src/SwaggerModeler.cs:line 404
at AutoRest.Modeler.SwaggerModeler.Build(ServiceDefinition serviceDefinition) in /opt/vsts/work/1/s/src/SwaggerModeler.cs:line 106
at AutoRest.Modeler.Program.<ProcessInternal>d2.MoveNext() in /opt/vsts/work/1/s/src/Program.cs:line 60
--- End of stack trace from previous location where exception was thrown ---

Warkaround:

  1. Download ./VirtoCommerce.Platform/swagger.json file

  2. Open it in any text editor, Find and Rename section from application/x-www-form-urlencoded to application/json-patch+json

  3. Run script

Current ./VirtoCommerce.Platform/swagger.json file

Fixed ./VirtoCommerce.Platform/swagger.json file
image

Result

2 Likes