Autorest V3 csharp petstore example failing on 'source' parameter when include requestBody
After converting https://petstore.swagger.io/v2/swagger.json to OpenAPI 3.0.1
by loading it into https://editor.swagger.io/ then Edit | Convert to Open API 3 - > sending it to https://converter.swagger.io/api/convert
downloading the resultant json and using
Autorest --v3 --input-file=petstore3.json --csharp --output-folder=petstore --namespace=petstore
results in:
Loading AutoRest extension '@microsoft.azure/autorest.csharp' (~2.3.79->2.3.84)
Loading AutoRest extension '@microsoft.azure/autorest.modeler' (2.3.55->2.3.55)
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
Note: When running the https://github.com/Azure/autorest.modeler/pull/59 test project there are no errors.
Is autorest.modeler 2.3.55 uptodate?
Feature Request : add a --debug flag to have progress 'info' e.g. 'paths' / node name info etc. output to console during run of extensions.
Is there developer guidance as to how to import a custom build of an extension into the autorest installed locally?
if remove this section of the petstore.json, no more errors:
,
"requestBody": {
"content": {
"application/x-www-form-urlencoded": {
"schema": {
"properties": {
"name": {
"type": "string",
"description": "Updated name of the pet"
},
"status": {
"type": "string",
"description": "Updated status of the pet"
}
}
}
}
}
},
Please ignore
Incorrectly parsed old schema in.
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md : "The request body applicable for this operation. The requestBody is only supported in HTTP methods where the HTTP 1.1 specification RFC7231 has explicitly defined semantics for request bodies. In other cases where the HTTP spec is vague, requestBody SHALL be ignored by consumers."
but .... according to Swagger.io converter issue the "Paramters/in:body" should be and now is converted to requestBody??
Hello, i'm facing the same issue, with my openapi 3 json documentation.
Here is the autorest command line :
autorest --input-file=swagger.json --csharp --v3 --add-credentials --output-folder=RestClient --namespace=MyNamespace --debug
The exception is thrown in the modeler pipeline. I cloned the modeler project running unit test with the same json file the test passes.
Is there a way to load a custom build of the modeler ?
autorest : FATAL: System.ArgumentNullException: Value cannot be null.
+ autorest --input-file=swagger.json --csharp --v3 --add-credentials - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ 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()
at AutoRest.Modeler.SwaggerModeler.Unwrap(SwaggerParameter swaggerParameter)
at AutoRest.Modeler.OperationBuilder.BuildMethodParameters(Method method)
at AutoRest.Modeler.OperationBuilder.BuildMethod(HttpMethod httpMethod, String url, String methodName, String methodGroup)
at AutoRest.Modeler.SwaggerModeler.BuildMethod(HttpMethod httpMethod, String url, String name, Operation operation)
at AutoRest.Modeler.SwaggerModeler.Build(ServiceDefinition serviceDefinition)
at AutoRest.Modeler.Program.<ProcessInternal>d__2.MoveNext()
--- 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()
C:\Users\HossamLaanait\.autorest\@[email protected]\node_modules\@autorest\core\dist\lib\pipeline\pipeline.js - FAILURE {}
@laanaithossam add a 'thumbsup' to the first post in this issue and it might get more attention.
Looks like the same issue as #3441?
Closing as duplicate of #3441.