question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Regression] Modeler ArgumentNullException with request body parameters

See original GitHub issue

Attempting to generate code for an OpenAPI 3.0 document with a multipart/form-data request body, such as the following:

openapi: '3.0.3'
info:
  title: OpenAPI 3 example with multipart/form-data request body
  version: '1.0.0'
components:
  schemas:
    ExampleFormDataBody:
      type: object
      properties:
        prop1:
          type: string
        prop2:
          type: string
paths:
  /post-example:
    post:
      operationId: postExample
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/ExampleFormDataBody'
      responses:
        '201':
          description: Success

Using the command autorest --v3 --csharp --input-file=openapi.yaml, produces an error such as:

AutoRest code generation utility [cli version: 3.0.6187; node: v10.17.0, max-memory: 8192 gb]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
   Loading AutoRest core      '/home/kevin/.autorest/@autorest_core@3.0.6246/node_modules/@autorest/core/dist' (3.0.6246)
   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
   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()
  Error: Plugin imodeler1 reported failure.

Thanks, Kevin

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:16
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
kevinoidcommented, Mar 8, 2020

I just noticed this issue also affects OpenAPI 2 documents. For example:

OpenAPI 2 example with formData parameters
swagger: '2.0'
info:
  title: OpenAPI 2 example with multipart/form-data request body
  version: 1.0.0
definitions:
  ExampleFormDataBody:
    properties:
      prop1:
        type: string
      prop2:
        type: string
    type: object
paths:
  /post-example:
    post:
      consumes:
      - multipart/form-data
      parameters:
      - in: formData
        name: prop1
        type: string
      - in: formData
        name: prop2
        type: string
      responses:
        '201':
          description: Success
      operationId: postExample

I also bisected the affected versions and found that --version:3.0.6130 works correctly while--version:3.0.6132 does not.

2reactions
UncleFirefoxcommented, Nov 24, 2020

Hi, we’re also getting the additionalProperties problem doing autorest --input-file=swagger.json --output-folder=. --typescript --version=3.0.6274 anybody looking at it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Value cannot be null. (Parameter 'key'). What do I wrong ...
Does somebody know, what I am doing wrong? System.ArgumentNullException: Value cannot be null. (Parameter 'key') at System.Collections.Generic.
Read more >
Logging the model data from the POST request body
Hi,. My requirement is to log the model data that I am receiving from a POST request. but when I am tring to...
Read more >
Dials, Tune, and Parsnip: Tidymodels' Way to Create and ...
In this post, I present three ways to tune parameters with tidymodels and provide example codes. Most examples of tidymodels I have seen...
Read more >
Accepting Raw Request Body Content in ASP.NET Core API ...
Make sure you add [FromBody] to any parameter that tries to read data from the POST body and maps it. It's easy to...
Read more >
Exactly how many parameters are in multiple linear regression ...
I've read some resources such as my Introductory Econometrics textbook that state the model parameters are B0, B1, ..., Bp where p is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found