I have an endpoint that allows uploading a file.
After updating to the latest version of Autorest, I can't generate a client anymore and receive a generic error. I went through the issues here but didn't find an answer. I'm still using OpenApi2.0 spec.
According to the spec, I'm setting all the parameters needed.
Running autorest with --verbose --debug parameters didn't give me any additional info.
{
"swagger": "2.0",
"info": {
"title": "test",
"description": "test",
"version": "v1"
},
"paths": {
"/logo": {
"put": {
"tags": [
"test"
],
"summary": "test",
"description": "test",
"operationId": "test",
"consumes": [
"multipart/form-data"
],
"produces": [
],
"parameters": [
{
"in": "formData",
"name": "formFile",
"description": "The file to upload.",
"required": true,
"type": "file"
}
],
"responses": {
"204": {
"description": "Success."
}
}
}
}
},
"definitions": {
},
"securityDefinitions": {
}
}
FATAL: System.ArgumentNullException: Value cannot be null.
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>d__2.MoveNext() in /opt/vsts/work/1/s/src/Program.cs:line 60
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NewPlugin.<Process>d__15.MoveNext()
/private/var/root/.autorest/@[email protected]/node_modules/@autorest/core/dist/lib/pipeline/pipeline.js - FAILURE {}
Process() cancelled due to exception : Plugin imodeler1 reported failure. / Error: Plugin imodeler1 reported failure.
at /private/var/root/.autorest/@[email protected]/node_modules/@autorest/core/dist/lib/pipeline/plugins/external.js:26:19
at async ScheduleNode (/private/var/root/.autorest/@[email protected]/node_modules/@autorest/core/dist/lib/pipeline/pipeline.js:294:33)
Error: Plugin imodeler1 reported failure.
autorest --info
AutoRest code generation utility [cli version: 3.0.6187; node: v12.13.0, max-memory: 8192 gb]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
Showing All Installed Extensions
Type Extension Name Version Location
core @autorest/core 3.0.6262 /var/root/.autorest/@[email protected]
extension @microsoft.azure/autorest.csharp 2.3.84 /var/root/.autorest/@[email protected]
extension @microsoft.azure/autorest.modeler 2.3.55 /var/root/.autorest/@[email protected]
According to OAS V2 spec 'file' is OK
In V3 it changes to string:binary and that may have a knock on effect.
What are your results if you npm install an older version? You can also try a
specify an older version of autorest.modeler in config.yaml
are you using --version:latest in your command? don't.
try
"type": "object",
"format": "file"
Ref modeler project: https://github.com/Azure/autorest.modeler/blob/master/src/BuilderExtensions.cs#L77
@OzBob, @fearthecowboy,
thanks for your answers.
unfortunately, it still doesn't work with autorest v3.0.6262
Using:
"type": "object",
"format": "file"
causes another error:
ERROR: Schema violation: Data does not match any schemas from 'oneOf'
I ended up using an older version of autorest: 2.0.4413
Why all issues about it closed?
This is not resolved yet!.
We cannot use "in": "formData", every time error. For file or for string.
NSWag (https://github.com/RicoSuter/NSwag) seems to have better support for file parameters.
@ANovitsky if you have a current issue could you please open a new one and mention this issue 3463, please.
Most helpful comment
Why all issues about it closed?
This is not resolved yet!.
We cannot use "in": "formData", every time error. For file or for string.