Skip to content

Support null-returning operations #5340

@aelij

Description

@aelij

Describe the issue or request
Currently operations that return null don't check for this option, so the deserialization fails. For example:

  @get
  myOp(): MyModel[] | null;

generates:

            using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
            List<MyModel> array = new List<MyModel>();
            foreach (var item in document.RootElement.EnumerateArray())
            {
                array.Add(MyModel.DeserializeMyModel(item));
            }

Describe your ideas for solutions
Check if the root element is a JSON null and if so return null.

Metadata

Metadata

Assignees

No one assigned

    Labels

    v3Version 3 of AutoRest C# generator.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions